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

[PATCH 2/2] gitweb: Add 'status_str' to parse_difftree_raw_line output

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 1, 2007, 11:38 UTC
Message-ID
<1193917089-15920-3-git-send-email-jnareb@gmail.com>
In-Reply-To
<1193917089-15920-1-git-send-email-jnareb@gmail.com>
Add 'status_str' to diffinfo output, which stores status (also for
merge commit) as a string.  This allows for easy checking if there is
given status among all for merge commit, e.g.
  $diffinfo->{'status_str'} =~ /D/;
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 79ea7ec..e36dec1 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1990,7 +1990,7 @@ sub parse_difftree_raw_line {
 		$res{'to_mode'} = $2;
 		$res{'from_id'} = $3;
 		$res{'to_id'} = $4;
-		$res{'status'} = $5;
+		$res{'status'} = $res{'status_str'} = $5;
 		$res{'similarity'} = $6;
 		if ($res{'status'} eq 'R' || $res{'status'} eq 'C') { # renamed or copied
 			($res{'from_file'}, $res{'to_file'}) = map { unquote($_) } split("\t", $7);
@@ -2006,6 +2006,7 @@ sub parse_difftree_raw_line {
 		$res{'to_mode'} = pop @{$res{'from_mode'}};
 		$res{'from_id'} = [ split(' ', $3) ];
 		$res{'to_id'} = pop @{$res{'from_id'}};
+		$res{'status_str'} = $4;
 		$res{'status'} = [ split('', $4) ];
 		$res{'to_file'} = unquote($5);
 	}
@@ -2821,7 +2822,7 @@ sub fill_from_file_info {
 sub is_deleted {
 	my $diffinfo = shift;
 
-	return $diffinfo->{'to_id'} eq ('0' x 40);
+	return $diffinfo->{'status_str'} =~ /D/;
 }
 
 # does patch correspond to [previous] difftree raw line
-- 
1.5.3.4
Previous: Jakub Narebski
Message 5 of 5 in “gitweb: Simplify dealing with raw diff output”
  1. 0/2 gitweb: Simplify dealing with raw diff outputJakub Narebski, Nov 1, 2007
  2. 1/2 gitweb: Always set 'from_file' and 'to_file' in parse_difftree_raw_lineJakub Narebski, Nov 1, 2007
  3. Junio C HamanoNov 1, 2007
  4. Jakub NarebskiNov 1, 2007
  5. 2/2 gitweb: Add 'status_str' to parse_difftree_raw_line outputJakub Narebski, Nov 1, 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.