Code

send-pack: respect '+' on wildcard refspecs
authorJeff King <peff@peff.net>
Fri, 19 Oct 2007 09:04:00 +0000 (05:04 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Sat, 20 Oct 2007 02:59:10 +0000 (22:59 -0400)
When matching source and destination refs, we were failing
to pull the 'force' parameter from wildcard refspecs (but
not explicit ones) and attach it to the ref struct.

This adds a test for explicit and wildcard refspecs; the
latter fails without this patch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
remote.c
t/t5400-send-pack.sh

index bb774d0bcc3f5b3e7a8cdbb29ba43fcaf00f0d4c..cdbbdcb00dee400f4fe654a86c1dd0060a613904 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -626,6 +626,8 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
                        hashcpy(dst_peer->new_sha1, src->new_sha1);
                }
                dst_peer->peer_ref = src;
+               if (pat)
+                       dst_peer->force = pat->force;
        free_name:
                free(dst_name);
        }
index 57c6397be116bb93af2ccffb0cee2d4bb3901ca4..2d0c07fd6a38d786efc895bc5c5c0d7dd268b31f 100755 (executable)
@@ -123,4 +123,52 @@ test_expect_success \
        git-branch -a >branches && ! grep -q origin/master branches
 '
 
+rewound_push_setup() {
+       rm -rf parent child &&
+       mkdir parent && cd parent &&
+       git-init && echo one >file && git-add file && git-commit -m one &&
+       echo two >file && git-commit -a -m two &&
+       cd .. &&
+       git-clone parent child && cd child && git-reset --hard HEAD^
+}
+
+rewound_push_succeeded() {
+       cmp ../parent/.git/refs/heads/master .git/refs/heads/master
+}
+
+rewound_push_failed() {
+       if rewound_push_succeeded
+       then
+               false
+       else
+               true
+       fi
+}
+
+test_expect_success \
+       'pushing explicit refspecs respects forcing' '
+       rewound_push_setup &&
+       if git-send-pack ../parent/.git refs/heads/master:refs/heads/master
+       then
+               false
+       else
+               true
+       fi && rewound_push_failed &&
+       git-send-pack ../parent/.git +refs/heads/master:refs/heads/master &&
+       rewound_push_succeeded
+'
+
+test_expect_success \
+       'pushing wildcard refspecs respects forcing' '
+       rewound_push_setup &&
+       if git-send-pack ../parent/.git refs/heads/*:refs/heads/*
+       then
+               false
+       else
+               true
+       fi && rewound_push_failed &&
+       git-send-pack ../parent/.git +refs/heads/*:refs/heads/* &&
+       rewound_push_succeeded
+'
+
 test_done