mirror of
https://github.com/git/git.git
synced 2024-11-24 10:26:17 +08:00
Merge branch 'js/reverse'
* js/reverse: Teach revision machinery about --reverse
This commit is contained in:
commit
c230390b47
@ -27,6 +27,7 @@ SYNOPSIS
|
|||||||
[ \--pretty | \--header ]
|
[ \--pretty | \--header ]
|
||||||
[ \--bisect ]
|
[ \--bisect ]
|
||||||
[ \--merge ]
|
[ \--merge ]
|
||||||
|
[ \--reverse ]
|
||||||
[ \--walk-reflogs ]
|
[ \--walk-reflogs ]
|
||||||
<commit>... [ \-- <paths>... ]
|
<commit>... [ \-- <paths>... ]
|
||||||
|
|
||||||
@ -266,6 +267,10 @@ By default, the commits are shown in reverse chronological order.
|
|||||||
parent comes before all of its children, but otherwise things
|
parent comes before all of its children, but otherwise things
|
||||||
are still ordered in the commit timestamp order.
|
are still ordered in the commit timestamp order.
|
||||||
|
|
||||||
|
--reverse::
|
||||||
|
|
||||||
|
Output the commits in reverse order.
|
||||||
|
|
||||||
Object Traversal
|
Object Traversal
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
38
revision.c
38
revision.c
@ -1058,6 +1058,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
|
|||||||
git_log_output_encoding = "";
|
git_log_output_encoding = "";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(arg, "--reverse")) {
|
||||||
|
revs->reverse ^= 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
|
opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
|
||||||
if (opts > 0) {
|
if (opts > 0) {
|
||||||
@ -1286,6 +1290,40 @@ struct commit *get_revision(struct rev_info *revs)
|
|||||||
{
|
{
|
||||||
struct commit *c = NULL;
|
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) {
|
if (0 < revs->skip_count) {
|
||||||
while ((c = get_revision_1(revs)) != NULL) {
|
while ((c = get_revision_1(revs)) != NULL) {
|
||||||
if (revs->skip_count-- <= 0)
|
if (revs->skip_count-- <= 0)
|
||||||
|
@ -42,7 +42,8 @@ struct rev_info {
|
|||||||
unpacked:1, /* see also ignore_packed below */
|
unpacked:1, /* see also ignore_packed below */
|
||||||
boundary:1,
|
boundary:1,
|
||||||
left_right:1,
|
left_right:1,
|
||||||
parents:1;
|
parents:1,
|
||||||
|
reverse:2;
|
||||||
|
|
||||||
/* Diff flags */
|
/* Diff flags */
|
||||||
unsigned int diff:1,
|
unsigned int diff:1,
|
||||||
|
Loading…
Reference in New Issue
Block a user