Skip to content

Commit 46a510b

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 <johannes.schindelin@gmx.de> Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
1 parent 78c324d commit 46a510b

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
@@ -2768,11 +2768,25 @@ int git_config_get_virtualfilesystem(void)
27682768
if (core_virtualfilesystem && !*core_virtualfilesystem)
27692769
core_virtualfilesystem = NULL;
27702770

2771-
/* virtual file system relies on the sparse checkout logic so force it on */
27722771
if (core_virtualfilesystem) {
2773-
core_apply_sparse_checkout = 1;
2774-
virtual_filesystem_result = 1;
2775-
return 1;
2772+
/*
2773+
* Some git commands spawn helpers and redirect the index to a different
2774+
* location. These include "difftool -d" and the sequencer
2775+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2776+
* In those instances we don't want to update their temporary index with
2777+
* our virtualization data.
2778+
*/
2779+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2780+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2781+
2782+
free(default_index_file);
2783+
if (should_run_hook) {
2784+
/* virtual file system relies on the sparse checkout logic so force it on */
2785+
core_apply_sparse_checkout = 1;
2786+
virtual_filesystem_result = 1;
2787+
return 1;
2788+
}
2789+
core_virtualfilesystem = NULL;
27762790
}
27772791

27782792
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)