{"thread":{"id":"59508","subject":"[GSOC][PATCH] describe: enable sparse index for describe","startedAt":"2023-03-31T14:28:56Z","lastAt":"2023-03-31T14:28:56Z","messageCount":1,"participants":["Raghul Nanth A"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"474504","messageId":"20230331142738.52824-1-nanth.raghul@gmail.com","threadId":"59508","inReplyTo":null,"subject":"[GSOC][PATCH] describe: enable sparse index for describe","fromName":"Raghul Nanth A","fromEmail":"nanth.raghul@gmail.com","sentAt":"2023-03-31T14:27:38Z","receivedAt":"2023-03-31T14:28:56Z","isPatch":true,"sender":{"key":"nanth.raghul@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61490162?v=4"},"body":"Add usage and performance tests for describe\n\ngit describe compares the index with the working tree when (and only\nwhen) it is run with the \"--dirty\" flag. This is done by the\nrun_diff_index() function. The function has been made aware of the\nsparse-index in the series that led to 8d2c3732 (Merge branch\n'ld/sparse-diff-blame', 2021-12-21). Hence we can just set the\nrequires-full-index to false for \"describe\".\n\nPerformance metrics\n\n  Test                                                     HEAD~1            HEAD\n  -------------------------------------------------------------------------------------------------\n  2000.2: git describe --dirty (full-v3)                   0.08(0.09+0.01)   0.08(0.06+0.03) +0.0%\n  2000.3: git describe --dirty (full-v4)                   0.09(0.07+0.03)   0.08(0.05+0.04) -11.1%\n  2000.4: git describe --dirty (sparse-v3)                 0.88(0.82+0.06)   0.02(0.01+0.05) -97.7%\n  2000.5: git describe --dirty (sparse-v4)                 0.68(0.60+0.08)   0.02(0.02+0.04) -97.1%\n  2000.6: echo >>new && git describe --dirty (full-v3)     0.08(0.04+0.05)   0.08(0.05+0.04) +0.0%\n  2000.7: echo >>new && git describe --dirty (full-v4)     0.08(0.07+0.03)   0.08(0.05+0.04) +0.0%\n  2000.8: echo >>new && git describe --dirty (sparse-v3)   0.75(0.69+0.07)   0.02(0.03+0.03) -97.3%\n  2000.9: echo >>new && git describe --dirty (sparse-v4)   0.81(0.73+0.09)   0.02(0.01+0.05) -97.5%\n\nSigned-off-by: Raghul Nanth A <nanth.raghul@gmail.com>\n---\n builtin/describe.c                       |  2 ++\n t/perf/p2000-sparse-operations.sh        |  3 +++\n t/t1092-sparse-checkout-compatibility.sh | 30 ++++++++++++++++++++++++\n 3 files changed, 35 insertions(+)\n\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 5b5930f5c8..7ff9b5e4b2 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -654,6 +654,8 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \t\t\tint fd, result;\n \n \t\t\tsetup_work_tree();\n+\t\t\tprepare_repo_settings(the_repository);\n+\t\t\tthe_repository->settings.command_requires_full_index = 0;\n \t\t\trepo_read_index(the_repository);\n \t\t\trefresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,\n \t\t\t\t      NULL, NULL, NULL);\ndiff --git a/t/perf/p2000-sparse-operations.sh b/t/perf/p2000-sparse-operations.sh\nindex 3242cfe91a..db7887470f 100755\n--- a/t/perf/p2000-sparse-operations.sh\n+++ b/t/perf/p2000-sparse-operations.sh\n@@ -43,6 +43,7 @@ test_expect_success 'setup repo and indexes' '\n \tdone &&\n \n \tgit sparse-checkout init --cone &&\n+\tgit tag -a v1.0 -m \"Final\" &&\n \tgit sparse-checkout set $SPARSE_CONE &&\n \tgit checkout -b wide $OLD_COMMIT &&\n \n@@ -125,5 +126,7 @@ test_perf_on_all git checkout-index -f --all\n test_perf_on_all git update-index --add --remove $SPARSE_CONE/a\n test_perf_on_all \"git rm -f $SPARSE_CONE/a && git checkout HEAD -- $SPARSE_CONE/a\"\n test_perf_on_all git grep --cached --sparse bogus -- \"f2/f1/f1/*\"\n+test_perf_on_all git describe --dirty\n+test_perf_on_all 'echo >>new && git describe --dirty'\n \n test_done\ndiff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh\nindex 801919009e..2b46fb2a48 100755\n--- a/t/t1092-sparse-checkout-compatibility.sh\n+++ b/t/t1092-sparse-checkout-compatibility.sh\n@@ -1514,6 +1514,36 @@ test_expect_success 'sparse-index is not expanded: stash' '\n \tensure_not_expanded stash pop\n '\n \n+test_expect_success 'describe tested on all' '\n+\tinit_repos &&\n+\n+\t# Add tag to be read by describe\n+\n+\trun_on_all git tag -a v1.0 -m \"Version 1\" &&\n+\ttest_all_match git describe --dirty &&\n+\trun_on_all rm g &&\n+\ttest_all_match git describe --dirty\n+'\n+\n+\n+test_expect_success 'sparse-index is not expanded: describe' '\n+\tinit_repos &&\n+\n+\t# Add tag to be read by describe\n+\n+\tgit -C sparse-index tag -a v1.0 -m \"Version 1\" &&\n+\n+\tensure_not_expanded describe --dirty &&\n+\techo \"test\" >>sparse-index/g &&\n+\tensure_not_expanded describe --dirty &&\n+\techo \"v1.0-dirty\" >actual &&\n+\n+\t# Check describe on dirty work tree\n+\n+\ttest_cmp sparse-index-out actual &&\n+\tensure_not_expanded describe\n+'\n+\n test_expect_success 'sparse index is not expanded: diff' '\n \tinit_repos &&\n \n-- \n2.40.0\n\nAs for the previous questions, yes I am intereseted in GSOC. I had\nmissed the part regarding the micro projects when I was going through\nthe requirements. Sorry about that. Would I be required to make one now?\n"}]}