tag: change --point-at to default to HEAD
Change the --points-at option to default to HEAD for consistency with its siblings --contains, --merged etc. which default to HEAD. Previously we'd get: $ git tag --points-at 2>&1 | head -n 1 error: option `points-at' requires a value This changes behavior added in commit ae7706b9ac (tag: add --points-at list option, 2012-02-08). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Mar 24, 2017 at 18:40 UTC
1e0c3b680c6e7b37fc51bd69a410af01897a4f94
3 files changed
+12
-3
Documentation/git-tag.txt
+2
-1
@@ -139,7 +139,8 @@ This option is only applicable when listing tags without annotation lines.
139
commit (`HEAD` if not specified), incompatible with `--merged`.
140
141
--points-at <object>::
142
- Only list tags of the given object. Implies `--list`.
142
+ Only list tags of the given object (HEAD if not
143
+ specified). Implies `--list`.
144
145
-m <msg>::
146
--message=<msg>::
builtin/tag.c
+2
-1
@@ -431,7 +431,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
431
N_("field name to sort on"), &parse_opt_ref_sorting),
432
{
433
OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"),
434
- N_("print only tags of the object"), 0, parse_opt_object_name
434
+ N_("print only tags of the object"), PARSE_OPT_LASTARG_DEFAULT,
435
+ parse_opt_object_name, (intptr_t) "HEAD"
436
},
437
OPT_STRING( 0 , "format", &format, N_("format"), N_("format to use for the output")),
438
OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
t/t7004-tag.sh
+8
-1
@@ -1534,7 +1534,8 @@ do
1534
"
1535
test_expect_success "Doing 'git tag --list-like $option <commit> <pattern> is permitted" "
1536
git tag -n $option HEAD HEAD &&
1537
- git tag $option HEAD HEAD
1537
+ git tag $option HEAD HEAD &&
1538
+ git tag $option
1539
"
1540
done
1541
@@ -1546,6 +1547,12 @@ test_expect_success '--points-at can be used in non-list mode' '
1547
test_cmp expect actual
1548
'
1549
1550
+test_expect_success '--points-at is a synonym for --points-at HEAD' '
1551
+ echo v4.0 >expect &&
1552
+ git tag --points-at >actual &&
1553
+ test_cmp expect actual
1554
+'
1555
+
1556
test_expect_success '--points-at finds lightweight tags' '
1557
echo v4.0 >expect &&
1558
git tag --points-at v4.0 >actual &&