Skip to content

Commit 621b059

Browse files
committed
send-pack: move REF_STATUS_REJECT_NODELETE logic a bit higher
20e8b46 (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 <[email protected]>
1 parent 39895c7 commit 621b059

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

send-pack.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ int send_pack(struct send_pack_args *args,
231231
return 0;
232232
}
233233

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+
234243
if (!args->dry_run)
235244
advertise_shallow_grafts_buf(&req_buf);
236245

@@ -249,17 +258,13 @@ int send_pack(struct send_pack_args *args,
249258
case REF_STATUS_REJECT_FETCH_FIRST:
250259
case REF_STATUS_REJECT_NEEDS_FORCE:
251260
case REF_STATUS_REJECT_STALE:
261+
case REF_STATUS_REJECT_NODELETE:
252262
case REF_STATUS_UPTODATE:
253263
continue;
254264
default:
255265
; /* do nothing */
256266
}
257267

258-
if (ref->deletion && !allow_deleting_refs) {
259-
ref->status = REF_STATUS_REJECT_NODELETE;
260-
continue;
261-
}
262-
263268
if (!ref->deletion)
264269
new_refs++;
265270

0 commit comments

Comments
 (0)