Skip to content

Commit 0269f96

Browse files
moygitster
authored andcommitted
log -L: improve error message on malformed argument
The old message did not mention the :regex:file form. To avoid overly long lines, split the message into two lines (in case item->string is long, it will be the only part truncated in a narrow terminal). Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d349e0e commit 0269f96

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

line-log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ parse_lines(struct commit *commit, const char *prefix, struct string_list *args)
575575

576576
name_part = skip_range_arg(item->string);
577577
if (!name_part || *name_part != ':' || !name_part[1])
578-
die("-L argument '%s' not of the form start,end:file",
578+
die("-L argument not 'start,end:file' or ':funcname:file': %s",
579579
item->string);
580580
range_part = xstrndup(item->string, name_part - item->string);
581581
name_part++;

t/t4211-line-log.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ canned_test "-L 4:a.c -L 8,12:a.c simple" multiple-superset
5454
canned_test "-L 8,12:a.c -L 4:a.c simple" multiple-superset
5555

5656
test_bad_opts "-L" "switch.*requires a value"
57-
test_bad_opts "-L b.c" "argument.*not of the form"
58-
test_bad_opts "-L 1:" "argument.*not of the form"
57+
test_bad_opts "-L b.c" "argument not .start,end:file"
58+
test_bad_opts "-L 1:" "argument not .start,end:file"
5959
test_bad_opts "-L 1:nonexistent" "There is no path"
6060
test_bad_opts "-L 1:simple" "There is no path"
61-
test_bad_opts "-L '/foo:b.c'" "argument.*not of the form"
61+
test_bad_opts "-L '/foo:b.c'" "argument not .start,end:file"
6262
test_bad_opts "-L 1000:b.c" "has only.*lines"
6363
test_bad_opts "-L 1,1000:b.c" "has only.*lines"
64-
test_bad_opts "-L :b.c" "argument.*not of the form"
64+
test_bad_opts "-L :b.c" "argument not .start,end:file"
6565
test_bad_opts "-L :foo:b.c" "no match"
6666

6767
test_expect_success '-L X (X == nlines)' '

0 commit comments

Comments
 (0)