1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 12:59:41 +01:00

Merge branch 'jk/line-log-with-patch'

"git log -L<from>,<to>:<path>" with "-s" did not suppress the patch
output as it should.  This has been corrected.

* jk/line-log-with-patch:
  line-log: detect unsupported formats
  line-log: suppress diff output with "-s"
This commit is contained in:
Junio C Hamano 2019-04-10 02:14:23 +09:00
commit 31df2c1019
3 changed files with 25 additions and 2 deletions

View file

@ -1103,10 +1103,12 @@ static int process_all_files(struct line_log_data **range_out,
int line_log_print(struct rev_info *rev, struct commit *commit)
{
struct line_log_data *range = lookup_line_range(rev, commit);
show_log(rev);
dump_diff_hacky(rev, range);
if (!(rev->diffopt.output_format & DIFF_FORMAT_NO_OUTPUT)) {
struct line_log_data *range = lookup_line_range(rev, commit);
dump_diff_hacky(rev, range);
}
return 1;
}

View file

@ -2689,6 +2689,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
if (revs->first_parent_only && revs->bisect)
die(_("--first-parent is incompatible with --bisect"));
if (revs->line_level_traverse &&
(revs->diffopt.output_format & ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT)))
die(_("-L does not yet support diff formats besides -p and -s"));
if (revs->expand_tabs_in_log < 0)
revs->expand_tabs_in_log = revs->expand_tabs_in_log_default;

View file

@ -115,4 +115,21 @@ test_expect_success 'range_set_union' '
git log $(for x in $(test_seq 200); do echo -L $((2*x)),+1:c.c; done)
'
test_expect_success '-s shows only line-log commits' '
git log --format="commit %s" -L1,24:b.c >expect.raw &&
grep ^commit expect.raw >expect &&
git log --format="commit %s" -L1,24:b.c -s >actual &&
test_cmp expect actual
'
test_expect_success '-p shows the default patch output' '
git log -L1,24:b.c >expect &&
git log -L1,24:b.c -p >actual &&
test_cmp expect actual
'
test_expect_success '--raw is forbidden' '
test_must_fail git log -L1,24:b.c --raw
'
test_done