Skip to content

Commit 3011dc5

Browse files
authored
Merge pull request git-for-windows#431 from ldennington/sparse-index-blame
blame: enable and test the sparse index
2 parents b05892f + dd14948 commit 3011dc5

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

builtin/blame.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
902902
long anchor;
903903
const int hexsz = the_hash_algo->hexsz;
904904

905+
prepare_repo_settings(the_repository);
906+
the_repository->settings.command_requires_full_index = 0;
905907
setup_default_color_by_age();
906908
git_config(git_blame_config, &output_option);
907909
repo_init_revisions(the_repository, &revs, NULL);

t/perf/p2000-sparse-operations.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,7 @@ test_perf_on_all git update-index --add --remove
121121
test_perf_on_all git diff
122122
test_perf_on_all git diff --staged
123123
test_perf_on_all git sparse-checkout reapply
124+
test_perf_on_all git blame $SPARSE_CONE/a
125+
test_perf_on_all git blame $SPARSE_CONE/f3/a
124126

125127
test_done

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,14 @@ test_expect_success 'blame with pathspec inside sparse definition' '
488488

489489
# TODO: blame currently does not support blaming files outside of the
490490
# sparse definition. It complains that the file doesn't exist locally.
491-
test_expect_failure 'blame with pathspec outside sparse definition' '
491+
test_expect_success 'blame with pathspec outside sparse definition' '
492492
init_repos &&
493493
494-
test_all_match git blame folder1/a &&
495-
test_all_match git blame folder2/a &&
496-
test_all_match git blame deep/deeper2/a &&
497-
test_all_match git blame deep/deeper2/deepest/a
494+
test_sparse_match git sparse-checkout set &&
495+
test_sparse_match test_must_fail git blame folder1/a &&
496+
test_sparse_match test_must_fail git blame folder2/a &&
497+
test_sparse_match test_must_fail git blame deep/deeper2/a &&
498+
test_sparse_match test_must_fail git blame deep/deeper2/deepest/a
498499
'
499500

500501
# TODO: This behaves correctly in microsoft/git. Why?
@@ -1322,6 +1323,15 @@ test_expect_success 'stash -u outside sparse checkout definition' '
13221323
test_all_match git status --porcelain=v2
13231324
'
13241325

1326+
test_expect_success 'sparse index is not expanded: blame' '
1327+
init_repos &&
1328+
1329+
ensure_not_expanded blame a &&
1330+
ensure_not_expanded blame deep/a &&
1331+
ensure_not_expanded blame deep/deeper1/a &&
1332+
ensure_not_expanded blame deep/deeper1/deepest/a
1333+
'
1334+
13251335
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout
13261336
# in this scenario, but it shouldn't.
13271337
test_expect_success 'reset mixed and checkout orphan' '

0 commit comments

Comments
 (0)