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

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

From
PBPeter Baumann <peter.b.baumann@stud.informatik.uni-erlangen.de>
Date
Nov 23, 2006, 09:36 UTC
Message-ID
<slrnemaqt1.esn.Peter.B.Baumann@xp.machine.xx>
In-Reply-To
<7v64d8y4tu.fsf@assigned-by-dhcp.cox.net>

This allows one to see the root commit as a diff in commands like git-log, git-show and git-whatchanged. It also modifies git-diff-tree to act as --root was specified on the commandline. The default is set to true.

Signed-off-by: Peter Baumann <Peter.B.Baumannn@stud.informatik.uni-erlangen.de>
---
I'm not sure if making core.showroot acting on git-diff-tree is the
right thing to do. Please check first bevore applying.
 Documentation/config.txt |    6 ++++++
 builtin-diff-tree.c      |    1 +
 builtin-log.c            |    3 +++
 cache.h                  |    1 +
 config.c                 |    5 +++++
 environment.c            |    1 +
 6 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 9d3c71c..7e600ca 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -110,6 +110,12 @@ core.legacyheaders::
 	database directly (where the "http://" and "rsync://" protocols
 	count as direct access).
 
+core.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.
+
 alias.*::
 	Command aliases for the gitlink:git[1] command wrapper - e.g.
 	after defining "alias.last = cat-file commit HEAD", the invocation
diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c
index 24cb2d7..d58b7ca 100644
--- a/builtin-diff-tree.c
+++ b/builtin-diff-tree.c
@@ -72,6 +72,7 @@ int cmd_diff_tree(int argc, const char *
 	nr_sha1 = 0;
 	opt->abbrev = 0;
 	opt->diff = 1;
+	opt->show_root_diff = show_root_diff;
 	argc = setup_revisions(argc, argv, opt, NULL);
 
 	while (--argc > 0) {
diff --git a/builtin-log.c b/builtin-log.c
index fedb013..9541c7d 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -53,6 +53,7 @@ int cmd_whatchanged(int argc, const char
 	rev.diff = 1;
 	rev.diffopt.recursive = 1;
 	rev.simplify_history = 0;
+	rev.show_root_diff = show_root_diff;
 	cmd_log_init(argc, argv, prefix, &rev);
 	if (!rev.diffopt.output_format)
 		rev.diffopt.output_format = DIFF_FORMAT_RAW;
@@ -72,6 +73,7 @@ int cmd_show(int argc, const char **argv
 	rev.always_show_header = 1;
 	rev.ignore_merges = 0;
 	rev.no_walk = 1;
+	rev.show_root_diff = show_root_diff;
 	cmd_log_init(argc, argv, prefix, &rev);
 	return cmd_log_walk(&rev);
 }
@@ -83,6 +85,7 @@ int cmd_log(int argc, const char **argv,
 	git_config(git_diff_ui_config);
 	init_revisions(&rev, prefix);
 	rev.always_show_header = 1;
+	rev.show_root_diff = show_root_diff;
 	cmd_log_init(argc, argv, prefix, &rev);
 	return cmd_log_walk(&rev);
 }
diff --git a/cache.h b/cache.h
index f2ec5c8..feff2bd 100644
--- a/cache.h
+++ b/cache.h
@@ -191,6 +191,7 @@ extern int warn_ambiguous_refs;
 extern int shared_repository;
 extern const char *apply_default_whitespace;
 extern int zlib_compression_level;
+extern int show_root_diff;
 
 #define GIT_REPO_VERSION 0
 extern int repository_format_version;
diff --git a/config.c b/config.c
index 3cae390..dd720b5 100644
--- a/config.c
+++ b/config.c
@@ -319,6 +319,11 @@ int git_default_config(const char *var,
 		return 0;
 	}
 
+	if (!strcmp(var, "core.showroot")) {
+		show_root_diff = git_config_bool(var, value);
+		return 0;
+	}
+
 	/* Add other config variables here and to Documentation/config.txt. */
 	return 0;
 }
diff --git a/environment.c b/environment.c
index 84d870c..71099f4 100644
--- a/environment.c
+++ b/environment.c
@@ -24,6 +24,7 @@ const char *apply_default_whitespace;
 int zlib_compression_level = Z_DEFAULT_COMPRESSION;
 int pager_in_use;
 int pager_use_color = 1;
+int show_root_diff = 1;
 
 static const char *git_dir;
 static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;
-- 
1.4.3.3
Previous: Jakub NarebskiNext: Junio C Hamano
Message 26 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.