Skip to content

Commit 5a4e054

Browse files
derrickstoleegitster
authored andcommitted
fetch/pull: use the sparse index
The 'git fetch' and 'git pull' commands parse the index in order to determine if submodules exist. Without command_requires_full_index=0, this will expand a sparse index, causing slow performance even when there is no new data to fetch. The .gitmodules file will never be inside a sparse directory entry, and even if it was, the index_name_pos() method would expand the sparse index if needed as we search for the path by name. These commands do not iterate over the index, which is the typical thing we are careful about when integrating with the sparse index. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 597af31 commit 5a4e054

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

builtin/fetch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
19991999
}
20002000

20012001
git_config(git_fetch_config, NULL);
2002+
prepare_repo_settings(the_repository);
2003+
the_repository->settings.command_requires_full_index = 0;
20022004

20032005
argc = parse_options(argc, argv, prefix,
20042006
builtin_fetch_options, builtin_fetch_usage, 0);

builtin/pull.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
994994
set_reflog_message(argc, argv);
995995

996996
git_config(git_pull_config, NULL);
997+
prepare_repo_settings(the_repository);
998+
the_repository->settings.command_requires_full_index = 0;
997999

9981000
argc = parse_options(argc, argv, prefix, pull_options, pull_usage, 0);
9991001

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,16 @@ test_expect_success 'sparse index is not expanded: blame' '
10091009
done
10101010
'
10111011

1012+
test_expect_success 'sparse index is not expanded: fetch/pull' '
1013+
init_repos &&
1014+
1015+
git -C sparse-index remote add full "file://$(pwd)/full-checkout" &&
1016+
ensure_not_expanded fetch full &&
1017+
git -C full-checkout commit --allow-empty -m "for pull merge" &&
1018+
git -C sparse-index commit --allow-empty -m "for pull merge" &&
1019+
ensure_not_expanded pull full base
1020+
'
1021+
10121022
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
10131023
# in this scenario, but it shouldn't.
10141024
test_expect_success 'reset mixed and checkout orphan' '

0 commit comments

Comments
 (0)