Skip to content

Commit 9ebcdab

Browse files
committed
Merge branch 'busybox-w32'
These are follow-ups to the original topic introducing support for using BusyBox-w32 to run Git for Windows' test suite; The new batch is meant to use the new mechanism of `core.shell`.
2 parents fb8c759 + 923892b commit 9ebcdab

17 files changed

Lines changed: 59 additions & 24 deletions

builtin/history.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ static int fill_commit_message(struct repository *repo,
7777
wt_status_collect_free_buffers(&s);
7878
string_list_clear_func(&s.change, change_data_free);
7979

80+
/*
81+
* Close the handle before launching the editor: on Windows an open
82+
* handle would prevent the editor from replacing the file (e.g.
83+
* BusyBox' `ash` cannot overwrite a file that another process keeps
84+
* open), and leaving it open leaks the descriptor everywhere else.
85+
*/
86+
fclose(s.fp);
87+
8088
strbuf_reset(out);
8189
if (launch_editor(path, out, NULL)) {
8290
fprintf(stderr, _("Aborting commit as launching the editor failed.\n"));

connect.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,9 @@ static enum url_scheme parse_connect_url(const char *url_orig, char **ret_host,
10941094
path = host - 2; /* include the leading "//" */
10951095
else if (scheme == URL_SCHEME_FILE && has_dos_drive_prefix(end))
10961096
path = end; /* "file://$(pwd)" may be "file://C:/projects/repo" */
1097+
else if (scheme == URL_SCHEME_FILE && end[0] == '/' &&
1098+
has_dos_drive_prefix(end + 1))
1099+
path = end + 1; /* "file:///C:/repo" (RFC 8089) -> "C:/repo" */
10971100
else
10981101
path = strchr(end, separator);
10991102

contrib/subtree/git-subtree.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
# Copyright (C) 2009 Avery Pennarun <apenwarr@gmail.com>
66
#
77

8+
case "$PATH" in *\;*) PATH_SEP=\;;; *) PATH_SEP=:;; esac
9+
810
if test -z "$GIT_EXEC_PATH" || ! test -f "$GIT_EXEC_PATH/git-sh-setup" || {
9-
test "${PATH#"${GIT_EXEC_PATH}:"}" = "$PATH" &&
10-
test ! "$GIT_EXEC_PATH" -ef "${PATH%%:*}" 2>/dev/null
11+
test "${PATH#"${GIT_EXEC_PATH}$PATH_SEP"}" = "$PATH" &&
12+
test ! "$GIT_EXEC_PATH" -ef "${PATH%%$PATH_SEP*}" 2>/dev/null
1113
}
1214
then
1315
basename=${0##*[/\\]}

gettext.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,13 @@ int gettext_width(const char *s)
141141

142142
int is_utf8_locale(void)
143143
{
144-
#ifdef NO_GETTEXT
144+
/*
145+
* The charset is normally set by git_setup_gettext(), but it bails out
146+
* early when the locale directory is missing, leaving `charset` NULL.
147+
* As is_encoding_utf8(NULL) answers "yes", that would make us assume a
148+
* UTF-8 locale even under e.g. LC_ALL=C, so derive the charset from the
149+
* environment ourselves in that case.
150+
*/
145151
if (!charset) {
146152
const char *env = getenv("LC_ALL");
147153
if (!env || !*env)
@@ -154,6 +160,5 @@ int is_utf8_locale(void)
154160
env = strchr(env, '.') + 1;
155161
charset = xstrdup(env);
156162
}
157-
#endif
158163
return is_encoding_utf8(charset);
159164
}

path.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,10 @@ char *interpolate_path(const char *path, int real_home)
706706
if (skip_prefix(path, "%(prefix)/", &path))
707707
return system_path(path);
708708

709+
#ifdef __MINGW32__
710+
if (!strcmp(path, "/dev/null"))
711+
return xstrdup("NUL");
712+
#endif
709713
if (path[0] == '~') {
710714
const char *first_slash = strchrnul(path, '/');
711715
const char *username = path + 1;

t/lib-subtest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ _run_sub_test_lib_test_common () {
4848
GIT_SKIP_TESTS=$skip &&
4949
export GIT_SKIP_TESTS &&
5050
sane_unset GIT_TEST_FAIL_PREREQS &&
51-
./"$name.sh" "$@" >out 2>err;
51+
./"$name.sh" ${no_bin_wrappers:+--no-bin-wrappers} "$@" >out 2>err;
5252
ret=$? &&
5353
test "$ret" "$cmp_op" "$want_code"
5454
)

t/t0007-git-var.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ test_expect_success POSIXPERM 'GIT_SHELL_PATH points to a valid executable' '
156156
test_expect_success MINGW 'GIT_SHELL_PATH points to a suitable shell' '
157157
shellpath=$(git var GIT_SHELL_PATH) &&
158158
case "$shellpath" in
159-
[A-Z]:/*/sh.exe) test -f "$shellpath";;
159+
[A-Z]:/*/*sh.exe) test -f "$shellpath";;
160160
*) return 1;;
161161
esac
162162
'
@@ -189,7 +189,7 @@ test_expect_success 'GIT_CONFIG_SYSTEM points to the correct location' '
189189
systempath=$(git var GIT_CONFIG_SYSTEM) &&
190190
test "$systempath" != "" &&
191191
systempath=$(GIT_CONFIG_SYSTEM=/dev/null git var GIT_CONFIG_SYSTEM) &&
192-
if test_have_prereq MINGW
192+
if test_have_prereq MINGW && ! test_have_prereq BUSYBOX
193193
then
194194
test "$systempath" = "nul"
195195
else
@@ -213,7 +213,7 @@ test_expect_success 'GIT_CONFIG_GLOBAL points to the correct location' '
213213
echo "$TRASHDIR/.gitconfig" >>expected &&
214214
test_cmp expected actual &&
215215
globalpath=$(GIT_CONFIG_GLOBAL=/dev/null git var GIT_CONFIG_GLOBAL) &&
216-
if test_have_prereq MINGW
216+
if test_have_prereq MINGW && ! test_have_prereq BUSYBOX
217217
then
218218
test "$globalpath" = "nul"
219219
else

t/t2205-add-worktree-config.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ test_expect_success '1a: setup--config worktree' '
7272
test_expect_success '1b: pre-add all' '
7373
(
7474
cd test1 &&
75-
local parent_dir="$(pwd)" &&
75+
parent_dir="$(pwd)" &&
7676
git -C repo ls-files -o --exclude-standard "$parent_dir" >actual-all-unsorted &&
7777
sort actual-all-unsorted >actual-all &&
7878
sort expect-all-unsorted >expect-all &&
@@ -83,7 +83,7 @@ test_expect_success '1b: pre-add all' '
8383
test_expect_success '1c: pre-add dir all' '
8484
(
8585
cd test1 &&
86-
local parent_dir="$(pwd)" &&
86+
parent_dir="$(pwd)" &&
8787
git -C repo ls-files -o --directory --exclude-standard "$parent_dir" >actual-all-dir-unsorted &&
8888
sort actual-all-dir-unsorted >actual-all &&
8989
sort expect-all-dir-unsorted >expect-all &&
@@ -94,7 +94,7 @@ test_expect_success '1c: pre-add dir all' '
9494
test_expect_success '1d: post-add tracked' '
9595
(
9696
cd test1 &&
97-
local parent_dir="$(pwd)" &&
97+
parent_dir="$(pwd)" &&
9898
(
9999
cd repo &&
100100
git add file-tracked &&
@@ -112,7 +112,7 @@ test_expect_success '1d: post-add tracked' '
112112
test_expect_success '1e: post-add untracked' '
113113
(
114114
cd test1 &&
115-
local parent_dir="$(pwd)" &&
115+
parent_dir="$(pwd)" &&
116116
git -C repo ls-files -o --exclude-standard "$parent_dir" >actual-untracked-unsorted &&
117117
sort actual-untracked-unsorted >actual-untracked &&
118118
sort expect-untracked-unsorted >expect-untracked &&

t/t2501-cwd-empty.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ test_expect_success '`rm -rf dir` even with only tracked files will remove somet
222222
test_path_is_dir a/b
223223
'
224224

225-
test_expect_success 'git version continues working from a deleted dir' '
225+
test_expect_success !BUSYBOX 'git version continues working from a deleted dir' '
226226
mkdir tmp &&
227227
(
228228
cd tmp &&
@@ -267,7 +267,7 @@ test_expect_success 'rm -r leaves submodule if cwd inside' '
267267
git --git-dir=../.git --work-tree=.. rm -r ../my_submodule/
268268
'
269269

270-
test_expect_success 'rm -rf removes submodule even if cwd inside' '
270+
test_expect_success !BUSYBOX 'rm -rf removes submodule even if cwd inside' '
271271
test_submodule_removal missing \
272272
git --git-dir=../.git --work-tree=.. rm -rf ../my_submodule/
273273
'

t/t3430-rebase-merges.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ test_expect_success 'merge -c rewords when a strategy is given' '
234234
git add G.t
235235
EOF
236236
237-
PATH="$PWD:$PATH" \
237+
PATH="$PWD$PATH_SEP$PATH" \
238238
GIT_SEQUENCE_EDITOR="echo merge -c H G >" \
239239
GIT_EDITOR="echo edited >>" \
240240
git rebase --no-ff -ir -s override -Xxopt E &&
@@ -570,7 +570,7 @@ test_expect_success '--rebase-merges with strategies' '
570570
echo overridden$1 >>G.t
571571
git add G.t
572572
EOF
573-
PATH="$PWD:$PATH" git rebase -ir -s override -Xxopt G &&
573+
PATH="$PWD$PATH_SEP$PATH" git rebase -ir -s override -Xxopt G &&
574574
test_write_lines G overridden--xopt >expect &&
575575
test_cmp expect G.t
576576
'

0 commit comments

Comments
 (0)