]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t5505-remote.sh
push: add an advice on unqualified <dst> push
[thirdparty/git.git] / t / t5505-remote.sh
index d2a2cdd453396b1dba5525f32b6325ac8a10d95d..f069cbcc24204bc15b75ec88ef7cec45f12244a8 100755 (executable)
@@ -1222,4 +1222,32 @@ test_expect_success 'add remote matching the "insteadOf" URL' '
        git remote add backup xyz@example.com
 '
 
+test_expect_success 'unqualified <dst> refspec DWIM and advice' '
+       test_when_finished "(cd test && git tag -d some-tag)" &&
+       (
+               cd test &&
+               git tag -a -m "Some tag" some-tag master &&
+               exit_with=true &&
+               for type in commit tag tree blob
+               do
+                       if test "$type" = "blob"
+                       then
+                               oid=$(git rev-parse some-tag:file)
+                       else
+                               oid=$(git rev-parse some-tag^{$type})
+                       fi &&
+                       test_must_fail git push origin $oid:dst 2>err &&
+                       test_i18ngrep "error: The destination you" err &&
+                       test_i18ngrep "hint: Did you mean" err &&
+                       test_must_fail git -c advice.pushUnqualifiedRefName=false \
+                               push origin $oid:dst 2>err &&
+                       test_i18ngrep "error: The destination you" err &&
+                       test_i18ngrep ! "hint: Did you mean" err ||
+                       exit_with=false
+               done &&
+               $exit_with
+       )
+'
+
+
 test_done