path: root/t/
diff options
authorTay Ray Chuan <>2010-01-08 02:12:41 (GMT)
committerJunio C Hamano <>2010-01-10 07:34:10 (GMT)
commit7b69079be964ca0a09a1a7895455ba3df379984e (patch)
tree87fdf7776ae7d1a5b24b789eb611cc8d937e9429 /t/
parent1945237486851bc3a0c6d65eaeb21cb22cac2ea1 (diff)
git-7b69079be964ca0a09a1a7895455ba3df379984e.tar.bz2 add test for unmatched, non-fast-forwarded refs
Some refs can only be matched to a remote ref with an explicit refspec. When such a ref is a non-fast-forward of its remote ref, test that pushing them (with the explicit refspec specified) fails with a non- fast-foward-type error (viz. printing of ref status and help message). Signed-off-by: Tay Ray Chuan <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 21 insertions, 0 deletions
diff --git a/t/ b/t/
index f49c7c4..cc740fe 100755
--- a/t/
+++ b/t/
@@ -111,5 +111,26 @@ Merge the remote changes before pushing again. See the '"'non-fast-forward'"'
section of '"'git push --help'"' for details." output
+test_expect_failure 'push fails for non-fast-forward refs unmatched by remote helper' '
+ # create a dissimilarly-named remote ref so that git is unable to match the
+ # two refs (viz. local, remote) unless an explicit refspec is provided.
+ git push origin master:retsam
+ echo "change changed" > path2 &&
+ git commit -a -m path2 --amend &&
+ # push master too; this ensures there is at least one '"'push'"' command to
+ # the remote helper and triggers interaction with the helper.
+ !(git push -v origin +master master:retsam >output 2>&1) &&
+ grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output &&
+ grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output &&
+ grep \
+"To prevent you from losing history, non-fast-forward updates were rejected
+Merge the remote changes before pushing again. See the '"'non-fast-forward'"'
+section of '"'git push --help'"' for details." output