login
Header Space

 
 

Re: [PATCH] Lose perl dependency. (fwd)

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Junio C Hamano <junkio@...>
Cc: <git@...>
Date: Saturday, January 20, 2007 - 6:04 pm

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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] Lose perl dependency. (fwd), Junio C Hamano, (Sat Jan 20, 2:31 pm)
Re: [PATCH] Lose perl dependency. (fwd), Johannes Schindelin, (Sat Jan 20, 6:04 pm)
Re: [PATCH] Lose perl dependency. (fwd), Simon 'corecode' Schubert..., (Sat Jan 20, 10:56 pm)
[PATCH] Teach revision machinery about --reverse, Johannes Schindelin, (Sun Jan 21, 7:19 am)
Re: [PATCH] Lose perl dependency. (fwd), Robin Rosenberg, (Sat Jan 20, 8:37 pm)
Re: [PATCH] Lose perl dependency. (fwd), Johannes Schindelin, (Sat Jan 20, 9:39 pm)
Re: [PATCH] Lose perl dependency. (fwd), Bill Lear, (Sat Jan 20, 10:32 pm)
Re: [PATCH] Lose perl dependency. (fwd), Junio C Hamano, (Sat Jan 20, 11:17 pm)
speck-geostationary