From: Chris Rorvick Date: Fri, 30 Nov 2012 01:41:35 +0000 (-0600) Subject: push: keep track of "update" state separately X-Git-Tag: v1.8.2-rc0~185^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ffe81ef2ac5bcf83b9ab792e4d05ec95744a2fb6;p=thirdparty%2Fgit.git push: keep track of "update" state separately 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 Signed-off-by: Junio C Hamano --- diff --git a/cache.h b/cache.h index d72b64d8b0..722321c6da 100644 --- 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, diff --git a/remote.c b/remote.c index 51016831b9..07040b8824 100644 --- 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; + } } } }