Skip to content

Commit 31df2c1

Browse files
committed
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"
2 parents ac9e40e + 05314ef commit 31df2c1

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

line-log.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,10 +1103,12 @@ static int process_all_files(struct line_log_data **range_out,
11031103

11041104
int line_log_print(struct rev_info *rev, struct commit *commit)
11051105
{
1106-
struct line_log_data *range = lookup_line_range(rev, commit);
11071106

11081107
show_log(rev);
1109-
dump_diff_hacky(rev, range);
1108+
if (!(rev->diffopt.output_format & DIFF_FORMAT_NO_OUTPUT)) {
1109+
struct line_log_data *range = lookup_line_range(rev, commit);
1110+
dump_diff_hacky(rev, range);
1111+
}
11101112
return 1;
11111113
}
11121114

revision.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,6 +2689,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
26892689
if (revs->first_parent_only && revs->bisect)
26902690
die(_("--first-parent is incompatible with --bisect"));
26912691

2692+
if (revs->line_level_traverse &&
2693+
(revs->diffopt.output_format & ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT)))
2694+
die(_("-L does not yet support diff formats besides -p and -s"));
2695+
26922696
if (revs->expand_tabs_in_log < 0)
26932697
revs->expand_tabs_in_log = revs->expand_tabs_in_log_default;
26942698

t/t4211-line-log.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,21 @@ test_expect_success 'range_set_union' '
115115
git log $(for x in $(test_seq 200); do echo -L $((2*x)),+1:c.c; done)
116116
'
117117

118+
test_expect_success '-s shows only line-log commits' '
119+
git log --format="commit %s" -L1,24:b.c >expect.raw &&
120+
grep ^commit expect.raw >expect &&
121+
git log --format="commit %s" -L1,24:b.c -s >actual &&
122+
test_cmp expect actual
123+
'
124+
125+
test_expect_success '-p shows the default patch output' '
126+
git log -L1,24:b.c >expect &&
127+
git log -L1,24:b.c -p >actual &&
128+
test_cmp expect actual
129+
'
130+
131+
test_expect_success '--raw is forbidden' '
132+
test_must_fail git log -L1,24:b.c --raw
133+
'
134+
118135
test_done

0 commit comments

Comments
 (0)