diff options
author | Junio C Hamano <junkio@cox.net> | 2007-03-31 23:09:02 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-04-03 23:44:32 -0700 |
commit | 30ca07a249744e57163c02250fca420cea364299 (patch) | |
tree | 67cfa219ff2e8e5c293d3f2e7eb475093e354771 /builtin-apply.c | |
parent | 89815cab95268e8f0f58142b848ac4cd5e9cbdcb (diff) | |
download | git-30ca07a249744e57163c02250fca420cea364299.tar.gz git-30ca07a249744e57163c02250fca420cea364299.tar.xz |
_GIT_INDEX_OUTPUT: allow plumbing to output to an alternative index file.
When defined, this allows plumbing commands that update the
index (add, apply, checkout-index, merge-recursive, mv,
read-tree, rm, update-index, and write-tree) to write their
resulting index to an alternative index file while holding a
lock to the original index file. With this, git-commit that
jumps the index does not have to make an extra copy of the index
file, and more importantly, it can do the update while holding
the lock on the index.
However, I think the interface to let an environment variable
specify the output is a mistake, as shown in the documentation.
If a curious user has the environment variable set to something
other than the file GIT_INDEX_FILE points at, almost everything
will break. This should instead be a command line parameter to
tell these plumbing commands to write the result in the named
file, to prevent stupid mistakes.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-apply.c')
-rw-r--r-- | builtin-apply.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin-apply.c b/builtin-apply.c index 27a182bfa..12011c1c9 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -2664,8 +2664,8 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof) write_index = check_index && apply; if (write_index && newfd < 0) - newfd = hold_lock_file_for_update(&lock_file, - get_index_file(), 1); + newfd = hold_locked_index(&lock_file, 1); + if (check_index) { if (read_cache() < 0) die("unable to read index file"); @@ -2872,7 +2872,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix) if (write_index) { if (write_cache(newfd, active_cache, active_nr) || - close(newfd) || commit_lock_file(&lock_file)) + close(newfd) || commit_locked_index(&lock_file)) die("Unable to write new index file"); } |