Skip to content

Commit 3fb4e78

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 bb9f5c7 commit 3fb4e78

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
@@ -2854,11 +2854,25 @@ int git_config_get_virtualfilesystem(void)
28542854
if (core_virtualfilesystem && !*core_virtualfilesystem)
28552855
core_virtualfilesystem = NULL;
28562856

2857-
/* virtual file system relies on the sparse checkout logic so force it on */
28582857
if (core_virtualfilesystem) {
2859-
core_apply_sparse_checkout = 1;
2860-
virtual_filesystem_result = 1;
2861-
return 1;
2858+
/*
2859+
* Some git commands spawn helpers and redirect the index to a different
2860+
* location. These include "difftool -d" and the sequencer
2861+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2862+
* In those instances we don't want to update their temporary index with
2863+
* our virtualization data.
2864+
*/
2865+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2866+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2867+
2868+
free(default_index_file);
2869+
if (should_run_hook) {
2870+
/* virtual file system relies on the sparse checkout logic so force it on */
2871+
core_apply_sparse_checkout = 1;
2872+
virtual_filesystem_result = 1;
2873+
return 1;
2874+
}
2875+
core_virtualfilesystem = NULL;
28622876
}
28632877

28642878
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)