_GIT_INDEX_OUTPUT: allow plumbing to output to an alternative index file.
[gitweb.git] / lockfile.c
index 4824f4dc026e7b3f978fe4e9b2154335359e9d2e..2023ebb6ffa4642a49b46cbce99bd49d3befebb6 100644 (file)
@@ -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])