push: flag updates that require force
authorChris Rorvick <chris@rorvick.com>
Fri, 30 Nov 2012 01:41:36 +0000 (19:41 -0600)
committerJunio C Hamano <gitster@pobox.com>
Sun, 2 Dec 2012 09:44:15 +0000 (01:44 -0800)
Add a flag for indicating an update to a reference requires force.
Currently the `nonfastforward` flag is used for this when generating the
status message.  A separate flag insulates dependent logic from the
details of set_ref_status_for_push().

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

diff --git a/cache.h b/cache.h
index 722321c6da936492e297059ae07b6cf54f94d67d..b7ab4ac62428a3bc50224801bfee0277c6139e16 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -999,7 +999,9 @@ struct ref {
        unsigned char old_sha1[20];
        unsigned char new_sha1[20];
        char *symref;
-       unsigned int force:1,
+       unsigned int
+               force:1,
+               requires_force:1,
                merge:1,
                nonfastforward:1,
                not_forwardable:1,
index 07040b8824771db9b83025a20af957baf7a6d591..4a6f822089c076c10417cee6afc7a09de9777120 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1293,6 +1293,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
        struct ref *ref;
 
        for (ref = remote_refs; ref; ref = ref->next) {
+               int force_ref_update = ref->force || force_update;
+
                if (ref->peer_ref)
                        hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
                else if (!send_mirror)
@@ -1335,9 +1337,12 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
                                !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;
+                       if (ref->nonfastforward) {
+                               ref->requires_force = 1;
+                               if (!force_ref_update) {
+                                       ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
+                                       continue;
+                               }
                        }
                }
        }
index bc31e8e66beac675a4334b32b8d1547350bbb470..f3160b142f7f5142a0935168e65461d34a5b2b7a 100644 (file)
@@ -659,7 +659,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
                const char *msg;
 
                strcpy(quickref, status_abbrev(ref->old_sha1));
-               if (ref->nonfastforward) {
+               if (ref->requires_force) {
                        strcat(quickref, "...");
                        type = '+';
                        msg = "forced update";