merge-recur: do not setenv("GIT_INDEX_FILE")
Since there are no external calls left in merge-recur, we do not need to set the environment variable GIT_INDEX_FILE all the time. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Johannes Schindelin committed
Aug 9, 2006 at 15:07 UTC
c1964a006f9035cbdc6de8e55768fc6ad00d4825
1 file changed
+9
-13
merge-recursive.c
+9
-13
@@ -116,6 +116,7 @@ static void output_commit_title(struct commit *commit)
116
}
117
}
118
119
+static const char *current_index_file = NULL;
120
static const char *original_index_file;
121
static const char *temporary_index_file;
122
static int cache_dirty = 0;
@@ -124,12 +125,12 @@ static int flush_cache(void)
125
{
126
/* flush temporary index */
127
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
127
- int fd = hold_lock_file_for_update(lock, getenv("GIT_INDEX_FILE"));
128
+ int fd = hold_lock_file_for_update(lock, current_index_file);
129
if (fd < 0)
130
die("could not lock %s", lock->filename);
131
if (write_cache(fd, active_cache, active_nr) ||
132
close(fd) || commit_lock_file(lock))
132
- die ("unable to write %s", getenv("GIT_INDEX_FILE"));
133
+ die ("unable to write %s", current_index_file);
134
discard_cache();
135
cache_dirty = 0;
136
return 0;
@@ -137,11 +138,10 @@ static int flush_cache(void)
138
139
static void setup_index(int temp)
140
{
140
- const char *idx = temp ? temporary_index_file: original_index_file;
141
+ current_index_file = temp ? temporary_index_file: original_index_file;
142
if (cache_dirty)
143
die("fatal: cache changed flush_cache();");
144
unlink(temporary_index_file);
144
- setenv("GIT_INDEX_FILE", idx, 1);
145
discard_cache();
146
}
147
@@ -174,7 +174,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
174
{
175
struct cache_entry *ce;
176
if (!cache_dirty)
177
- read_cache_from(getenv("GIT_INDEX_FILE"));
177
+ read_cache_from(current_index_file);
178
cache_dirty++;
179
ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path, stage, refresh);
180
if (!ce)
@@ -223,7 +223,7 @@ static int git_merge_trees(int index_only,
223
struct unpack_trees_options opts;
224
225
if (!cache_dirty) {
226
- read_cache_from(getenv("GIT_INDEX_FILE"));
226
+ read_cache_from(current_index_file);
227
cache_dirty = 1;
228
}
229
@@ -260,7 +260,7 @@ static struct tree *git_write_tree(void)
260
return NULL;
261
}
262
} else
263
- read_cache_from(getenv("GIT_INDEX_FILE"));
263
+ read_cache_from(current_index_file);
264
265
if (!active_cache_tree)
266
active_cache_tree = cache_tree();
@@ -338,7 +338,7 @@ static struct path_list *get_unmerged(void)
338
339
unmerged->strdup_paths = 1;
340
if (!cache_dirty) {
341
- read_cache_from(getenv("GIT_INDEX_FILE"));
341
+ read_cache_from(current_index_file);
342
cache_dirty++;
343
}
344
for (i = 0; i < active_nr; i++) {
@@ -468,10 +468,6 @@ static int remove_path(const char *name)
468
return ret;
469
}
470
471
-/*
472
- * TODO: once we no longer call external programs, we'd probably be better off
473
- * not setting / getting the environment variable GIT_INDEX_FILE all the time.
474
- */
471
int remove_file(int clean, const char *path)
472
{
473
int update_cache = index_only || clean;
@@ -479,7 +475,7 @@ int remove_file(int clean, const char *path)
475
476
if (update_cache) {
477
if (!cache_dirty)
482
- read_cache_from(getenv("GIT_INDEX_FILE"));
478
+ read_cache_from(current_index_file);
479
cache_dirty++;
480
if (remove_file_from_cache(path))
481
return -1;