]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'mh/write-refs-sooner-2.4' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 5 Jun 2015 19:00:17 +0000 (12:00 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Jun 2015 19:00:17 +0000 (12:00 -0700)
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

1  2 
refs.c
t/t1400-update-ref.sh

diff --cc refs.c
index 97043fd2ef88fd50dadf05d673bb80018d3caf06,96f50467125dad661a79c60e13ecf5b389c4ef10..67d6745e28ca44be1042e0ac41f9577ae6f8619b
--- 1/refs.c
--- 2/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));
  
Simple merge