Merge branch 'pb/diffroot'

* pb/diffroot:
  config option log.showroot to show the diff of root commits
This commit is contained in:
Junio C Hamano
2006-11-24 03:49:57 -08:00
3 changed files with 23 additions and 4 deletions

View File

@ -219,6 +219,12 @@ i18n.commitEncoding::
browser (and possibly at other places in the future or in other browser (and possibly at other places in the future or in other
porcelains). See e.g. gitlink:git-mailinfo[1]. Defaults to 'utf-8'. 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:: merge.summary::
Whether to include summaries of merged commits in newly created Whether to include summaries of merged commits in newly created
merge commit messages. False by default. merge commit messages. False by default.

View File

@ -13,6 +13,8 @@
#include <time.h> #include <time.h>
#include <sys/time.h> #include <sys/time.h>
static int default_show_root = 1;
/* this is in builtin-diff.c */ /* this is in builtin-diff.c */
void add_head(struct rev_info *revs); void add_head(struct rev_info *revs);
@ -22,6 +24,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
rev->abbrev = DEFAULT_ABBREV; rev->abbrev = DEFAULT_ABBREV;
rev->commit_format = CMIT_FMT_DEFAULT; rev->commit_format = CMIT_FMT_DEFAULT;
rev->verbose_header = 1; rev->verbose_header = 1;
rev->show_root_diff = default_show_root;
argc = setup_revisions(argc, argv, rev, "HEAD"); argc = setup_revisions(argc, argv, rev, "HEAD");
if (rev->diffopt.pickaxe || rev->diffopt.filter) if (rev->diffopt.pickaxe || rev->diffopt.filter)
rev->always_show_header = 0; rev->always_show_header = 0;
@ -44,11 +47,20 @@ static int cmd_log_walk(struct rev_info *rev)
return 0; 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) int cmd_whatchanged(int argc, const char **argv, const char *prefix)
{ {
struct rev_info rev; struct rev_info rev;
git_config(git_diff_ui_config); git_config(git_log_config);
init_revisions(&rev, prefix); init_revisions(&rev, prefix);
rev.diff = 1; rev.diff = 1;
rev.diffopt.recursive = 1; rev.diffopt.recursive = 1;
@ -63,7 +75,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
{ {
struct rev_info rev; struct rev_info rev;
git_config(git_diff_ui_config); git_config(git_log_config);
init_revisions(&rev, prefix); init_revisions(&rev, prefix);
rev.diff = 1; rev.diff = 1;
rev.diffopt.recursive = 1; rev.diffopt.recursive = 1;
@ -80,7 +92,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)
{ {
struct rev_info rev; struct rev_info rev;
git_config(git_diff_ui_config); git_config(git_log_config);
init_revisions(&rev, prefix); init_revisions(&rev, prefix);
rev.always_show_header = 1; rev.always_show_header = 1;
cmd_log_init(argc, argv, prefix, &rev); cmd_log_init(argc, argv, prefix, &rev);
@ -109,7 +121,7 @@ static int git_format_config(const char *var, const char *value)
if (!strcmp(var, "diff.color")) { if (!strcmp(var, "diff.color")) {
return 0; return 0;
} }
return git_diff_ui_config(var, value); return git_log_config(var, value);
} }

View File

@ -73,6 +73,7 @@ test_expect_success setup '
for i in 1 2; do echo $i; done >>dir/sub && for i in 1 2; do echo $i; done >>dir/sub &&
git update-index file0 dir/sub && git update-index file0 dir/sub &&
git repo-config log.showroot false &&
git commit --amend && git commit --amend &&
git show-branch git show-branch
' '