Skip to content

Commit 7ac228c

Browse files
committed
Merge branch 'rn/sparse-describe'
"git describe --dirty" learns to work better with sparse-index. * rn/sparse-describe: describe: enable sparse index for describe
2 parents de73a20 + 748b8d6 commit 7ac228c

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

builtin/describe.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,8 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
658658
int fd, result;
659659

660660
setup_work_tree();
661+
prepare_repo_settings(the_repository);
662+
the_repository->settings.command_requires_full_index = 0;
661663
repo_read_index(the_repository);
662664
refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
663665
NULL, NULL, NULL);

t/perf/p2000-sparse-operations.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ test_expect_success 'setup repo and indexes' '
4343
done &&
4444
4545
git sparse-checkout init --cone &&
46+
git tag -a v1.0 -m "Final" &&
4647
git sparse-checkout set $SPARSE_CONE &&
4748
git checkout -b wide $OLD_COMMIT &&
4849
@@ -126,5 +127,7 @@ test_perf_on_all git update-index --add --remove $SPARSE_CONE/a
126127
test_perf_on_all "git rm -f $SPARSE_CONE/a && git checkout HEAD -- $SPARSE_CONE/a"
127128
test_perf_on_all git grep --cached bogus -- "f2/f1/f1/*"
128129
test_perf_on_all git write-tree
130+
test_perf_on_all git describe --dirty
131+
test_perf_on_all 'echo >>new && git describe --dirty'
129132

130133
test_done

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,31 @@ test_expect_success 'sparse-index is not expanded: stash' '
15141514
ensure_not_expanded stash pop
15151515
'
15161516

1517+
test_expect_success 'describe tested on all' '
1518+
init_repos &&
1519+
1520+
# Add tag to be read by describe
1521+
1522+
run_on_all git tag -a v1.0 -m "Version 1" &&
1523+
test_all_match git describe --dirty &&
1524+
run_on_all rm g &&
1525+
test_all_match git describe --dirty
1526+
'
1527+
1528+
1529+
test_expect_success 'sparse-index is not expanded: describe' '
1530+
init_repos &&
1531+
1532+
# Add tag to be read by describe
1533+
1534+
git -C sparse-index tag -a v1.0 -m "Version 1" &&
1535+
1536+
ensure_not_expanded describe --dirty &&
1537+
echo "test" >>sparse-index/g &&
1538+
ensure_not_expanded describe --dirty &&
1539+
ensure_not_expanded describe
1540+
'
1541+
15171542
test_expect_success 'sparse index is not expanded: diff' '
15181543
init_repos &&
15191544

0 commit comments

Comments
 (0)