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

Re: [PATCH] config option core.showroot to enable showing the diff of the root commit

From
Junio C Hamano <junkio@cox.net>
Date
Nov 24, 2006, 01:30 UTC
Message-ID
<7vzmahfx6q.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vejrthf2y.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 15 quoted lines
> Peter Baumann <Peter.B.Baumann@stud.informatik.uni-erlangen.de>
> writes:
>
>> Sorry, but I don't understand. The color handling doesn't look any different
>> to me than the handling of the other config entrys. Did I miss something?
>
> "git-diff-tree --color HEAD" (with explicit command line
> instruction to color it) still colours its output, but "[diff]
> color = auto" in ~/.gitconfig would not affect the coloring.
> Hence, "git-diff-tree HEAD" with the configuration entry gives
> monochrome.
>
> "git diff HEAD" on the other hand looks at '[diff] color = auto"
> and will color its output without being told on the command
> line.

Since this is about "log" family that deals with revision structure, how about....

-- >8 -- [PATCH] config option log.showroot to show the diff of root commits

From: Peter Baumann <Peter.B.Baumann@stud.informatik.uni-erlangen.de>

This allows one to see a root commit as a diff in commands like git-log, git-show and git-whatchanged.

Signed-off-by: Peter Baumann <Peter.B.Baumannn@stud.informatik.uni-erlangen.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 Documentation/config.txt |    6 ++++++
 builtin-log.c            |   20 ++++++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 9d3c71c..9090762 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -219,6 +219,12 @@ i18n.commitEncoding::
 	browser (and possibly at other places in the future or in other
 	porcelains). See e.g. gitlink:git-mailinfo[1]. Defaults to 'utf-8'.
 
+log.showroot::
+	If true, the initial commit will be shown as a big creation event.
+	This is equivalent to a diff against an empty tree.
+	Tools like gitlink:git-log[1] or gitlink:git-whatchanged[1], which
+	normally hide the root commit will now show it. True by default.
+
 merge.summary::
 	Whether to include summaries of merged commits in newly created
 	merge commit messages. False by default.
diff --git a/builtin-log.c b/builtin-log.c
index fedb013..7acf5d3 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -13,6 +13,8 @@
 #include <time.h>
 #include <sys/time.h>
 
+static int default_show_root = 1;
+
 /* this is in builtin-diff.c */
 void add_head(struct rev_info *revs);
 
@@ -22,6 +24,7 @@ static void cmd_log_init(int argc, const
 	rev->abbrev = DEFAULT_ABBREV;
 	rev->commit_format = CMIT_FMT_DEFAULT;
 	rev->verbose_header = 1;
+	rev->show_root_diff = default_show_root;
 	argc = setup_revisions(argc, argv, rev, "HEAD");
 	if (rev->diffopt.pickaxe || rev->diffopt.filter)
 		rev->always_show_header = 0;
@@ -44,11 +47,20 @@ static int cmd_log_walk(struct rev_info
 	return 0;
 }
 
+static int git_log_config(const char *var, const char *value)
+{
+	if (!strcmp(var, "log.showroot")) {
+		default_show_root = git_config_bool(var, value);
+		return 0;
+	}
+	return git_diff_ui_config(var, value);
+}
+
 int cmd_whatchanged(int argc, const char **argv, const char *prefix)
 {
 	struct rev_info rev;
 
-	git_config(git_diff_ui_config);
+	git_config(git_log_config);
 	init_revisions(&rev, prefix);
 	rev.diff = 1;
 	rev.diffopt.recursive = 1;
@@ -63,7 +75,7 @@ int cmd_show(int argc, const char **argv
 {
 	struct rev_info rev;
 
-	git_config(git_diff_ui_config);
+	git_config(git_log_config);
 	init_revisions(&rev, prefix);
 	rev.diff = 1;
 	rev.diffopt.recursive = 1;
@@ -80,7 +92,7 @@ int cmd_log(int argc, const char **argv,
 {
 	struct rev_info rev;
 
-	git_config(git_diff_ui_config);
+	git_config(git_log_config);
 	init_revisions(&rev, prefix);
 	rev.always_show_header = 1;
 	cmd_log_init(argc, argv, prefix, &rev);
@@ -109,7 +121,7 @@ static int git_format_config(const char
 	if (!strcmp(var, "diff.color")) {
 		return 0;
 	}
-	return git_diff_ui_config(var, value);
+	return git_log_config(var, value);
 }
 
 
-- 
1.4.4.1.g77614
Previous: Junio C HamanoNext: Peter Baumann
Message 30 of 35 in “git-show --stat on first commit”
  1. Andy ParkinsNov 21, 2006
  2. Jakub NarebskiNov 21, 2006
  3. Santi BéjarNov 21, 2006
  4. Peter BaumannNov 21, 2006
  5. Jakub NarebskiNov 21, 2006
  6. Peter BaumannNov 21, 2006
  7. Linus TorvaldsNov 21, 2006
  8. Shawn PearceNov 21, 2006
  9. Peter BaumannNov 21, 2006
  10. Linus TorvaldsNov 21, 2006
  11. Olivier GalibertNov 21, 2006
  12. Shawn PearceNov 21, 2006
  13. Petr BaudisNov 21, 2006
  14. Petr BaudisNov 21, 2006
  15. Jakub NarebskiNov 21, 2006
  16. Petr BaudisNov 21, 2006
  17. Shawn PearceNov 21, 2006
  18. Andy ParkinsNov 21, 2006
  19. Petr BaudisNov 21, 2006
  20. Shawn PearceNov 21, 2006
  21. Petr BaudisNov 21, 2006
  22. Junio C HamanoNov 21, 2006
  23. Jakub NarebskiNov 21, 2006
  24. Andy ParkinsNov 23, 2006
  25. Jakub NarebskiNov 24, 2006
  26. config option core.showroot to enable showing the diff of the root commitPeter Baumann, Nov 23, 2006
  27. Junio C HamanoNov 23, 2006
  28. Peter BaumannNov 23, 2006
  29. Junio C HamanoNov 24, 2006
  30. Junio C HamanoNov 24, 2006
  31. Peter BaumannNov 24, 2006
  32. Junio C HamanoNov 24, 2006
  33. Peter BaumannNov 24, 2006
  34. Carl WorthNov 21, 2006
  35. Junio C HamanoNov 21, 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.