git-read-tree --index-output=<file>
authorJunio C Hamano <junkio@cox.net>
Sun, 1 Apr 2007 06:27:41 +0000 (23:27 -0700)
committerJunio C Hamano <junkio@cox.net>
Wed, 4 Apr 2007 06:44:32 +0000 (23:44 -0700)
This corrects the interface mistake of the previous one, and
gives a command line parameter to the only plumbing command that
currently needs it: "git-read-tree".

We can add the calls to set_alternate_index_output() to other
plumbing commands that update the index if/when needed.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-read-tree.txt
Documentation/git.txt
builtin-read-tree.c
cache.h
git-commit.sh
lockfile.c
index 0ff2890c7fb76155e08eaf9e361bf1eb6cf50f25..019c8bef7af2868af150b4a13472b8ce26744ea3 100644 (file)
@@ -8,7 +8,7 @@ git-read-tree - Reads tree information into the index
 
 SYNOPSIS
 --------
 
 SYNOPSIS
 --------
-'git-read-tree' (<tree-ish> | [[-m [--aggressive] | --reset | --prefix=<prefix>] [-u | -i]] [--exclude-per-directory=<gitignore>] <tree-ish1> [<tree-ish2> [<tree-ish3>]])
+'git-read-tree' (<tree-ish> | [[-m [--aggressive] | --reset | --prefix=<prefix>] [-u | -i]] [--exclude-per-directory=<gitignore>] [--index-output=<file>] <tree-ish1> [<tree-ish2> [<tree-ish3>]])
 
 
 DESCRIPTION
 
 
 DESCRIPTION
@@ -86,6 +86,18 @@ OPTIONS
        file (usually '.gitignore') and allows such an untracked
        but explicitly ignored file to be overwritten.
 
        file (usually '.gitignore') and allows such an untracked
        but explicitly ignored file to be overwritten.
 
+--index-output=<file>::
+       Instead of writing the results out to `$GIT_INDEX_FILE`,
+       write the resulting index in the named file.  While the
+       command is operating, the original index file is locked
+       with the same mechanism as usual.  The file must allow
+       to be rename(2)ed into from a temporary file that is
+       created next to the usual index file; typically this
+       means it needs to be on the same filesystem as the index
+       file itself, and you need write permission to the
+       directories the index file and index output file are
+       located in.
+
 <tree-ish#>::
        The id of the tree object(s) to be read/merged.
 
 <tree-ish#>::
        The id of the tree object(s) to be read/merged.
 
index 8fa1a0a58827e84b884d6c997686564dae1a6a58..9defc332736e1b6297ac003e491706d5ce32e834 100644 (file)
@@ -315,14 +315,6 @@ git so take care if using Cogito etc.
        index file. If not specified, the default of `$GIT_DIR/index`
        is used.
 
        index file. If not specified, the default of `$GIT_DIR/index`
        is used.
 
-'_GIT_INDEX_OUTPUT'::
-       When this environment is defined, plumbing level
-       commands that update the index writes the resulting
-       index to this file, instead of `$GIT_INDEX_FILE` (or its
-       default `$GIT_DIR/index`).  This is solely meant to be
-       used by Porcelain to drive low-level plumbing.  Defining
-       this in user's environment is always an error.
-
 'GIT_OBJECT_DIRECTORY'::
        If the object storage directory is specified via this
        environment variable then the sha1 directories are created
 'GIT_OBJECT_DIRECTORY'::
        If the object storage directory is specified via this
        environment variable then the sha1 directories are created
index 87048f82ee22cc3f2310bb7329328c31127280e0..213bd93c7f535ad90c49bc30280563fc3f4e6268 100644 (file)
@@ -84,7 +84,7 @@ static void prime_cache_tree(void)
 
 }
 
 
 }
 
-static const char read_tree_usage[] = "git-read-tree (<sha> | [[-m [--aggressive] | --reset | --prefix=<prefix>] [-u | -i]] [--exclude-per-directory=<gitignore>] <sha1> [<sha2> [<sha3>]])";
+static const char read_tree_usage[] = "git-read-tree (<sha> | [[-m [--aggressive] | --reset | --prefix=<prefix>] [-u | -i]] [--exclude-per-directory=<gitignore>] [--index-output=<file>] <sha1> [<sha2> [<sha3>]])";
 
 static struct lock_file lock_file;
 
 
 static struct lock_file lock_file;
 
@@ -128,6 +128,11 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
                        continue;
                }
 
                        continue;
                }
 
+               if (!prefixcmp(arg, "--index-output=")) {
+                       set_alternate_index_output(arg + 15);
+                       continue;
+               }
+
                /* "--prefix=<subdirectory>/" means keep the current index
                 *  entries and put the entries from the tree under the
                 * given subdirectory.
                /* "--prefix=<subdirectory>/" means keep the current index
                 *  entries and put the entries from the tree under the
                 * given subdirectory.
diff --git a/cache.h b/cache.h
index 59a05c1a459fcbb014b3d93ac434608a09fa8d30..592331f70615b7ff66b9d26a947bb07878b44e82 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -147,7 +147,6 @@ enum object_type {
 #define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
 #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
 #define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
 #define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
 #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
 #define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
-#define INDEX_OUTPUT_ENVIRONMENT "_GIT_INDEX_OUTPUT"
 #define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
 #define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
 #define CONFIG_ENVIRONMENT "GIT_CONFIG"
 #define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
 #define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
 #define CONFIG_ENVIRONMENT "GIT_CONFIG"
@@ -216,6 +215,7 @@ extern int commit_lock_file(struct lock_file *);
 
 extern int hold_locked_index(struct lock_file *, int);
 extern int commit_locked_index(struct lock_file *);
 
 extern int hold_locked_index(struct lock_file *, int);
 extern int commit_locked_index(struct lock_file *);
+extern void set_alternate_index_output(const char *);
 
 extern void rollback_lock_file(struct lock_file *);
 extern int delete_ref(const char *, unsigned char *sha1);
 
 extern void rollback_lock_file(struct lock_file *);
 extern int delete_ref(const char *, unsigned char *sha1);
index 20c0dc806f8cb42b4094ab7ad56b8eb582c1827f..9e0959aec06c4d4d7b4f14660c26bc9dd941f111 100755 (executable)
@@ -370,8 +370,8 @@ t,)
                # the same way.
                if test -z "$initial_commit"
                then
                # the same way.
                if test -z "$initial_commit"
                then
-                       _GIT_INDEX_OUTPUT="$TMP_INDEX" \
-                       GIT_INDEX_FILE="$THIS_INDEX" git-read-tree -i -m HEAD
+                       GIT_INDEX_FILE="$THIS_INDEX" \
+                       git-read-tree --index-output="$TMP_INDEX" -i -m HEAD
                else
                        rm -f "$TMP_INDEX"
                fi || exit
                else
                        rm -f "$TMP_INDEX"
                fi || exit
index 2023ebb6ffa4642a49b46cbce99bd49d3befebb6..bed6b21daf302c76cb87bb99b613f168df9899e1 100644 (file)
@@ -4,6 +4,7 @@
 #include "cache.h"
 
 static struct lock_file *lock_file_list;
 #include "cache.h"
 
 static struct lock_file *lock_file_list;
+static const char *alternate_index_output;
 
 static void remove_lock_file(void)
 {
 
 static void remove_lock_file(void)
 {
@@ -70,11 +71,15 @@ 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);
 }
 
        return hold_lock_file_for_update(lk, get_index_file(), die_on_error);
 }
 
+void set_alternate_index_output(const char *name)
+{
+       alternate_index_output = name;
+}
+
 int commit_locked_index(struct lock_file *lk)
 {
 int commit_locked_index(struct lock_file *lk)
 {
-       char *output = getenv(INDEX_OUTPUT_ENVIRONMENT);
-       if (output && *output) {
-               int result = rename(lk->filename, output);
+       if (alternate_index_output) {
+               int result = rename(lk->filename, alternate_index_output);
                lk->filename[0] = 0;
                return result;
        }
                lk->filename[0] = 0;
                return result;
        }