Skip to content

Commit 5148836

Browse files
benpeartvdye
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 2cff5e9 commit 5148836

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
@@ -2985,11 +2985,25 @@ int git_config_get_virtualfilesystem(void)
29852985
if (core_virtualfilesystem && !*core_virtualfilesystem)
29862986
core_virtualfilesystem = NULL;
29872987

2988-
/* virtual file system relies on the sparse checkout logic so force it on */
29892988
if (core_virtualfilesystem) {
2990-
core_apply_sparse_checkout = 1;
2991-
virtual_filesystem_result = 1;
2992-
return 1;
2989+
/*
2990+
* Some git commands spawn helpers and redirect the index to a different
2991+
* location. These include "difftool -d" and the sequencer
2992+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2993+
* In those instances we don't want to update their temporary index with
2994+
* our virtualization data.
2995+
*/
2996+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2997+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2998+
2999+
free(default_index_file);
3000+
if (should_run_hook) {
3001+
/* virtual file system relies on the sparse checkout logic so force it on */
3002+
core_apply_sparse_checkout = 1;
3003+
virtual_filesystem_result = 1;
3004+
return 1;
3005+
}
3006+
core_virtualfilesystem = NULL;
29933007
}
29943008

29953009
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)