Re: [PATCH 2/3] push: introduce REJECT_FETCH_FIRST and REJECT_NEEDS_FORCE
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 22, 2013, 06:04 UTC
- Message-ID
- <7vd2wxda91.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1358834027-32039-3-git-send-email-gitster@pobox.com>
This one has a logic flaw. The logic outlined in the cover letter is correct, and the one described in the log message of this one is not.
We should say "fetch first" only when we do not have old_sha1.
diff --git a/remote.c b/remote.c index 248910f..8c39ea2 100644 --- a/remote.c +++ b/remote.c @@ -1325,10 +1325,10 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror, if (!prefixcmp(ref->name, "refs/tags/")) ref->status = REF_STATUS_REJECT_ALREADY_EXISTS; - else if (!has_sha1_file(ref->old_sha1) || - !lookup_commit_reference_gently(ref->old_sha1, 1)) + else if (!has_sha1_file(ref->old_sha1)) ref->status = REF_STATUS_REJECT_FETCH_FIRST; - else if (!lookup_commit_reference_gently(ref->new_sha1, 1)) + else if (!lookup_commit_reference_gently(ref->new_sha1, 1) || + !lookup_commit_reference_gently(ref->old_sha1, 1)) ref->status = REF_STATUS_REJECT_NEEDS_FORCE; else if (!ref_newer(ref->new_sha1, ref->old_sha1)) ref->status = REF_STATUS_REJECT_NONFASTFORWARD;