Skip to content

Commit dafd0c9

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 225a9aa commit dafd0c9

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

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

27462760
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)