@matheusbsbs / matheus-bagliano / commits / 0f03ca9461
Fork 0

config option log.showroot to show the diff of root commits

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>

Peter Baumann committed Nov 23, 2006 at 10:36 UTC 0f03ca946142bd656c1af9ff811cb9efbc8314da
3 files changed +23 -4
Documentation/config.txt
+6
@@ -219,6 +219,12 @@ i18n.commitEncoding::
219 browser (and possibly at other places in the future or in other
220 porcelains). See e.g. gitlink:git-mailinfo[1]. Defaults to 'utf-8'.
221
222 +log.showroot::
223 + If true, the initial commit will be shown as a big creation event.
224 + This is equivalent to a diff against an empty tree.
225 + Tools like gitlink:git-log[1] or gitlink:git-whatchanged[1], which
226 + normally hide the root commit will now show it. True by default.
227 +
228 merge.summary::
229 Whether to include summaries of merged commits in newly created
230 merge commit messages. False by default.
builtin-log.c
+16 -4
@@ -13,6 +13,8 @@
13 #include <time.h>
14 #include <sys/time.h>
15
16 +static int default_show_root = 1;
17 +
18 /* this is in builtin-diff.c */
19 void add_head(struct rev_info *revs);
20
@@ -22,6 +24,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
24 rev->abbrev = DEFAULT_ABBREV;
25 rev->commit_format = CMIT_FMT_DEFAULT;
26 rev->verbose_header = 1;
27 + rev->show_root_diff = default_show_root;
28 argc = setup_revisions(argc, argv, rev, "HEAD");
29 if (rev->diffopt.pickaxe || rev->diffopt.filter)
30 rev->always_show_header = 0;
@@ -44,11 +47,20 @@ static int cmd_log_walk(struct rev_info *rev)
47 return 0;
48 }
49
50 +static int git_log_config(const char *var, const char *value)
51 +{
52 + if (!strcmp(var, "log.showroot")) {
53 + default_show_root = git_config_bool(var, value);
54 + return 0;
55 + }
56 + return git_diff_ui_config(var, value);
57 +}
58 +
59 int cmd_whatchanged(int argc, const char **argv, const char *prefix)
60 {
61 struct rev_info rev;
62
51 - git_config(git_diff_ui_config);
63 + git_config(git_log_config);
64 init_revisions(&rev, prefix);
65 rev.diff = 1;
66 rev.diffopt.recursive = 1;
@@ -63,7 +75,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
75 {
76 struct rev_info rev;
77
66 - git_config(git_diff_ui_config);
78 + git_config(git_log_config);
79 init_revisions(&rev, prefix);
80 rev.diff = 1;
81 rev.diffopt.recursive = 1;
@@ -80,7 +92,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)
92 {
93 struct rev_info rev;
94
83 - git_config(git_diff_ui_config);
95 + git_config(git_log_config);
96 init_revisions(&rev, prefix);
97 rev.always_show_header = 1;
98 cmd_log_init(argc, argv, prefix, &rev);
@@ -109,7 +121,7 @@ static int git_format_config(const char *var, const char *value)
121 if (!strcmp(var, "diff.color")) {
122 return 0;
123 }
112 - return git_diff_ui_config(var, value);
124 + return git_log_config(var, value);
125 }
126
127
t/t4013-diff-various.sh
+1
@@ -73,6 +73,7 @@ test_expect_success setup '
73 for i in 1 2; do echo $i; done >>dir/sub &&
74 git update-index file0 dir/sub &&
75
76 + git repo-config log.showroot false &&
77 git commit --amend &&
78 git show-branch
79 '