@matheusbsbs / matheus-bagliano / commits / 5eb7358167
Fork 0

send-pack: respect '+' on wildcard refspecs

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>

Jeff King committed Oct 19, 2007 at 05:04 UTC 5eb73581679abb41dcdf9ad7fa63fa156e078790
2 files changed +50
remote.c
+2
@@ -626,6 +626,8 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
626 hashcpy(dst_peer->new_sha1, src->new_sha1);
627 }
628 dst_peer->peer_ref = src;
629 + if (pat)
630 + dst_peer->force = pat->force;
631 free_name:
632 free(dst_name);
633 }
t/t5400-send-pack.sh
+48
@@ -123,4 +123,52 @@ test_expect_success \
123 git-branch -a >branches && ! grep -q origin/master branches
124 '
125
126 +rewound_push_setup() {
127 + rm -rf parent child &&
128 + mkdir parent && cd parent &&
129 + git-init && echo one >file && git-add file && git-commit -m one &&
130 + echo two >file && git-commit -a -m two &&
131 + cd .. &&
132 + git-clone parent child && cd child && git-reset --hard HEAD^
133 +}
134 +
135 +rewound_push_succeeded() {
136 + cmp ../parent/.git/refs/heads/master .git/refs/heads/master
137 +}
138 +
139 +rewound_push_failed() {
140 + if rewound_push_succeeded
141 + then
142 + false
143 + else
144 + true
145 + fi
146 +}
147 +
148 +test_expect_success \
149 + 'pushing explicit refspecs respects forcing' '
150 + rewound_push_setup &&
151 + if git-send-pack ../parent/.git refs/heads/master:refs/heads/master
152 + then
153 + false
154 + else
155 + true
156 + fi && rewound_push_failed &&
157 + git-send-pack ../parent/.git +refs/heads/master:refs/heads/master &&
158 + rewound_push_succeeded
159 +'
160 +
161 +test_expect_success \
162 + 'pushing wildcard refspecs respects forcing' '
163 + rewound_push_setup &&
164 + if git-send-pack ../parent/.git refs/heads/*:refs/heads/*
165 + then
166 + false
167 + else
168 + true
169 + fi && rewound_push_failed &&
170 + git-send-pack ../parent/.git +refs/heads/*:refs/heads/* &&
171 + rewound_push_succeeded
172 +'
173 +
174 test_done