Skip to content

Commit f9cd4ca

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 8352584 commit f9cd4ca

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
@@ -2817,11 +2817,25 @@ int git_config_get_virtualfilesystem(void)
28172817
if (core_virtualfilesystem && !*core_virtualfilesystem)
28182818
core_virtualfilesystem = NULL;
28192819

2820-
/* virtual file system relies on the sparse checkout logic so force it on */
28212820
if (core_virtualfilesystem) {
2822-
core_apply_sparse_checkout = 1;
2823-
virtual_filesystem_result = 1;
2824-
return 1;
2821+
/*
2822+
* Some git commands spawn helpers and redirect the index to a different
2823+
* location. These include "difftool -d" and the sequencer
2824+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2825+
* In those instances we don't want to update their temporary index with
2826+
* our virtualization data.
2827+
*/
2828+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2829+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2830+
2831+
free(default_index_file);
2832+
if (should_run_hook) {
2833+
/* virtual file system relies on the sparse checkout logic so force it on */
2834+
core_apply_sparse_checkout = 1;
2835+
virtual_filesystem_result = 1;
2836+
return 1;
2837+
}
2838+
core_virtualfilesystem = NULL;
28252839
}
28262840

28272841
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)