Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions gvfs-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1352,13 +1352,16 @@ static int option_parse_shared_cache_directory(const struct option *opt,
*/
strbuf_addbuf(&gvfs_shared_cache_pathname, &buf_arg);

/* Attempt to create the directory, in case it doesn't exist. */
safe_create_leading_directories(the_repository,
gvfs_shared_cache_pathname.buf);
mkdir(gvfs_shared_cache_pathname.buf, 0777);

odb_add_to_alternates_memory(the_repository->objects, buf_arg.buf);

strbuf_release(&buf_arg);
return 0;
}

else {
} else {
/*
* The requested shared-cache is different from the one
* we inherited. Replace the inherited value with this
Expand All @@ -1371,6 +1374,11 @@ static int option_parse_shared_cache_directory(const struct option *opt,
strbuf_setlen(&gvfs_shared_cache_pathname, 0);
strbuf_addbuf(&gvfs_shared_cache_pathname, &buf_arg);

/* Attempt to create the directory, in case it doesn't exist. */
safe_create_leading_directories(the_repository,
gvfs_shared_cache_pathname.buf);
mkdir(gvfs_shared_cache_pathname.buf, 0777);

odb_add_to_alternates_memory(the_repository->objects, buf_arg.buf);

/*
Expand Down
31 changes: 31 additions & 0 deletions t/t9210-scalar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,37 @@ test_expect_success '`scalar clone` with GVFS-enabled server' '
)
'

test_expect_success '`scalar clone` with GVFS-enabled server; local cache path' '
: the fake cache server requires fake authentication &&
git config --global core.askPass true &&

LOCAL_CACHE_BASE="$(pwd)/local" &&

# We must set credential.interactive=true to bypass a setting
# in "scalar clone" that disables interactive credentials during
# an unattended command.
scalar \
-c credential.interactive=true \
clone --gvfs-protocol \
--local-cache-path="$LOCAL_CACHE_BASE" \
--single-branch -- http://$ORIGIN_HOST_PORT/ with-local &&

: verify that the shared cache has been configured &&
cache_key="url_$(printf "%s" http://$ORIGIN_HOST_PORT/ |
tr A-Z a-z |
test-tool sha1)" &&
LOCAL_CACHE_DIR="$LOCAL_CACHE_BASE/$cache_key" &&
echo "$LOCAL_CACHE_DIR" >expect &&
git -C with-local/src config gvfs.sharedCache >actual &&
test_cmp expect actual &&

: check the local cache is recreated on fetch &&
rm -rf $LOCAL_CACHE_BASE &&
git -C with-local fetch &&
test_path_is_dir "$LOCAL_CACHE_DIR" &&
test_path_is_dir "$LOCAL_CACHE_DIR/pack"
'

. "$TEST_DIRECTORY"/lib-gvfs-helper.sh

test_expect_success 'scalar clone: all verbs with different servers' '
Expand Down
Loading