Skip to content

Commit

Permalink
push: keep track of "update" state separately
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chris Rorvick authored and Junio C Hamano committed Dec 2, 2012
1 parent b24e604 commit ffe81ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ struct ref {
merge:1,
nonfastforward:1,
not_forwardable:1,
update:1,
deletion:1;
enum {
REF_STATUS_NONE = 0,
Expand Down
18 changes: 11 additions & 7 deletions remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit ffe81ef

Please sign in to comment.