Skip to content

Commit 9f607cd

Browse files
peffgitster
authored andcommitted
line-log: suppress diff output with "-s"
When "-L" is in use, we ignore any diff output format that the user provides to us, and just always print a patch (with extra context lines covering the whole area of interest). It's not entirely clear what we should do with all formats (e.g., should "--stat" show just the diffstat of the touched lines, or the stat for the whole file?). But "-s" is pretty clear: the user probably wants to see just the commits that touched those lines, without any diff at all. Let's at least make that work. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 36eb1cb commit 9f607cd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-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

t/t4211-line-log.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,11 @@ 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+
118125
test_done

0 commit comments

Comments
 (0)