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

[PATCH 4/6] gitweb: Make blob diff -p1 like commit diff

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 6, 2006, 00:13 UTC
Message-ID
<200608060213.50613.jnareb@gmail.com>
In-Reply-To
<200608060206.49086.jnareb@gmail.com>

Add 'a/' and 'b/' as prefix for blobdiff, blobdiff_plain, like it is in commitdiff, commitdiff_plain. Ensure that label for /dev/null is actually /dev/null.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
For consistency.
 gitweb/gitweb.perl |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index cdce481..f402c8f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1236,6 +1236,8 @@ sub git_diff_print {
 		print { $fd2 } <$fd>;
 		close $fd2;
 		close $fd;
+	} else {
+		$from_name = "/dev/null";
 	}
 
 	# create tmp to-file
@@ -1247,6 +1249,8 @@ sub git_diff_print {
 		print { $fd2 } <$fd>;
 		close $fd2;
 		close $fd;
+	} else {
+		$to_name = "/dev/null";
 	}
 
 	open my $fd, "-|", "/usr/bin/diff",
@@ -2105,7 +2109,8 @@ sub git_blobdiff {
 	      " -> blob:" .
 	      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) .
 	      "</div>\n";
-	git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
+	git_diff_print($hash_parent, 'a/' . ($file_name || $hash_parent),
+	               $hash,        'b/' . ($file_name || $hash));
 	print "</div>";
 	git_footer_html();
 }
@@ -2113,7 +2118,8 @@ sub git_blobdiff {
 sub git_blobdiff_plain {
 	mkdir($git_temp, 0700);
 	print $cgi->header(-type => "text/plain", -charset => 'utf-8');
-	git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain");
+	git_diff_print($hash_parent, 'a/' . ($file_name || $hash_parent),
+	               $hash,        'b/' . ($file_name || $hash), "plain");
 }
 
 sub git_commitdiff {
-- 
1.4.1.1
Previous: Jakub NarebskiNext: Jakub Narebski
Message 8 of 12 in “gitweb: Further refactoring”
  1. 0/6 gitweb: Further refactoringJakub Narebski, Aug 6, 2006
  2. 1/6 gitweb: Refactor untabifying - converting tabs to spacesJakub Narebski, Aug 6, 2006
  3. Matthias LederhoferAug 6, 2006
  4. 2/6 gitweb: Simplify git_diff_printJakub Narebski, Aug 6, 2006
  5. Junio C HamanoAug 6, 2006
  6. Jakub NarebskiAug 6, 2006
  7. 3/6 gitweb: Remove unused parse_date invocation from git_shortlog_bodyJakub Narebski, Aug 6, 2006
  8. 4/6 gitweb: Make blob diff -p1 like commit diffJakub Narebski, Aug 6, 2006
  9. 5/6 gitweb: Refactor printing shortened title in git_shortlog_body and git_tags_bodyJakub Narebski, Aug 6, 2006
  10. 6/6 gitweb: Refactor git_history_bodyJakub Narebski, Aug 6, 2006
  11. Junio C HamanoAug 6, 2006
  12. Jakub NarebskiAug 6, 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.