threads / discuss / 11306

Oddity in git commit summary

Subject: Oddity in git commit summary

## tl;dr

5 messages between Dec 15, 2007 and Dec 17, 2007.

replies: 4people: 2as markdown or json

Daniel Barkalow· Dec 15, 2007, 20:29 UTC · lore

I just noticed that I got a strange summary from git commit -a --amend with the current master. It said:

Created commit f16cb29: Build in checkout
 5 files changed, 482 insertions(+), 299 deletions(-)
 create mode 100644 builtin-checkout.c
 delete mode 100755 git-checkout.sh
But git show --stat says:
 7 files changed, 780 insertions(+), 306 deletions(-)
And git show --stat -C says:
 6 files changed, 482 insertions(+), 8 deletions(-)
The commit that I noticed this on is available from:
 git://iabervon.org/~barkalow/git.git builtin-checkout

I've never particularly paid attention to this message before, so I don't know if it's saying something accurate I'm not understanding, or if it's actually inaccurate about what it's trying to show.

	-Daniel
*This .sig left intentionally blank*
Junio C Hamano· Dec 16, 2007, 23:01 UTC · re: Daniel Barkalow · lore

Re: Oddity in git commit summary

Daniel Barkalow <barkalow@iabervon.org> writes:
Show 13 quoted lines
> I just noticed that I got a strange summary from git commit -a --amend 
> with the current master. It said:
>
> Created commit f16cb29: Build in checkout
>  5 files changed, 482 insertions(+), 299 deletions(-)
>  create mode 100644 builtin-checkout.c
>  delete mode 100755 git-checkout.sh
>
> But git show --stat says:
>  7 files changed, 780 insertions(+), 306 deletions(-)
>
> And git show --stat -C says:
>  6 files changed, 482 insertions(+), 8 deletions(-)

Because "git status" has -B -M and your second one does not pass any, I would not worry about the first two differences. But 5 vs 6 seems funny.

print_summary() is broken.
diff --git a/builtin-commit.c b/builtin-commit.c
index 518ebe0..8435702 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -663,6 +665,8 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 	rev.commit_format = get_commit_format("format:%h: %s");
 	rev.always_show_header = 0;
 
+	diff_setup_done(&rev.diffopt);
+
 	printf("Created %scommit ", initial_commit ? "initial " : "");
 
 	if (!log_tree_commit(&rev, commit)) {
Junio C Hamano· Dec 16, 2007, 23:11 UTC · re: Daniel Barkalow · lore

[PATCH 1/2] builtin-commit: fix summary output.

Because print_summary() forgot to call diff_setup_done() after futzing with diff output options, it failed to activate recursive diff, which resulted in an incorrect summary.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This fixes the "5 files" problem you saw with your commit, which was
   totally bogus (it looked at "git diff-tree HEAD" output that was
   non-recursive, discarding the change of tree t/ itself).  Now it will
   show "7 files" in line with your "git show".
 builtin-commit.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 518ebe0..61770ef 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -662,6 +662,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 	rev.show_root_diff = 1;
 	rev.commit_format = get_commit_format("format:%h: %s");
 	rev.always_show_header = 0;
+	diff_setup_done(&rev.diffopt);
 
 	printf("Created %scommit ", initial_commit ? "initial " : "");
 
-- 
1.5.4.rc0.52.gb90ce
Junio C Hamano· Dec 16, 2007, 23:12 UTC · re: Daniel Barkalow · lore

[PATCH 2/2] builtin-commit: make summary output consistent with status

This enables -B -M to the summary output after a commit is made so that it is in line with what is shown in git-status and commit log template.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * And this fixes the "7 files" because print_summary() does not pass -B
   -M which makes it inconsistent with the status output.  After this
   you should see "6 files".
 builtin-commit.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 61770ef..0a91013 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -662,6 +662,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 	rev.show_root_diff = 1;
 	rev.commit_format = get_commit_format("format:%h: %s");
 	rev.always_show_header = 0;
+	rev.diffopt.detect_rename = 1;
+	rev.diffopt.rename_limit = 100;
+	rev.diffopt.break_opt = 0;
 	diff_setup_done(&rev.diffopt);
 
 	printf("Created %scommit ", initial_commit ? "initial " : "");
-- 
1.5.4.rc0.52.gb90ce
Daniel Barkalow· Dec 17, 2007, 03:42 UTC · re: Junio C Hamano · lore

Re: [PATCH 2/2] builtin-commit: make summary output consistent with status

On Sun, 16 Dec 2007, Junio C Hamano wrote:
>  * And this fixes the "7 files" because print_summary() does not pass -B
>    -M which makes it inconsistent with the status output.  After this
>    you should see "6 files".
Yup, it now looks like what I thought that commit consisted of.
	-Daniel
*This .sig left intentionally blank*

← back to recent threads