Skip to content

Commit 2736e7e

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 <derrickstolee@github.com>
1 parent 1e13ab8 commit 2736e7e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

scalar.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "trace2.h"
2323
#include "json-parser.h"
2424
#include "remote.h"
25+
#include "path.h"
2526

2627
static int is_unattended(void) {
2728
return git_env_bool("Scalar_UNATTENDED", 0);
@@ -476,8 +477,13 @@ static char *default_cache_root(const char *root)
476477
{
477478
const char *env;
478479

479-
if (is_unattended())
480-
return xstrfmt("%s/.scalarCache", root);
480+
if (is_unattended()) {
481+
struct strbuf path = STRBUF_INIT;
482+
strbuf_addstr(&path, root);
483+
strip_last_path_component(&path);
484+
strbuf_addstr(&path, "/.scalarCache");
485+
return strbuf_detach(&path, NULL);
486+
}
481487

482488
#ifdef WIN32
483489
(void)env;

t/t9210-scalar.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ test_expect_success '`scalar clone` with GVFS-enabled server' '
306306
cache_key="url_$(printf "%s" http://$HOST_PORT/ |
307307
tr A-Z a-z |
308308
test-tool sha1)" &&
309-
echo "$(pwd)/using-gvfs/.scalarCache/$cache_key" >expect &&
309+
echo "$(pwd)/.scalarCache/$cache_key" >expect &&
310310
git -C using-gvfs/src config gvfs.sharedCache >actual &&
311311
test_cmp expect actual &&
312312

0 commit comments

Comments
 (0)