Hi, On Sat, 20 Jan 2007, Junio C Hamano wrote:That is exactly what I meant. Yes. But I have to traverse this _first_, before even returning a commit from get_revision(). I had the impression that limit_list() traversed all commits. But I am probably wrong, ain't I? Okay, I thought that limit_list() honours --skip and --max-count. Looking at the code it seems to me that this assumption is wrong. But that would not work, would it? Example: A - B - C - D D is the HEAD. Now, when we do not limit_list(), when we get into get_revision() for the first time, revs->commits contains _only_ D (we do the ancestry walk on-the-fly). So, your code would "reverse" the list containing only D, reset the reverse flag. In effect, it would do exactly the same as without --reverse. What I _wanted_, was to walk the ancestry chain first, then just reverse the commits, and be done. However, it seems I was utterly mistaken in my approach. This should work better: --- [PATCH] Teach revision machinery about --reverse The option --reverse reverses the order of the commits. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> --- Documentation/git-rev-list.txt | 5 +++++ revision.c | 25 +++++++++++++++++++++++++ revision.h | 3 ++- 3 files changed, 32 insertions(+), 1 deletions(-) diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 86c94e7..6bb9f51 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -27,6 +27,7 @@ SYNOPSIS [ \--pretty | \--header ] [ \--bisect ] [ \--merge ] + [ \--reverse ] <commit>... [ \-- <paths>... ] DESCRIPTION @@ -249,6 +250,10 @@ By default, the commits are shown in reverse chronological order. parent comes before all of its children, but otherwise things are still ordered in the commit timestamp order. +--reverse:: + + Output the commits in reverse order. + Object Traversal ~~~~~~~~~~~~~~~~ diff --git a/revision.c b/revision.c index ebd0250..afc824c 100644 --- a/revision.c +++ b/revision.c @@ -1057,6 +1057,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch git_log_output_encoding = ""; continue; } + if (!strcmp(arg, "--reverse")) { + revs->reverse ^= 1; + continue; + } opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i); if (opts > 0) { @@ -1285,6 +1289,27 @@ struct commit *get_revision(struct rev_info *revs) { struct commit *c = NULL; + if (revs->reverse) { + struct commit_list *list; + + if (revs->reverse == 1) { + revs->reverse = 0; + list = NULL; + while ((c = get_revision(revs))) + commit_list_insert(c, &list); + revs->commits = list; + revs->reverse = 2; + } + + if (!revs->commits) + return NULL; + c = revs->commits->item; + list = revs->commits->next; + free(revs->commits); + revs->commits = list; + return c; + } + if (0 < revs->skip_count) { while ((c = get_revision_1(revs)) != NULL) { if (revs->skip_count-- <= 0) diff --git a/revision.h b/revision.h index d93481f..5fec184 100644 --- a/revision.h +++ b/revision.h @@ -42,7 +42,8 @@ struct rev_info { unpacked:1, /* see also ignore_packed below */ boundary:1, left_right:1, - parents:1; + parents:1, + reverse:2; /* Diff flags */ unsigned int diff:1, - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| Ryan Hope | reiser4 for 2.6.27-rc1 |
| Paul Menage | Re: [RFC][PATCH 6/7] Account for the number of tasks within container |
| Glauber de Oliveira Costa | [PATCH 1/19] unify desc_struct |
| David Woodhouse | Re: OT: character encodings (was: Linux 2.6.20-rc4) |
git: | |
| Eric Wong | Re: [RFC] Git config file reader in Perl (WIP) |
| Junio C Hamano | [PATCH/POLL] git-format-patch: the default suffix is now .patch, not .txt |
| Martin Langhoff | Re: pack operation is thrashing my server |
| Franck Bui-Huu | Re: [PATCH 1/2] Add git-archive |
| Chris Bullock | OpenBSD isakmpd and pf vs Cisco PIX or ASA |
| Richard Stallman | Real men don't attack straw men |
| Axton | Re: rouge IPs / user |
| Hannah Schroeter | Re: Improving disk reliability |
| Andi Kleen | [PATCH RFC] [4/9] modpost: Fix format string warnings |
| Jeff Garzik | Re: [regression] e1000e broke e1000 |
| Linus Torvalds | Re: [GIT]: Networking |
| Pekka Enberg | Re: [rfc][patch 1/3] slub: fix small HWCACHE_ALIGN alignment |
