Skip to content

Commit 99de5bf

Browse files
committed
Merge pull request #536: Allow --no-src during clones and git worktree after clones
These are two highly-requested items from an internal team considering a move to Scalar using Azure Repos. 1. Remove the requirement that we create a `src` directory at clone time. 2. Allow `git worktree` even when using the GVFS protocol. These are not difficult to implement. The `--no-src` option could even be submitted upstream (though the commit will need to drop one bit about an interaction with the local cache path).
2 parents 850cf4d + 5073191 commit 99de5bf

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

abspath.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int is_directory(const char *path)
1414
}
1515

1616
/* removes the last path component from 'path' except if 'path' is root */
17-
static void strip_last_component(struct strbuf *path)
17+
void strip_last_path_component(struct strbuf *path)
1818
{
1919
size_t offset = offset_1st_component(path->buf);
2020
size_t len = path->len;
@@ -119,7 +119,7 @@ static char *strbuf_realpath_1(struct strbuf *resolved, const char *path,
119119
continue; /* '.' component */
120120
} else if (next.len == 2 && !strcmp(next.buf, "..")) {
121121
/* '..' component; strip the last path component */
122-
strip_last_component(resolved);
122+
strip_last_path_component(resolved);
123123
continue;
124124
}
125125

@@ -171,7 +171,7 @@ static char *strbuf_realpath_1(struct strbuf *resolved, const char *path,
171171
* strip off the last component since it will
172172
* be replaced with the contents of the symlink
173173
*/
174-
strip_last_component(resolved);
174+
strip_last_path_component(resolved);
175175
}
176176

177177
/*

abspath.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ char *real_pathdup(const char *path, int die_on_error);
1010
const char *absolute_path(const char *path);
1111
char *absolute_pathdup(const char *path);
1212

13+
/**
14+
* Remove the last path component from 'path' except if 'path' is root.
15+
*/
16+
void strip_last_path_component(struct strbuf *path);
17+
1318
/*
1419
* Concatenate "prefix" (if len is non-zero) and "path", with no
1520
* connecting characters (so "prefix" should end with a "/").

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)