diff options
author | Junio C Hamano <junkio@cox.net> | 2007-02-13 19:20:06 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-02-13 19:20:06 -0800 |
commit | c230390b4773b9e4469085283033da9e910e50a6 (patch) | |
tree | 97ccde4c5907c1d3a4435ea6b382523f415d8cbb /revision.c | |
parent | 3eee9c6dbebcf6341ad202f7dd4d416ef3fcba5e (diff) | |
parent | 9c5e66e97da8cadcc45a278c4e39a7d25674d4ff (diff) | |
download | git-c230390b4773b9e4469085283033da9e910e50a6.tar.gz |
Merge branch 'js/reverse'
* js/reverse:
Teach revision machinery about --reverse
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/revision.c b/revision.c index 15bdaf6095..5b1794b0ef 100644 --- a/revision.c +++ b/revision.c @@ -1058,6 +1058,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) { @@ -1286,6 +1290,40 @@ struct commit *get_revision(struct rev_info *revs) { 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) |