Skip to content

Commit ffe81ef

Browse files
crorvickgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b24e604 commit ffe81ef

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ struct ref {
10031003
merge:1,
10041004
nonfastforward:1,
10051005
not_forwardable:1,
1006+
update:1,
10061007
deletion:1;
10071008
enum {
10081009
REF_STATUS_NONE = 0,

remote.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,15 +1326,19 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
13261326

13271327
ref->not_forwardable = !is_forwardable(ref);
13281328

1329-
ref->nonfastforward =
1329+
ref->update =
13301330
!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);
13341332

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+
}
13381342
}
13391343
}
13401344
}

0 commit comments

Comments
 (0)