summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6e7b330)
raw | patch | inline | side by side (parent: 6e7b330)
author | Bert Wesarg <bert.wesarg@googlemail.com> | |
Mon, 13 Apr 2009 10:25:47 +0000 (12:25 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 13 Apr 2009 16:36:52 +0000 (09:36 -0700) |
core.warnAmbiguousRefs is used to select strict mode for the
abbreviation for the ":short" format specifier of "refname" and "upstream".
In strict mode, the abbreviated ref will never trigger the
'warn_ambiguous_refs' warning. I.e. for these refs:
refs/heads/xyzzy
refs/tags/xyzzy
the abbreviated forms are:
heads/xyzzy
tags/xyzzy
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
abbreviation for the ":short" format specifier of "refname" and "upstream".
In strict mode, the abbreviated ref will never trigger the
'warn_ambiguous_refs' warning. I.e. for these refs:
refs/heads/xyzzy
refs/tags/xyzzy
the abbreviated forms are:
heads/xyzzy
tags/xyzzy
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-for-each-ref.txt | patch | blob | history | |
builtin-for-each-ref.c | patch | blob | history | |
t/t6300-for-each-ref.sh | patch | blob | history |
index b362e9ed12fb8c45802d488eb5685f8842e0607d..8dc873fd4465879ec3224732c690f1173a6e2dc2 100644 (file)
refname::
The name of the ref (the part after $GIT_DIR/).
For a non-ambiguous short name of the ref append `:short`.
+ The option core.warnAmbiguousRefs is used to select the strict
+ abbreviation mode.
objecttype::
The type of the object (`blob`, `tree`, `commit`, `tag`).
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index cfff686ac8e151c9624788e27dda9cda268e41e8..91e8f95fd20215cae72e206a691370c71dbc575e 100644 (file)
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
if (formatp) {
formatp++;
if (!strcmp(formatp, "short"))
- refname = shorten_unambiguous_ref(refname, 0);
+ refname = shorten_unambiguous_ref(refname,
+ warn_ambiguous_refs);
else
die("unknown %.*s format %s",
(int)(formatp - name), name, formatp);
sort = default_sort();
sort_atom_limit = used_atom_cnt;
+ /* for warn_ambiguous_refs */
+ git_config(git_default_config, NULL);
+
memset(&cbdata, 0, sizeof(cbdata));
cbdata.grab_pattern = argv;
for_each_ref(grab_single_ref, &cbdata);
index daf02d5c103a55575edeefc53643a5b3794de121..8052c86ad3516505765ab214f4801940c8cc1684 100755 (executable)
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
cat >expected <<\EOF
heads/master
-master
+tags/master
EOF
-test_expect_success 'Check ambiguous head and tag refs' '
+test_expect_success 'Check ambiguous head and tag refs (strict)' '
+ git config --bool core.warnambiguousrefs true &&
git checkout -b newtag &&
echo "Using $datestamp" > one &&
git add one &&
test_cmp expected actual
'
+cat >expected <<\EOF
+heads/master
+master
+EOF
+
+test_expect_success 'Check ambiguous head and tag refs (loose)' '
+ git config --bool core.warnambiguousrefs false &&
+ git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual &&
+ test_cmp expected actual
+'
+
cat >expected <<\EOF
heads/ambiguous
ambiguous
EOF
-test_expect_success 'Check ambiguous head and tag refs II' '
+test_expect_success 'Check ambiguous head and tag refs II (loose)' '
git checkout master &&
git tag ambiguous testtag^0 &&
git branch ambiguous testtag^0 &&