Skip to content

Commit

Permalink
scalar: .scalarCache should live above enlistment
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
derrickstolee authored and dscho committed Aug 16, 2023
1 parent d0a6222 commit 1d252e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "trace2.h"
#include "json-parser.h"
#include "remote.h"
#include "path.h"

static int is_unattended(void) {
return git_env_bool("Scalar_UNATTENDED", 0);
Expand Down Expand Up @@ -476,8 +477,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;
Expand Down
2 changes: 1 addition & 1 deletion t/t9210-scalar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,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 &&
Expand Down

0 comments on commit 1d252e9

Please sign in to comment.