Skip to content

Commit 1e0c3b6

Browse files
avargitster
authored andcommitted
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 ae7706b (tag: add --points-at list option, 2012-02-08). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6a33814 commit 1e0c3b6

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

Documentation/git-tag.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ This option is only applicable when listing tags without annotation lines.
139139
commit (`HEAD` if not specified), incompatible with `--merged`.
140140

141141
--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`.
143144

144145
-m <msg>::
145146
--message=<msg>::

builtin/tag.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
431431
N_("field name to sort on"), &parse_opt_ref_sorting),
432432
{
433433
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"
435436
},
436437
OPT_STRING( 0 , "format", &format, N_("format"), N_("format to use for the output")),
437438
OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),

t/t7004-tag.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,8 @@ do
15341534
"
15351535
test_expect_success "Doing 'git tag --list-like $option <commit> <pattern> is permitted" "
15361536
git tag -n $option HEAD HEAD &&
1537-
git tag $option HEAD HEAD
1537+
git tag $option HEAD HEAD &&
1538+
git tag $option
15381539
"
15391540
done
15401541

@@ -1546,6 +1547,12 @@ test_expect_success '--points-at can be used in non-list mode' '
15461547
test_cmp expect actual
15471548
'
15481549

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+
15491556
test_expect_success '--points-at finds lightweight tags' '
15501557
echo v4.0 >expect &&
15511558
git tag --points-at v4.0 >actual &&

0 commit comments

Comments
 (0)