diff options
| author | Junio C Hamano <gitster@pobox.com> | 2010-01-20 14:39:48 -0800 | 
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2010-01-20 14:39:48 -0800 | 
| commit | 07301eaa766efac7818eac7a4a6db0d0c3948d66 (patch) | |
| tree | e8d278300591713f61fbdcc5213dedb7d742c0f2 /builtin-send-pack.c | |
| parent | bd0d1916de221425fc22b69940ff71b0ce6aad9c (diff) | |
| parent | c1ceea1d273925fe6ecb0824e7ea08eb6e6e2635 (diff) | |
| download | git-07301eaa766efac7818eac7a4a6db0d0c3948d66.tar.gz | |
Merge branch 'tr/http-push-ref-status'
* tr/http-push-ref-status:
  transport-helper.c::push_refs(): emit "no refs" error message
  transport-helper.c::push_refs(): ignore helper-reported status if ref is not to be pushed
  transport.c::transport_push(): make ref status affect return value
  refactor ref status logic for pushing
  t5541-http-push.sh: add test for unmatched, non-fast-forwarded refs
  t5541-http-push.sh: add tests for non-fast-forward pushes
Conflicts:
	transport-helper.c
Diffstat (limited to 'builtin-send-pack.c')
| -rw-r--r-- | builtin-send-pack.c | 51 | 
1 files changed, 12 insertions, 39 deletions
diff --git a/builtin-send-pack.c b/builtin-send-pack.c index 8fffdbf200..76c72065de 100644 --- a/builtin-send-pack.c +++ b/builtin-send-pack.c @@ -406,50 +406,20 @@ int send_pack(struct send_pack_args *args,  	 */  	new_refs = 0;  	for (ref = remote_refs; ref; ref = ref->next) { - -		if (ref->peer_ref) -			hashcpy(ref->new_sha1, ref->peer_ref->new_sha1); -		else if (!args->send_mirror) +		if (!ref->peer_ref && !args->send_mirror)  			continue; -		ref->deletion = is_null_sha1(ref->new_sha1); -		if (ref->deletion && !allow_deleting_refs) { -			ref->status = REF_STATUS_REJECT_NODELETE; -			continue; -		} -		if (!ref->deletion && -		    !hashcmp(ref->old_sha1, ref->new_sha1)) { -			ref->status = REF_STATUS_UPTODATE; +		/* Check for statuses set by set_ref_status_for_push() */ +		switch (ref->status) { +		case REF_STATUS_REJECT_NONFASTFORWARD: +		case REF_STATUS_UPTODATE:  			continue; +		default: +			; /* do nothing */  		} -		/* This part determines what can overwrite what. -		 * The rules are: -		 * -		 * (0) you can always use --force or +A:B notation to -		 *     selectively force individual ref pairs. -		 * -		 * (1) if the old thing does not exist, it is OK. -		 * -		 * (2) if you do not have the old thing, you are not allowed -		 *     to overwrite it; you would not know what you are losing -		 *     otherwise. -		 * -		 * (3) if both new and old are commit-ish, and new is a -		 *     descendant of old, it is OK. -		 * -		 * (4) regardless of all of the above, removing :B is -		 *     always allowed. -		 */ - -		ref->nonfastforward = -		    !ref->deletion && -		    !is_null_sha1(ref->old_sha1) && -		    (!has_sha1_file(ref->old_sha1) -		      || !ref_newer(ref->new_sha1, ref->old_sha1)); - -		if (ref->nonfastforward && !ref->force && !args->force_update) { -			ref->status = REF_STATUS_REJECT_NONFASTFORWARD; +		if (ref->deletion && !allow_deleting_refs) { +			ref->status = REF_STATUS_REJECT_NODELETE;  			continue;  		} @@ -673,6 +643,9 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)  	if (match_refs(local_refs, &remote_refs, nr_refspecs, refspecs, flags))  		return -1; +	set_ref_status_for_push(remote_refs, args.send_mirror, +		args.force_update); +  	ret = send_pack(&args, fd, conn, remote_refs, &extra_have);  	if (helper_status)  | 
