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

gitk shows an empty line between "Comments" and changed files

From
PRPavel Roskin <proski@gnu.org>
Date
Oct 27, 2005, 17:30 UTC
Message-ID
<1130434230.19641.21.camel@dv>
Hello!

gitk is now showing an empty line between "Comments" and changes files. This change was caused by 8b7e5d76e836396a097bb6f61cf930ea872a7bd3 (Make "gitk" work better with dense revlists).

git-diff-tree outputs some SHA1 as the first line if only one tree-ish argument is provided. I don't see any way to suppress that output (see diff-tree.c, line 114).

One solution would be to add an option to git-diff-tree to suppress all headers (let's call it --no-headers).

Or maybe the SHA1 header should never be printed at all? It looks like it's not documented anywhere. It doesn't break the tests.

While debugging the patch, I have found that the p variable is unused in both functions that stopped passing it to git-diff-tree.

Also, gettreediffs function in gitk could use --names-only for git-diff-tree, because it only needs names.

Maybe --names-only and --name-status should suppress the SHA1 header to match their descriptions? Unfortunately, they don't suppress the patch is -p is specified, so "matching the descriptions" would have to take care of it.

P.S. I consider printing the SHA1 header in git-diff-tree an undocumented feature (in other words, a bug).

Proposed patch:
Don't print the SHA1 when only one tree-ish is given to git-diff-tree.
Signed-off-by: Pavel Roskin <proski@gnu.org>
diff --git a/diff-tree.c b/diff-tree.c
index 382011a..ac53f48 100644
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -111,7 +111,6 @@ static int diff_tree_commit(const unsign
 		unsigned char parent[20];
 		if (get_sha1_hex(buf + offset + 7, parent))
 			return -1;
-		header = generate_header(name, sha1_to_hex(parent), buf, size);
 		diff_tree_sha1_top(parent, commit, "");
 		if (!header && verbose_header) {
 			header_prefix = "\ndiff-tree ";
-- 
Regards,
Pavel Roskin
Next: Junio C Hamano
Message 1 of 11 in “gitk shows an empty line between "Comments" and changed files”
  1. Pavel RoskinOct 27, 2005
  2. Junio C HamanoOct 27, 2005
  3. Pavel RoskinOct 28, 2005
  4. Junio C HamanoOct 28, 2005
  5. Pavel RoskinOct 28, 2005
  6. Linus TorvaldsOct 28, 2005
  7. Junio C HamanoOct 29, 2005
  8. Linus TorvaldsOct 29, 2005
  9. Pavel RoskinOct 29, 2005
  10. Linus TorvaldsOct 29, 2005
  11. Pavel RoskinOct 29, 2005

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.