Skip to content

Commit b47a29c

Browse files
derrickstoleedscho
authored andcommitted
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 <[email protected]>
1 parent aa3fed6 commit b47a29c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

scalar.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,13 @@ static char *default_cache_root(const char *root)
488488
{
489489
const char *env;
490490

491-
if (is_unattended())
492-
return xstrfmt("%s/.scalarCache", root);
491+
if (is_unattended()) {
492+
struct strbuf path = STRBUF_INIT;
493+
strbuf_addstr(&path, root);
494+
strip_last_path_component(&path);
495+
strbuf_addstr(&path, "/.scalarCache");
496+
return strbuf_detach(&path, NULL);
497+
}
493498

494499
#ifdef WIN32
495500
(void)env;

t/t9210-scalar.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ test_expect_success '`scalar clone` with GVFS-enabled server' '
382382
cache_key="url_$(printf "%s" http://$HOST_PORT/ |
383383
tr A-Z a-z |
384384
test-tool sha1)" &&
385-
echo "$(pwd)/using-gvfs/.scalarCache/$cache_key" >expect &&
385+
echo "$(pwd)/.scalarCache/$cache_key" >expect &&
386386
git -C using-gvfs/src config gvfs.sharedCache >actual &&
387387
test_cmp expect actual &&
388388

0 commit comments

Comments
 (0)