send-pack: move REF_STATUS_REJECT_NODELETE logic a bit higher

20e8b465 (refactor ref status logic for pushing, 2010-01-08) restructured the code to set status for each ref to be pushed, but did not quite go far enough. We inspect the status set earlier by set_refs_status_for_push() and then perform yet another update to the status of a ref with an otherwise OK status to be deleted to mark it with REF_STATUS_REJECT_NODELETE when the protocol tells us never to delete. Split the latter into a separate loop that comes before we enter the per-ref loop. This way we would have one less condition to check in the main loop. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 12, 2014 at 15:04 UTC 621b0599fda143aff7fbf2bca7479997a06a5d11
1 file changed +10 -5
send-pack.c
+10 -5
@@ -231,6 +231,15 @@ int send_pack(struct send_pack_args *args,
231 return 0;
232 }
233
234 + /*
235 + * NEEDSWORK: why does delete-refs have to be so specific to
236 + * send-pack machinery that set_ref_status_for_push() cannot
237 + * set this bit for us???
238 + */
239 + for (ref = remote_refs; ref; ref = ref->next)
240 + if (ref->deletion && !allow_deleting_refs)
241 + ref->status = REF_STATUS_REJECT_NODELETE;
242 +
243 if (!args->dry_run)
244 advertise_shallow_grafts_buf(&req_buf);
245
@@ -249,17 +258,13 @@ int send_pack(struct send_pack_args *args,
258 case REF_STATUS_REJECT_FETCH_FIRST:
259 case REF_STATUS_REJECT_NEEDS_FORCE:
260 case REF_STATUS_REJECT_STALE:
261 + case REF_STATUS_REJECT_NODELETE:
262 case REF_STATUS_UPTODATE:
263 continue;
264 default:
265 ; /* do nothing */
266 }
267
258 - if (ref->deletion && !allow_deleting_refs) {
259 - ref->status = REF_STATUS_REJECT_NODELETE;
260 - continue;
261 - }
262 -
268 if (!ref->deletion)
269 new_refs++;
270