Skip to content

Commit 06228cd

Browse files
benpeartdscho
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 d29907e commit 06228cd

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
@@ -2830,11 +2830,25 @@ int git_config_get_virtualfilesystem(void)
28302830
if (core_virtualfilesystem && !*core_virtualfilesystem)
28312831
core_virtualfilesystem = NULL;
28322832

2833-
/* virtual file system relies on the sparse checkout logic so force it on */
28342833
if (core_virtualfilesystem) {
2835-
core_apply_sparse_checkout = 1;
2836-
virtual_filesystem_result = 1;
2837-
return 1;
2834+
/*
2835+
* Some git commands spawn helpers and redirect the index to a different
2836+
* location. These include "difftool -d" and the sequencer
2837+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2838+
* In those instances we don't want to update their temporary index with
2839+
* our virtualization data.
2840+
*/
2841+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2842+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2843+
2844+
free(default_index_file);
2845+
if (should_run_hook) {
2846+
/* virtual file system relies on the sparse checkout logic so force it on */
2847+
core_apply_sparse_checkout = 1;
2848+
virtual_filesystem_result = 1;
2849+
return 1;
2850+
}
2851+
core_virtualfilesystem = NULL;
28382852
}
28392853

28402854
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)