Skip to content

Commit 3a23415

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 fb3896b commit 3a23415

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

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

28292843
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)