From 003d6ddaf41aa5614ac49693d199d1ad5f21fcbf Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 25 May 2006 19:06:15 -0700 Subject: t3300-funny-names: shell portability fixes echo isn't remotely standardized for handling backslashes, so cat + heredoc seems better Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh index 72a93da..c12270e 100755 --- a/t/t3300-funny-names.sh +++ b/t/t3300-funny-names.sh @@ -40,9 +40,11 @@ test_expect_success 'git-ls-files no-funny' \ t0=`git-write-tree` echo "$t0" >t0 -echo 'just space +cat > expected <<\EOF +just space no-funny -"tabs\t,\" (dq) and spaces"' >expected +"tabs\t,\" (dq) and spaces" +EOF test_expect_success 'git-ls-files with-funny' \ 'git-update-index --add "$p1" && git-ls-files >current && @@ -58,14 +60,18 @@ test_expect_success 'git-ls-files -z with-funny' \ t1=`git-write-tree` echo "$t1" >t1 -echo 'just space +cat > expected <<\EOF +just space no-funny -"tabs\t,\" (dq) and spaces"' >expected +"tabs\t,\" (dq) and spaces" +EOF test_expect_success 'git-ls-tree with funny' \ 'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current && diff -u expected current' -echo 'A "tabs\t,\" (dq) and spaces"' >expected +cat > expected <<\EOF +A "tabs\t,\" (dq) and spaces" +EOF test_expect_success 'git-diff-index with-funny' \ 'git-diff-index --name-status $t0 >current && diff -u expected current' @@ -84,53 +90,62 @@ test_expect_success 'git-diff-tree -z with-funny' \ 'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current && diff -u expected current' -echo 'CNUM no-funny "tabs\t,\" (dq) and spaces"' >expected +cat > expected <<\EOF +CNUM no-funny "tabs\t,\" (dq) and spaces" +EOF test_expect_success 'git-diff-tree -C with-funny' \ 'git-diff-tree -C --find-copies-harder --name-status \ $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current && diff -u expected current' -echo 'RNUM no-funny "tabs\t,\" (dq) and spaces"' >expected +cat > expected <<\EOF +RNUM no-funny "tabs\t,\" (dq) and spaces" +EOF test_expect_success 'git-diff-tree delete with-funny' \ 'git-update-index --force-remove "$p0" && git-diff-index -M --name-status \ $t0 | sed -e 's/^R[0-9]*/RNUM/' >current && diff -u expected current' -echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" +cat > expected <<\EOF +diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" similarity index NUM% rename from no-funny -rename to "tabs\t,\" (dq) and spaces"' >expected - +rename to "tabs\t,\" (dq) and spaces" +EOF test_expect_success 'git-diff-tree delete with-funny' \ 'git-diff-index -M -p $t0 | sed -e "s/index [0-9]*%/index NUM%/" >current && diff -u expected current' chmod +x "$p1" -echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" +cat > expected <<\EOF +diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" old mode 100644 new mode 100755 similarity index NUM% rename from no-funny -rename to "tabs\t,\" (dq) and spaces"' >expected - +rename to "tabs\t,\" (dq) and spaces" +EOF test_expect_success 'git-diff-tree delete with-funny' \ 'git-diff-index -M -p $t0 | sed -e "s/index [0-9]*%/index NUM%/" >current && diff -u expected current' -echo >expected ' "tabs\t,\" (dq) and spaces" - 1 files changed, 0 insertions(+), 0 deletions(-)' +cat >expected <<\EOF + "tabs\t,\" (dq) and spaces" + 1 files changed, 0 insertions(+), 0 deletions(-) +EOF test_expect_success 'git-diff-tree rename with-funny applied' \ 'git-diff-index -M -p $t0 | git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && diff -u expected current' -echo >expected ' no-funny +cat > expected <<\EOF + no-funny "tabs\t,\" (dq) and spaces" - 2 files changed, 3 insertions(+), 3 deletions(-)' - + 2 files changed, 3 insertions(+), 3 deletions(-) +EOF test_expect_success 'git-diff-tree delete with-funny applied' \ 'git-diff-index -p $t0 | git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && -- cgit v0.10.2-6-g49f6 From c7053aa88f80e4983ec45fd39a44d146197c21d0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 25 May 2006 19:06:16 -0700 Subject: tests: Remove heredoc usage inside quotes The use of heredoc inside quoted strings doesn't seem to be supported by dash. pdksh seems to handle it fine, however. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano diff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh index 77aed8d..a78ea7f 100755 --- a/t/t2101-update-index-reupdate.sh +++ b/t/t2101-update-index-reupdate.sh @@ -8,15 +8,16 @@ test_description='git-update-index --again test. . ./test-lib.sh +cat > expected <<\EOF +100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1 +100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2 +EOF test_expect_success 'update-index --add' \ 'echo hello world >file1 && echo goodbye people >file2 && git-update-index --add file1 file2 && git-ls-files -s >current && - cmp current - <<\EOF -100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1 -100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2 -EOF' + cmp current expected' test_expect_success 'update-index --again' \ 'rm -f file1 && @@ -29,20 +30,22 @@ test_expect_success 'update-index --again' \ echo happy - failed as expected fi && git-ls-files -s >current && - cmp current - <<\EOF -100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1 -100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2 -EOF' + cmp current expected' +cat > expected <<\EOF +100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 +EOF test_expect_success 'update-index --remove --again' \ 'git-update-index --remove --again && git-ls-files -s >current && - cmp current - <<\EOF -100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 -EOF' + cmp current expected' test_expect_success 'first commit' 'git-commit -m initial' +cat > expected <<\EOF +100644 53ab446c3f4e42ce9bb728a0ccb283a101be4979 0 dir1/file3 +100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 +EOF test_expect_success 'update-index again' \ 'mkdir -p dir1 && echo hello world >dir1/file3 && @@ -52,11 +55,12 @@ test_expect_success 'update-index again' \ echo happy >dir1/file3 && git-update-index --again && git-ls-files -s >current && - cmp current - <<\EOF -100644 53ab446c3f4e42ce9bb728a0ccb283a101be4979 0 dir1/file3 -100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 -EOF' + cmp current expected' +cat > expected <<\EOF +100644 d7fb3f695f06c759dbf3ab00046e7cc2da22d10f 0 dir1/file3 +100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 +EOF test_expect_success 'update-index --update from subdir' \ 'echo not so happy >file2 && cd dir1 && @@ -64,19 +68,17 @@ test_expect_success 'update-index --update from subdir' \ git-update-index --again && cd .. && git-ls-files -s >current && - cmp current - <<\EOF -100644 d7fb3f695f06c759dbf3ab00046e7cc2da22d10f 0 dir1/file3 -100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 -EOF' + cmp current expected' +cat > expected <<\EOF +100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3 +100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 +EOF test_expect_success 'update-index --update with pathspec' \ 'echo very happy >file2 && cat file2 >dir1/file3 && git-update-index --again dir1/ && git-ls-files -s >current && - cmp current - <<\EOF -100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3 -100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 -EOF' + cmp current expected' test_done diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh index bdd95c0..323606c 100755 --- a/t/t4012-diff-binary.sh +++ b/t/t4012-diff-binary.sh @@ -16,25 +16,20 @@ test_expect_success 'prepare repository' \ echo git >c && cat b b >d' -test_expect_success 'diff without --binary' \ - 'git-diff | git-apply --stat --summary >current && - cmp current - <<\EOF +cat > expected <<\EOF a | 2 +- b | Bin c | 2 +- d | Bin 4 files changed, 2 insertions(+), 2 deletions(-) -EOF' +EOF +test_expect_success 'diff without --binary' \ + 'git-diff | git-apply --stat --summary >current && + cmp current expected' test_expect_success 'diff with --binary' \ 'git-diff --binary | git-apply --stat --summary >current && - cmp current - <<\EOF - a | 2 +- - b | Bin - c | 2 +- - d | Bin - 4 files changed, 2 insertions(+), 2 deletions(-) -EOF' + cmp current expected' # apply needs to be able to skip the binary material correctly # in order to report the line number of a corrupt patch. -- cgit v0.10.2-6-g49f6 From 1010437d515a2740b7c0f3eeecf6af804062a9ff Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 25 May 2006 19:06:17 -0700 Subject: t5500-fetch-pack: remove local (bashism) usage. None of the variables seem to conflict, so local was unnecessary. Also replaced ${var:pos:len} with the sed equivalent. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 92f12d9..f7625a6 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -12,11 +12,11 @@ test_description='Testing multi_ack pack fetching # Some convenience functions -function add () { - local name=$1 - local text="$@" - local branch=${name:0:1} - local parents="" +add () { + name=$1 + text="$@" + branch=`echo $name | sed -e 's/^\(.\).*$/\1/'` + parents="" shift while test $1; do @@ -36,13 +36,13 @@ function add () { eval ${branch}TIP=$commit } -function count_objects () { +count_objects () { ls .git/objects/??/* 2>>log2.txt | wc -l | tr -d " " } -function test_expect_object_count () { - local message=$1 - local count=$2 +test_expect_object_count () { + message=$1 + count=$2 output="$(count_objects)" test_expect_success \ @@ -50,18 +50,18 @@ function test_expect_object_count () { "test $count = $output" } -function pull_to_client () { - local number=$1 - local heads=$2 - local count=$3 - local no_strict_count_check=$4 +pull_to_client () { + number=$1 + heads=$2 + count=$3 + no_strict_count_check=$4 cd client test_expect_success "$number pull" \ "git-fetch-pack -k -v .. $heads" case "$heads" in *A*) echo $ATIP > .git/refs/heads/A;; esac case "$heads" in *B*) echo $BTIP > .git/refs/heads/B;; esac - git-symbolic-ref HEAD refs/heads/${heads:0:1} + git-symbolic-ref HEAD refs/heads/`echo $heads | sed -e 's/^\(.\).*$/\1/'` test_expect_success "fsck" 'git-fsck-objects --full > fsck.txt 2>&1' -- cgit v0.10.2-6-g49f6 From 933e4f090dd39d44279f155f7a7347ff34964d2d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 25 May 2006 19:06:18 -0700 Subject: t6000lib: workaround a possible dash bug pdksh doesn't need this patch, of course bash works fine since that what most users use. Normally, 'var=val command' seems to work fine with dash, but perhaps there's something weird going on with "$@". dash is pretty widespread, so it'll be good to support this even though it does seem like a bug in dash. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano diff --git a/t/t6000lib.sh b/t/t6000lib.sh index c6752af..d402621 100755 --- a/t/t6000lib.sh +++ b/t/t6000lib.sh @@ -69,7 +69,9 @@ on_committer_date() { _date=$1 shift 1 - GIT_COMMITTER_DATE=$_date "$@" + export GIT_COMMITTER_DATE="$_date" + "$@" + unset GIT_COMMITTER_DATE } # Execute a command and suppress any error output. -- cgit v0.10.2-6-g49f6