From d6b0350194a95ed6a1f601570c1aa50bffe8800d Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 30 Sep 2022 12:41:27 -0400 Subject: [PATCH] scalar: .scalarCache should live above enlistment We should not be putting the .scalarCache inside the enlistment as a sibling to the 'src' directory. This only happens in "unattended" mode, but it also negates any benefit of a shared object cache because each enlistment absolutely does not share any objects with others. Move the shared object cache in this case to a level above the enlistment, so at least there is some hope that it can be reused. This is also critical to the upcoming --no-src option, since the shared object cache cannot be located within the Git repository. Signed-off-by: Derrick Stolee --- scalar.c | 9 +++++++-- t/t9210-scalar.sh | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scalar.c b/scalar.c index 36ca55c6ed5b83..65129d6ff05898 100644 --- a/scalar.c +++ b/scalar.c @@ -481,8 +481,13 @@ static char *default_cache_root(const char *root) { const char *env; - if (is_unattended()) - return xstrfmt("%s/.scalarCache", root); + if (is_unattended()) { + struct strbuf path = STRBUF_INIT; + strbuf_addstr(&path, root); + strip_last_path_component(&path); + strbuf_addstr(&path, "/.scalarCache"); + return strbuf_detach(&path, NULL); + } #ifdef WIN32 (void)env; diff --git a/t/t9210-scalar.sh b/t/t9210-scalar.sh index b14221a061dd26..f41694ea315680 100755 --- a/t/t9210-scalar.sh +++ b/t/t9210-scalar.sh @@ -355,7 +355,7 @@ test_expect_success '`scalar clone` with GVFS-enabled server' ' cache_key="url_$(printf "%s" http://$HOST_PORT/ | tr A-Z a-z | test-tool sha1)" && - echo "$(pwd)/using-gvfs/.scalarCache/$cache_key" >expect && + echo "$(pwd)/.scalarCache/$cache_key" >expect && git -C using-gvfs/src config gvfs.sharedCache >actual && test_cmp expect actual &&