Skip to content

Commit 05314ef

Browse files
peffgitster
authored andcommitted
line-log: detect unsupported formats
If you use "log -L" with an output format like "--raw" or "--stat", we'll silently ignore the format and just output the normal patch. Let's detect and complain about this, which at least tells the user what's going on. The tests here aren't exhaustive over the set of all formats, but it should at least let us know if somebody breaks the format-checking. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9f607cd commit 05314ef

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

revision.c

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

2686+
if (revs->line_level_traverse &&
2687+
(revs->diffopt.output_format & ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT)))
2688+
die(_("-L does not yet support diff formats besides -p and -s"));
2689+
26862690
if (revs->expand_tabs_in_log < 0)
26872691
revs->expand_tabs_in_log = revs->expand_tabs_in_log_default;
26882692

t/t4211-line-log.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,14 @@ test_expect_success '-s shows only line-log commits' '
122122
test_cmp expect actual
123123
'
124124

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+
125135
test_done

0 commit comments

Comments
 (0)