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

Fixes for option parsing

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 16, 2006, 22:17 UTC
Message-ID
<Pine.LNX.4.64.0604161433000.3701@g5.osdl.org>

Make sure "git show" always show the header, regardless of whether there is a diff or not.

Also, make sure "always_show_header" actually works, since generate_header only tested it in one out of three return paths.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/git.c b/git.c
index c5de8d3..fc4e429 100644
--- a/git.c
+++ b/git.c
@@ -373,6 +373,7 @@ static int cmd_show(int argc, const char
 	rev.diffopt.recursive = 1;
 	rev.combine_merges = 1;
 	rev.dense_combined_merges = 1;
+	rev.always_show_header = 1;
 	rev.ignore_merges = 0;
 	rev.no_walk = 1;
 	return cmd_log_wc(argc, argv, envp, &rev);
diff --git a/log-tree.c b/log-tree.c
index 7d9f41e..81dff8f 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -43,7 +43,7 @@ static int diff_root_tree(struct rev_inf
 	return retval;
 }
 
-static const char *generate_header(struct rev_info *opt,
+static const char *get_header(struct rev_info *opt,
 				   const unsigned char *commit_sha1,
 				   const unsigned char *parent_sha1,
 				   const struct commit *commit)
@@ -75,11 +75,21 @@ static const char *generate_header(struc
 	offset += pretty_print_commit(opt->commit_format, commit, len,
 				      this_header + offset,
 				      sizeof(this_header) - offset, abbrev);
+	return this_header;
+}
+
+static const char *generate_header(struct rev_info *opt,     
+					const unsigned char *commit_sha1,
+					const unsigned char *parent_sha1,
+					const struct commit *commit)
+{
+	const char *header = get_header(opt, commit_sha1, parent_sha1, commit);
+
 	if (opt->always_show_header) {
-		puts(this_header);
-		return NULL;
+		puts(header);
+		header = NULL;
 	}
-	return this_header;
+	return header;
 }
 
 static int do_diff_combined(struct rev_info *opt, struct commit *commit)
Next: Junio C Hamano
Message 1 of 18 in “Fixes for option parsing”
  1. Linus TorvaldsApr 16, 2006
  2. Junio C HamanoApr 17, 2006
  3. Linus TorvaldsApr 17, 2006
  4. Linus TorvaldsApr 17, 2006
  5. Junio C HamanoApr 17, 2006
  6. Linus TorvaldsApr 17, 2006
  7. Log message printout cleanupsLinus Torvalds, Apr 17, 2006
  8. Junio C HamanoApr 17, 2006
  9. Linus TorvaldsApr 17, 2006
  10. Junio C HamanoApr 18, 2006
  11. Junio C HamanoApr 18, 2006
  12. Linus TorvaldsApr 18, 2006
  13. Junio C HamanoApr 18, 2006
  14. Linus TorvaldsApr 18, 2006
  15. Linus TorvaldsApr 18, 2006
  16. Junio C HamanoApr 18, 2006
  17. diff --stat: make sure to set recursive.Junio C Hamano, Apr 18, 2006
  18. Linus TorvaldsApr 18, 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.