Skip to content

Commit 2b232b7

Browse files
benpeartdscho
authored andcommitted
Merge pull request #15 from benpeart/difftool
virtualfilesystem: don't run the virtual file system hook if the index has been redirected
2 parents 0c41f25 + 8a2a445 commit 2b232b7

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

config.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,10 +2313,24 @@ int git_config_get_virtualfilesystem(void)
23132313
if (core_virtualfilesystem && !*core_virtualfilesystem)
23142314
core_virtualfilesystem = NULL;
23152315

2316-
/* virtual file system relies on the sparse checkout logic so force it on */
23172316
if (core_virtualfilesystem) {
2318-
core_apply_sparse_checkout = 1;
2319-
return 1;
2317+
/*
2318+
* Some git commands spawn helpers and redirect the index to a different
2319+
* location. These include "difftool -d" and the sequencer
2320+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2321+
* In those instances we don't want to update their temporary index with
2322+
* our virtualization data.
2323+
*/
2324+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2325+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2326+
2327+
free(default_index_file);
2328+
if (should_run_hook) {
2329+
/* virtual file system relies on the sparse checkout logic so force it on */
2330+
core_apply_sparse_checkout = 1;
2331+
return 1;
2332+
}
2333+
core_virtualfilesystem = NULL;
23202334
}
23212335

23222336
return 0;

0 commit comments

Comments
 (0)