tag: change --point-at to default to HEAD
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 24 Mar 2017 18:40:56 +0000 (18:40 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Mar 2017 19:15:26 +0000 (12:15 -0700)
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>
Documentation/git-tag.txt
builtin/tag.c
t/t7004-tag.sh
index 4d289f5dd5e983db85c57aa0e4a82e9a98df8fed..d5cdb18d9614a15a1f9163e48dd6ce693e88412e 100644 (file)
@@ -139,7 +139,8 @@ This option is only applicable when listing tags without annotation lines.
        commit (`HEAD` if not specified), incompatible with `--merged`.
 
 --points-at <object>::
        commit (`HEAD` if not specified), incompatible with `--merged`.
 
 --points-at <object>::
-       Only list tags of the given object. Implies `--list`.
+       Only list tags of the given object (HEAD if not
+       specified). Implies `--list`.
 
 -m <msg>::
 --message=<msg>::
 
 -m <msg>::
 --message=<msg>::
index 3c686961db23ad84f798fd17a6a186bd579a8265..8bf6d8517649478b907152a8b68e15206b865ad9 100644 (file)
@@ -431,7 +431,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
                             N_("field name to sort on"), &parse_opt_ref_sorting),
                {
                        OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"),
                             N_("field name to sort on"), &parse_opt_ref_sorting),
                {
                        OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"),
-                       N_("print only tags of the object"), 0, parse_opt_object_name
+                       N_("print only tags of the object"), PARSE_OPT_LASTARG_DEFAULT,
+                       parse_opt_object_name, (intptr_t) "HEAD"
                },
                OPT_STRING(  0 , "format", &format, N_("format"), N_("format to use for the output")),
                OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
                },
                OPT_STRING(  0 , "format", &format, N_("format"), N_("format to use for the output")),
                OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
index 5823de16aac752d3e2f89c85d52fdb4950605903..3529c3009caa4d70113e64fce15d2c9622a2a2cc 100755 (executable)
@@ -1534,7 +1534,8 @@ do
        "
        test_expect_success "Doing 'git tag --list-like $option <commit> <pattern> is permitted" "
                git tag -n $option HEAD HEAD &&
        "
        test_expect_success "Doing 'git tag --list-like $option <commit> <pattern> is permitted" "
                git tag -n $option HEAD HEAD &&
-               git tag $option HEAD HEAD
+               git tag $option HEAD HEAD &&
+               git tag $option
        "
 done
 
        "
 done
 
@@ -1546,6 +1547,12 @@ test_expect_success '--points-at can be used in non-list mode' '
        test_cmp expect actual
 '
 
        test_cmp expect actual
 '
 
+test_expect_success '--points-at is a synonym for --points-at HEAD' '
+       echo v4.0 >expect &&
+       git tag --points-at >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success '--points-at finds lightweight tags' '
        echo v4.0 >expect &&
        git tag --points-at v4.0 >actual &&
 test_expect_success '--points-at finds lightweight tags' '
        echo v4.0 >expect &&
        git tag --points-at v4.0 >actual &&