Skip to content

Commit b0883aa

Browse files
committed
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 <[email protected]>
1 parent a9c7c43 commit b0883aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

submodule.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int is_submodule_modified(const char *path)
126126
"--porcelain",
127127
NULL,
128128
};
129-
char *env[3];
129+
char *env[4];
130130
struct strbuf buf = STRBUF_INIT;
131131

132132
strbuf_addf(&buf, "%s/.git/", path);
@@ -142,7 +142,9 @@ int is_submodule_modified(const char *path)
142142
env[0] = strbuf_detach(&buf, NULL);
143143
strbuf_addf(&buf, "GIT_DIR=%s/.git", path);
144144
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;
146148

147149
memset(&cp, 0, sizeof(cp));
148150
cp.argv = argv;
@@ -161,6 +163,7 @@ int is_submodule_modified(const char *path)
161163

162164
free(env[0]);
163165
free(env[1]);
166+
free(env[2]);
164167
strbuf_release(&buf);
165168
return len != 0;
166169
}

0 commit comments

Comments
 (0)