Skip to content

Commit

Permalink
Merge branch 'bd/tests'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed May 14, 2008
2 parents 486d1a5 + 4a7aacc commit 761adeb
Show file tree
Hide file tree
Showing 57 changed files with 591 additions and 539 deletions.
2 changes: 1 addition & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ static int store_write_section(int fd, const char* key)
if (dot) {
strbuf_addf(&sb, "[%.*s \"", (int)(dot - key), key);
for (i = dot - key + 1; i < store.baselen; i++) {
if (key[i] == '"')
if (key[i] == '"' || key[i] == '\\')
strbuf_addch(&sb, '\\');
strbuf_addch(&sb, key[i]);
}
Expand Down
2 changes: 1 addition & 1 deletion git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ do
else
die "No rebase in progress?"
fi
git reset --hard $(cat $dotest/orig-head)
git reset --hard $(cat "$dotest/orig-head")
rm -r "$dotest"
exit
;;
Expand Down
2 changes: 1 addition & 1 deletion git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ sub expand_aliases {
close(C);

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

open(C2,">",$compose_filename . ".final")
or die "Failed to open $compose_filename.final : " . $!;
Expand Down
2 changes: 1 addition & 1 deletion t/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
trash
/trash directory
3 changes: 2 additions & 1 deletion t/lib-git-svn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ then
fi

svnrepo=$PWD/svnrepo
export svnrepo

perl -w -e "
use SVN::Core;
use SVN::Repos;
\$SVN::Core::VERSION gt '1.1.0' or exit(42);
system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or exit(41);
system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
" >&3 2>&4
x=$?
if test $x -ne 0
Expand Down
3 changes: 2 additions & 1 deletion t/lib-httpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ prepare_httpd() {
-new -x509 -nodes \
-out $HTTPD_ROOT_PATH/httpd.pem \
-keyout $HTTPD_ROOT_PATH/httpd.pem
export GIT_SSL_NO_VERIFY=t
GIT_SSL_NO_VERIFY=t
export GIT_SSL_NO_VERIFY
HTTPD_PARA="$HTTPD_PARA -DSSL"
else
HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT
Expand Down
4 changes: 2 additions & 2 deletions t/t0000-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ test_expect_success 'absolute path works as expected' '
file="$dir"/index &&
test "$file" = "$(test-absolute-path $dir2/index)" &&
basename=blub &&
test "$dir/$basename" = $(cd .git && test-absolute-path $basename) &&
test "$dir/$basename" = "$(cd .git && test-absolute-path "$basename")" &&
ln -s ../first/file .git/syml &&
sym="$(cd first; pwd -P)"/file &&
test "$sym" = "$(test-absolute-path $dir2/syml)"
test "$sym" = "$(test-absolute-path "$dir2/syml")"
'

test_expect_success 'very long name in the index handled sanely' '
Expand Down
22 changes: 11 additions & 11 deletions t/t1020-subdirectory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LF='
'

test_expect_success 'update-index and ls-files' '
cd $HERE &&
cd "$HERE" &&
git update-index --add one &&
case "`git ls-files`" in
one) echo ok one ;;
Expand All @@ -41,7 +41,7 @@ test_expect_success 'update-index and ls-files' '
'

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

test_expect_success 'diff-files' '
cd $HERE &&
cd "$HERE" &&
echo a >>one &&
echo d >>dir/two &&
case "`git diff-files --name-only`" in
Expand All @@ -74,7 +74,7 @@ test_expect_success 'diff-files' '
'

test_expect_success 'write-tree' '
cd $HERE &&
cd "$HERE" &&
top=`git write-tree` &&
echo $top &&
cd dir &&
Expand All @@ -84,7 +84,7 @@ test_expect_success 'write-tree' '
'

test_expect_success 'checkout-index' '
cd $HERE &&
cd "$HERE" &&
git checkout-index -f -u one &&
cmp one original.one &&
cd dir &&
Expand All @@ -93,7 +93,7 @@ test_expect_success 'checkout-index' '
'

test_expect_success 'read-tree' '
cd $HERE &&
cd "$HERE" &&
rm -f one dir/two &&
tree=`git write-tree` &&
git read-tree --reset -u "$tree" &&
Expand All @@ -107,27 +107,27 @@ test_expect_success 'read-tree' '
'

test_expect_success 'no file/rev ambiguity check inside .git' '
cd $HERE &&
cd "$HERE" &&
git commit -a -m 1 &&
cd $HERE/.git &&
cd "$HERE"/.git &&
git show -s HEAD
'

test_expect_success 'no file/rev ambiguity check inside a bare repo' '
cd $HERE &&
cd "$HERE" &&
git clone -s --bare .git foo.git &&
cd foo.git && GIT_DIR=. git show -s HEAD
'

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

test_expect_success 'detection should not be fooled by a symlink' '
cd $HERE &&
cd "$HERE" &&
rm -fr foo.git &&
git clone -s .git another &&
ln -s another yetanother &&
Expand Down
6 changes: 6 additions & 0 deletions t/t1303-wacky-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ test_expect_success 'add key in different section' '
check section2.key bar
'

SECTION="test.q\"s\\sq'sp e.key"
test_expect_success 'make sure git-config escapes section names properly' '
git config "$SECTION" bar &&
check "$SECTION" bar
'

test_done
9 changes: 5 additions & 4 deletions t/t1500-rev-parse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ test_rev_parse 'core.bare undefined' false false true

mkdir work || exit 1
cd work || exit 1
export GIT_DIR=../.git
export GIT_CONFIG="$(pwd)"/../.git/config
GIT_DIR=../.git
GIT_CONFIG="$(pwd)"/../.git/config
export GIT_DIR GIT_CONFIG

git config core.bare false
test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true ''
Expand All @@ -64,8 +65,8 @@ git config --unset core.bare
test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''

mv ../.git ../repo.git || exit 1
export GIT_DIR=../repo.git
export GIT_CONFIG="$(pwd)"/../repo.git/config
GIT_DIR=../repo.git
GIT_CONFIG="$(pwd)"/../repo.git/config

git config core.bare false
test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true ''
Expand Down
34 changes: 18 additions & 16 deletions t/t1501-worktree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,25 @@ mkdir -p work/sub/dir || exit 1
mv .git repo.git || exit 1

say "core.worktree = relative path"
export GIT_DIR=repo.git
export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
GIT_DIR=repo.git
GIT_CONFIG="$(pwd)"/$GIT_DIR/config
export GIT_DIR GIT_CONFIG
unset GIT_WORK_TREE
git config core.worktree ../work
test_rev_parse 'outside' false false false
cd work || exit 1
export GIT_DIR=../repo.git
export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
GIT_DIR=../repo.git
GIT_CONFIG="$(pwd)"/$GIT_DIR/config
test_rev_parse 'inside' false false true ''
cd sub/dir || exit 1
export GIT_DIR=../../../repo.git
export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
GIT_DIR=../../../repo.git
GIT_CONFIG="$(pwd)"/$GIT_DIR/config
test_rev_parse 'subdirectory' false false true sub/dir/
cd ../../.. || exit 1

say "core.worktree = absolute path"
export GIT_DIR=$(pwd)/repo.git
export GIT_CONFIG=$GIT_DIR/config
GIT_DIR=$(pwd)/repo.git
GIT_CONFIG=$GIT_DIR/config
git config core.worktree "$(pwd)/work"
test_rev_parse 'outside' false false false
cd work || exit 1
Expand All @@ -59,25 +60,26 @@ test_rev_parse 'subdirectory' false false true sub/dir/
cd ../../.. || exit 1

say "GIT_WORK_TREE=relative path (override core.worktree)"
export GIT_DIR=$(pwd)/repo.git
export GIT_CONFIG=$GIT_DIR/config
GIT_DIR=$(pwd)/repo.git
GIT_CONFIG=$GIT_DIR/config
git config core.worktree non-existent
export GIT_WORK_TREE=work
GIT_WORK_TREE=work
export GIT_WORK_TREE
test_rev_parse 'outside' false false false
cd work || exit 1
export GIT_WORK_TREE=.
GIT_WORK_TREE=.
test_rev_parse 'inside' false false true ''
cd sub/dir || exit 1
export GIT_WORK_TREE=../..
GIT_WORK_TREE=../..
test_rev_parse 'subdirectory' false false true sub/dir/
cd ../../.. || exit 1

mv work repo.git/work

say "GIT_WORK_TREE=absolute path, work tree below git dir"
export GIT_DIR=$(pwd)/repo.git
export GIT_CONFIG=$GIT_DIR/config
export GIT_WORK_TREE=$(pwd)/repo.git/work
GIT_DIR=$(pwd)/repo.git
GIT_CONFIG=$GIT_DIR/config
GIT_WORK_TREE=$(pwd)/repo.git/work
test_rev_parse 'outside' false false false
cd repo.git || exit 1
test_rev_parse 'in repo.git' false true false
Expand Down
2 changes: 1 addition & 1 deletion t/t3050-subprojects-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test_expect_success setup '
'

test_expect_success clone '
git clone file://`pwd`/.git cloned &&
git clone "file://$(pwd)/.git" cloned &&
(git rev-parse HEAD; git ls-files -s) >expected &&
(
cd cloned &&
Expand Down
3 changes: 2 additions & 1 deletion t/t3400-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ This test runs git rebase and checks that the author information is not lost.
'
. ./test-lib.sh

export GIT_AUTHOR_EMAIL=bogus_email_address
GIT_AUTHOR_EMAIL=bogus_email_address
export GIT_AUTHOR_EMAIL

test_expect_success \
'prepare repository with topic branches' \
Expand Down
3 changes: 1 addition & 2 deletions t/t3404-rebase-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ for line in $FAKE_LINES; do
done
EOF

test_set_editor "$(pwd)/fake-editor.sh"
chmod a+x fake-editor.sh
VISUAL="$(pwd)/fake-editor.sh"
export VISUAL

test_expect_success 'no changes are a nop' '
git rebase -i F &&
Expand Down
33 changes: 21 additions & 12 deletions t/t3407-rebase-abort.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ test_description='git rebase --abort tests'

. ./test-lib.sh

### Test that we handle space characters properly
work_dir="$(pwd)/test dir"

test_expect_success setup '
mkdir -p "$work_dir" &&
cd "$work_dir" &&
git init &&
echo a > a &&
git add a &&
git commit -m a &&
Expand All @@ -28,40 +34,43 @@ testrebase() {
dotest=$2

test_expect_success "rebase$type --abort" '
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase
test_must_fail git rebase'"$type"' master &&
test -d '$dotest' &&
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
test -d "$dotest" &&
git rebase --abort &&
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
test ! -d '$dotest'
test ! -d "$dotest"
'

test_expect_success "rebase$type --abort after --skip" '
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase
test_must_fail git rebase'"$type"' master &&
test -d '$dotest' &&
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
test -d "$dotest" &&
test_must_fail git rebase --skip &&
test $(git rev-parse HEAD) = $(git rev-parse master) &&
git-rebase --abort &&
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
test ! -d '$dotest'
test ! -d "$dotest"
'

test_expect_success "rebase$type --abort after --continue" '
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase
test_must_fail git rebase'"$type"' master &&
test -d '$dotest' &&
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
test -d "$dotest" &&
echo c > a &&
echo d >> a &&
git add a &&
test_must_fail git rebase --continue &&
test $(git rev-parse HEAD) != $(git rev-parse master) &&
git rebase --abort &&
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
test ! -d '$dotest'
test ! -d "$dotest"
'
}

Expand Down
3 changes: 2 additions & 1 deletion t/t3500-cherry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ checks that git cherry only returns the second patch in the local branch
'
. ./test-lib.sh

export GIT_AUTHOR_EMAIL=bogus_email_address
GIT_AUTHOR_EMAIL=bogus_email_address
export GIT_AUTHOR_EMAIL

test_expect_success \
'prepare repository with topic branch, and check cherry finds the 2 patches from there' \
Expand Down
4 changes: 2 additions & 2 deletions t/t5500-fetch-pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ add () {
sec=$(($sec+1))
commit=$(echo "$text" | GIT_AUTHOR_DATE=$sec \
git commit-tree $tree $parents 2>>log2.txt)
export $name=$commit
eval "$name=$commit; export $name"
echo $commit > .git/refs/heads/$branch
eval ${branch}TIP=$commit
}
Expand Down Expand Up @@ -129,7 +129,7 @@ pull_to_client 2nd "B" $((64*3))

pull_to_client 3rd "A" $((1*3)) # old fails

test_expect_success "clone shallow" "git-clone --depth 2 file://`pwd`/. shallow"
test_expect_success "clone shallow" 'git-clone --depth 2 "file://$(pwd)/." shallow'

(cd shallow; git count-objects -v) > count.shallow

Expand Down
2 changes: 1 addition & 1 deletion t/t5512-ls-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test_expect_success setup '
git show-ref -d | sed -e "s/ / /"
) >expected.all &&
git remote add self $(pwd)/.git
git remote add self "$(pwd)/.git"
'

Expand Down
Loading

0 comments on commit 761adeb

Please sign in to comment.