Skip to content

Commit 81cb521

Browse files
committed
log: reject pickaxe options when combined with -L
The previous commit fixed a crash when -G, -S, or --find-object was used together with -L and rename detection. However, these options still have no effect on -L output: line-log uses its own commit-filtering logic in line_log_filter() and never consults the pickaxe machinery. Rather than silently ignoring these options, reject the combination with a clear error message. This replaces the known-breakage tests from the previous commit with tests that verify the rejection for all three options. A future series could teach line-log to honor these options and remove this restriction. Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
1 parent 273ebf6 commit 81cb521

File tree

2 files changed

+13
-43
lines changed

2 files changed

+13
-43
lines changed

builtin/log.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
317317
if (rev->line_level_traverse && rev->prune_data.nr)
318318
die(_("-L<range>:<file> cannot be used with pathspec"));
319319

320+
if (rev->line_level_traverse &&
321+
(rev->diffopt.pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
322+
die(_("-L does not yet support -G, -S, or --find-object"));
323+
320324
memset(&w, 0, sizeof(w));
321325
userformat_find_requirements(NULL, &w);
322326

t/t4211-line-log.sh

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -367,53 +367,19 @@ test_expect_success 'show line-log with graph' '
367367
test_cmp expect actual
368368
'
369369

370-
test_expect_success 'setup for -L with -G/-S/--find-object and a merge with rename' '
371-
git checkout --orphan pickaxe-rename &&
372-
git reset --hard &&
373-
374-
echo content >file &&
375-
git add file &&
376-
git commit -m "add file" &&
377-
378-
git checkout -b pickaxe-rename-side &&
379-
git mv file renamed-file &&
380-
git commit -m "rename file" &&
381-
382-
git checkout pickaxe-rename &&
383-
git commit --allow-empty -m "diverge" &&
384-
git merge --no-edit pickaxe-rename-side &&
385-
386-
git mv renamed-file file &&
387-
git commit -m "rename back"
388-
'
389-
390-
test_expect_success '-L -G does not crash with merge and rename' '
391-
git log --format="%s" --no-patch -L 1,1:file -G "." >actual
392-
'
393-
394-
test_expect_success '-L -S does not crash with merge and rename' '
395-
git log --format="%s" --no-patch -L 1,1:file -S content >actual
396-
'
397-
398-
test_expect_success '-L --find-object does not crash with merge and rename' '
399-
git log --format="%s" --no-patch -L 1,1:file \
400-
--find-object=$(git rev-parse HEAD:file) >actual
401-
'
402-
403-
test_expect_failure '-L -G should filter commits by pattern' '
404-
git log --format="%s" --no-patch -L 1,1:file -G "nomatch" >actual &&
405-
test_must_be_empty actual
370+
test_expect_success '-L with -G is rejected' '
371+
test_must_fail git log -L 1,1:a.c -G "pattern" 2>err &&
372+
test_grep "does not yet support" err
406373
'
407374

408-
test_expect_failure '-L -S should filter commits by pattern' '
409-
git log --format="%s" --no-patch -L 1,1:file -S "nomatch" >actual &&
410-
test_must_be_empty actual
375+
test_expect_success '-L with -S is rejected' '
376+
test_must_fail git log -L 1,1:a.c -S "pattern" 2>err &&
377+
test_grep "does not yet support" err
411378
'
412379

413-
test_expect_failure '-L --find-object should filter commits by object' '
414-
git log --format="%s" --no-patch -L 1,1:file \
415-
--find-object=$ZERO_OID >actual &&
416-
test_must_be_empty actual
380+
test_expect_success '-L with --find-object is rejected' '
381+
test_must_fail git log -L 1,1:a.c --find-object=HEAD 2>err &&
382+
test_grep "does not yet support" err
417383
'
418384

419385
test_done

0 commit comments

Comments
 (0)