Skip to content

Commit 8c1e2c8

Browse files
benpeartvdye
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 81dc570 commit 8c1e2c8

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

config.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,11 +2809,25 @@ int git_config_get_virtualfilesystem(void)
28092809
if (core_virtualfilesystem && !*core_virtualfilesystem)
28102810
core_virtualfilesystem = NULL;
28112811

2812-
/* virtual file system relies on the sparse checkout logic so force it on */
28132812
if (core_virtualfilesystem) {
2814-
core_apply_sparse_checkout = 1;
2815-
virtual_filesystem_result = 1;
2816-
return 1;
2813+
/*
2814+
* Some git commands spawn helpers and redirect the index to a different
2815+
* location. These include "difftool -d" and the sequencer
2816+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2817+
* In those instances we don't want to update their temporary index with
2818+
* our virtualization data.
2819+
*/
2820+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2821+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2822+
2823+
free(default_index_file);
2824+
if (should_run_hook) {
2825+
/* virtual file system relies on the sparse checkout logic so force it on */
2826+
core_apply_sparse_checkout = 1;
2827+
virtual_filesystem_result = 1;
2828+
return 1;
2829+
}
2830+
core_virtualfilesystem = NULL;
28172831
}
28182832

28192833
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)