Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-04-01 10:09:02 +0400
committerJunio C Hamano <junkio@cox.net>2007-04-04 10:44:32 +0400
commit30ca07a249744e57163c02250fca420cea364299 (patch)
tree67cfa219ff2e8e5c293d3f2e7eb475093e354771 /lockfile.c
parent89815cab95268e8f0f58142b848ac4cd5e9cbdcb (diff)
_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 'lockfile.c')
-rw-r--r--lockfile.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lockfile.c b/lockfile.c
index 4824f4dc02..2023ebb6ff 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -65,6 +65,23 @@ int commit_lock_file(struct lock_file *lk)
return i;
}
+int hold_locked_index(struct lock_file *lk, int die_on_error)
+{
+ return hold_lock_file_for_update(lk, get_index_file(), die_on_error);
+}
+
+int commit_locked_index(struct lock_file *lk)
+{
+ char *output = getenv(INDEX_OUTPUT_ENVIRONMENT);
+ if (output && *output) {
+ int result = rename(lk->filename, output);
+ lk->filename[0] = 0;
+ return result;
+ }
+ else
+ return commit_lock_file(lk);
+}
+
void rollback_lock_file(struct lock_file *lk)
{
if (lk->filename[0])