Merge branch 'jk/log-graph-name-only'
authorJunio C Hamano <gitster@pobox.com>
Fri, 10 Feb 2017 20:52:26 +0000 (12:52 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Feb 2017 20:52:27 +0000 (12:52 -0800)
"git log --graph" did not work well with "--name-only", even though
other forms of "diff" output were handled correctly.

* jk/log-graph-name-only:
diff: print line prefix for --name-only output

diff.c
t/t4202-log.sh
diff --git a/diff.c b/diff.c
index d91a344908abe7335eaffef4157fc59fefdf3815..a79f3408da44a085f97d5cc1b29c200a2e1defbf 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -4450,6 +4450,7 @@ static void flush_one_pair(struct diff_filepair *p, struct diff_options *opt)
                name_a = p->two->path;
                name_b = NULL;
                strip_prefix(opt->prefix_length, &name_a, &name_b);
+               fprintf(opt->file, "%s", diff_line_prefix(opt));
                write_name_quoted(name_a, opt->file, opt->line_termination);
        }
 }
index 08ea725de3307c886d8f341b49c61c0d3436f91c..48b55bfd274a7adffe18af13489a54a7d92707a4 100755 (executable)
@@ -1212,6 +1212,54 @@ test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
        test_i18ncmp expect actual.sanitized
 '
 
+cat >expect <<-\EOF
+* reach
+|
+| A    reach.t
+* Merge branch 'tangle'
+*   Merge branch 'side'
+|\
+| * side-2
+|
+|   A  2
+* Second
+|
+| A    one
+* sixth
+
+  D    a/two
+EOF
+
+test_expect_success 'log --graph with --name-status' '
+       git log --graph --format=%s --name-status tangle..reach >actual &&
+       sanitize_output <actual >actual.sanitized &&
+       test_cmp expect actual.sanitized
+'
+
+cat >expect <<-\EOF
+* reach
+|
+| reach.t
+* Merge branch 'tangle'
+*   Merge branch 'side'
+|\
+| * side-2
+|
+|   2
+* Second
+|
+| one
+* sixth
+
+  a/two
+EOF
+
+test_expect_success 'log --graph with --name-only' '
+       git log --graph --format=%s --name-only tangle..reach >actual &&
+       sanitize_output <actual >actual.sanitized &&
+       test_cmp expect actual.sanitized
+'
+
 test_expect_success 'dotdot is a parent directory' '
        mkdir -p a/b &&
        ( echo sixth && echo fifth ) >expect &&