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

[PATCH (take 3)] git blame -C: fix output format tweaks when crossing file boundary.

From
Junio C Hamano <junkio@cox.net>
Date
Nov 29, 2006, 06:32 UTC
Message-ID
<7vhcwiu5jz.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<7vmz6au626.fsf@assigned-by-dhcp.cox.net>

We used to get the case that more than two paths came from the same commit wrong when computing the output width and deciding to turn on --show-name option automatically. When we find that lines that came from a path that is different from what we started digging from, we should always turn --show-name on, and we should count the name length for all files involved.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * BLUSH.  Both of the previous ones were botched.
   Third time lucky, hopefully.
 builtin-blame.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index 066dee7..53fed45 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -1435,14 +1435,14 @@ static void find_alignment(struct scoreboard *sb, int *option)
 		struct commit_info ci;
 		int num;
 
+		if (strcmp(suspect->path, sb->path))
+			*option |= OUTPUT_SHOW_NAME;
+		num = strlen(suspect->path);
+		if (longest_file < num)
+			longest_file = num;
 		if (!(suspect->commit->object.flags & METAINFO_SHOWN)) {
 			suspect->commit->object.flags |= METAINFO_SHOWN;
 			get_commit_info(suspect->commit, &ci, 1);
-			if (strcmp(suspect->path, sb->path))
-				*option |= OUTPUT_SHOW_NAME;
-			num = strlen(suspect->path);
-			if (longest_file < num)
-				longest_file = num;
 			num = strlen(ci.author);
 			if (longest_author < num)
 				longest_author = num;
-- 
1.4.4.1.gad0c3-dirty
Previous: Junio C Hamano
Message 4 of 4 in “Bug in "git blame -C"”
  1. Linus TorvaldsNov 29, 2006
  2. Junio C HamanoNov 29, 2006
  3. Junio C HamanoNov 29, 2006
  4. git blame -C: fix output format tweaks when crossing file boundary.Junio C Hamano, Nov 29, 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.