Skip to content

Commit dbdef3f

Browse files
benpeartderrickstolee
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 c346691 commit dbdef3f

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

config.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,11 +2538,25 @@ int git_config_get_virtualfilesystem(void)
25382538
if (core_virtualfilesystem && !*core_virtualfilesystem)
25392539
core_virtualfilesystem = NULL;
25402540

2541-
/* virtual file system relies on the sparse checkout logic so force it on */
25422541
if (core_virtualfilesystem) {
2543-
core_apply_sparse_checkout = 1;
2544-
virtual_filesystem_result = 1;
2545-
return 1;
2542+
/*
2543+
* Some git commands spawn helpers and redirect the index to a different
2544+
* location. These include "difftool -d" and the sequencer
2545+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2546+
* In those instances we don't want to update their temporary index with
2547+
* our virtualization data.
2548+
*/
2549+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2550+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2551+
2552+
free(default_index_file);
2553+
if (should_run_hook) {
2554+
/* virtual file system relies on the sparse checkout logic so force it on */
2555+
core_apply_sparse_checkout = 1;
2556+
virtual_filesystem_result = 1;
2557+
return 1;
2558+
}
2559+
core_virtualfilesystem = NULL;
25462560
}
25472561

25482562
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)