Skip to content

Commit 9e67545

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 dd7bbd6 commit 9e67545

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
@@ -2735,11 +2735,25 @@ int repo_config_get_virtualfilesystem(struct repository *r)
27352735
if (core_virtualfilesystem && !*core_virtualfilesystem)
27362736
core_virtualfilesystem = NULL;
27372737

2738-
/* virtual file system relies on the sparse checkout logic so force it on */
27392738
if (core_virtualfilesystem) {
2740-
core_apply_sparse_checkout = 1;
2741-
virtual_filesystem_result = 1;
2742-
return 1;
2739+
/*
2740+
* Some git commands spawn helpers and redirect the index to a different
2741+
* location. These include "difftool -d" and the sequencer
2742+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2743+
* In those instances we don't want to update their temporary index with
2744+
* our virtualization data.
2745+
*/
2746+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2747+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2748+
2749+
free(default_index_file);
2750+
if (should_run_hook) {
2751+
/* virtual file system relies on the sparse checkout logic so force it on */
2752+
core_apply_sparse_checkout = 1;
2753+
virtual_filesystem_result = 1;
2754+
return 1;
2755+
}
2756+
core_virtualfilesystem = NULL;
27432757
}
27442758

27452759
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)