log: fix indentation for --graph --show-signature

The git log --graph --show-signature command incorrectly indents the gpg information about signed commits and merged signed tags. It does not follow the level of indentation of the current commit. Example of garbled output: $ git log --show-signature --graph * commit 258e0a237cb69aaa587b0a4fb528bb0316b1b776 |\ gpg: Signature made Mon, Jun 30, 2014 13:22:33 EDT using RSA key ID DA08 gpg: Good signature from "Jason Pyeron <jpye...@pdinc.us>" Merge: 727c355 1ca13ed | | Author: Jason Pyeron <jpye...@pdinc.us> | | Date: Mon Jun 30 13:22:29 2014 -0400 | | | | Merge of 1ca13ed2271d60ba9 branch - rebranding | | | * commit 1ca13ed2271d60ba93d40bcc8db17ced8545f172 | | gpg: Signature made Mon, Jun 23, 2014 9:45:47 EDT using RSA key ID DD37 gpg: Good signature from "Stephen Robert Guglielmo <s...@guglielmo.us>" gpg: aka "Stephen Robert Guglielmo <srguglie...@gmail.com>" Author: Stephen R Guglielmo <s...@guglielmo.us> | | Date: Mon Jun 23 09:45:27 2014 -0400 | | | | Minor URL updates In log-tree.c modify show_sig_lines() function to call graph_show_oneline() after each line of gpg information it has printed in order to preserve the level of indentation for the next output line. Reported-by: Jason Pyeron <jpyeron@pdinc.us> Signed-off-by: Zoltan Klinger <zoltan.klinger@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Zoltan Klinger committed Jul 9, 2014 at 12:10 UTC cf3983d1ff861657c8813feb7df82a74a29d06bc
2 files changed +32
log-tree.c
+1
@@ -365,6 +365,7 @@ static void show_sig_lines(struct rev_info *opt, int status, const char *bol)
365 eol = strchrnul(bol, '\n');
366 printf("%s%.*s%s%s", color, (int)(eol - bol), bol, reset,
367 *eol ? "\n" : "");
368 + graph_show_oneline(opt->graph);
369 bol = (*eol) ? (eol + 1) : eol;
370 }
371 }
t/t4202-log.sh
+31
@@ -3,6 +3,7 @@
3 test_description='git log'
4
5 . ./test-lib.sh
6 +. "$TEST_DIRECTORY/lib-gpg.sh"
7
8 test_expect_success setup '
9
@@ -841,4 +842,34 @@ test_expect_success 'dotdot is a parent directory' '
842 test_cmp expect actual
843 '
844
845 +test_expect_success GPG 'log --graph --show-signature' '
846 + test_when_finished "git reset --hard && git checkout master" &&
847 + git checkout -b signed master &&
848 + echo foo >foo &&
849 + git add foo &&
850 + git commit -S -m signed_commit &&
851 + git log --graph --show-signature -n1 signed >actual &&
852 + grep "^| gpg: Signature made" actual &&
853 + grep "^| gpg: Good signature" actual
854 +'
855 +
856 +test_expect_success GPG 'log --graph --show-signature for merged tag' '
857 + test_when_finished "git reset --hard && git checkout master" &&
858 + git checkout -b plain master &&
859 + echo aaa >bar &&
860 + git add bar &&
861 + git commit -m bar_commit &&
862 + git checkout -b tagged master &&
863 + echo bbb >baz &&
864 + git add baz &&
865 + git commit -m baz_commit &&
866 + git tag -s -m signed_tag_msg signed_tag &&
867 + git checkout plain &&
868 + git merge --no-ff -m msg signed_tag &&
869 + git log --graph --show-signature -n1 plain >actual &&
870 + grep "^|\\\ merged tag" actual &&
871 + grep "^| | gpg: Signature made" actual &&
872 + grep "^| | gpg: Good signature" actual
873 +'
874 +
875 test_done