push: keep track of "update" state separately
authorChris Rorvick <chris@rorvick.com>
Fri, 30 Nov 2012 01:41:35 +0000 (19:41 -0600)
committerJunio C Hamano <gitster@pobox.com>
Sun, 2 Dec 2012 09:43:28 +0000 (01:43 -0800)
If the reference exists on the remote and it is not being removed, then
mark as an update.  This is in preparation for handling tags (lightweight
and annotated) exceptionally.

Signed-off-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
remote.c

diff --git a/cache.h b/cache.h
index d72b64d8b0958216e1f7266b11816c210be0efb9..722321c6da936492e297059ae07b6cf54f94d67d 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1003,6 +1003,7 @@ struct ref {
                merge:1,
                nonfastforward:1,
                not_forwardable:1,
+               update:1,
                deletion:1;
        enum {
                REF_STATUS_NONE = 0,
index 51016831b94d8e11f1397bf250a01c986a5d13f5..07040b8824771db9b83025a20af957baf7a6d591 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1326,15 +1326,19 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
 
                ref->not_forwardable = !is_forwardable(ref);
 
-               ref->nonfastforward =
+               ref->update =
                        !ref->deletion &&
-                       !is_null_sha1(ref->old_sha1) &&
-                       (!has_sha1_file(ref->old_sha1)
-                         || !ref_newer(ref->new_sha1, ref->old_sha1));
+                       !is_null_sha1(ref->old_sha1);
 
-               if (ref->nonfastforward && !ref->force && !force_update) {
-                       ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
-                       continue;
+               if (ref->update) {
+                       ref->nonfastforward =
+                               !has_sha1_file(ref->old_sha1)
+                                 || !ref_newer(ref->new_sha1, ref->old_sha1);
+
+                       if (ref->nonfastforward && !ref->force && !force_update) {
+                               ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
+                               continue;
+                       }
                }
        }
 }