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 <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed Apr 20, 2015 at 14:09 UTC 0269f968b7effea8a4f61f1fb0ac7e9386a9d90c
2 files changed +5 -5
line-log.c
+1 -1
@@ -575,7 +575,7 @@ parse_lines(struct commit *commit, const char *prefix, struct string_list *args)
575
576 name_part = skip_range_arg(item->string);
577 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",
579 item->string);
580 range_part = xstrndup(item->string, name_part - item->string);
581 name_part++;
t/t4211-line-log.sh
+4 -4
@@ -54,14 +54,14 @@ canned_test "-L 4:a.c -L 8,12:a.c simple" multiple-superset
54 canned_test "-L 8,12:a.c -L 4:a.c simple" multiple-superset
55
56 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"
59 test_bad_opts "-L 1:nonexistent" "There is no path"
60 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"
62 test_bad_opts "-L 1000:b.c" "has only.*lines"
63 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"
65 test_bad_opts "-L :foo:b.c" "no match"
66
67 test_expect_success '-L X (X == nlines)' '