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 <chris@rorvick.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Chris Rorvick committed Nov 29, 2012 at 19:41 UTC ffe81ef2ac5bcf83b9ab792e4d05ec95744a2fb6
2 files changed +12 -7
cache.h
+1
@@ -1003,6 +1003,7 @@ struct ref {
1003 merge:1,
1004 nonfastforward:1,
1005 not_forwardable:1,
1006 + update:1,
1007 deletion:1;
1008 enum {
1009 REF_STATUS_NONE = 0,
remote.c
+11 -7
@@ -1326,15 +1326,19 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1326
1327 ref->not_forwardable = !is_forwardable(ref);
1328
1329 - ref->nonfastforward =
1329 + ref->update =
1330 !ref->deletion &&
1331 - !is_null_sha1(ref->old_sha1) &&
1332 - (!has_sha1_file(ref->old_sha1)
1333 - || !ref_newer(ref->new_sha1, ref->old_sha1));
1331 + !is_null_sha1(ref->old_sha1);
1332
1335 - if (ref->nonfastforward && !ref->force && !force_update) {
1336 - ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
1337 - continue;
1333 + if (ref->update) {
1334 + ref->nonfastforward =
1335 + !has_sha1_file(ref->old_sha1)
1336 + || !ref_newer(ref->new_sha1, ref->old_sha1);
1337 +
1338 + if (ref->nonfastforward && !ref->force && !force_update) {
1339 + ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
1340 + continue;
1341 + }
1342 }
1343 }
1344 }