diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-11-06 13:11:21 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-11-06 13:11:21 +0900 |
commit | 0b646bcac96a57e345887e607e0b8c9a64ff262a (patch) | |
tree | 4c4e0e29d1743413c7fa0e1172ccebb7cbc37191 /builtin/clone.c | |
parent | Git 2.15 (diff) | |
parent | read_cache: roll back lock in `update_index_if_able()` (diff) | |
download | tgif-0b646bcac96a57e345887e607e0b8c9a64ff262a.tar.xz |
Merge branch 'ma/lockfile-fixes'
An earlier update made it possible to use an on-stack in-core
lockfile structure (as opposed to having to deliberately leak an
on-heap one). Many codepaths have been updated to take advantage
of this new facility.
* ma/lockfile-fixes:
read_cache: roll back lock in `update_index_if_able()`
read-cache: leave lock in right state in `write_locked_index()`
read-cache: drop explicit `CLOSE_LOCK`-flag
cache.h: document `write_locked_index()`
apply: remove `newfd` from `struct apply_state`
apply: move lockfile into `apply_state`
cache-tree: simplify locking logic
checkout-index: simplify locking logic
tempfile: fix documentation on `delete_tempfile()`
lockfile: fix documentation on `close_lock_file_gently()`
treewide: prefer lockfiles on the stack
sha1_file: do not leak `lock_file`
Diffstat (limited to 'builtin/clone.c')
-rw-r--r-- | builtin/clone.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index dbddd98f80..96a3aaaa1f 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -706,7 +706,7 @@ static int checkout(int submodule_progress) { struct object_id oid; char *head; - struct lock_file *lock_file; + struct lock_file lock_file = LOCK_INIT; struct unpack_trees_options opts; struct tree *tree; struct tree_desc t; @@ -733,8 +733,7 @@ static int checkout(int submodule_progress) /* We need to be in the new work tree for the checkout */ setup_work_tree(); - lock_file = xcalloc(1, sizeof(struct lock_file)); - hold_locked_index(lock_file, LOCK_DIE_ON_ERROR); + hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR); memset(&opts, 0, sizeof opts); opts.update = 1; @@ -750,7 +749,7 @@ static int checkout(int submodule_progress) if (unpack_trees(1, &t, &opts) < 0) die(_("unable to checkout working tree")); - if (write_locked_index(&the_index, lock_file, COMMIT_LOCK)) + if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK)) die(_("unable to write new index file")); err |= run_hook_le(NULL, "post-checkout", sha1_to_hex(null_sha1), |