From: Junio C Hamano Date: Wed, 14 Feb 2007 03:20:06 +0000 (-0800) Subject: Merge branch 'js/reverse' X-Git-Tag: v1.5.1-rc1~297 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c230390b4773b9e4469085283033da9e910e50a6?ds=inline;hp=-c Merge branch 'js/reverse' * js/reverse: Teach revision machinery about --reverse --- c230390b4773b9e4469085283033da9e910e50a6 diff --combined Documentation/git-rev-list.txt index c742117595,beb090651b..4f145eaba4 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@@ -27,6 -27,7 +27,7 @@@ SYNOPSI [ \--pretty | \--header ] [ \--bisect ] [ \--merge ] + [ \--reverse ] [ \--walk-reflogs ] ... [ \-- ... ] @@@ -191,7 -192,7 +192,7 @@@ limiting may be applied In addition to the '' listed on the command line, read them from the standard input. ---walk-reflogs:: +-g, --walk-reflogs:: Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones. @@@ -266,6 -267,10 +267,10 @@@ By default, the commits are shown in re 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 --combined revision.c index 15bdaf6095,6726f736ed..5b1794b0ef --- a/revision.c +++ b/revision.c @@@ -532,7 -532,7 +532,7 @@@ static void handle_reflog(struct rev_in struct all_refs_cb cb; cb.all_revs = revs; cb.all_flags = flags; - for_each_ref(handle_one_reflog, &cb); + for_each_reflog(handle_one_reflog, &cb); } static int add_parents_only(struct rev_info *revs, const char *arg, int flags) @@@ -868,8 -868,7 +868,8 @@@ int setup_revisions(int argc, const cha handle_reflog(revs, flags); continue; } - if (!strcmp(arg, "--walk-reflogs")) { + if (!strcmp(arg, "-g") || + !strcmp(arg, "--walk-reflogs")) { init_reflog_walk(&revs->reflog_info); continue; } @@@ -1058,6 -1057,10 +1058,10 @@@ 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) { @@@ -1286,6 -1289,40 +1290,40 @@@ struct commit *get_revision(struct rev_ { struct commit *c = NULL; + if (revs->reverse) { + struct commit_list *list; + + /* + * rev_info.reverse is used to note the fact that we + * want to output the list of revisions in reverse + * order. To accomplish this goal, reverse can have + * different values: + * + * 0 do nothing + * 1 reverse the list + * 2 internal use: we have already obtained and + * reversed the list, now we only need to yield + * its items. + */ + + 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)