@matheusbsbs / matheus-bagliano / commits / 1f0e2a1a65
Fork 0

send-pack: check ref->status before updating tracking refs

Previously, we manually checked the 'NONE' and 'UPTODATE' conditions. Now that we have ref->status, we can easily say "only update if we pushed successfully". This adds a test for and fixes a regression introduced in ed31df31 where deleted refs did not have their tracking branches removed. This was due to a bogus per-ref error test that is superseded by the more accurate ref->status flag. Signed-off-by: Jeff King <peff@peff.net> Completely-Acked-By: Alex "Sleepy" Riesen <raa.lkml@gmail.com> Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Nov 17, 2007 at 07:55 UTC 1f0e2a1a65477c2b8eb8812e5bf0ad07bf03738e
2 files changed +10 -13
builtin-send-pack.c
+5 -13
@@ -180,24 +180,17 @@ static int receive_status(int in)
180 static void update_tracking_ref(struct remote *remote, struct ref *ref)
181 {
182 struct refspec rs;
183 - int will_delete_ref;
183
185 - rs.src = ref->name;
186 - rs.dst = NULL;
187 -
188 - if (!ref->peer_ref)
184 + if (ref->status != REF_STATUS_OK)
185 return;
186
191 - will_delete_ref = is_null_sha1(ref->peer_ref->new_sha1);
192 -
193 - if (!will_delete_ref &&
194 - !hashcmp(ref->old_sha1, ref->peer_ref->new_sha1))
195 - return;
187 + rs.src = ref->name;
188 + rs.dst = NULL;
189
190 if (!remote_find_tracking(remote, &rs)) {
191 if (args.verbose)
192 fprintf(stderr, "updating local tracking ref '%s'\n", rs.dst);
200 - if (is_null_sha1(ref->peer_ref->new_sha1)) {
193 + if (ref->deletion) {
194 if (delete_ref(rs.dst, NULL))
195 error("Failed to delete");
196 } else
@@ -444,8 +437,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
437
438 if (!args.dry_run && remote) {
439 for (ref = remote_refs; ref; ref = ref->next)
447 - if (!is_null_sha1(ref->new_sha1))
448 - update_tracking_ref(remote, ref);
440 + update_tracking_ref(remote, ref);
441 }
442
443 if (!new_refs)
t/t5404-tracking-branches.sh
+5
@@ -45,4 +45,9 @@ test_expect_success 'check tracking branches not updated for failed refs' '
45 test "$(git rev-parse origin/b2)" = "$b2"
46 '
47
48 +test_expect_success 'deleted branches have their tracking branches removed' '
49 + git push origin :b1 &&
50 + test "$(git rev-parse origin/b1)" = "origin/b1"
51 +'
52 +
53 test_done