git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 18, 2007, 13:57 UTC
Message-ID
<Pine.LNX.4.63.0701181441010.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<45AF5F83.6090207@fs.ei.tum.de>
Hi,
On Thu, 18 Jan 2007, Simon 'corecode' Schubert wrote:
Show 11 quoted lines
> Johannes Schindelin wrote:
> > On Thu, 18 Jan 2007, Simon 'corecode' Schubert wrote:
> > 
> > >  for cmt in `git-rev-list --no-merges "$upstream"..ORIG_HEAD \
> > > -			| @@PERL@@ -e 'print reverse <>'`
> > > +			| sed -ne '1!G;$p;h'`
> > 
> > Why not teach the revision machinery to output in reverse with "--reverse"?
> 
> I'm more in favour of "small is beautiful".  Also from looking at the code,
> this seems to be a bit complicated.

I'm more in favour of "less shell dependecy is beautiful". And from what I can tell, it should be relatively easy:

---
	14 insertions and 11 deletions stem from moving (and extern'ing) 
	reverse_commit_list() from merge-recursive.c to commit.c
	So the change is actually 9 insertions and one deletion.
 commit.c          |   11 +++++++++++
 commit.h          |    3 +++
 merge-recursive.c |   11 -----------
 revision.c        |    7 +++++++
 revision.h        |    3 ++-
 5 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/commit.c b/commit.c
index f495e2d..2735283 100644
--- a/commit.c
+++ b/commit.c
@@ -1231,3 +1231,14 @@ int in_merge_bases(struct commit *commit, struct commit **reference, int num)
 	}
 	return ret;
 }
+
+struct commit_list *reverse_commit_list(struct commit_list *list)
+{
+	struct commit_list *next = NULL, *current, *backup;
+	for (current = list; current; current = backup) {
+		backup = current->next;
+		current->next = next;
+		next = current;
+	}
+	return next;
+}
diff --git a/commit.h b/commit.h
index b8e6e18..563fe86 100644
--- a/commit.h
+++ b/commit.h
@@ -115,4 +115,7 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,
 		int depth, int shallow_flag, int not_shallow_flag);
 
 int in_merge_bases(struct commit *, struct commit **, int);
+
+extern struct commit_list *reverse_commit_list(struct commit_list *list);
+
 #endif /* COMMIT_H */
diff --git a/merge-recursive.c b/merge-recursive.c
index fa320eb..75fec5b 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1162,17 +1162,6 @@ static int merge_trees(struct tree *head,
 	return clean;
 }
 
-static struct commit_list *reverse_commit_list(struct commit_list *list)
-{
-	struct commit_list *next = NULL, *current, *backup;
-	for (current = list; current; current = backup) {
-		backup = current->next;
-		current->next = next;
-		next = current;
-	}
-	return next;
-}
-
 /*
  * Merge the commits h1 and h2, return the resulting virtual
  * commit object and a flag indicating the cleaness of the merge.
diff --git a/revision.c b/revision.c
index ebd0250..6dc00ba 100644
--- a/revision.c
+++ b/revision.c
@@ -1057,6 +1057,11 @@ 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;
+				revs->limited = 1;
+				continue;
+			}
 
 			opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
 			if (opts > 0) {
@@ -1155,6 +1160,8 @@ void prepare_revision_walk(struct rev_info *revs)
 		sort_in_topological_order_fn(&revs->commits, revs->lifo,
 					     revs->topo_setter,
 					     revs->topo_getter);
+	if (revs->reverse)
+		revs->commits = reverse_commit_list(revs->commits);
 }
 
 static int rewrite_one(struct rev_info *revs, struct commit **pp)
diff --git a/revision.h b/revision.h
index d93481f..3eb1ce4 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:1;
 
 	/* Diff flags */
 	unsigned int	diff:1,
Previous: Simon 'corecode' SchubertNext: Simon 'corecode' Schubert
Message 3 of 31 in “Re: [PATCH] Lose perl dependency. (fwd)”
  1. Johannes SchindelinJan 18, 2007
  2. Simon 'corecode' SchubertJan 18, 2007
  3. Johannes SchindelinJan 18, 2007
  4. Simon 'corecode' SchubertJan 18, 2007
  5. Andy ParkinsJan 18, 2007
  6. Johannes SchindelinJan 18, 2007
  7. Junio C HamanoJan 19, 2007
  8. Johannes SchindelinJan 19, 2007
  9. Junio C HamanoJan 20, 2007
  10. Johannes SchindelinJan 20, 2007
  11. Junio C HamanoJan 20, 2007
  12. Johannes SchindelinJan 20, 2007
  13. Junio C HamanoJan 20, 2007
  14. Simon 'corecode' SchubertJan 20, 2007
  15. Johannes SchindelinJan 20, 2007
  16. Junio C HamanoJan 20, 2007
  17. Johannes SchindelinJan 20, 2007
  18. Robin RosenbergJan 21, 2007
  19. Johannes SchindelinJan 21, 2007
  20. Bill LearJan 21, 2007
  21. Junio C HamanoJan 21, 2007
  22. David KågedalJan 21, 2007
  23. Johannes SchindelinJan 21, 2007
  24. Krzysztof HalasaJan 23, 2007
  25. David KågedalJan 23, 2007
  26. Krzysztof HalasaJan 23, 2007
  27. Randal L. SchwartzJan 23, 2007
  28. Krzysztof HalasaJan 23, 2007
  29. Krzysztof HalasaJan 23, 2007
  30. Simon 'corecode' SchubertJan 21, 2007
  31. Teach revision machinery about --reverseJohannes Schindelin, Jan 21, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.