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

[PATCH 2/8] gitweb: We do longer need the --parents flag in rev-list.

From
RFRobert Fitzsimons <robfitz@273k.net>
Date
Dec 24, 2006, 14:31 UTC
Message-ID
<11669707094097-git-send-email-robfitz@273k.net>
In-Reply-To
<11669707092427-git-send-email-robfitz@273k.net>

We only want to know the direct parents of a given commit object, these parents are available in the --header output of rev-list. If --parents is supplied with --full-history the output includes merge commits that aren't relevant.

Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
---
 gitweb/gitweb.perl |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6bd57a4..c645686 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1281,13 +1281,14 @@ sub parse_commit_text {
 	if (!($header =~ m/^[0-9a-fA-F]{40}/)) {
 		return;
 	}
-	($co{'id'}, my @parents) = split ' ', $header;
-	$co{'parents'} = \@parents;
-	$co{'parent'} = $parents[0];
+	$co{'id'} = $header;
+	my @parents;
 	while (my $line = shift @commit_lines) {
 		last if $line eq "\n";
 		if ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {
 			$co{'tree'} = $1;
+		} elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) {
+			push @parents, $1;
 		} elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {
 			$co{'author'} = $1;
 			$co{'author_epoch'} = $2;
@@ -1314,6 +1315,8 @@ sub parse_commit_text {
 	if (!defined $co{'tree'}) {
 		return;
 	};
+	$co{'parents'} = \@parents;
+	$co{'parent'} = $parents[0];
 
 	foreach my $title (@commit_lines) {
 		$title =~ s/^    //;
@@ -1371,7 +1374,6 @@ sub parse_commit {
 
 	open my $fd, "-|", git_cmd(), "rev-list",
 		"--header",
-		"--parents",
 		"--max-count=1",
 		$commit_id,
 		"--",
@@ -1414,7 +1416,6 @@ sub parse_commits {
 
 	open my $fd, "-|", git_cmd(), "rev-list",
 		"--header",
-		"--parents",
 		($arg ? ($arg) : ()),
 		("--max-count=" . $maxcount),
 		# Add once rev-list supports the --skip option
-- 
1.4.4.3.ge655-dirty
Previous: Robert FitzsimonsNext: Robert Fitzsimons
Message 2 of 10 in “gitweb: Add parse_commits, used to bulk load commit objects.”
  1. 1/8 gitweb: Add parse_commits, used to bulk load commit objects.Robert Fitzsimons, Dec 24, 2006
  2. 2/8 gitweb: We do longer need the --parents flag in rev-list.Robert Fitzsimons, Dec 24, 2006
  3. 3/8 gitweb: Change summary, shortlog actions to use parse_commits.Robert Fitzsimons, Dec 24, 2006
  4. 4/8 gitweb: Change log action to use parse_commits.Robert Fitzsimons, Dec 24, 2006
  5. 5/8 gitweb: Change header search action to use parse_commits.Robert Fitzsimons, Dec 24, 2006
  6. 6/8 gitweb: Change atom, rss actions to use parse_commits.Robert Fitzsimons, Dec 24, 2006
  7. 7/8 gitweb: Change history action to use parse_commits.Robert Fitzsimons, Dec 24, 2006
  8. 8/8 gitweb: Use rev-list --skip option.Robert Fitzsimons, Dec 24, 2006
  9. Jakub NarebskiDec 25, 2006
  10. gitweb: Re-enable rev-list --parents for parse_commit.Robert Fitzsimons, Dec 27, 2006

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.