Skip to content

Commit d69bd0b

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 2bc1e53 commit d69bd0b

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
@@ -2540,10 +2540,24 @@ int git_config_get_virtualfilesystem(void)
25402540
if (core_virtualfilesystem && !*core_virtualfilesystem)
25412541
core_virtualfilesystem = NULL;
25422542

2543-
/* virtual file system relies on the sparse checkout logic so force it on */
25442543
if (core_virtualfilesystem) {
2545-
core_apply_sparse_checkout = 1;
2546-
return 1;
2544+
/*
2545+
* Some git commands spawn helpers and redirect the index to a different
2546+
* location. These include "difftool -d" and the sequencer
2547+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2548+
* In those instances we don't want to update their temporary index with
2549+
* our virtualization data.
2550+
*/
2551+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2552+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2553+
2554+
free(default_index_file);
2555+
if (should_run_hook) {
2556+
/* virtual file system relies on the sparse checkout logic so force it on */
2557+
core_apply_sparse_checkout = 1;
2558+
return 1;
2559+
}
2560+
core_virtualfilesystem = NULL;
25472561
}
25482562

25492563
return 0;

0 commit comments

Comments
 (0)