Skip to content

Commit 2148bb0

Browse files
benpeartderrickstolee
authored andcommitted
virtualfilesystem: don't run the virtual file system hook if the index has been redirected
Fixes #13 Some git commands spawn helpers and redirect the index to a different location. These include "difftool -d" and the sequencer (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others. In those instances we don't want to update their temporary index with our virtualization data. Helped-by: Johannes Schindelin <[email protected]> Signed-off-by: Ben Peart <[email protected]>
1 parent 895fe5e commit 2148bb0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

config.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,10 +2355,24 @@ int git_config_get_virtualfilesystem(void)
23552355
if (core_virtualfilesystem && !*core_virtualfilesystem)
23562356
core_virtualfilesystem = NULL;
23572357

2358-
/* virtual file system relies on the sparse checkout logic so force it on */
23592358
if (core_virtualfilesystem) {
2360-
core_apply_sparse_checkout = 1;
2361-
return 1;
2359+
/*
2360+
* Some git commands spawn helpers and redirect the index to a different
2361+
* location. These include "difftool -d" and the sequencer
2362+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2363+
* In those instances we don't want to update their temporary index with
2364+
* our virtualization data.
2365+
*/
2366+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2367+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2368+
2369+
free(default_index_file);
2370+
if (should_run_hook) {
2371+
/* virtual file system relies on the sparse checkout logic so force it on */
2372+
core_apply_sparse_checkout = 1;
2373+
return 1;
2374+
}
2375+
core_virtualfilesystem = NULL;
23622376
}
23632377

23642378
return 0;

0 commit comments

Comments
 (0)