@matheusbsbs / matheus-bagliano / commits / b0883aa6c7
Fork 0

is_submodule_modified(): fix breakage with external GIT_INDEX_FILE

Even when the environment was given for the top-level process, checking in the submodule work tree should use the index file associated with the work tree of the submodule. Do not export it to the environment. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 30, 2010 at 12:08 UTC b0883aa6c77111e88496bd0afe073caf68ab9f99
1 file changed +5 -2
submodule.c
+5 -2
@@ -126,7 +126,7 @@ int is_submodule_modified(const char *path)
126 "--porcelain",
127 NULL,
128 };
129 - char *env[3];
129 + char *env[4];
130 struct strbuf buf = STRBUF_INIT;
131
132 strbuf_addf(&buf, "%s/.git/", path);
@@ -142,7 +142,9 @@ int is_submodule_modified(const char *path)
142 env[0] = strbuf_detach(&buf, NULL);
143 strbuf_addf(&buf, "GIT_DIR=%s/.git", path);
144 env[1] = strbuf_detach(&buf, NULL);
145 - env[2] = NULL;
145 + strbuf_addf(&buf, "GIT_INDEX_FILE");
146 + env[2] = strbuf_detach(&buf, NULL);
147 + env[3] = NULL;
148
149 memset(&cp, 0, sizeof(cp));
150 cp.argv = argv;
@@ -161,6 +163,7 @@ int is_submodule_modified(const char *path)
163
164 free(env[0]);
165 free(env[1]);
166 + free(env[2]);
167 strbuf_release(&buf);
168 return len != 0;
169 }