Skip to content

Commit ea134ec

Browse files
benpeartmjcheetham
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 8d90680 commit ea134ec

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
@@ -2732,11 +2732,25 @@ int repo_config_get_virtualfilesystem(struct repository *r)
27322732
if (core_virtualfilesystem && !*core_virtualfilesystem)
27332733
FREE_AND_NULL(core_virtualfilesystem);
27342734

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

27422756
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)