Skip to content

Commit 761adeb

Browse files
committed
Merge branch 'bd/tests'
* bd/tests: Rename the test trash directory to contain spaces. Fix tests breaking when checkout path contains shell metacharacters Don't use the 'export NAME=value' in the test scripts. lib-git-svn.sh: Fix quoting issues with paths containing shell metacharacters test-lib.sh: Fix some missing path quoting Use test_set_editor in t9001-send-email.sh test-lib.sh: Add a test_set_editor function to safely set $VISUAL git-send-email.perl: Handle shell metacharacters in $EDITOR properly config.c: Escape backslashes in section names properly git-rebase.sh: Fix --merge --abort failures when path contains whitespace Conflicts: t/t9115-git-svn-dcommit-funky-renames.sh
2 parents 486d1a5 + 4a7aacc commit 761adeb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+591
-539
lines changed

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ static int store_write_section(int fd, const char* key)
698698
if (dot) {
699699
strbuf_addf(&sb, "[%.*s \"", (int)(dot - key), key);
700700
for (i = dot - key + 1; i < store.baselen; i++) {
701-
if (key[i] == '"')
701+
if (key[i] == '"' || key[i] == '\\')
702702
strbuf_addch(&sb, '\\');
703703
strbuf_addch(&sb, key[i]);
704704
}

git-rebase.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ do
214214
else
215215
die "No rebase in progress?"
216216
fi
217-
git reset --hard $(cat $dotest/orig-head)
217+
git reset --hard $(cat "$dotest/orig-head")
218218
rm -r "$dotest"
219219
exit
220220
;;

git-send-email.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ sub expand_aliases {
513513
close(C);
514514

515515
my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
516-
system('sh', '-c', '$0 $@', $editor, $compose_filename);
516+
system('sh', '-c', $editor.' "$@"', $editor, $compose_filename);
517517

518518
open(C2,">",$compose_filename . ".final")
519519
or die "Failed to open $compose_filename.final : " . $!;

t/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
trash
1+
/trash directory

t/lib-git-svn.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ then
2020
fi
2121

2222
svnrepo=$PWD/svnrepo
23+
export svnrepo
2324

2425
perl -w -e "
2526
use SVN::Core;
2627
use SVN::Repos;
2728
\$SVN::Core::VERSION gt '1.1.0' or exit(42);
28-
system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or exit(41);
29+
system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
2930
" >&3 2>&4
3031
x=$?
3132
if test $x -ne 0

t/lib-httpd.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ prepare_httpd() {
6161
-new -x509 -nodes \
6262
-out $HTTPD_ROOT_PATH/httpd.pem \
6363
-keyout $HTTPD_ROOT_PATH/httpd.pem
64-
export GIT_SSL_NO_VERIFY=t
64+
GIT_SSL_NO_VERIFY=t
65+
export GIT_SSL_NO_VERIFY
6566
HTTPD_PARA="$HTTPD_PARA -DSSL"
6667
else
6768
HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT

t/t0000-basic.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ test_expect_success 'absolute path works as expected' '
305305
file="$dir"/index &&
306306
test "$file" = "$(test-absolute-path $dir2/index)" &&
307307
basename=blub &&
308-
test "$dir/$basename" = $(cd .git && test-absolute-path $basename) &&
308+
test "$dir/$basename" = "$(cd .git && test-absolute-path "$basename")" &&
309309
ln -s ../first/file .git/syml &&
310310
sym="$(cd first; pwd -P)"/file &&
311-
test "$sym" = "$(test-absolute-path $dir2/syml)"
311+
test "$sym" = "$(test-absolute-path "$dir2/syml")"
312312
'
313313

314314
test_expect_success 'very long name in the index handled sanely' '

t/t1020-subdirectory.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LF='
2121
'
2222

2323
test_expect_success 'update-index and ls-files' '
24-
cd $HERE &&
24+
cd "$HERE" &&
2525
git update-index --add one &&
2626
case "`git ls-files`" in
2727
one) echo ok one ;;
@@ -41,7 +41,7 @@ test_expect_success 'update-index and ls-files' '
4141
'
4242

4343
test_expect_success 'cat-file' '
44-
cd $HERE &&
44+
cd "$HERE" &&
4545
two=`git ls-files -s dir/two` &&
4646
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
4747
echo "$two" &&
@@ -54,7 +54,7 @@ test_expect_success 'cat-file' '
5454
rm -f actual dir/actual
5555

5656
test_expect_success 'diff-files' '
57-
cd $HERE &&
57+
cd "$HERE" &&
5858
echo a >>one &&
5959
echo d >>dir/two &&
6060
case "`git diff-files --name-only`" in
@@ -74,7 +74,7 @@ test_expect_success 'diff-files' '
7474
'
7575

7676
test_expect_success 'write-tree' '
77-
cd $HERE &&
77+
cd "$HERE" &&
7878
top=`git write-tree` &&
7979
echo $top &&
8080
cd dir &&
@@ -84,7 +84,7 @@ test_expect_success 'write-tree' '
8484
'
8585

8686
test_expect_success 'checkout-index' '
87-
cd $HERE &&
87+
cd "$HERE" &&
8888
git checkout-index -f -u one &&
8989
cmp one original.one &&
9090
cd dir &&
@@ -93,7 +93,7 @@ test_expect_success 'checkout-index' '
9393
'
9494

9595
test_expect_success 'read-tree' '
96-
cd $HERE &&
96+
cd "$HERE" &&
9797
rm -f one dir/two &&
9898
tree=`git write-tree` &&
9999
git read-tree --reset -u "$tree" &&
@@ -107,27 +107,27 @@ test_expect_success 'read-tree' '
107107
'
108108

109109
test_expect_success 'no file/rev ambiguity check inside .git' '
110-
cd $HERE &&
110+
cd "$HERE" &&
111111
git commit -a -m 1 &&
112-
cd $HERE/.git &&
112+
cd "$HERE"/.git &&
113113
git show -s HEAD
114114
'
115115

116116
test_expect_success 'no file/rev ambiguity check inside a bare repo' '
117-
cd $HERE &&
117+
cd "$HERE" &&
118118
git clone -s --bare .git foo.git &&
119119
cd foo.git && GIT_DIR=. git show -s HEAD
120120
'
121121

122122
# This still does not work as it should...
123123
: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
124-
cd $HERE &&
124+
cd "$HERE" &&
125125
git clone -s --bare .git foo.git &&
126126
cd foo.git && git show -s HEAD
127127
'
128128

129129
test_expect_success 'detection should not be fooled by a symlink' '
130-
cd $HERE &&
130+
cd "$HERE" &&
131131
rm -fr foo.git &&
132132
git clone -s .git another &&
133133
ln -s another yetanother &&

t/t1303-wacky-config.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@ test_expect_success 'add key in different section' '
3434
check section2.key bar
3535
'
3636

37+
SECTION="test.q\"s\\sq'sp e.key"
38+
test_expect_success 'make sure git-config escapes section names properly' '
39+
git config "$SECTION" bar &&
40+
check "$SECTION" bar
41+
'
42+
3743
test_done

t/t1500-rev-parse.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ test_rev_parse 'core.bare undefined' false false true
5151

5252
mkdir work || exit 1
5353
cd work || exit 1
54-
export GIT_DIR=../.git
55-
export GIT_CONFIG="$(pwd)"/../.git/config
54+
GIT_DIR=../.git
55+
GIT_CONFIG="$(pwd)"/../.git/config
56+
export GIT_DIR GIT_CONFIG
5657

5758
git config core.bare false
5859
test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true ''
@@ -64,8 +65,8 @@ git config --unset core.bare
6465
test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''
6566

6667
mv ../.git ../repo.git || exit 1
67-
export GIT_DIR=../repo.git
68-
export GIT_CONFIG="$(pwd)"/../repo.git/config
68+
GIT_DIR=../repo.git
69+
GIT_CONFIG="$(pwd)"/../repo.git/config
6970

7071
git config core.bare false
7172
test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true ''

0 commit comments

Comments
 (0)