Merge branch 'jk/log-graph-name-only'

"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
This commit is contained in:
Junio C Hamano 2017-02-10 12:52:26 -08:00
commit e53c7f8731
2 changed files with 49 additions and 0 deletions

1
diff.c
View File

@ -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);
}
}

View File

@ -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 &&