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
9 changes: 8 additions & 1 deletion connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,14 @@ struct child_process *git_connect(int fd[2], const char *url,
version);
}
}
strvec_push(&conn->args, cmd.buf);
if (!conn->use_shell || conn->args.nr > 0 ||
does_cmd_require_shell(prog))
strvec_push(&conn->args, cmd.buf);
else {
/* avoid running through shell; it's unnecessary */
strvec_pushl(&conn->args, prog, path, NULL);
conn->use_shell = 0;
}

if (start_command(conn))
die(_("unable to fork"));
Expand Down
2 changes: 1 addition & 1 deletion run-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static const char **prepare_shell_cmd(struct strvec *out, const char **argv)
if (!argv[0])
BUG("shell command is empty");

if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) {
if (does_cmd_require_shell(argv[0])) {
strvec_push_nodup(out, git_shell_path());
strvec_push(out, "-c");

Expand Down
9 changes: 9 additions & 0 deletions run-command.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ int exists_in_PATH(const char *command);
*/
char *git_shell_path(void);

/**
* Determines whether the command needs to run through a shell (for example,
* `git-upload-pack` does not need a shell, while `less -R` does).
*/
static inline int does_cmd_require_shell(const char *cmd)
{
return strcspn(cmd, "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(cmd);
}

/**
* Start a sub-process. Takes a pointer to a `struct child_process`
* that specifies the details and returns pipe FDs (if requested).
Expand Down
2 changes: 1 addition & 1 deletion t/lib-bundle-uri-protocol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ BUNDLE_URI_TEST_BUNDLE_URI=
case "$BUNDLE_URI_PROTOCOL" in
file)
BUNDLE_URI_PARENT=file_parent
BUNDLE_URI_REPO_URI="file://$PWD/file_parent"
BUNDLE_URI_REPO_URI="file://$(pwd)/file_parent"
BUNDLE_URI_BUNDLE_URI="$BUNDLE_URI_REPO_URI/fake.bdl"
test_set_prereq BUNDLE_URI_FILE
;;
Expand Down
2 changes: 1 addition & 1 deletion t/t1900-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test_expect_success 'setup remote' '
'

test_repo_info 'shallow repository = true is retrieved correctly' \
'git clone --depth 1 "file://$PWD/remote"' 'shallow' 'layout.shallow' 'true'
'git clone --depth 1 "file://$(pwd)/remote"' 'shallow' 'layout.shallow' 'true'

test_repo_info 'object.format = sha1 is retrieved correctly' \
'git init --object-format=sha1' 'sha1' 'object.format' 'sha1'
Expand Down
2 changes: 1 addition & 1 deletion t/t3421-rebase-topology-linear.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test_expect_success 'setup branches and remote tracking' '
do
git branch branch-$tag $tag || return 1
done &&
git remote add origin "file://$PWD" &&
git remote add origin "file://$(pwd)" &&
git fetch origin
'

Expand Down
2 changes: 1 addition & 1 deletion t/t5150-request-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test_expect_success 'setup' '
git clone upstream.git upstream-private &&
git clone downstream.git local &&

trash_url="file://$TRASH_DIRECTORY" &&
trash_url="$TRASH_DIRECTORY_URL" &&
downstream_url="$trash_url/downstream.git/" &&
upstream_url="$trash_url/upstream.git/" &&

Expand Down
2 changes: 1 addition & 1 deletion t/t5318-commit-graph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ test_expect_success 'commit grafts invalidate commit-graph' '

test_expect_success 'replace-objects invalidates commit-graph' '
test_when_finished rm -rf shallow &&
git clone --depth 2 "file://$TRASH_DIRECTORY/full" shallow &&
git clone --depth 2 "$TRASH_DIRECTORY_URL/full" shallow &&
(
cd shallow &&
git commit-graph write --reachable &&
Expand Down
4 changes: 2 additions & 2 deletions t/t5510-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ test_expect_success 'fetch.writeCommitGraph with submodules' '
git clone dups super &&
(
cd super &&
git submodule add "file://$TRASH_DIRECTORY/three" &&
git submodule add "$TRASH_DIRECTORY_URL/three" &&
git commit -m "add submodule"
) &&
git clone "super" super-clone &&
Expand Down Expand Up @@ -1314,7 +1314,7 @@ test_expect_success 'fetching with auto-gc does not lock up' '
echo "$*" &&
false
EOF
git clone "file://$PWD" auto-gc &&
git clone "file://$(pwd)" auto-gc &&
test_commit test2 &&
(
cd auto-gc &&
Expand Down
2 changes: 1 addition & 1 deletion t/t5527-fetch-odd-refs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test_expect_success 'setup repo with odd suffix ref' '
'

test_expect_success 'suffix ref is ignored during fetch' '
git clone --bare file://"$PWD" suffix &&
git clone --bare file://"$(pwd)" suffix &&
echo three >expect &&
git --git-dir=suffix log -1 --format=%s refs/heads/main >actual &&
test_cmp expect actual
Expand Down
2 changes: 1 addition & 1 deletion t/t5537-fetch-shallow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ test_expect_success '.git/shallow is edited by repack' '
git -C shallow-server checkout main &&

git clone --depth=1 --no-tags --no-single-branch \
"file://$PWD/shallow-server" shallow-client &&
"file://$(pwd)/shallow-server" shallow-client &&

: now remove the branch and fetch with prune &&
git -C shallow-server branch -D branch &&
Expand Down
6 changes: 3 additions & 3 deletions t/t5553-set-upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test_expect_success 'fetch --set-upstream ./does-not-exist fails with invalid ur

test_expect_success 'fetch --set-upstream with valid URL sets upstream to URL' '
clear_config other other2 &&
url="file://$PWD" &&
url="file://$(pwd)" &&
git fetch --set-upstream "$url" &&
check_config main "$url" HEAD &&
check_config_missing other &&
Expand Down Expand Up @@ -172,7 +172,7 @@ test_expect_success 'pull --set-upstream upstream with more than one branch does
test_expect_success 'pull --set-upstream with valid URL sets upstream to URL' '
clear_config main other other2 &&
git checkout main &&
url="file://$PWD" &&
url="file://$(pwd)" &&
git pull --set-upstream "$url" &&
check_config main "$url" HEAD &&
check_config_missing other &&
Expand All @@ -182,7 +182,7 @@ test_expect_success 'pull --set-upstream with valid URL sets upstream to URL' '
test_expect_success 'pull --set-upstream with valid URL and branch sets branch' '
clear_config main other other2 &&
git checkout main &&
url="file://$PWD" &&
url="file://$(pwd)" &&
git pull --set-upstream "$url" main &&
check_config main "$url" refs/heads/main &&
check_config_missing other &&
Expand Down
6 changes: 3 additions & 3 deletions t/t5601-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ test_expect_success 'clone respects global branch.autosetuprebase' '

test_expect_success 'respect url-encoding of file://' '
git init x+y &&
git clone "file://$PWD/x+y" xy-url-1 &&
git clone "file://$PWD/x%2By" xy-url-2
git clone "file://$(pwd)/x+y" xy-url-1 &&
git clone "file://$(pwd)/x%2By" xy-url-2
'

test_expect_success 'do not query-string-decode + in URLs' '
rm -rf x+y &&
git init "x y" &&
test_must_fail git clone "file://$PWD/x+y" xy-no-plus
test_must_fail git clone "file://$(pwd)/x+y" xy-no-plus
'

test_expect_success 'do not respect url-encoding of non-url path' '
Expand Down
8 changes: 4 additions & 4 deletions t/t5610-clone-detached.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test_expect_success 'setup' '

test_expect_success 'clone repo (detached HEAD points to branch)' '
git checkout main^0 &&
git clone "file://$PWD" detached-branch
git clone "file://$(pwd)" detached-branch
'
test_expect_success 'cloned HEAD matches' '
echo three >expect &&
Expand All @@ -37,7 +37,7 @@ test_expect_failure 'cloned HEAD is detached' '

test_expect_success 'clone repo (detached HEAD points to tag)' '
git checkout two^0 &&
git clone "file://$PWD" detached-tag
git clone "file://$(pwd)" detached-tag
'
test_expect_success 'cloned HEAD matches' '
echo two >expect &&
Expand All @@ -50,7 +50,7 @@ test_expect_success 'cloned HEAD is detached' '

test_expect_success 'clone repo (detached HEAD points to history)' '
git checkout two^ &&
git clone "file://$PWD" detached-history
git clone "file://$(pwd)" detached-history
'
test_expect_success 'cloned HEAD matches' '
echo one >expect &&
Expand All @@ -65,7 +65,7 @@ test_expect_success 'clone repo (orphan detached HEAD)' '
git checkout main^0 &&
echo four >file &&
git commit -a -m four &&
git clone "file://$PWD" detached-orphan
git clone "file://$(pwd)" detached-orphan
'
test_expect_success 'cloned HEAD matches' '
echo four >expect &&
Expand Down
2 changes: 1 addition & 1 deletion t/t5810-proto-disable-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_expect_success 'setup repository to clone' '
test_commit one
'

test_proto "file://" file "file://$PWD"
test_proto "file://" file "file://$(pwd)"
test_proto "path" file .

test_expect_success 'setup repo with dash' '
Expand Down
2 changes: 1 addition & 1 deletion t/t7406-submodule-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ test_expect_success 'submodule update --quiet passes quietness to fetch with a s
test_when_finished "rm -rf super4 super5 super6" &&
git clone . super4 &&
(cd super4 &&
git submodule add --quiet file://"$TRASH_DIRECTORY"/submodule submodule3 &&
git submodule add --quiet "$TRASH_DIRECTORY_URL"/submodule submodule3 &&
git commit -am "setup submodule3"
) &&
(cd submodule &&
Expand Down
2 changes: 2 additions & 0 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ case "$TRASH_DIRECTORY" in
/*) ;; # absolute path is good
*) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;;
esac
TRASH_DIRECTORY_URL=file://"$TRASH_DIRECTORY"

# If --stress was passed, run this test repeatedly in several parallel loops.
if test "$GIT_TEST_STRESS_STARTED" = "done"
Expand Down Expand Up @@ -1682,6 +1683,7 @@ Darwin)
test_set_prereq GREP_STRIPS_CR
test_set_prereq WINDOWS
GIT_TEST_CMP="GIT_DIR=/dev/null git diff --no-index --ignore-cr-at-eol --"
TRASH_DIRECTORY_URL=file://"$(cygpath -am "$TRASH_DIRECTORY")"
;;
*CYGWIN*)
test_set_prereq POSIXPERM
Expand Down
Loading