Skip to content

Commit

Permalink
is_submodule_modified(): fix breakage with external GIT_INDEX_FILE
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Jan 30, 2010
1 parent a9c7c43 commit b0883aa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int is_submodule_modified(const char *path)
"--porcelain",
NULL,
};
char *env[3];
char *env[4];
struct strbuf buf = STRBUF_INIT;

strbuf_addf(&buf, "%s/.git/", path);
Expand All @@ -142,7 +142,9 @@ int is_submodule_modified(const char *path)
env[0] = strbuf_detach(&buf, NULL);
strbuf_addf(&buf, "GIT_DIR=%s/.git", path);
env[1] = strbuf_detach(&buf, NULL);
env[2] = NULL;
strbuf_addf(&buf, "GIT_INDEX_FILE");
env[2] = strbuf_detach(&buf, NULL);
env[3] = NULL;

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

free(env[0]);
free(env[1]);
free(env[2]);
strbuf_release(&buf);
return len != 0;
}

0 comments on commit b0883aa

Please sign in to comment.