From: Junio C Hamano Date: Fri, 5 Jun 2015 19:00:17 +0000 (-0700) Subject: Merge branch 'mh/write-refs-sooner-2.4' into maint X-Git-Tag: v2.4.3~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7c997bcbf68738f2b0cb1a94228ace211c9ba075;p=thirdparty%2Fgit.git Merge branch 'mh/write-refs-sooner-2.4' into maint Multi-ref transaction support we merged a few releases ago unnecessarily kept many file descriptors open, risking to fail with resource exhaustion. This is for 2.4.x track. * mh/write-refs-sooner-2.4: ref_transaction_commit(): fix atomicity and avoid fd exhaustion ref_transaction_commit(): remove the local flags variable ref_transaction_commit(): inline call to write_ref_sha1() rename_ref(): inline calls to write_ref_sha1() from this function commit_ref_update(): new function, extracted from write_ref_sha1() write_ref_to_lockfile(): new function, extracted from write_ref_sha1() t7004: rename ULIMIT test prerequisite to ULIMIT_STACK_SIZE update-ref: test handling large transactions properly ref_transaction_commit(): fix atomicity and avoid fd exhaustion ref_transaction_commit(): remove the local flags variable ref_transaction_commit(): inline call to write_ref_sha1() rename_ref(): inline calls to write_ref_sha1() from this function commit_ref_update(): new function, extracted from write_ref_sha1() write_ref_to_lockfile(): new function, extracted from write_ref_sha1() t7004: rename ULIMIT test prerequisite to ULIMIT_STACK_SIZE update-ref: test handling large transactions properly --- 7c997bcbf68738f2b0cb1a94228ace211c9ba075 diff --cc refs.c index 97043fd2ef,96f5046712..67d6745e28 --- a/refs.c +++ b/refs.c @@@ -3833,30 -3782,19 +3859,24 @@@ int ref_transaction_commit(struct ref_t update->refname, ((update->flags & REF_HAVE_OLD) ? update->old_sha1 : NULL), - NULL, + &affected_refnames, NULL, - flags, + update->flags, - &update->type); + &update->type, + err); if (!update->lock) { + char *reason; + ret = (errno == ENOTDIR) ? TRANSACTION_NAME_CONFLICT : TRANSACTION_GENERIC_ERROR; - strbuf_addf(err, "Cannot lock the ref '%s'.", - update->refname); + reason = strbuf_detach(err, NULL); + strbuf_addf(err, "Cannot lock ref '%s': %s", + update->refname, reason); + free(reason); goto cleanup; } - } - - /* Perform updates first so live commits remain referenced */ - for (i = 0; i < n; i++) { - struct ref_update *update = updates[i]; - int flags = update->flags; - - if ((flags & REF_HAVE_NEW) && !is_null_sha1(update->new_sha1)) { + if ((update->flags & REF_HAVE_NEW) && + !(update->flags & REF_DELETING)) { int overwriting_symref = ((update->type & REF_ISSYMREF) && (update->flags & REF_NODEREF));