diff options
Diffstat (limited to 't')
152 files changed, 6493 insertions, 1679 deletions
diff --git a/t/Makefile b/t/Makefile index 19e38508a7..72d7884232 100644 --- a/t/Makefile +++ b/t/Makefile @@ -6,6 +6,7 @@ #GIT_TEST_OPTS=--verbose --debug SHELL_PATH ?= $(SHELL) TAR ?= $(TAR) +RM ?= rm -f # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) @@ -19,7 +20,7 @@ $(T): @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS) clean: - rm -fr trash + $(RM) -r trash # we can test NO_OPTIMIZE_COMMITS independently of LC_ALL full-svn-test: @@ -28,4 +29,3 @@ full-svn-test: .PHONY: $(T) clean .NOTPARALLEL: - diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index f6fe78cd27..8d4a447213 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -48,3 +48,37 @@ svnrepo="file://$svnrepo" poke() { test-chmtime +1 "$1" } + +SVN_HTTPD_MODULE_PATH=${SVN_HTTPD_MODULE_PATH-'/usr/lib/apache2/modules'} +SVN_HTTPD_PATH=${SVN_HTTPD_PATH-'/usr/sbin/apache2'} + +start_httpd () { + if test -z "$SVN_HTTPD_PORT" + then + echo >&2 'SVN_HTTPD_PORT is not defined!' + return + fi + + mkdir "$GIT_DIR"/logs + + cat > "$GIT_DIR/httpd.conf" <<EOF +ServerName "git-svn test" +ServerRoot "$GIT_DIR" +DocumentRoot "$GIT_DIR" +PidFile "$GIT_DIR/httpd.pid" +Listen 127.0.0.1:$SVN_HTTPD_PORT +LoadModule dav_module $SVN_HTTPD_MODULE_PATH/mod_dav.so +LoadModule dav_svn_module $SVN_HTTPD_MODULE_PATH/mod_dav_svn.so +<Location /svn> + DAV svn + SVNPath $rawsvnrepo +</Location> +EOF + "$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k start + svnrepo=http://127.0.0.1:$SVN_HTTPD_PORT/svn +} + +stop_httpd () { + test -z "$SVN_HTTPD_PORT" && return + "$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k stop +} diff --git a/t/lib-read-tree-m-3way.sh b/t/lib-read-tree-m-3way.sh index d195603dfa..168329adbc 100644 --- a/t/lib-read-tree-m-3way.sh +++ b/t/lib-read-tree-m-3way.sh @@ -10,14 +10,14 @@ do echo This is Z/$p from the original tree. >Z/$p test_expect_success \ "adding test file $p and Z/$p" \ - 'git-update-index --add $p && - git-update-index --add Z/$p' + 'git update-index --add $p && + git update-index --add Z/$p' done done echo This is SS from the original tree. >SS test_expect_success \ 'adding test file SS' \ - 'git-update-index --add SS' + 'git update-index --add SS' cat >TT <<\EOF This is a trivial merge sample text. Branch A is expected to upcase this word, here. @@ -32,10 +32,10 @@ This concludes the trivial merge sample file. EOF test_expect_success \ 'adding test file TT' \ - 'git-update-index --add TT' + 'git update-index --add TT' test_expect_success \ 'prepare initial tree' \ - 'tree_O=$(git-write-tree)' + 'tree_O=$(git write-tree)' ################################################################ # Branch A and B makes the changes according to the above matrix. @@ -47,14 +47,14 @@ to_remove=$(echo D? Z/D?) rm -f $to_remove test_expect_success \ 'change in branch A (removal)' \ - 'git-update-index --remove $to_remove' + 'git update-index --remove $to_remove' for p in M? Z/M? do echo This is modified $p in the branch A. >$p test_expect_success \ 'change in branch A (modification)' \ - "git-update-index $p" + "git update-index $p" done for p in AN AA Z/AN Z/AA @@ -62,32 +62,32 @@ do echo This is added $p in the branch A. >$p test_expect_success \ 'change in branch A (addition)' \ - "git-update-index --add $p" + "git update-index --add $p" done echo This is SS from the modified tree. >SS echo This is LL from the modified tree. >LL test_expect_success \ 'change in branch A (addition)' \ - 'git-update-index --add LL && - git-update-index SS' + 'git update-index --add LL && + git update-index SS' mv TT TT- sed -e '/Branch A/s/word/WORD/g' <TT- >TT rm -f TT- test_expect_success \ 'change in branch A (edit)' \ - 'git-update-index TT' + 'git update-index TT' mkdir DF echo Branch A makes a file at DF/DF, creating a directory DF. >DF/DF test_expect_success \ 'change in branch A (change file to directory)' \ - 'git-update-index --add DF/DF' + 'git update-index --add DF/DF' test_expect_success \ 'recording branch A tree' \ - 'tree_A=$(git-write-tree)' - + 'tree_A=$(git write-tree)' + ################################################################ # Branch B # Start from O @@ -96,21 +96,21 @@ rm -rf [NDMASLT][NDMASLT] Z DF mkdir Z test_expect_success \ 'reading original tree and checking out' \ - 'git-read-tree $tree_O && - git-checkout-index -a' + 'git read-tree $tree_O && + git checkout-index -a' to_remove=$(echo ?D Z/?D) rm -f $to_remove test_expect_success \ 'change in branch B (removal)' \ - "git-update-index --remove $to_remove" + "git update-index --remove $to_remove" for p in ?M Z/?M do echo This is modified $p in the branch B. >$p test_expect_success \ 'change in branch B (modification)' \ - "git-update-index $p" + "git update-index $p" done for p in NA AA Z/NA Z/AA @@ -118,41 +118,41 @@ do echo This is added $p in the branch B. >$p test_expect_success \ 'change in branch B (addition)' \ - "git-update-index --add $p" + "git update-index --add $p" done echo This is SS from the modified tree. >SS echo This is LL from the modified tree. >LL test_expect_success \ 'change in branch B (addition and modification)' \ - 'git-update-index --add LL && - git-update-index SS' + 'git update-index --add LL && + git update-index SS' mv TT TT- sed -e '/Branch B/s/word/WORD/g' <TT- >TT rm -f TT- test_expect_success \ 'change in branch B (modification)' \ - 'git-update-index TT' + 'git update-index TT' echo Branch B makes a file at DF. >DF test_expect_success \ 'change in branch B (addition of a file to conflict with directory)' \ - 'git-update-index --add DF' + 'git update-index --add DF' test_expect_success \ 'recording branch B tree' \ - 'tree_B=$(git-write-tree)' + 'tree_B=$(git write-tree)' test_expect_success \ 'keep contents of 3 trees for easy access' \ 'rm -f .git/index && - git-read-tree $tree_O && + git read-tree $tree_O && mkdir .orig-O && - git-checkout-index --prefix=.orig-O/ -f -q -a && + git checkout-index --prefix=.orig-O/ -f -q -a && rm -f .git/index && - git-read-tree $tree_A && + git read-tree $tree_A && mkdir .orig-A && - git-checkout-index --prefix=.orig-A/ -f -q -a && + git checkout-index --prefix=.orig-A/ -f -q -a && rm -f .git/index && - git-read-tree $tree_B && + git read-tree $tree_B && mkdir .orig-B && - git-checkout-index --prefix=.orig-B/ -f -q -a' + git checkout-index --prefix=.orig-B/ -f -q -a' diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 186de70243..4e49d59065 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -31,13 +31,13 @@ fi . ./test-lib.sh ################################################################ -# git-init has been done in an empty repository. +# git init has been done in an empty repository. # make sure it is empty. find .git/objects -type f -print >should-be-empty test_expect_success \ - '.git/objects should be empty after git-init in an empty repo.' \ - 'cmp -s /dev/null should-be-empty' + '.git/objects should be empty after git init in an empty repo.' \ + 'cmp -s /dev/null should-be-empty' # also it should have 2 subdirectories; no fan-out anymore, pack, and info. # 3 is counting "objects" itself @@ -51,17 +51,17 @@ test_expect_success \ # updating a new file without --add should fail. test_expect_failure \ - 'git-update-index without --add should fail adding.' \ - 'git-update-index should-be-empty' + 'git update-index without --add should fail adding.' \ + 'git update-index should-be-empty' # and with --add it should succeed, even if it is empty (it used to fail). test_expect_success \ - 'git-update-index with --add should succeed.' \ - 'git-update-index --add should-be-empty' + 'git update-index with --add should succeed.' \ + 'git update-index --add should-be-empty' test_expect_success \ - 'writing tree out with git-write-tree' \ - 'tree=$(git-write-tree)' + 'writing tree out with git write-tree' \ + 'tree=$(git write-tree)' # we know the shape and contents of the tree and know the object ID for it. test_expect_success \ @@ -71,17 +71,17 @@ test_expect_success \ # Removing paths. rm -f should-be-empty full-of-directories test_expect_failure \ - 'git-update-index without --remove should fail removing.' \ - 'git-update-index should-be-empty' + 'git update-index without --remove should fail removing.' \ + 'git update-index should-be-empty' test_expect_success \ - 'git-update-index with --remove should be able to remove.' \ - 'git-update-index --remove should-be-empty' + 'git update-index with --remove should be able to remove.' \ + 'git update-index --remove should-be-empty' # Empty tree can be written with recent write-tree. test_expect_success \ - 'git-write-tree should be able to write an empty tree.' \ - 'tree=$(git-write-tree)' + 'git write-tree should be able to write an empty tree.' \ + 'tree=$(git write-tree)' test_expect_success \ 'validate object ID of a known tree.' \ @@ -95,13 +95,13 @@ do ln -s "hello $p" ${p}sym done test_expect_success \ - 'adding various types of objects with git-update-index --add.' \ - 'find path* ! -type d -print | xargs git-update-index --add' + 'adding various types of objects with git update-index --add.' \ + 'find path* ! -type d -print | xargs git update-index --add' # Show them and see that matches what we expect. test_expect_success \ - 'showing stage with git-ls-files --stage' \ - 'git-ls-files --stage >current' + 'showing stage with git ls-files --stage' \ + 'git ls-files --stage >current' cat >expected <<\EOF 100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0 @@ -114,19 +114,19 @@ cat >expected <<\EOF 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0 path3/subp3/file3sym EOF test_expect_success \ - 'validate git-ls-files output for a known tree.' \ + 'validate git ls-files output for a known tree.' \ 'diff current expected' test_expect_success \ - 'writing tree out with git-write-tree.' \ - 'tree=$(git-write-tree)' + 'writing tree out with git write-tree.' \ + 'tree=$(git write-tree)' test_expect_success \ 'validate object ID for a known tree.' \ 'test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b' test_expect_success \ - 'showing tree with git-ls-tree' \ - 'git-ls-tree $tree >current' + 'showing tree with git ls-tree' \ + 'git ls-tree $tree >current' cat >expected <<\EOF 100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0 120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym @@ -134,14 +134,14 @@ cat >expected <<\EOF 040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3 EOF test_expect_success \ - 'git-ls-tree output for a known tree.' \ + 'git ls-tree output for a known tree.' \ 'diff current expected' # This changed in ls-tree pathspec change -- recursive does # not show tree nodes anymore. test_expect_success \ - 'showing tree with git-ls-tree -r' \ - 'git-ls-tree -r $tree >current' + 'showing tree with git ls-tree -r' \ + 'git ls-tree -r $tree >current' cat >expected <<\EOF 100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0 120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym @@ -153,13 +153,13 @@ cat >expected <<\EOF 120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym EOF test_expect_success \ - 'git-ls-tree -r output for a known tree.' \ + 'git ls-tree -r output for a known tree.' \ 'diff current expected' # But with -r -t we can have both. test_expect_success \ - 'showing tree with git-ls-tree -r -t' \ - 'git-ls-tree -r -t $tree >current' + 'showing tree with git ls-tree -r -t' \ + 'git ls-tree -r -t $tree >current' cat >expected <<\EOF 100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0 120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym @@ -174,19 +174,19 @@ cat >expected <<\EOF 120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym EOF test_expect_success \ - 'git-ls-tree -r output for a known tree.' \ + 'git ls-tree -r output for a known tree.' \ 'diff current expected' test_expect_success \ - 'writing partial tree out with git-write-tree --prefix.' \ - 'ptree=$(git-write-tree --prefix=path3)' + 'writing partial tree out with git write-tree --prefix.' \ + 'ptree=$(git write-tree --prefix=path3)' test_expect_success \ 'validate object ID for a known tree.' \ 'test "$ptree" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3' test_expect_success \ - 'writing partial tree out with git-write-tree --prefix.' \ - 'ptree=$(git-write-tree --prefix=path3/subp3)' + 'writing partial tree out with git write-tree --prefix.' \ + 'ptree=$(git write-tree --prefix=path3/subp3)' test_expect_success \ 'validate object ID for a known tree.' \ 'test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2' @@ -202,24 +202,24 @@ EOF rm .git/index test_expect_success \ 'put invalid objects into the index.' \ - 'git-update-index --index-info < badobjects' + 'git update-index --index-info < badobjects' test_expect_failure \ 'writing this tree without --missing-ok.' \ - 'git-write-tree' + 'git write-tree' test_expect_success \ 'writing this tree with --missing-ok.' \ - 'git-write-tree --missing-ok' + 'git write-tree --missing-ok' ################################################################ rm .git/index test_expect_success \ - 'git-read-tree followed by write-tree should be idempotent.' \ - 'git-read-tree $tree && + 'git read-tree followed by write-tree should be idempotent.' \ + 'git read-tree $tree && test -f .git/index && - newtree=$(git-write-tree) && + newtree=$(git write-tree) && test "$newtree" = "$tree"' cat >expected <<\EOF @@ -233,36 +233,36 @@ cat >expected <<\EOF :120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M path3/subp3/file3sym EOF test_expect_success \ - 'validate git-diff-files output for a know cache/work tree state.' \ - 'git-diff-files >current && diff >/dev/null -b current expected' + 'validate git diff-files output for a know cache/work tree state.' \ + 'git diff-files >current && diff >/dev/null -b current expected' test_expect_success \ - 'git-update-index --refresh should succeed.' \ - 'git-update-index --refresh' + 'git update-index --refresh should succeed.' \ + 'git update-index --refresh' test_expect_success \ - 'no diff after checkout and git-update-index --refresh.' \ - 'git-diff-files >current && cmp -s current /dev/null' + 'no diff after checkout and git update-index --refresh.' \ + 'git diff-files >current && cmp -s current /dev/null' ################################################################ P=087704a96baf1c2d1c869a8b084481e121c88b5b test_expect_success \ - 'git-commit-tree records the correct tree in a commit.' \ - 'commit0=$(echo NO | git-commit-tree $P) && + 'git commit-tree records the correct tree in a commit.' \ + 'commit0=$(echo NO | git commit-tree $P) && tree=$(git show --pretty=raw $commit0 | sed -n -e "s/^tree //p" -e "/^author /q") && test "z$tree" = "z$P"' test_expect_success \ - 'git-commit-tree records the correct parent in a commit.' \ - 'commit1=$(echo NO | git-commit-tree $P -p $commit0) && + 'git commit-tree records the correct parent in a commit.' \ + 'commit1=$(echo NO | git commit-tree $P -p $commit0) && parent=$(git show --pretty=raw $commit1 | sed -n -e "s/^parent //p" -e "/^author /q") && test "z$commit0" = "z$parent"' test_expect_success \ - 'git-commit-tree omits duplicated parent in a commit.' \ - 'commit2=$(echo NO | git-commit-tree $P -p $commit0 -p $commit0) && + 'git commit-tree omits duplicated parent in a commit.' \ + 'commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) && parent=$(git show --pretty=raw $commit2 | sed -n -e "s/^parent //p" -e "/^author /q" | sort -u) && @@ -281,4 +281,20 @@ test_expect_success 'update-index D/F conflict' ' test $numpath0 = 1 ' +test_expect_success 'absolute path works as expected' ' + mkdir first && + ln -s ../.git first/.git && + mkdir second && + ln -s ../first second/other && + mkdir third && + dir="$(cd .git; pwd -P)" && + dir2=third/../second/other/.git && + test "$dir" = "$(test-absolute-path $dir2)" && + file="$dir"/index && + test "$file" = "$(test-absolute-path $dir2/index)" && + ln -s ../first/file .git/syml && + sym="$(cd first; pwd -P)"/file && + test "$sym" = "$(test-absolute-path $dir2/syml)" +' + test_done diff --git a/t/t0022-crlf-rename.sh b/t/t0022-crlf-rename.sh new file mode 100755 index 0000000000..430a1d1d38 --- /dev/null +++ b/t/t0022-crlf-rename.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +test_description='ignore CR in CRLF sequence while computing similiarity' + +. ./test-lib.sh + +test_expect_success setup ' + + cat ../t0022-crlf-rename.sh >sample && + git add sample && + + test_tick && + git commit -m Initial && + + sed -e "s/\$/
/" ../t0022-crlf-rename.sh >elpmas && + git add elpmas && + rm -f sample && + + test_tick && + git commit -a -m Second + +' + +test_expect_success 'diff -M' ' + + git diff-tree -M -r --name-status HEAD^ HEAD | + sed -e "s/R[0-9]*/RNUM/" >actual && + echo "RNUM sample elpmas" >expect && + diff -u expect actual + +' + +test_done diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh new file mode 100755 index 0000000000..b1c900379b --- /dev/null +++ b/t/t0030-stripspace.sh @@ -0,0 +1,395 @@ +#!/bin/sh +# +# Copyright (c) 2007 Carlos Rica +# + +test_description='git stripspace' + +. ./test-lib.sh + +t40='A quick brown fox jumps over the lazy do' +s40=' ' +sss="$s40$s40$s40$s40$s40$s40$s40$s40$s40$s40" # 400 +ttt="$t40$t40$t40$t40$t40$t40$t40$t40$t40$t40" # 400 + +test_expect_success \ + 'long lines without spaces should be unchanged' ' + echo "$ttt" >expect && + git stripspace <expect >actual && + git diff expect actual && + + echo "$ttt$ttt" >expect && + git stripspace <expect >actual && + git diff expect actual && + + echo "$ttt$ttt$ttt" >expect && + git stripspace <expect >actual && + git diff expect actual && + + echo "$ttt$ttt$ttt$ttt" >expect && + git stripspace <expect >actual && + git diff expect actual +' + +test_expect_success \ + 'lines with spaces at the beginning should be unchanged' ' + echo "$sss$ttt" >expect && + git stripspace <expect >actual && + git diff expect actual && + + echo "$sss$sss$ttt" >expect && + git stripspace <expect >actual && + git diff expect actual && + + echo "$sss$sss$sss$ttt" >expect && + git stripspace <expect >actual && + git diff expect actual +' + +test_expect_success \ + 'lines with intermediate spaces should be unchanged' ' + echo "$ttt$sss$ttt" >expect && + git stripspace <expect >actual && + git diff expect actual && + + echo "$ttt$sss$sss$ttt" >expect && + git stripspace <expect >actual && + git diff expect actual +' + +test_expect_success \ + 'consecutive blank lines should be unified' ' + printf "$ttt\n\n$ttt\n" > expect && + printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt\n\n$ttt\n" > expect && + printf "$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt$ttt\n\n$ttt\n" > expect && + printf "$ttt$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n\n$ttt\n" > expect && + printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n\n$ttt$ttt\n" > expect && + printf "$ttt\n\n\n\n\n$ttt$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n\n$ttt$ttt$ttt\n" > expect && + printf "$ttt\n\n\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n\n$ttt\n" > expect && + printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt\n\n$ttt\n" > expect && + printf "$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt$ttt\n\n$ttt\n" > expect && + printf "$ttt$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n\n$ttt\n" > expect && + printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n\n$ttt$ttt\n" > expect && + printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n\n$ttt$ttt$ttt\n" > expect && + printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt$ttt\n" | git stripspace >actual && + git diff expect actual +' + +test_expect_success \ + 'only consecutive blank lines should be completely removed' ' + > expect && + + printf "\n" | git stripspace >actual && + git diff expect actual && + + printf "\n\n\n" | git stripspace >actual && + git diff expect actual && + + printf "$sss\n$sss\n$sss\n" | git stripspace >actual && + git diff expect actual && + + printf "$sss$sss\n$sss\n\n" | git stripspace >actual && + git diff expect actual && + + printf "\n$sss\n$sss$sss\n" | git stripspace >actual && + git diff expect actual && + + printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual && + git diff expect actual && + + printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual && + git diff expect actual && + + printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual && + git diff expect actual +' + +test_expect_success \ + 'consecutive blank lines at the beginning should be removed' ' + printf "$ttt\n" > expect && + printf "\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n" > expect && + printf "\n\n\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt\n" > expect && + printf "\n\n\n$ttt$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt$ttt\n" > expect && + printf "\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt$ttt$ttt\n" > expect && + printf "\n\n\n$ttt$ttt$ttt$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n" > expect && + + printf "$sss\n$sss\n$sss\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "\n$sss\n$sss$sss\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$sss$sss\n$sss\n\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$sss$sss$sss\n\n\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "\n$sss$sss$sss\n\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "\n\n$sss$sss$sss\n$ttt\n" | git stripspace >actual && + git diff expect actual +' + +test_expect_success \ + 'consecutive blank lines at the end should be removed' ' + printf "$ttt\n" > expect && + printf "$ttt\n\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n" > expect && + printf "$ttt\n\n\n\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt\n" > expect && + printf "$ttt$ttt\n\n\n\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt$ttt\n" > expect && + printf "$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt$ttt$ttt\n" > expect && + printf "$ttt$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n" > expect && + + printf "$ttt\n$sss\n$sss\n$sss\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n\n$sss\n$sss$sss\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n$sss$sss\n$sss\n\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n$sss$sss$sss\n\n\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n\n$sss$sss$sss\n\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n\n\n$sss$sss$sss\n" | git stripspace >actual && + git diff expect actual +' + +test_expect_success \ + 'text without newline at end should end with newline' ' + test `printf "$ttt" | git stripspace | wc -l` -gt 0 && + test `printf "$ttt$ttt" | git stripspace | wc -l` -gt 0 && + test `printf "$ttt$ttt$ttt" | git stripspace | wc -l` -gt 0 && + test `printf "$ttt$ttt$ttt$ttt" | git stripspace | wc -l` -gt 0 +' + +# text plus spaces at the end: + +test_expect_success \ + 'text plus spaces without newline at end should end with newline' ' + test `printf "$ttt$sss" | git stripspace | wc -l` -gt 0 && + test `printf "$ttt$ttt$sss" | git stripspace | wc -l` -gt 0 && + test `printf "$ttt$ttt$ttt$sss" | git stripspace | wc -l` -gt 0 && + test `printf "$ttt$sss$sss" | git stripspace | wc -l` -gt 0 && + test `printf "$ttt$ttt$sss$sss" | git stripspace | wc -l` -gt 0 && + test `printf "$ttt$sss$sss$sss" | git stripspace | wc -l` -gt 0 +' + +test_expect_failure \ + 'text plus spaces without newline at end should not show spaces' ' + printf "$ttt$sss" | git stripspace | grep -q " " || + printf "$ttt$ttt$sss" | git stripspace | grep -q " " || + printf "$ttt$ttt$ttt$sss" | git stripspace | grep -q " " || + printf "$ttt$sss$sss" | git stripspace | grep -q " " || + printf "$ttt$ttt$sss$sss" | git stripspace | grep -q " " || + printf "$ttt$sss$sss$sss" | git stripspace | grep -q " " +' + +test_expect_success \ + 'text plus spaces without newline should show the correct lines' ' + printf "$ttt\n" >expect && + printf "$ttt$sss" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n" >expect && + printf "$ttt$sss$sss" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n" >expect && + printf "$ttt$sss$sss$sss" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt\n" >expect && + printf "$ttt$ttt$sss" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt\n" >expect && + printf "$ttt$ttt$sss$sss" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt$ttt\n" >expect && + printf "$ttt$ttt$ttt$sss" | git stripspace >actual && + git diff expect actual +' + +test_expect_failure \ + 'text plus spaces at end should not show spaces' ' + echo "$ttt$sss" | git stripspace | grep -q " " || + echo "$ttt$ttt$sss" | git stripspace | grep -q " " || + echo "$ttt$ttt$ttt$sss" | git stripspace | grep -q " " || + echo "$ttt$sss$sss" | git stripspace | grep -q " " || + echo "$ttt$ttt$sss$sss" | git stripspace | grep -q " " || + echo "$ttt$sss$sss$sss" | git stripspace | grep -q " " +' + +test_expect_success \ + 'text plus spaces at end should be cleaned and newline must remain' ' + echo "$ttt" >expect && + echo "$ttt$sss" | git stripspace >actual && + git diff expect actual && + + echo "$ttt" >expect && + echo "$ttt$sss$sss" | git stripspace >actual && + git diff expect actual && + + echo "$ttt" >expect && + echo "$ttt$sss$sss$sss" | git stripspace >actual && + git diff expect actual && + + echo "$ttt$ttt" >expect && + echo "$ttt$ttt$sss" | git stripspace >actual && + git diff expect actual && + + echo "$ttt$ttt" >expect && + echo "$ttt$ttt$sss$sss" | git stripspace >actual && + git diff expect actual && + + echo "$ttt$ttt$ttt" >expect && + echo "$ttt$ttt$ttt$sss" | git stripspace >actual && + git diff expect actual +' + +# spaces only: + +test_expect_success \ + 'spaces with newline at end should be replaced with empty string' ' + printf "" >expect && + + echo | git stripspace >actual && + git diff expect actual && + + echo "$sss" | git stripspace >actual && + git diff expect actual && + + echo "$sss$sss" | git stripspace >actual && + git diff expect actual && + + echo "$sss$sss$sss" | git stripspace >actual && + git diff expect actual && + + echo "$sss$sss$sss$sss" | git stripspace >actual && + git diff expect actual +' + +test_expect_failure \ + 'spaces without newline at end should not show spaces' ' + printf "" | git stripspace | grep -q " " || + printf "$sss" | git stripspace | grep -q " " || + printf "$sss$sss" | git stripspace | grep -q " " || + printf "$sss$sss$sss" | git stripspace | grep -q " " || + printf "$sss$sss$sss$sss" | git stripspace | grep -q " " +' + +test_expect_success \ + 'spaces without newline at end should be replaced with empty string' ' + printf "" >expect && + + printf "" | git stripspace >actual && + git diff expect actual && + + printf "$sss$sss" | git stripspace >actual && + git diff expect actual && + + printf "$sss$sss$sss" | git stripspace >actual && + git diff expect actual && + + printf "$sss$sss$sss$sss" | git stripspace >actual && + git diff expect actual +' + +test_expect_success \ + 'consecutive text lines should be unchanged' ' + printf "$ttt$ttt\n$ttt\n" >expect && + printf "$ttt$ttt\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n$ttt$ttt\n$ttt\n" >expect && + printf "$ttt\n$ttt$ttt\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" >expect && + printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" >expect && + printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" >expect && + printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" | git stripspace >actual && + git diff expect actual && + + printf "$ttt\n$ttt$ttt\n\n$ttt\n" >expect && + printf "$ttt\n$ttt$ttt\n\n$ttt\n" | git stripspace >actual && + git diff expect actual +' + +test_done diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh index de4e5eb61f..37add1b504 100755 --- a/t/t1000-read-tree-m-3way.sh +++ b/t/t1000-read-tree-m-3way.sh @@ -130,28 +130,28 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" check_result () { - git-ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current && + git ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current && git diff expected current } # This is done on an empty work directory, which is the normal # merge person behaviour. test_expect_success \ - '3-way merge with git-read-tree -m, empty cache' \ + '3-way merge with git read-tree -m, empty cache' \ "rm -fr [NDMALTS][NDMALTSF] Z && rm .git/index && - git-read-tree -m $tree_O $tree_A $tree_B && + git read-tree -m $tree_O $tree_A $tree_B && check_result" # This starts out with the first head, which is the normal # patch submitter behaviour. test_expect_success \ - '3-way merge with git-read-tree -m, match H' \ + '3-way merge with git read-tree -m, match H' \ "rm -fr [NDMALTS][NDMALTSF] Z && rm .git/index && - git-read-tree $tree_A && - git-checkout-index -f -u -a && - git-read-tree -m $tree_O $tree_A $tree_B && + git read-tree $tree_A && + git checkout-index -f -u -a && + git read-tree -m $tree_O $tree_A $tree_B && check_result" : <<\END_OF_CASE_TABLE @@ -160,7 +160,7 @@ We have so far tested only empty index and clean-and-matching-A index case which are trivial. Make sure index requirements are also checked. -"git-read-tree -m O A B" +"git read-tree -m O A B" O A B result index requirements ------------------------------------------------------------------- @@ -214,87 +214,87 @@ test_expect_failure \ '1 - must not have an entry not in A.' \ "rm -f .git/index XX && echo XX >XX && - git-update-index --add XX && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add XX && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '2 - must match B in !O && !A && B case.' \ "rm -f .git/index NA && cp .orig-B/NA NA && - git-update-index --add NA && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add NA && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '2 - matching B alone is OK in !O && !A && B case.' \ "rm -f .git/index NA && cp .orig-B/NA NA && - git-update-index --add NA && + git update-index --add NA && echo extra >>NA && - git-read-tree -m $tree_O $tree_A $tree_B" + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '3 - must match A in !O && A && !B case.' \ "rm -f .git/index AN && cp .orig-A/AN AN && - git-update-index --add AN && - git-read-tree -m $tree_O $tree_A $tree_B && + git update-index --add AN && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_success \ '3 - matching A alone is OK in !O && A && !B case.' \ "rm -f .git/index AN && cp .orig-A/AN AN && - git-update-index --add AN && + git update-index --add AN && echo extra >>AN && - git-read-tree -m $tree_O $tree_A $tree_B" + git read-tree -m $tree_O $tree_A $tree_B" test_expect_failure \ '3 (fail) - must match A in !O && A && !B case.' \ "rm -f .git/index AN && cp .orig-A/AN AN && echo extra >>AN && - git-update-index --add AN && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add AN && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '4 - must match and be up-to-date in !O && A && B && A!=B case.' \ "rm -f .git/index AA && cp .orig-A/AA AA && - git-update-index --add AA && - git-read-tree -m $tree_O $tree_A $tree_B && + git update-index --add AA && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_failure \ '4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' \ "rm -f .git/index AA && cp .orig-A/AA AA && - git-update-index --add AA && + git update-index --add AA && echo extra >>AA && - git-read-tree -m $tree_O $tree_A $tree_B" + git read-tree -m $tree_O $tree_A $tree_B" test_expect_failure \ '4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' \ "rm -f .git/index AA && cp .orig-A/AA AA && echo extra >>AA && - git-update-index --add AA && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add AA && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '5 - must match in !O && A && B && A==B case.' \ "rm -f .git/index LL && cp .orig-A/LL LL && - git-update-index --add LL && - git-read-tree -m $tree_O $tree_A $tree_B && + git update-index --add LL && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_success \ '5 - must match in !O && A && B && A==B case.' \ "rm -f .git/index LL && cp .orig-A/LL LL && - git-update-index --add LL && + git update-index --add LL && echo extra >>LL && - git-read-tree -m $tree_O $tree_A $tree_B && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_failure \ @@ -302,117 +302,117 @@ test_expect_failure \ "rm -f .git/index LL && cp .orig-A/LL LL && echo extra >>LL && - git-update-index --add LL && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add LL && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_failure \ '6 - must not exist in O && !A && !B case' \ "rm -f .git/index DD && echo DD >DD - git-update-index --add DD && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add DD && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_failure \ '7 - must not exist in O && !A && B && O!=B case' \ "rm -f .git/index DM && cp .orig-B/DM DM && - git-update-index --add DM && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add DM && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_failure \ '8 - must not exist in O && !A && B && O==B case' \ "rm -f .git/index DN && cp .orig-B/DN DN && - git-update-index --add DN && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add DN && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '9 - must match and be up-to-date in O && A && !B && O!=A case' \ "rm -f .git/index MD && cp .orig-A/MD MD && - git-update-index --add MD && - git-read-tree -m $tree_O $tree_A $tree_B && + git update-index --add MD && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_failure \ '9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' \ "rm -f .git/index MD && cp .orig-A/MD MD && - git-update-index --add MD && + git update-index --add MD && echo extra >>MD && - git-read-tree -m $tree_O $tree_A $tree_B" + git read-tree -m $tree_O $tree_A $tree_B" test_expect_failure \ '9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' \ "rm -f .git/index MD && cp .orig-A/MD MD && echo extra >>MD && - git-update-index --add MD && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add MD && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '10 - must match and be up-to-date in O && A && !B && O==A case' \ "rm -f .git/index ND && cp .orig-A/ND ND && - git-update-index --add ND && - git-read-tree -m $tree_O $tree_A $tree_B && + git update-index --add ND && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_failure \ '10 (fail) - must match and be up-to-date in O && A && !B && O==A case' \ "rm -f .git/index ND && cp .orig-A/ND ND && - git-update-index --add ND && + git update-index --add ND && echo extra >>ND && - git-read-tree -m $tree_O $tree_A $tree_B" + git read-tree -m $tree_O $tree_A $tree_B" test_expect_failure \ '10 (fail) - must match and be up-to-date in O && A && !B && O==A case' \ "rm -f .git/index ND && cp .orig-A/ND ND && echo extra >>ND && - git-update-index --add ND && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add ND && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '11 - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \ "rm -f .git/index MM && cp .orig-A/MM MM && - git-update-index --add MM && - git-read-tree -m $tree_O $tree_A $tree_B && + git update-index --add MM && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_failure \ '11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \ "rm -f .git/index MM && cp .orig-A/MM MM && - git-update-index --add MM && + git update-index --add MM && echo extra >>MM && - git-read-tree -m $tree_O $tree_A $tree_B" + git read-tree -m $tree_O $tree_A $tree_B" test_expect_failure \ '11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \ "rm -f .git/index MM && cp .orig-A/MM MM && echo extra >>MM && - git-update-index --add MM && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add MM && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '12 - must match A in O && A && B && O!=A && A==B case' \ "rm -f .git/index SS && cp .orig-A/SS SS && - git-update-index --add SS && - git-read-tree -m $tree_O $tree_A $tree_B && + git update-index --add SS && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_success \ '12 - must match A in O && A && B && O!=A && A==B case' \ "rm -f .git/index SS && cp .orig-A/SS SS && - git-update-index --add SS && + git update-index --add SS && echo extra >>SS && - git-read-tree -m $tree_O $tree_A $tree_B && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_failure \ @@ -420,74 +420,74 @@ test_expect_failure \ "rm -f .git/index SS && cp .orig-A/SS SS && echo extra >>SS && - git-update-index --add SS && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add SS && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '13 - must match A in O && A && B && O!=A && O==B case' \ "rm -f .git/index MN && cp .orig-A/MN MN && - git-update-index --add MN && - git-read-tree -m $tree_O $tree_A $tree_B && + git update-index --add MN && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_success \ '13 - must match A in O && A && B && O!=A && O==B case' \ "rm -f .git/index MN && cp .orig-A/MN MN && - git-update-index --add MN && + git update-index --add MN && echo extra >>MN && - git-read-tree -m $tree_O $tree_A $tree_B && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_success \ '14 - must match and be up-to-date in O && A && B && O==A && O!=B case' \ "rm -f .git/index NM && cp .orig-A/NM NM && - git-update-index --add NM && - git-read-tree -m $tree_O $tree_A $tree_B && + git update-index --add NM && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_success \ '14 - may match B in O && A && B && O==A && O!=B case' \ "rm -f .git/index NM && cp .orig-B/NM NM && - git-update-index --add NM && + git update-index --add NM && echo extra >>NM && - git-read-tree -m $tree_O $tree_A $tree_B && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_failure \ '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \ "rm -f .git/index NM && cp .orig-A/NM NM && - git-update-index --add NM && + git update-index --add NM && echo extra >>NM && - git-read-tree -m $tree_O $tree_A $tree_B" + git read-tree -m $tree_O $tree_A $tree_B" test_expect_failure \ '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \ "rm -f .git/index NM && cp .orig-A/NM NM && echo extra >>NM && - git-update-index --add NM && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add NM && + git read-tree -m $tree_O $tree_A $tree_B" test_expect_success \ '15 - must match A in O && A && B && O==A && O==B case' \ "rm -f .git/index NN && cp .orig-A/NN NN && - git-update-index --add NN && - git-read-tree -m $tree_O $tree_A $tree_B && + git update-index --add NN && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_success \ '15 - must match A in O && A && B && O==A && O==B case' \ "rm -f .git/index NN && cp .orig-A/NN NN && - git-update-index --add NN && + git update-index --add NN && echo extra >>NN && - git-read-tree -m $tree_O $tree_A $tree_B && + git read-tree -m $tree_O $tree_A $tree_B && check_result" test_expect_failure \ @@ -495,20 +495,20 @@ test_expect_failure \ "rm -f .git/index NN && cp .orig-A/NN NN && echo extra >>NN && - git-update-index --add NN && - git-read-tree -m $tree_O $tree_A $tree_B" + git update-index --add NN && + git read-tree -m $tree_O $tree_A $tree_B" # #16 test_expect_success \ '16 - A matches in one and B matches in another.' \ 'rm -f .git/index F16 && echo F16 >F16 && - git-update-index --add F16 && - tree0=`git-write-tree` && + git update-index --add F16 && + tree0=`git write-tree` && echo E16 >F16 && - git-update-index F16 && - tree1=`git-write-tree` && - git-read-tree -m $tree0 $tree1 $tree1 $tree0 && - git-ls-files --stage' + git update-index F16 && + tree1=`git write-tree` && + git read-tree -m $tree0 $tree1 $tree1 $tree0 && + git ls-files --stage' test_done diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh index 030226bbfb..b01b0037a0 100755 --- a/t/t1001-read-tree-m-2way.sh +++ b/t/t1001-read-tree-m-2way.sh @@ -11,7 +11,7 @@ There is the head (called H) and another commit (called M), which is simply ahead of H. The index and the work tree contains a state that is derived from H, but may also have local changes. This test checks all the combinations described in the two-tree merge "carry forward" -rules, found in <Documentation/git-read-tree.txt>. +rules, found in <Documentation/git read-tree.txt>. In the test, these paths are used: bozbar - in H, stays in M, modified from bozbar to gnusto @@ -23,7 +23,7 @@ In the test, these paths are used: . ./test-lib.sh read_tree_twoway () { - git-read-tree -m "$1" "$2" && git-ls-files --stage + git read-tree -m "$1" "$2" && git ls-files --stage } _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' @@ -37,7 +37,7 @@ compare_change () { } check_cache_at () { - clean_if_empty=`git-diff-files -- "$1"` + clean_if_empty=`git diff-files -- "$1"` case "$clean_if_empty" in '') echo "$1: clean" ;; ?*) echo "$1: dirty" ;; @@ -68,24 +68,24 @@ test_expect_success \ cat bozbar-old >bozbar && echo rezrov >rezrov && echo yomin >yomin && - git-update-index --add nitfol bozbar rezrov && - treeH=`git-write-tree` && + git update-index --add nitfol bozbar rezrov && + treeH=`git write-tree` && echo treeH $treeH && - git-ls-tree $treeH && + git ls-tree $treeH && cat bozbar-new >bozbar && - git-update-index --add frotz bozbar --force-remove rezrov && - git-ls-files --stage >M.out && - treeM=`git-write-tree` && + git update-index --add frotz bozbar --force-remove rezrov && + git ls-files --stage >M.out && + treeM=`git write-tree` && echo treeM $treeM && - git-ls-tree $treeM && - git-diff-tree $treeH $treeM' + git ls-tree $treeM && + git diff-tree $treeH $treeM' test_expect_success \ '1, 2, 3 - no carry forward' \ 'rm -f .git/index && read_tree_twoway $treeH $treeM && - git-ls-files --stage >1-3.out && + git ls-files --stage >1-3.out && git diff M.out 1-3.out && check_cache_at bozbar dirty && check_cache_at frotz dirty && @@ -96,11 +96,11 @@ echo '+100644 X 0 yomin' >expected test_expect_success \ '4 - carry forward local addition.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && - git-update-index --add yomin && + git read-tree $treeH && + git checkout-index -u -f -q -a && + git update-index --add yomin && read_tree_twoway $treeH $treeM && - git-ls-files --stage >4.out || return 1 + git ls-files --stage >4.out || return 1 git diff M.out 4.out >4diff.out compare_change 4diff.out expected && check_cache_at yomin clean' @@ -108,13 +108,13 @@ test_expect_success \ test_expect_success \ '5 - carry forward local addition.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo yomin >yomin && - git-update-index --add yomin && + git update-index --add yomin && echo yomin yomin >yomin && read_tree_twoway $treeH $treeM && - git-ls-files --stage >5.out || return 1 + git ls-files --stage >5.out || return 1 git diff M.out 5.out >5diff.out compare_change 5diff.out expected && check_cache_at yomin dirty' @@ -122,83 +122,83 @@ test_expect_success \ test_expect_success \ '6 - local addition already has the same.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && - git-update-index --add frotz && + git read-tree $treeH && + git checkout-index -u -f -q -a && + git update-index --add frotz && read_tree_twoway $treeH $treeM && - git-ls-files --stage >6.out && + git ls-files --stage >6.out && git diff M.out 6.out && check_cache_at frotz clean' test_expect_success \ '7 - local addition already has the same.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo frotz >frotz && - git-update-index --add frotz && + git update-index --add frotz && echo frotz frotz >frotz && read_tree_twoway $treeH $treeM && - git-ls-files --stage >7.out && + git ls-files --stage >7.out && git diff M.out 7.out && check_cache_at frotz dirty' test_expect_success \ '8 - conflicting addition.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo frotz frotz >frotz && - git-update-index --add frotz && + git update-index --add frotz && if read_tree_twoway $treeH $treeM; then false; else :; fi' test_expect_success \ '9 - conflicting addition.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo frotz frotz >frotz && - git-update-index --add frotz && + git update-index --add frotz && echo frotz >frotz && if read_tree_twoway $treeH $treeM; then false; else :; fi' test_expect_success \ '10 - path removed.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo rezrov >rezrov && - git-update-index --add rezrov && + git update-index --add rezrov && read_tree_twoway $treeH $treeM && - git-ls-files --stage >10.out && + git ls-files --stage >10.out && git diff M.out 10.out' test_expect_success \ '11 - dirty path removed.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo rezrov >rezrov && - git-update-index --add rezrov && + git update-index --add rezrov && echo rezrov rezrov >rezrov && if read_tree_twoway $treeH $treeM; then false; else :; fi' test_expect_success \ '12 - unmatching local changes being removed.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo rezrov rezrov >rezrov && - git-update-index --add rezrov && + git update-index --add rezrov && if read_tree_twoway $treeH $treeM; then false; else :; fi' test_expect_success \ '13 - unmatching local changes being removed.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo rezrov rezrov >rezrov && - git-update-index --add rezrov && + git update-index --add rezrov && echo rezrov >rezrov && if read_tree_twoway $treeH $treeM; then false; else :; fi' @@ -210,12 +210,12 @@ EOF test_expect_success \ '14 - unchanged in two heads.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo nitfol nitfol >nitfol && - git-update-index --add nitfol && + git update-index --add nitfol && read_tree_twoway $treeH $treeM && - git-ls-files --stage >14.out || return 1 + git ls-files --stage >14.out || return 1 git diff M.out 14.out >14diff.out compare_change 14diff.out expected && check_cache_at nitfol clean' @@ -223,13 +223,13 @@ test_expect_success \ test_expect_success \ '15 - unchanged in two heads.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo nitfol nitfol >nitfol && - git-update-index --add nitfol && + git update-index --add nitfol && echo nitfol nitfol nitfol >nitfol && read_tree_twoway $treeH $treeM && - git-ls-files --stage >15.out || return 1 + git ls-files --stage >15.out || return 1 git diff M.out 15.out >15diff.out compare_change 15diff.out expected && check_cache_at nitfol dirty' @@ -237,66 +237,66 @@ test_expect_success \ test_expect_success \ '16 - conflicting local change.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo bozbar bozbar >bozbar && - git-update-index --add bozbar && + git update-index --add bozbar && if read_tree_twoway $treeH $treeM; then false; else :; fi' test_expect_success \ '17 - conflicting local change.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && echo bozbar bozbar >bozbar && - git-update-index --add bozbar && + git update-index --add bozbar && echo bozbar bozbar bozbar >bozbar && if read_tree_twoway $treeH $treeM; then false; else :; fi' test_expect_success \ '18 - local change already having a good result.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && cat bozbar-new >bozbar && - git-update-index --add bozbar && + git update-index --add bozbar && read_tree_twoway $treeH $treeM && - git-ls-files --stage >18.out && + git ls-files --stage >18.out && git diff M.out 18.out && check_cache_at bozbar clean' test_expect_success \ '19 - local change already having a good result, further modified.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && cat bozbar-new >bozbar && - git-update-index --add bozbar && + git update-index --add bozbar && echo gnusto gnusto >bozbar && read_tree_twoway $treeH $treeM && - git-ls-files --stage >19.out && + git ls-files --stage >19.out && git diff M.out 19.out && check_cache_at bozbar dirty' test_expect_success \ '20 - no local change, use new tree.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && cat bozbar-old >bozbar && - git-update-index --add bozbar && + git update-index --add bozbar && read_tree_twoway $treeH $treeM && - git-ls-files --stage >20.out && + git ls-files --stage >20.out && git diff M.out 20.out && check_cache_at bozbar dirty' test_expect_success \ '21 - no local change, dirty cache.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && cat bozbar-old >bozbar && - git-update-index --add bozbar && + git update-index --add bozbar && echo gnusto gnusto >bozbar && if read_tree_twoway $treeH $treeM; then false; else :; fi' @@ -304,10 +304,10 @@ test_expect_success \ test_expect_success \ '22 - local change cache updated.' \ 'rm -f .git/index && - git-read-tree $treeH && - git-checkout-index -u -f -q -a && + git read-tree $treeH && + git checkout-index -u -f -q -a && sed -e "s/such as/SUCH AS/" bozbar-old >bozbar && - git-update-index --add bozbar && + git update-index --add bozbar && if read_tree_twoway $treeH $treeM; then false; else :; fi' # Also make sure we did not break DF vs DF/DF case. @@ -315,28 +315,28 @@ test_expect_success \ 'DF vs DF/DF case setup.' \ 'rm -f .git/index && echo DF >DF && - git-update-index --add DF && - treeDF=`git-write-tree` && + git update-index --add DF && + treeDF=`git write-tree` && echo treeDF $treeDF && - git-ls-tree $treeDF && + git ls-tree $treeDF && rm -f DF && mkdir DF && echo DF/DF >DF/DF && - git-update-index --add --remove DF DF/DF && - treeDFDF=`git-write-tree` && + git update-index --add --remove DF DF/DF && + treeDFDF=`git write-tree` && echo treeDFDF $treeDFDF && - git-ls-tree $treeDFDF && - git-ls-files --stage >DFDF.out' + git ls-tree $treeDFDF && + git ls-files --stage >DFDF.out' test_expect_success \ 'DF vs DF/DF case test.' \ 'rm -f .git/index && rm -fr DF && echo DF >DF && - git-update-index --add DF && + git update-index --add DF && read_tree_twoway $treeDF $treeDFDF && - git-ls-files --stage >DFDFcheck.out && + git ls-files --stage >DFDFcheck.out && git diff DFDF.out DFDFcheck.out && check_cache_at DF/DF dirty && :' diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh index 87fe993f59..42e5cf8181 100755 --- a/t/t1002-read-tree-m-u-2way.sh +++ b/t/t1002-read-tree-m-u-2way.sh @@ -20,7 +20,7 @@ compare_change () { } check_cache_at () { - clean_if_empty=`git-diff-files -- "$1"` + clean_if_empty=`git diff-files -- "$1"` case "$clean_if_empty" in '') echo "$1: clean" ;; ?*) echo "$1: dirty" ;; @@ -39,26 +39,26 @@ test_expect_success \ echo nitfol >nitfol && echo bozbar >bozbar && echo rezrov >rezrov && - git-update-index --add nitfol bozbar rezrov && - treeH=`git-write-tree` && + git update-index --add nitfol bozbar rezrov && + treeH=`git write-tree` && echo treeH $treeH && - git-ls-tree $treeH && + git ls-tree $treeH && echo gnusto >bozbar && - git-update-index --add frotz bozbar --force-remove rezrov && - git-ls-files --stage >M.out && - treeM=`git-write-tree` && + git update-index --add frotz bozbar --force-remove rezrov && + git ls-files --stage >M.out && + treeM=`git write-tree` && echo treeM $treeM && - git-ls-tree $treeM && + git ls-tree $treeM && sum bozbar frotz nitfol >M.sum && - git-diff-tree $treeH $treeM' + git diff-tree $treeH $treeM' test_expect_success \ '1, 2, 3 - no carry forward' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >1-3.out && + git read-tree --reset -u $treeH && + git read-tree -m -u $treeH $treeM && + git ls-files --stage >1-3.out && cmp M.out 1-3.out && sum bozbar frotz nitfol >actual3.sum && cmp M.sum actual3.sum && @@ -69,12 +69,12 @@ test_expect_success \ test_expect_success \ '4 - carry forward local addition.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo "+100644 X 0 yomin" >expected && echo yomin >yomin && - git-update-index --add yomin && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >4.out || return 1 + git update-index --add yomin && + git read-tree -m -u $treeH $treeM && + git ls-files --stage >4.out || return 1 diff -U0 M.out 4.out >4diff.out compare_change 4diff.out expected && check_cache_at yomin clean && @@ -87,13 +87,13 @@ test_expect_success \ test_expect_success \ '5 - carry forward local addition.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && - git-read-tree -m -u $treeH && + git read-tree --reset -u $treeH && + git read-tree -m -u $treeH && echo yomin >yomin && - git-update-index --add yomin && + git update-index --add yomin && echo yomin yomin >yomin && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >5.out || return 1 + git read-tree -m -u $treeH $treeM && + git ls-files --stage >5.out || return 1 diff -U0 M.out 5.out >5diff.out compare_change 5diff.out expected && check_cache_at yomin dirty && @@ -107,11 +107,11 @@ test_expect_success \ test_expect_success \ '6 - local addition already has the same.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo frotz >frotz && - git-update-index --add frotz && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >6.out && + git update-index --add frotz && + git read-tree -m -u $treeH $treeM && + git ls-files --stage >6.out && diff -U0 M.out 6.out && check_cache_at frotz clean && sum bozbar frotz nitfol >actual3.sum && @@ -123,12 +123,12 @@ test_expect_success \ test_expect_success \ '7 - local addition already has the same.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo frotz >frotz && - git-update-index --add frotz && + git update-index --add frotz && echo frotz frotz >frotz && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >7.out && + git read-tree -m -u $treeH $treeM && + git ls-files --stage >7.out && diff -U0 M.out 7.out && check_cache_at frotz dirty && sum bozbar frotz nitfol >actual7.sum && @@ -141,28 +141,28 @@ test_expect_success \ test_expect_success \ '8 - conflicting addition.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo frotz frotz >frotz && - git-update-index --add frotz && - if git-read-tree -m -u $treeH $treeM; then false; else :; fi' + git update-index --add frotz && + if git read-tree -m -u $treeH $treeM; then false; else :; fi' test_expect_success \ '9 - conflicting addition.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo frotz frotz >frotz && - git-update-index --add frotz && + git update-index --add frotz && echo frotz >frotz && - if git-read-tree -m -u $treeH $treeM; then false; else :; fi' + if git read-tree -m -u $treeH $treeM; then false; else :; fi' test_expect_success \ '10 - path removed.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo rezrov >rezrov && - git-update-index --add rezrov && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >10.out && + git update-index --add rezrov && + git read-tree -m -u $treeH $treeM && + git ls-files --stage >10.out && cmp M.out 10.out && sum bozbar frotz nitfol >actual10.sum && cmp M.sum actual10.sum' @@ -170,28 +170,28 @@ test_expect_success \ test_expect_success \ '11 - dirty path removed.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo rezrov >rezrov && - git-update-index --add rezrov && + git update-index --add rezrov && echo rezrov rezrov >rezrov && - if git-read-tree -m -u $treeH $treeM; then false; else :; fi' + if git read-tree -m -u $treeH $treeM; then false; else :; fi' test_expect_success \ '12 - unmatching local changes being removed.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo rezrov rezrov >rezrov && - git-update-index --add rezrov && - if git-read-tree -m -u $treeH $treeM; then false; else :; fi' + git update-index --add rezrov && + if git read-tree -m -u $treeH $treeM; then false; else :; fi' test_expect_success \ '13 - unmatching local changes being removed.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo rezrov rezrov >rezrov && - git-update-index --add rezrov && + git update-index --add rezrov && echo rezrov >rezrov && - if git-read-tree -m -u $treeH $treeM; then false; else :; fi' + if git read-tree -m -u $treeH $treeM; then false; else :; fi' cat >expected <<EOF -100644 X 0 nitfol @@ -201,11 +201,11 @@ EOF test_expect_success \ '14 - unchanged in two heads.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo nitfol nitfol >nitfol && - git-update-index --add nitfol && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >14.out || return 1 + git update-index --add nitfol && + git read-tree -m -u $treeH $treeM && + git ls-files --stage >14.out || return 1 diff -U0 M.out 14.out >14diff.out compare_change 14diff.out expected && sum bozbar frotz >actual14.sum && @@ -221,12 +221,12 @@ test_expect_success \ test_expect_success \ '15 - unchanged in two heads.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo nitfol nitfol >nitfol && - git-update-index --add nitfol && + git update-index --add nitfol && echo nitfol nitfol nitfol >nitfol && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >15.out || return 1 + git read-tree -m -u $treeH $treeM && + git ls-files --stage >15.out || return 1 diff -U0 M.out 15.out >15diff.out compare_change 15diff.out expected && check_cache_at nitfol dirty && @@ -242,28 +242,28 @@ test_expect_success \ test_expect_success \ '16 - conflicting local change.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo bozbar bozbar >bozbar && - git-update-index --add bozbar && - if git-read-tree -m -u $treeH $treeM; then false; else :; fi' + git update-index --add bozbar && + if git read-tree -m -u $treeH $treeM; then false; else :; fi' test_expect_success \ '17 - conflicting local change.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo bozbar bozbar >bozbar && - git-update-index --add bozbar && + git update-index --add bozbar && echo bozbar bozbar bozbar >bozbar && - if git-read-tree -m -u $treeH $treeM; then false; else :; fi' + if git read-tree -m -u $treeH $treeM; then false; else :; fi' test_expect_success \ '18 - local change already having a good result.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo gnusto >bozbar && - git-update-index --add bozbar && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >18.out && + git update-index --add bozbar && + git read-tree -m -u $treeH $treeM && + git ls-files --stage >18.out && diff -U0 M.out 18.out && check_cache_at bozbar clean && sum bozbar frotz nitfol >actual18.sum && @@ -272,12 +272,12 @@ test_expect_success \ test_expect_success \ '19 - local change already having a good result, further modified.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo gnusto >bozbar && - git-update-index --add bozbar && + git update-index --add bozbar && echo gnusto gnusto >bozbar && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >19.out && + git read-tree -m -u $treeH $treeM && + git ls-files --stage >19.out && diff -U0 M.out 19.out && check_cache_at bozbar dirty && sum frotz nitfol >actual19.sum && @@ -292,11 +292,11 @@ test_expect_success \ test_expect_success \ '20 - no local change, use new tree.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo bozbar >bozbar && - git-update-index --add bozbar && - git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >20.out && + git update-index --add bozbar && + git read-tree -m -u $treeH $treeM && + git ls-files --stage >20.out && diff -U0 M.out 20.out && check_cache_at bozbar clean && sum bozbar frotz nitfol >actual20.sum && @@ -305,39 +305,39 @@ test_expect_success \ test_expect_success \ '21 - no local change, dirty cache.' \ 'rm -f .git/index nitfol bozbar rezrov frotz && - git-read-tree --reset -u $treeH && + git read-tree --reset -u $treeH && echo bozbar >bozbar && - git-update-index --add bozbar && + git update-index --add bozbar && echo gnusto gnusto >bozbar && - if git-read-tree -m -u $treeH $treeM; then false; else :; fi' + if git read-tree -m -u $treeH $treeM; then false; else :; fi' # Also make sure we did not break DF vs DF/DF case. test_expect_success \ 'DF vs DF/DF case setup.' \ 'rm -f .git/index echo DF >DF && - git-update-index --add DF && - treeDF=`git-write-tree` && + git update-index --add DF && + treeDF=`git write-tree` && echo treeDF $treeDF && - git-ls-tree $treeDF && + git ls-tree $treeDF && rm -f DF && mkdir DF && echo DF/DF >DF/DF && - git-update-index --add --remove DF DF/DF && - treeDFDF=`git-write-tree` && + git update-index --add --remove DF DF/DF && + treeDFDF=`git write-tree` && echo treeDFDF $treeDFDF && - git-ls-tree $treeDFDF && - git-ls-files --stage >DFDF.out' + git ls-tree $treeDFDF && + git ls-files --stage >DFDF.out' test_expect_success \ 'DF vs DF/DF case test.' \ 'rm -f .git/index && rm -fr DF && echo DF >DF && - git-update-index --add DF && - git-read-tree -m -u $treeDF $treeDFDF && - git-ls-files --stage >DFDFcheck.out && + git update-index --add DF && + git read-tree -m -u $treeDF $treeDFDF && + git ls-files --stage >DFDFcheck.out && diff -U0 DFDF.out DFDFcheck.out && check_cache_at DF/DF clean' diff --git a/t/t1003-read-tree-prefix.sh b/t/t1003-read-tree-prefix.sh index 48ab117d75..8c6d67edda 100755 --- a/t/t1003-read-tree-prefix.sh +++ b/t/t1003-read-tree-prefix.sh @@ -3,15 +3,15 @@ # Copyright (c) 2006 Junio C Hamano # -test_description='git-read-tree --prefix test. +test_description='git read-tree --prefix test. ' . ./test-lib.sh test_expect_success setup ' echo hello >one && - git-update-index --add one && - tree=`git-write-tree` && + git update-index --add one && + tree=`git write-tree` && echo tree is $tree ' @@ -19,8 +19,8 @@ echo 'one two/one' >expect test_expect_success 'read-tree --prefix' ' - git-read-tree --prefix=two/ $tree && - git-ls-files >actual && + git read-tree --prefix=two/ $tree && + git ls-files >actual && cmp expect actual ' diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh index c11420a8b6..d609a551ae 100755 --- a/t/t1004-read-tree-m-u-wf.sh +++ b/t/t1004-read-tree-m-u-wf.sh @@ -84,7 +84,7 @@ test_expect_success 'three-way not complaining on an untracked path in both' ' echo >file2 file two is untracked on the master side && echo >subdir/file2 file two is untracked on the master side && - git-read-tree -m -u branch-point master side + git read-tree -m -u branch-point master side ' test_expect_success 'three-way not clobbering a working tree file' ' diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 1e8f9e59df..b9cef3422c 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -22,19 +22,19 @@ LF=' test_expect_success 'update-index and ls-files' ' cd $HERE && - git-update-index --add one && - case "`git-ls-files`" in + git update-index --add one && + case "`git ls-files`" in one) echo ok one ;; *) echo bad one; exit 1 ;; esac && cd dir && - git-update-index --add two && - case "`git-ls-files`" in + git update-index --add two && + case "`git ls-files`" in two) echo ok two ;; *) echo bad two; exit 1 ;; esac && cd .. && - case "`git-ls-files`" in + case "`git ls-files`" in dir/two"$LF"one) echo ok both ;; *) echo bad; exit 1 ;; esac @@ -42,13 +42,13 @@ test_expect_success 'update-index and ls-files' ' test_expect_success 'cat-file' ' cd $HERE && - two=`git-ls-files -s dir/two` && + two=`git ls-files -s dir/two` && two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` && echo "$two" && - git-cat-file -p "$two" >actual && + git cat-file -p "$two" >actual && cmp dir/two actual && cd dir && - git-cat-file -p "$two" >actual && + git cat-file -p "$two" >actual && cmp two actual ' rm -f actual dir/actual @@ -57,17 +57,17 @@ test_expect_success 'diff-files' ' cd $HERE && echo a >>one && echo d >>dir/two && - case "`git-diff-files --name-only`" in + case "`git diff-files --name-only`" in dir/two"$LF"one) echo ok top ;; *) echo bad top; exit 1 ;; esac && # diff should not omit leading paths cd dir && - case "`git-diff-files --name-only`" in + case "`git diff-files --name-only`" in dir/two"$LF"one) echo ok subdir ;; *) echo bad subdir; exit 1 ;; esac && - case "`git-diff-files --name-only .`" in + case "`git diff-files --name-only .`" in dir/two) echo ok subdir limited ;; *) echo bad subdir limited; exit 1 ;; esac @@ -75,33 +75,33 @@ test_expect_success 'diff-files' ' test_expect_success 'write-tree' ' cd $HERE && - top=`git-write-tree` && + top=`git write-tree` && echo $top && cd dir && - sub=`git-write-tree` && + sub=`git write-tree` && echo $sub && test "z$top" = "z$sub" ' test_expect_success 'checkout-index' ' cd $HERE && - git-checkout-index -f -u one && + git checkout-index -f -u one && cmp one original.one && cd dir && - git-checkout-index -f -u two && + git checkout-index -f -u two && cmp two ../original.two ' test_expect_success 'read-tree' ' cd $HERE && rm -f one dir/two && - tree=`git-write-tree` && - git-read-tree --reset -u "$tree" && + tree=`git write-tree` && + git read-tree --reset -u "$tree" && cmp one original.one && cmp dir/two original.two && cd dir && rm -f two && - git-read-tree --reset -u "$tree" && + git read-tree --reset -u "$tree" && cmp two ../original.two && cmp ../one ../original.one ' diff --git a/t/t1100-commit-tree-options.sh b/t/t1100-commit-tree-options.sh index 19a0ed4d20..7f7fc36734 100755 --- a/t/t1100-commit-tree-options.sh +++ b/t/t1100-commit-tree-options.sh @@ -3,9 +3,9 @@ # Copyright (C) 2005 Rene Scharfe # -test_description='git-commit-tree options test +test_description='git commit-tree options test -This test checks that git-commit-tree can create a specific commit +This test checks that git commit-tree can create a specific commit object by defining all environment variables that it understands. ' @@ -21,7 +21,7 @@ EOF test_expect_success \ 'test preparation: write empty tree' \ - 'git-write-tree >treeid' + 'git write-tree >treeid' test_expect_success \ 'construct commit' \ @@ -32,11 +32,11 @@ test_expect_success \ GIT_COMMITTER_NAME="Committer Name" \ GIT_COMMITTER_EMAIL="committer@email" \ GIT_COMMITTER_DATE="2005-05-26 23:30" \ - TZ=GMT git-commit-tree `cat treeid` >commitid 2>/dev/null' + TZ=GMT git commit-tree `cat treeid` >commitid 2>/dev/null' test_expect_success \ 'read commit' \ - 'git-cat-file commit `cat commitid` >commit' + 'git cat-file commit `cat commitid` >commit' test_expect_success \ 'compare commit' \ diff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh index ca2c30f7af..991d3c5e9c 100755 --- a/t/t1200-tutorial.sh +++ b/t/t1200-tutorial.sh @@ -10,11 +10,11 @@ test_description='A simple turial in the form of a test case' echo "Hello World" > hello echo "Silly example" > example -git-update-index --add hello example +git update-index --add hello example -test_expect_success 'blob' "test blob = \"$(git-cat-file -t 557db03)\"" +test_expect_success 'blob' "test blob = \"$(git cat-file -t 557db03)\"" -test_expect_success 'blob 557db03' "test \"Hello World\" = \"$(git-cat-file blob 557db03)\"" +test_expect_success 'blob 557db03' "test \"Hello World\" = \"$(git cat-file blob 557db03)\"" echo "It's a new day for git" >>hello cat > diff.expect << EOF @@ -26,25 +26,25 @@ index 557db03..263414f 100644 Hello World +It's a new day for git EOF -git-diff-files -p > diff.output -test_expect_success 'git-diff-files -p' 'cmp diff.expect diff.output' +git diff-files -p > diff.output +test_expect_success 'git diff-files -p' 'cmp diff.expect diff.output' git diff > diff.output test_expect_success 'git diff' 'cmp diff.expect diff.output' -tree=$(git-write-tree 2>/dev/null) +tree=$(git write-tree 2>/dev/null) test_expect_success 'tree' "test 8988da15d077d4829fc51d8544c097def6644dbb = $tree" -output="$(echo "Initial commit" | git-commit-tree $(git-write-tree) 2>&1 > .git/refs/heads/master)" +output="$(echo "Initial commit" | git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master)" -git-diff-index -p HEAD > diff.output -test_expect_success 'git-diff-index -p HEAD' 'cmp diff.expect diff.output' +git diff-index -p HEAD > diff.output +test_expect_success 'git diff-index -p HEAD' 'cmp diff.expect diff.output' git diff HEAD > diff.output test_expect_success 'git diff HEAD' 'cmp diff.expect diff.output' #rm hello -#test_expect_success 'git-read-tree --reset HEAD' "git-read-tree --reset HEAD ; test \"hello: needs update\" = \"$(git-update-index --refresh)\"" +#test_expect_success 'git read-tree --reset HEAD' "git read-tree --reset HEAD ; test \"hello: needs update\" = \"$(git update-index --refresh)\"" cat > whatchanged.expect << EOF commit VARIABLE @@ -69,11 +69,11 @@ index 0000000..557db03 +Hello World EOF -git-whatchanged -p --root | \ +git whatchanged -p --root | \ sed -e "1s/^\(.\{7\}\).\{40\}/\1VARIABLE/" \ -e "2,3s/^\(.\{8\}\).*$/\1VARIABLE/" \ > whatchanged.output -test_expect_success 'git-whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output' +test_expect_success 'git whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output' git tag my-first-tag test_expect_success 'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag' @@ -159,4 +159,3 @@ test_expect_success 'git prune-packed' 'git prune-packed' test_expect_failure '-> only packed objects' 'find -type f .git/objects/[0-9a-f][0-9a-f]' test_done - diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index f1a78b19ac..1d2bf2c060 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -3,13 +3,13 @@ # Copyright (c) 2005 Johannes Schindelin # -test_description='Test git-config in different settings' +test_description='Test git config in different settings' . ./test-lib.sh test -f .git/config && rm .git/config -git-config core.penguin "little blue" +git config core.penguin "little blue" cat > expect << EOF [core] @@ -18,7 +18,7 @@ EOF test_expect_success 'initial' 'cmp .git/config expect' -git-config Core.Movie BadPhysics +git config Core.Movie BadPhysics cat > expect << EOF [core] @@ -28,7 +28,7 @@ EOF test_expect_success 'mixed case' 'cmp .git/config expect' -git-config Cores.WhatEver Second +git config Cores.WhatEver Second cat > expect << EOF [core] @@ -40,7 +40,7 @@ EOF test_expect_success 'similar section' 'cmp .git/config expect' -git-config CORE.UPPERCASE true +git config CORE.UPPERCASE true cat > expect << EOF [core] @@ -54,10 +54,10 @@ EOF test_expect_success 'similar section' 'cmp .git/config expect' test_expect_success 'replace with non-match' \ - 'git-config core.penguin kingpin !blue' + 'git config core.penguin kingpin !blue' test_expect_success 'replace with non-match (actually matching)' \ - 'git-config core.penguin "very blue" !kingpin' + 'git config core.penguin "very blue" !kingpin' cat > expect << EOF [core] @@ -86,7 +86,7 @@ EOF cp .git/config .git/config2 test_expect_success 'multiple unset' \ - 'git-config --unset-all beta.haha' + 'git config --unset-all beta.haha' cat > expect << EOF [beta] ; silly comment # another comment @@ -102,7 +102,7 @@ test_expect_success 'multiple unset is correct' 'cmp .git/config expect' mv .git/config2 .git/config test_expect_success '--replace-all' \ - 'git-config --replace-all beta.haha gamma' + 'git config --replace-all beta.haha gamma' cat > expect << EOF [beta] ; silly comment # another comment @@ -116,7 +116,7 @@ EOF test_expect_success 'all replaced' 'cmp .git/config expect' -git-config beta.haha alpha +git config beta.haha alpha cat > expect << EOF [beta] ; silly comment # another comment @@ -130,7 +130,7 @@ EOF test_expect_success 'really mean test' 'cmp .git/config expect' -git-config nextsection.nonewline wow +git config nextsection.nonewline wow cat > expect << EOF [beta] ; silly comment # another comment @@ -145,8 +145,8 @@ EOF test_expect_success 'really really mean test' 'cmp .git/config expect' -test_expect_success 'get value' 'test alpha = $(git-config beta.haha)' -git-config --unset beta.haha +test_expect_success 'get value' 'test alpha = $(git config beta.haha)' +git config --unset beta.haha cat > expect << EOF [beta] ; silly comment # another comment @@ -160,7 +160,7 @@ EOF test_expect_success 'unset' 'cmp .git/config expect' -git-config nextsection.NoNewLine "wow2 for me" "for me$" +git config nextsection.NoNewLine "wow2 for me" "for me$" cat > expect << EOF [beta] ; silly comment # another comment @@ -176,18 +176,18 @@ EOF test_expect_success 'multivar' 'cmp .git/config expect' test_expect_success 'non-match' \ - 'git-config --get nextsection.nonewline !for' + 'git config --get nextsection.nonewline !for' test_expect_success 'non-match value' \ - 'test wow = $(git-config --get nextsection.nonewline !for)' + 'test wow = $(git config --get nextsection.nonewline !for)' test_expect_failure 'ambiguous get' \ - 'git-config --get nextsection.nonewline' + 'git config --get nextsection.nonewline' test_expect_success 'get multivar' \ - 'git-config --get-all nextsection.nonewline' + 'git config --get-all nextsection.nonewline' -git-config nextsection.nonewline "wow3" "wow$" +git config nextsection.nonewline "wow3" "wow$" cat > expect << EOF [beta] ; silly comment # another comment @@ -202,15 +202,15 @@ EOF test_expect_success 'multivar replace' 'cmp .git/config expect' -test_expect_failure 'ambiguous value' 'git-config nextsection.nonewline' +test_expect_failure 'ambiguous value' 'git config nextsection.nonewline' test_expect_failure 'ambiguous unset' \ - 'git-config --unset nextsection.nonewline' + 'git config --unset nextsection.nonewline' test_expect_failure 'invalid unset' \ - 'git-config --unset somesection.nonewline' + 'git config --unset somesection.nonewline' -git-config --unset nextsection.nonewline "wow3$" +git config --unset nextsection.nonewline "wow3$" cat > expect << EOF [beta] ; silly comment # another comment @@ -224,12 +224,12 @@ EOF test_expect_success 'multivar unset' 'cmp .git/config expect' -test_expect_failure 'invalid key' 'git-config inval.2key blabla' +test_expect_failure 'invalid key' 'git config inval.2key blabla' -test_expect_success 'correct key' 'git-config 123456.a123 987' +test_expect_success 'correct key' 'git config 123456.a123 987' test_expect_success 'hierarchical section' \ - 'git-config Version.1.2.3eX.Alpha beta' + 'git config Version.1.2.3eX.Alpha beta' cat > expect << EOF [beta] ; silly comment # another comment @@ -255,7 +255,7 @@ version.1.2.3eX.alpha=beta EOF test_expect_success 'working --list' \ - 'git-config --list > output && cmp output expect' + 'git config --list > output && cmp output expect' cat > expect << EOF beta.noindent sillyValue @@ -263,9 +263,9 @@ nextsection.nonewline wow2 for me EOF test_expect_success '--get-regexp' \ - 'git-config --get-regexp in > output && cmp output expect' + 'git config --get-regexp in > output && cmp output expect' -git-config --add nextsection.nonewline "wow4 for you" +git config --add nextsection.nonewline "wow4 for you" cat > expect << EOF wow2 for me @@ -273,7 +273,7 @@ wow4 for you EOF test_expect_success '--add' \ - 'git-config --get-all nextsection.nonewline > output && cmp output expect' + 'git config --get-all nextsection.nonewline > output && cmp output expect' cat > .git/config << EOF [novalue] @@ -281,15 +281,15 @@ cat > .git/config << EOF EOF test_expect_success 'get variable with no value' \ - 'git-config --get novalue.variable ^$' + 'git config --get novalue.variable ^$' echo novalue.variable > expect test_expect_success 'get-regexp variable with no value' \ - 'git-config --get-regexp novalue > output && + 'git config --get-regexp novalue > output && cmp output expect' -git-config > output 2>&1 +git config > output 2>&1 test_expect_success 'no arguments, but no crash' \ "test $? = 129 && grep usage output" @@ -299,7 +299,7 @@ cat > .git/config << EOF c = d EOF -git-config a.x y +git config a.x y cat > expect << EOF [a.b] @@ -310,8 +310,8 @@ EOF test_expect_success 'new section is partial match of another' 'cmp .git/config expect' -git-config b.x y -git-config a.b c +git config b.x y +git config a.b c cat > expect << EOF [a.b] @@ -325,6 +325,9 @@ EOF test_expect_success 'new variable inserts into proper section' 'cmp .git/config expect' +test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' \ + 'git config --file non-existing-config -l; test $? != 0' + cat > other-config << EOF [ein] bahn = strasse @@ -334,11 +337,14 @@ cat > expect << EOF ein.bahn=strasse EOF -GIT_CONFIG=other-config git-config -l > output +GIT_CONFIG=other-config git config -l > output test_expect_success 'alternative GIT_CONFIG' 'cmp output expect' -GIT_CONFIG=other-config git-config anwohner.park ausweis +test_expect_success 'alternative GIT_CONFIG (--file)' \ + 'git config --file other-config -l > output && cmp output expect' + +GIT_CONFIG=other-config git config anwohner.park ausweis cat > expect << EOF [ein] @@ -361,7 +367,7 @@ weird EOF test_expect_success "rename section" \ - "git-config --rename-section branch.eins branch.zwei" + "git config --rename-section branch.eins branch.zwei" cat > expect << EOF # Hallo @@ -377,12 +383,12 @@ EOF test_expect_success "rename succeeded" "git diff expect .git/config" test_expect_failure "rename non-existing section" \ - 'git-config --rename-section branch."world domination" branch.drei' + 'git config --rename-section branch."world domination" branch.drei' test_expect_success "rename succeeded" "git diff expect .git/config" test_expect_success "rename another section" \ - 'git-config --rename-section branch."1 234 blabl/a" branch.drei' + 'git config --rename-section branch."1 234 blabl/a" branch.drei' cat > expect << EOF # Hallo @@ -425,20 +431,20 @@ EOF test_expect_success 'section ending' ' - git-config gitcvs.enabled true && - git-config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && - git-config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && + git config gitcvs.enabled true && + git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && + git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && cmp .git/config expect ' test_expect_success numbers ' - git-config kilo.gram 1k && - git-config mega.ton 1m && - k=$(git-config --int --get kilo.gram) && + git config kilo.gram 1k && + git config mega.ton 1m && + k=$(git config --int --get kilo.gram) && test z1024 = "z$k" && - m=$(git-config --int --get mega.ton) && + m=$(git config --int --get mega.ton) && test z1048576 = "z$m" ' @@ -455,33 +461,79 @@ EOF test_expect_success bool ' - git-config bool.true1 01 && - git-config bool.true2 -1 && - git-config bool.true3 YeS && - git-config bool.true4 true && - git-config bool.false1 000 && - git-config bool.false2 "" && - git-config bool.false3 nO && - git-config bool.false4 FALSE && + git config bool.true1 01 && + git config bool.true2 -1 && + git config bool.true3 YeS && + git config bool.true4 true && + git config bool.false1 000 && + git config bool.false2 "" && + git config bool.false3 nO && + git config bool.false4 FALSE && rm -f result && for i in 1 2 3 4 do - git-config --bool --get bool.true$i >>result - git-config --bool --get bool.false$i >>result + git config --bool --get bool.true$i >>result + git config --bool --get bool.false$i >>result done && cmp expect result' -test_expect_failure 'invalid bool' ' +test_expect_failure 'invalid bool (--get)' ' + + git config bool.nobool foobar && + git config --bool --get bool.nobool' + +test_expect_failure 'invalid bool (set)' ' + + git config --bool bool.nobool foobar' + +rm .git/config + +cat > expect <<\EOF +[bool] + true1 = true + true2 = true + true3 = true + true4 = true + false1 = false + false2 = false + false3 = false + false4 = false +EOF + +test_expect_success 'set --bool' ' + + git config --bool bool.true1 01 && + git config --bool bool.true2 -1 && + git config --bool bool.true3 YeS && + git config --bool bool.true4 true && + git config --bool bool.false1 000 && + git config --bool bool.false2 "" && + git config --bool bool.false3 nO && + git config --bool bool.false4 FALSE && + cmp expect .git/config' + +rm .git/config + +cat > expect <<\EOF +[int] + val1 = 1 + val2 = -1 + val3 = 5242880 +EOF - git-config bool.nobool foobar && - git-config --bool --get bool.nobool' +test_expect_success 'set --int' ' + + git config --int int.val1 01 && + git config --int int.val2 -1 && + git config --int int.val3 5m && + cmp expect .git/config' rm .git/config -git-config quote.leading " test" -git-config quote.ending "test " -git-config quote.semicolon "test;test" -git-config quote.hash "test#test" +git config quote.leading " test" +git config quote.ending "test " +git config quote.semicolon "test;test" +git config quote.hash "test#test" cat > expect << EOF [quote] @@ -519,5 +571,49 @@ git config --list > result test_expect_success 'value continued on next line' 'cmp result expect' -test_done +cat > .git/config <<\EOF +[section "sub=section"] + val1 = foo=bar + val2 = foo\nbar + val3 = \n\n + val4 = + val5 +EOF + +cat > expect <<\EOF +section.sub=section.val1 +foo=barQsection.sub=section.val2 +foo +barQsection.sub=section.val3 + + +Qsection.sub=section.val4 +Qsection.sub=section.val5Q +EOF + +git config --null --list | tr '[\000]' 'Q' > result +echo >>result +test_expect_success '--null --list' 'cmp result expect' + +git config --null --get-regexp 'val[0-9]' | tr '[\000]' 'Q' > result +echo >>result + +test_expect_success '--null --get-regexp' 'cmp result expect' + +test_expect_success 'symlinked configuration' ' + + ln -s notyet myconfig && + GIT_CONFIG=myconfig git config test.frotz nitfol && + test -h myconfig && + test -f notyet && + test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol && + GIT_CONFIG=myconfig git config test.xyzzy rezrov && + test -h myconfig && + test -f notyet && + test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol && + test "z$(GIT_CONFIG=notyet git config test.xyzzy)" = zrezrov + +' + +test_done diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh new file mode 100755 index 0000000000..bb5f30220a --- /dev/null +++ b/t/t1301-shared-repo.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# Copyright (c) 2007 Johannes Schindelin +# + +test_description='Test shared repository initialization' + +. ./test-lib.sh + +test_expect_success 'shared=all' ' + mkdir sub && + cd sub && + git init --shared=all && + test 2 = $(git config core.sharedrepository) +' + +test_expect_success 'update-server-info honors core.sharedRepository' ' + : > a1 && + git add a1 && + test_tick && + git commit -m a1 && + umask 0277 && + git update-server-info && + test 444 = $(stat -c %a .git/info/refs) +' + +test_done diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index d0aba2c2ae..c4c0dfaab1 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Shawn Pearce # -test_description='Test git-update-ref and basic ref logging' +test_description='Test git update-ref and basic ref logging' . ./test-lib.sh Z=0000000000000000000000000000000000000000 @@ -19,34 +19,34 @@ n=$n_dir/fixes test_expect_success \ "create $m" \ - "git-update-ref $m $A && + "git update-ref $m $A && test $A"' = $(cat .git/'"$m"')' test_expect_success \ "create $m" \ - "git-update-ref $m $B $A && + "git update-ref $m $B $A && test $B"' = $(cat .git/'"$m"')' rm -f .git/$m test_expect_success \ "fail to create $n" \ "touch .git/$n_dir - git-update-ref $n $A >out 2>err"' + git update-ref $n $A >out 2>err"' test $? != 0' rm -f .git/$n_dir out err test_expect_success \ "create $m (by HEAD)" \ - "git-update-ref HEAD $A && + "git update-ref HEAD $A && test $A"' = $(cat .git/'"$m"')' test_expect_success \ "create $m (by HEAD)" \ - "git-update-ref HEAD $B $A && + "git update-ref HEAD $B $A && test $B"' = $(cat .git/'"$m"')' rm -f .git/$m test_expect_failure \ '(not) create HEAD with old sha1' \ - "git-update-ref HEAD $A $B" + "git update-ref HEAD $A $B" test_expect_failure \ "(not) prior created .git/$m" \ "test -f .git/$m" @@ -54,10 +54,10 @@ rm -f .git/$m test_expect_success \ "create HEAD" \ - "git-update-ref HEAD $A" + "git update-ref HEAD $A" test_expect_failure \ '(not) change HEAD with wrong SHA1' \ - "git-update-ref HEAD $B $Z" + "git update-ref HEAD $B $Z" test_expect_failure \ "(not) changed .git/$m" \ "test $B"' = $(cat .git/'"$m"')' @@ -68,17 +68,17 @@ rm -f .git/$m test_expect_success \ "create $m (logged by touch)" \ 'GIT_COMMITTER_DATE="2005-05-26 23:30" \ - git-update-ref HEAD '"$A"' -m "Initial Creation" && + git update-ref HEAD '"$A"' -m "Initial Creation" && test '"$A"' = $(cat .git/'"$m"')' test_expect_success \ "update $m (logged by touch)" \ 'GIT_COMMITTER_DATE="2005-05-26 23:31" \ - git-update-ref HEAD'" $B $A "'-m "Switch" && + git update-ref HEAD'" $B $A "'-m "Switch" && test '"$B"' = $(cat .git/'"$m"')' test_expect_success \ "set $m (logged by touch)" \ 'GIT_COMMITTER_DATE="2005-05-26 23:41" \ - git-update-ref HEAD'" $A && + git update-ref HEAD'" $A && test $A"' = $(cat .git/'"$m"')' cat >expect <<EOF @@ -93,23 +93,23 @@ rm -rf .git/$m .git/logs expect test_expect_success \ 'enable core.logAllRefUpdates' \ - 'git-config core.logAllRefUpdates true && - test true = $(git-config --bool --get core.logAllRefUpdates)' + 'git config core.logAllRefUpdates true && + test true = $(git config --bool --get core.logAllRefUpdates)' test_expect_success \ "create $m (logged by config)" \ 'GIT_COMMITTER_DATE="2005-05-26 23:32" \ - git-update-ref HEAD'" $A "'-m "Initial Creation" && + git update-ref HEAD'" $A "'-m "Initial Creation" && test '"$A"' = $(cat .git/'"$m"')' test_expect_success \ "update $m (logged by config)" \ 'GIT_COMMITTER_DATE="2005-05-26 23:33" \ - git-update-ref HEAD'" $B $A "'-m "Switch" && + git update-ref HEAD'" $B $A "'-m "Switch" && test '"$B"' = $(cat .git/'"$m"')' test_expect_success \ "set $m (logged by config)" \ 'GIT_COMMITTER_DATE="2005-05-26 23:43" \ - git-update-ref HEAD '"$A && + git update-ref HEAD '"$A && test $A"' = $(cat .git/'"$m"')' cat >expect <<EOF @@ -122,7 +122,7 @@ test_expect_success \ 'diff expect .git/logs/$m' rm -f .git/$m .git/logs/$m expect -git-update-ref $m $D +git update-ref $m $D cat >.git/logs/$m <<EOF $C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500 $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500 @@ -136,49 +136,49 @@ ld="Thu, 26 May 2005 18:43:00 -0500" test_expect_success \ 'Query "master@{May 25 2005}" (before history)' \ 'rm -f o e - git-rev-parse --verify "master@{May 25 2005}" >o 2>e && + git rev-parse --verify "master@{May 25 2005}" >o 2>e && test '"$C"' = $(cat o) && test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"' test_expect_success \ "Query master@{2005-05-25} (before history)" \ 'rm -f o e - git-rev-parse --verify master@{2005-05-25} >o 2>e && + git rev-parse --verify master@{2005-05-25} >o 2>e && test '"$C"' = $(cat o) && echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"' test_expect_success \ 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \ 'rm -f o e - git-rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e && + git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e && test '"$C"' = $(cat o) && test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"' test_expect_success \ 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \ 'rm -f o e - git-rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e && + git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e && test '"$A"' = $(cat o) && test "" = "$(cat e)"' test_expect_success \ 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \ 'rm -f o e - git-rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e && + git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e && test '"$B"' = $(cat o) && test "warning: Log .git/logs/'"$m has gap after $gd"'." = "$(cat e)"' test_expect_success \ 'Query "master@{2005-05-26 23:38:00}" (middle of history)' \ 'rm -f o e - git-rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e && + git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e && test '"$Z"' = $(cat o) && test "" = "$(cat e)"' test_expect_success \ 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' \ 'rm -f o e - git-rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e && + git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e && test '"$E"' = $(cat o) && test "" = "$(cat e)"' test_expect_success \ 'Query "master@{2005-05-28}" (past end of history)' \ 'rm -f o e - git-rev-parse --verify "master@{2005-05-28}" >o 2>e && + git rev-parse --verify "master@{2005-05-28}" >o 2>e && test '"$D"' = $(cat o) && test "warning: Log .git/logs/'"$m unexpectedly ended on $ld"'." = "$(cat e)"' @@ -188,26 +188,26 @@ rm -f .git/$m .git/logs/$m expect test_expect_success \ 'creating initial files' \ 'echo TEST >F && - git-add F && + git add F && GIT_AUTHOR_DATE="2005-05-26 23:30" \ GIT_COMMITTER_DATE="2005-05-26 23:30" git-commit -m add -a && - h_TEST=$(git-rev-parse --verify HEAD) + h_TEST=$(git rev-parse --verify HEAD) echo The other day this did not work. >M && echo And then Bob told me how to fix it. >>M && echo OTHER >F && GIT_AUTHOR_DATE="2005-05-26 23:41" \ GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -F M -a && - h_OTHER=$(git-rev-parse --verify HEAD) && + h_OTHER=$(git rev-parse --verify HEAD) && echo FIXED >F && GIT_AUTHOR_DATE="2005-05-26 23:44" \ GIT_COMMITTER_DATE="2005-05-26 23:44" git-commit --amend && - h_FIXED=$(git-rev-parse --verify HEAD) && + h_FIXED=$(git rev-parse --verify HEAD) && echo TEST+FIXED >F && echo Merged initial commit and a later commit. >M && echo $h_TEST >.git/MERGE_HEAD && GIT_AUTHOR_DATE="2005-05-26 23:45" \ GIT_COMMITTER_DATE="2005-05-26 23:45" git-commit -F M && - h_MERGED=$(git-rev-parse --verify HEAD) + h_MERGED=$(git rev-parse --verify HEAD) rm -f M' cat >expect <<EOF @@ -222,13 +222,13 @@ test_expect_success \ unset h_TEST h_OTHER h_FIXED h_MERGED test_expect_success \ - 'git-cat-file blob master:F (expect OTHER)' \ - 'test OTHER = $(git-cat-file blob master:F)' + 'git cat-file blob master:F (expect OTHER)' \ + 'test OTHER = $(git cat-file blob master:F)' test_expect_success \ - 'git-cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \ - 'test TEST = $(git-cat-file blob "master@{2005-05-26 23:30}:F")' + 'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \ + 'test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F")' test_expect_success \ - 'git-cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \ - 'test OTHER = $(git-cat-file blob "master@{2005-05-26 23:42}:F")' + 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \ + 'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")' test_done diff --git a/t/t1420-lost-found.sh b/t/t1420-lost-found.sh new file mode 100755 index 0000000000..dc9e402c55 --- /dev/null +++ b/t/t1420-lost-found.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Copyright (c) 2007 Johannes E. Schindelin +# + +test_description='Test fsck --lost-found' +. ./test-lib.sh + +test_expect_success setup ' + git config core.logAllRefUpdates 0 && + : > file1 && + git add file1 && + test_tick && + git commit -m initial && + echo 1 > file1 && + echo 2 > file2 && + git add file1 file2 && + test_tick && + git commit -m second && + echo 3 > file3 && + git add file3 +' + +test_expect_success 'lost and found something' ' + git rev-parse HEAD > lost-commit && + git rev-parse :file3 > lost-other && + test_tick && + git reset --hard HEAD^ && + git fsck --lost-found && + test 2 = $(ls .git/lost-found/*/* | wc -l) && + test -f .git/lost-found/commit/$(cat lost-commit) && + test -f .git/lost-found/other/$(cat lost-other) +' + +test_done diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh new file mode 100755 index 0000000000..bea40cba8d --- /dev/null +++ b/t/t1500-rev-parse.sh @@ -0,0 +1,77 @@ +#!/bin/sh + +test_description='test git rev-parse' +. ./test-lib.sh + +test_rev_parse() { + name=$1 + shift + + test_expect_success "$name: is-bare-repository" \ + "test '$1' = \"\$(git rev-parse --is-bare-repository)\"" + shift + [ $# -eq 0 ] && return + + test_expect_success "$name: is-inside-git-dir" \ + "test '$1' = \"\$(git rev-parse --is-inside-git-dir)\"" + shift + [ $# -eq 0 ] && return + + test_expect_success "$name: is-inside-work-tree" \ + "test '$1' = \"\$(git rev-parse --is-inside-work-tree)\"" + shift + [ $# -eq 0 ] && return + + test_expect_success "$name: prefix" \ + "test '$1' = \"\$(git rev-parse --show-prefix)\"" + shift + [ $# -eq 0 ] && return +} + +test_rev_parse toplevel false false true '' + +cd .git || exit 1 +test_rev_parse .git/ true true false '' +cd objects || exit 1 +test_rev_parse .git/objects/ true true false '' +cd ../.. || exit 1 + +mkdir -p sub/dir || exit 1 +cd sub/dir || exit 1 +test_rev_parse subdirectory false false true sub/dir/ +cd ../.. || exit 1 + +git config core.bare true +test_rev_parse 'core.bare = true' true false false + +git config --unset core.bare +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 config core.bare false +test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true work/ + +git config core.bare true +test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false false '' + +git config --unset core.bare +test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true work/ + +mv ../.git ../repo.git || exit 1 +export GIT_DIR=../repo.git +export GIT_CONFIG="$(pwd)"/../repo.git/config + +git config core.bare false +test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true '' + +git config core.bare true +test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false '' + +git config --unset core.bare +test_rev_parse 'GIT_DIR=../repo.git, core.bare undefined' false false true '' + +test_done diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh new file mode 100755 index 0000000000..732216184f --- /dev/null +++ b/t/t1501-worktree.sh @@ -0,0 +1,106 @@ +#!/bin/sh + +test_description='test separate work tree' +. ./test-lib.sh + +test_rev_parse() { + name=$1 + shift + + test_expect_success "$name: is-bare-repository" \ + "test '$1' = \"\$(git rev-parse --is-bare-repository)\"" + shift + [ $# -eq 0 ] && return + + test_expect_success "$name: is-inside-git-dir" \ + "test '$1' = \"\$(git rev-parse --is-inside-git-dir)\"" + shift + [ $# -eq 0 ] && return + + test_expect_success "$name: is-inside-work-tree" \ + "test '$1' = \"\$(git rev-parse --is-inside-work-tree)\"" + shift + [ $# -eq 0 ] && return + + test_expect_success "$name: prefix" \ + "test '$1' = \"\$(git rev-parse --show-prefix)\"" + shift + [ $# -eq 0 ] && return +} + +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 +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 +test_rev_parse 'inside' false false true '' +cd sub/dir || exit 1 +export GIT_DIR=../../../repo.git +export 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 config core.worktree "$(pwd)/work" +test_rev_parse 'outside' false false false +cd work || exit 1 +test_rev_parse 'inside' false false true '' +cd sub/dir || exit 1 +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 config core.worktree non-existent +export GIT_WORK_TREE=work +test_rev_parse 'outside' false false false +cd work || exit 1 +export GIT_WORK_TREE=. +test_rev_parse 'inside' false false true '' +cd sub/dir || exit 1 +export 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 +test_rev_parse 'outside' false false false +cd repo.git || exit 1 +test_rev_parse 'in repo.git' false true false +cd objects || exit 1 +test_rev_parse 'in repo.git/objects' false true false +cd ../work || exit 1 +test_rev_parse 'in repo.git/work' false true true '' +cd sub/dir || exit 1 +test_rev_parse 'in repo.git/sub/dir' false true true sub/dir/ +cd ../../../.. || exit 1 + +test_expect_success 'repo finds its work tree' ' + (cd repo.git && + : > work/sub/dir/untracked && + test sub/dir/untracked = "$(git ls-files --others)") +' + +test_expect_success 'repo finds its work tree from work tree, too' ' + (cd repo.git/work/sub/dir && + : > tracked && + git --git-dir=../../.. add tracked && + cd ../../.. && + test sub/dir/tracked = "$(git ls-files)") +' + +test_done diff --git a/t/t2000-checkout-cache-clash.sh b/t/t2000-checkout-cache-clash.sh index 03ea4dece4..ac84335b0a 100755 --- a/t/t2000-checkout-cache-clash.sh +++ b/t/t2000-checkout-cache-clash.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-checkout-index test. +test_description='git checkout-index test. This test registers the following filesystem structure in the cache: @@ -16,7 +16,7 @@ And then tries to checkout in a work tree that has the following: path0/file0 - a file in a directory path1 - a file -The git-checkout-index command should fail when attempting to checkout +The git checkout-index command should fail when attempting to checkout path0, finding it is occupied by a directory, and path1/file1, finding path1 is occupied by a non-directory. With "-f" flag, it should remove the conflicting paths and succeed. @@ -28,8 +28,8 @@ mkdir path1 date >path1/file1 test_expect_success \ - 'git-update-index --add various paths.' \ - 'git-update-index --add path0 path1/file1' + 'git update-index --add various paths.' \ + 'git update-index --add path0 path1/file1' rm -fr path0 path1 mkdir path0 @@ -37,17 +37,15 @@ date >path0/file0 date >path1 test_expect_failure \ - 'git-checkout-index without -f should fail on conflicting work tree.' \ - 'git-checkout-index -a' + 'git checkout-index without -f should fail on conflicting work tree.' \ + 'git checkout-index -a' test_expect_success \ - 'git-checkout-index with -f should succeed.' \ - 'git-checkout-index -f -a' + 'git checkout-index with -f should succeed.' \ + 'git checkout-index -f -a' test_expect_success \ - 'git-checkout-index conflicting paths.' \ + 'git checkout-index conflicting paths.' \ 'test -f path0 && test -d path1 && test -f path1/file1' test_done - - diff --git a/t/t2001-checkout-cache-clash.sh b/t/t2001-checkout-cache-clash.sh index 0dcab8f1de..ef007532b1 100755 --- a/t/t2001-checkout-cache-clash.sh +++ b/t/t2001-checkout-cache-clash.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-checkout-index test. +test_description='git checkout-index test. This test registers the following filesystem structure in the cache: @@ -26,46 +26,46 @@ show_files() { find path? -ls | sed -e 's/^[0-9]* * [0-9]* * \([-bcdl]\)[^ ]* *[0-9]* *[^ ]* *[^ ]* *[0-9]* [A-Z][a-z][a-z] [0-9][0-9] [^ ]* /fs: \1 /' # what's in the cache, just mode and name - git-ls-files --stage | + git ls-files --stage | sed -e 's/^\([0-9]*\) [0-9a-f]* [0-3] /ca: \1 /' # what's in the tree, just mode and name. - git-ls-tree -r "$1" | + git ls-tree -r "$1" | sed -e 's/^\([0-9]*\) [^ ]* [0-9a-f]* /tr: \1 /' } mkdir path0 date >path0/file0 test_expect_success \ - 'git-update-index --add path0/file0' \ - 'git-update-index --add path0/file0' + 'git update-index --add path0/file0' \ + 'git update-index --add path0/file0' test_expect_success \ - 'writing tree out with git-write-tree' \ - 'tree1=$(git-write-tree)' + 'writing tree out with git write-tree' \ + 'tree1=$(git write-tree)' test_debug 'show_files $tree1' mkdir path1 date >path1/file1 test_expect_success \ - 'git-update-index --add path1/file1' \ - 'git-update-index --add path1/file1' + 'git update-index --add path1/file1' \ + 'git update-index --add path1/file1' test_expect_success \ - 'writing tree out with git-write-tree' \ - 'tree2=$(git-write-tree)' + 'writing tree out with git write-tree' \ + 'tree2=$(git write-tree)' test_debug 'show_files $tree2' rm -fr path1 test_expect_success \ 'read previously written tree and checkout.' \ - 'git-read-tree -m $tree1 && git-checkout-index -f -a' + 'git read-tree -m $tree1 && git checkout-index -f -a' test_debug 'show_files $tree1' ln -s path0 path1 test_expect_success \ - 'git-update-index --add a symlink.' \ - 'git-update-index --add path1' + 'git update-index --add a symlink.' \ + 'git update-index --add path1' test_expect_success \ - 'writing tree out with git-write-tree' \ - 'tree3=$(git-write-tree)' + 'writing tree out with git write-tree' \ + 'tree3=$(git write-tree)' test_debug 'show_files $tree3' # Morten says "Got that?" here. @@ -73,7 +73,7 @@ test_debug 'show_files $tree3' test_expect_success \ 'read previously written tree and checkout.' \ - 'git-read-tree $tree2 && git-checkout-index -f -a' + 'git read-tree $tree2 && git checkout-index -f -a' test_debug 'show_files $tree2' test_expect_success \ @@ -84,4 +84,3 @@ test_expect_success \ test ! -h path1/file1 && test -f path1/file1' test_done - diff --git a/t/t2002-checkout-cache-u.sh b/t/t2002-checkout-cache-u.sh index 4352ddb1cb..f7a0055920 100755 --- a/t/t2002-checkout-cache-u.sh +++ b/t/t2002-checkout-cache-u.sh @@ -3,31 +3,31 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-checkout-index -u test. +test_description='git checkout-index -u test. -With -u flag, git-checkout-index internally runs the equivalent of -git-update-index --refresh on the checked out entry.' +With -u flag, git checkout-index internally runs the equivalent of +git update-index --refresh on the checked out entry.' . ./test-lib.sh test_expect_success \ 'preparation' ' echo frotz >path0 && -git-update-index --add path0 && -t=$(git-write-tree)' +git update-index --add path0 && +t=$(git write-tree)' test_expect_failure \ -'without -u, git-checkout-index smudges stat information.' ' +'without -u, git checkout-index smudges stat information.' ' rm -f path0 && -git-read-tree $t && -git-checkout-index -f -a && -git-diff-files | diff - /dev/null' +git read-tree $t && +git checkout-index -f -a && +git diff-files | diff - /dev/null' test_expect_success \ -'with -u, git-checkout-index picks up stat information from new files.' ' +'with -u, git checkout-index picks up stat information from new files.' ' rm -f path0 && -git-read-tree $t && -git-checkout-index -u -f -a && -git-diff-files | diff - /dev/null' +git read-tree $t && +git checkout-index -u -f -a && +git diff-files | diff - /dev/null' test_done diff --git a/t/t2003-checkout-cache-mkdir.sh b/t/t2003-checkout-cache-mkdir.sh index f9bc90aee4..71894b3743 100755 --- a/t/t2003-checkout-cache-mkdir.sh +++ b/t/t2003-checkout-cache-mkdir.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-checkout-index --prefix test. +test_description='git checkout-index --prefix test. This test makes sure that --prefix option works as advertised, and also verifies that such leading path may contain symlinks, unlike @@ -17,14 +17,14 @@ test_expect_success \ 'mkdir path1 && echo frotz >path0 && echo rezrov >path1/file1 && - git-update-index --add path0 path1/file1' + git update-index --add path0 path1/file1' test_expect_success \ 'have symlink in place where dir is expected.' \ 'rm -fr path0 path1 && mkdir path2 && ln -s path2 path1 && - git-checkout-index -f -a && + git checkout-index -f -a && test ! -h path1 && test -d path1 && test -f path1/file1 && test ! -f path2/file1' @@ -32,7 +32,7 @@ test_expect_success \ 'use --prefix=path2/' \ 'rm -fr path0 path1 path2 && mkdir path2 && - git-checkout-index --prefix=path2/ -f -a && + git checkout-index --prefix=path2/ -f -a && test -f path2/path0 && test -f path2/path1/file1 && test ! -f path0 && @@ -41,7 +41,7 @@ test_expect_success \ test_expect_success \ 'use --prefix=tmp-' \ 'rm -fr path0 path1 path2 tmp* && - git-checkout-index --prefix=tmp- -f -a && + git checkout-index --prefix=tmp- -f -a && test -f tmp-path0 && test -f tmp-path1/file1 && test ! -f path0 && @@ -52,7 +52,7 @@ test_expect_success \ 'rm -fr path0 path1 path2 tmp* && echo nitfol >tmp-path1 && mkdir tmp-path0 && - git-checkout-index --prefix=tmp- -f -a && + git checkout-index --prefix=tmp- -f -a && test -f tmp-path0 && test -f tmp-path1/file1 && test ! -f path0 && @@ -64,7 +64,7 @@ test_expect_success \ 'rm -fr path0 path1 path2 tmp* && mkdir tmp1 tmp1/orary && ln -s tmp1 tmp && - git-checkout-index --prefix=tmp/orary/ -f -a && + git checkout-index --prefix=tmp/orary/ -f -a && test -d tmp1/orary && test -f tmp1/orary/path0 && test -f tmp1/orary/path1/file1 && @@ -76,7 +76,7 @@ test_expect_success \ 'rm -fr path0 path1 path2 tmp* && mkdir tmp1 && ln -s tmp1 tmp && - git-checkout-index --prefix=tmp/orary- -f -a && + git checkout-index --prefix=tmp/orary- -f -a && test -f tmp1/orary-path0 && test -f tmp1/orary-path1/file1 && test -h tmp' @@ -87,7 +87,7 @@ test_expect_success \ 'rm -fr path0 path1 path2 tmp* && mkdir tmp1 && ln -s tmp1 tmp-path1 && - git-checkout-index --prefix=tmp- -f -a && + git checkout-index --prefix=tmp- -f -a && test -f tmp-path0 && test ! -h tmp-path1 && test -d tmp-path1 && diff --git a/t/t2004-checkout-cache-temp.sh b/t/t2004-checkout-cache-temp.sh index c100959cad..39133b8c7a 100755 --- a/t/t2004-checkout-cache-temp.sh +++ b/t/t2004-checkout-cache-temp.sh @@ -3,9 +3,9 @@ # Copyright (c) 2006 Shawn Pearce # -test_description='git-checkout-index --temp test. +test_description='git checkout-index --temp test. -With --temp flag, git-checkout-index writes to temporary merge files +With --temp flag, git checkout-index writes to temporary merge files rather than the tracked path.' . ./test-lib.sh @@ -18,28 +18,28 @@ echo tree1path1 >path1 && echo tree1path3 >path3 && echo tree1path4 >path4 && echo tree1asubdir/path5 >asubdir/path5 && -git-update-index --add path0 path1 path3 path4 asubdir/path5 && -t1=$(git-write-tree) && +git update-index --add path0 path1 path3 path4 asubdir/path5 && +t1=$(git write-tree) && rm -f path* .merge_* out .git/index && echo tree2path0 >path0 && echo tree2path1 >path1 && echo tree2path2 >path2 && echo tree2path4 >path4 && -git-update-index --add path0 path1 path2 path4 && -t2=$(git-write-tree) && +git update-index --add path0 path1 path2 path4 && +t2=$(git write-tree) && rm -f path* .merge_* out .git/index && echo tree2path0 >path0 && echo tree3path1 >path1 && echo tree3path2 >path2 && echo tree3path3 >path3 && -git-update-index --add path0 path1 path2 path3 && -t3=$(git-write-tree)' +git update-index --add path0 path1 path2 path3 && +t3=$(git write-tree)' test_expect_success \ 'checkout one stage 0 to temporary file' ' rm -f path* .merge_* out .git/index && -git-read-tree $t1 && -git-checkout-index --temp -- path1 >out && +git read-tree $t1 && +git checkout-index --temp -- path1 >out && test $(wc -l <out) = 1 && test $(cut "-d " -f2 out) = path1 && p=$(cut "-d " -f1 out) && @@ -49,8 +49,8 @@ test $(cat $p) = tree1path1' test_expect_success \ 'checkout all stage 0 to temporary files' ' rm -f path* .merge_* out .git/index && -git-read-tree $t1 && -git-checkout-index -a --temp >out && +git read-tree $t1 && +git checkout-index -a --temp >out && test $(wc -l <out) = 5 && for f in path0 path1 path3 path4 asubdir/path5 do @@ -63,12 +63,12 @@ done' test_expect_success \ 'prepare 3-way merge' ' rm -f path* .merge_* out .git/index && -git-read-tree -m $t1 $t2 $t3' +git read-tree -m $t1 $t2 $t3' test_expect_success \ 'checkout one stage 2 to temporary file' ' rm -f path* .merge_* out && -git-checkout-index --stage=2 --temp -- path1 >out && +git checkout-index --stage=2 --temp -- path1 >out && test $(wc -l <out) = 1 && test $(cut "-d " -f2 out) = path1 && p=$(cut "-d " -f1 out) && @@ -78,7 +78,7 @@ test $(cat $p) = tree2path1' test_expect_success \ 'checkout all stage 2 to temporary files' ' rm -f path* .merge_* out && -git-checkout-index --all --stage=2 --temp >out && +git checkout-index --all --stage=2 --temp >out && test $(wc -l <out) = 3 && for f in path1 path2 path4 do @@ -91,13 +91,13 @@ done' test_expect_success \ 'checkout all stages/one file to nothing' ' rm -f path* .merge_* out && -git-checkout-index --stage=all --temp -- path0 >out && +git checkout-index --stage=all --temp -- path0 >out && test $(wc -l <out) = 0' test_expect_success \ 'checkout all stages/one file to temporary files' ' rm -f path* .merge_* out && -git-checkout-index --stage=all --temp -- path1 >out && +git checkout-index --stage=all --temp -- path1 >out && test $(wc -l <out) = 1 && test $(cut "-d " -f2 out) = path1 && cut "-d " -f1 out | (read s1 s2 s3 && @@ -111,7 +111,7 @@ test $(cat $s3) = tree3path1)' test_expect_success \ 'checkout some stages/one file to temporary files' ' rm -f path* .merge_* out && -git-checkout-index --stage=all --temp -- path2 >out && +git checkout-index --stage=all --temp -- path2 >out && test $(wc -l <out) = 1 && test $(cut "-d " -f2 out) = path2 && cut "-d " -f1 out | (read s1 s2 s3 && @@ -124,7 +124,7 @@ test $(cat $s3) = tree3path2)' test_expect_success \ 'checkout all stages/all files to temporary files' ' rm -f path* .merge_* out && -git-checkout-index -a --stage=all --temp >out && +git checkout-index -a --stage=all --temp >out && test $(wc -l <out) = 5' test_expect_success \ @@ -184,7 +184,7 @@ test $(cat $s1) = tree1asubdir/path5)' test_expect_success \ 'checkout --temp within subdir' ' (cd asubdir && - git-checkout-index -a --stage=all >out && + git checkout-index -a --stage=all >out && test $(wc -l <out) = 1 && test $(grep path5 out | cut "-d " -f2) = path5 && grep path5 out | cut "-d " -f1 | (read s1 s2 s3 && @@ -198,11 +198,11 @@ test_expect_success \ 'checkout --temp symlink' ' rm -f path* .merge_* out .git/index && ln -s b a && -git-update-index --add a && -t4=$(git-write-tree) && +git update-index --add a && +t4=$(git write-tree) && rm -f .git/index && -git-read-tree $t4 && -git-checkout-index --temp -a >out && +git read-tree $t4 && +git checkout-index --temp -a >out && test $(wc -l <out) = 1 && test $(cut "-d " -f2 out) = a && p=$(cut "-d " -f1 out) && diff --git a/t/t2005-checkout-index-symlinks.sh b/t/t2005-checkout-index-symlinks.sh index e34a515333..a84c5a6af9 100755 --- a/t/t2005-checkout-index-symlinks.sh +++ b/t/t2005-checkout-index-symlinks.sh @@ -3,22 +3,22 @@ # Copyright (c) 2007 Johannes Sixt # -test_description='git-checkout-index on filesystem w/o symlinks test. +test_description='git checkout-index on filesystem w/o symlinks test. -This tests that git-checkout-index creates a symbolic link as a plain +This tests that git checkout-index creates a symbolic link as a plain file if core.symlinks is false.' . ./test-lib.sh test_expect_success \ 'preparation' ' -git-config core.symlinks false && +git config core.symlinks false && l=$(echo -n file | git-hash-object -t blob -w --stdin) && -echo "120000 $l symlink" | git-update-index --index-info' +echo "120000 $l symlink" | git update-index --index-info' test_expect_success \ 'the checked-out symlink must be a file' ' -git-checkout-index symlink && +git checkout-index symlink && test -f symlink' test_expect_success \ diff --git a/t/t2100-update-cache-badpath.sh b/t/t2100-update-cache-badpath.sh index 5bc0a3bed3..04a1ed1a6b 100755 --- a/t/t2100-update-cache-badpath.sh +++ b/t/t2100-update-cache-badpath.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-update-index nonsense-path test. +test_description='git update-index nonsense-path test. This test creates the following structure in the cache: @@ -12,7 +12,7 @@ This test creates the following structure in the cache: path2/file2 - a file in a directory path3/file3 - a file in a directory -and tries to git-update-index --add the following: +and tries to git update-index --add the following: path0/file0 - a file in a directory path1/file1 - a file in a directory @@ -31,8 +31,8 @@ date >path2/file2 date >path3/file3 test_expect_success \ - 'git-update-index --add to add various paths.' \ - 'git-update-index --add -- path0 path1 path2/file2 path3/file3' + 'git update-index --add to add various paths.' \ + 'git update-index --add -- path0 path1 path2/file2 path3/file3' rm -fr path? @@ -45,7 +45,7 @@ date >path1/file1 for p in path0/file0 path1/file1 path2 path3 do test_expect_failure \ - "git-update-index to add conflicting path $p should fail." \ - "git-update-index --add -- $p" + "git update-index to add conflicting path $p should fail." \ + "git update-index --add -- $p" done test_done diff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh index a78ea7f0b0..59b560bfdf 100755 --- a/t/t2101-update-index-reupdate.sh +++ b/t/t2101-update-index-reupdate.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Junio C Hamano # -test_description='git-update-index --again test. +test_description='git update-index --again test. ' . ./test-lib.sh @@ -15,29 +15,29 @@ 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 && + git update-index --add file1 file2 && + git ls-files -s >current && cmp current expected' test_expect_success 'update-index --again' \ 'rm -f file1 && echo hello everybody >file2 && - if git-update-index --again + if git update-index --again then echo should have refused to remove file1 exit 1 else echo happy - failed as expected fi && - git-ls-files -s >current && + git ls-files -s >current && 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 && + 'git update-index --remove --again && + git ls-files -s >current && cmp current expected' test_expect_success 'first commit' 'git-commit -m initial' @@ -50,11 +50,11 @@ test_expect_success 'update-index again' \ 'mkdir -p dir1 && echo hello world >dir1/file3 && echo goodbye people >file2 && - git-update-index --add file2 dir1/file3 && + git update-index --add file2 dir1/file3 && echo hello everybody >file2 echo happy >dir1/file3 && - git-update-index --again && - git-ls-files -s >current && + git update-index --again && + git ls-files -s >current && cmp current expected' cat > expected <<\EOF @@ -65,9 +65,9 @@ test_expect_success 'update-index --update from subdir' \ 'echo not so happy >file2 && cd dir1 && cat ../file2 >file3 && - git-update-index --again && + git update-index --again && cd .. && - git-ls-files -s >current && + git ls-files -s >current && cmp current expected' cat > expected <<\EOF @@ -77,8 +77,8 @@ 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 && + git update-index --again dir1/ && + git ls-files -s >current && cmp current expected' test_done diff --git a/t/t2102-update-index-symlinks.sh b/t/t2102-update-index-symlinks.sh index 969ef891d3..19d0894d26 100755 --- a/t/t2102-update-index-symlinks.sh +++ b/t/t2102-update-index-symlinks.sh @@ -3,29 +3,29 @@ # Copyright (c) 2007 Johannes Sixt # -test_description='git-update-index on filesystem w/o symlinks test. +test_description='git update-index on filesystem w/o symlinks test. -This tests that git-update-index keeps the symbolic link property +This tests that git update-index keeps the symbolic link property even if a plain file is in the working tree if core.symlinks is false.' . ./test-lib.sh test_expect_success \ 'preparation' ' -git-config core.symlinks false && +git config core.symlinks false && l=$(echo -n file | git-hash-object -t blob -w --stdin) && -echo "120000 $l symlink" | git-update-index --index-info' +echo "120000 $l symlink" | git update-index --index-info' test_expect_success \ 'modify the symbolic link' ' echo -n new-file > symlink && -git-update-index symlink' +git update-index symlink' test_expect_success \ 'the index entry must still be a symbolic link' ' -case "`git-ls-files --stage --cached symlink`" in +case "`git ls-files --stage --cached symlink`" in 120000" "*symlink) echo ok;; -*) echo fail; git-ls-files --stage --cached symlink; (exit 1);; +*) echo fail; git ls-files --stage --cached symlink; (exit 1);; esac' test_done diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 83005e70d0..0a703af149 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-add -u with path limiting +test_description='git add -u with path limiting This test creates a working tree state with three files: @@ -8,7 +8,7 @@ This test creates a working tree state with three files: dir/sub (previously committed, modified) dir/other (untracked) -and issues a git-add -u with path limiting on "dir" to add +and issues a git add -u with path limiting on "dir" to add only the updates to dir/sub.' . ./test-lib.sh @@ -17,22 +17,22 @@ test_expect_success 'setup' ' echo initial >top && mkdir dir && echo initial >dir/sub && -git-add dir/sub top && +git add dir/sub top && git-commit -m initial && echo changed >top && echo changed >dir/sub && echo other >dir/other ' -test_expect_success 'update' 'git-add -u dir' +test_expect_success 'update' 'git add -u dir' test_expect_success 'update touched correct path' \ - 'test "`git-diff-files --name-status dir/sub`" = ""' + 'test "`git diff-files --name-status dir/sub`" = ""' test_expect_success 'update did not touch other tracked files' \ - 'test "`git-diff-files --name-status top`" = "M top"' + 'test "`git diff-files --name-status top`" = "M top"' test_expect_success 'update did not touch untracked files' \ - 'test "`git-diff-files --name-status dir/other`" = ""' + 'test "`git diff-files --name-status dir/other`" = ""' test_done diff --git a/t/t3000-ls-files-others.sh b/t/t3000-ls-files-others.sh index adcbe03d56..bc0a351392 100755 --- a/t/t3000-ls-files-others.sh +++ b/t/t3000-ls-files-others.sh @@ -3,9 +3,9 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-ls-files test (--others should pick up symlinks). +test_description='git ls-files test (--others should pick up symlinks). -This test runs git-ls-files --others with the following on the +This test runs git ls-files --others with the following on the filesystem. path0 - a file @@ -23,7 +23,7 @@ date >path2/file2 date >path2-junk date >path3/file3 date >path3-junk -git-update-index --add path3-junk path3/file3 +git update-index --add path3-junk path3/file3 cat >expected1 <<EOF expected1 @@ -37,20 +37,20 @@ EOF sed -e 's|path2/file2|path2/|' <expected1 >expected2 test_expect_success \ - 'git-ls-files --others to show output.' \ - 'git-ls-files --others >output' + 'git ls-files --others to show output.' \ + 'git ls-files --others >output' test_expect_success \ - 'git-ls-files --others should pick up symlinks.' \ + 'git ls-files --others should pick up symlinks.' \ 'diff output expected1' test_expect_success \ - 'git-ls-files --others --directory to show output.' \ - 'git-ls-files --others --directory >output' + 'git ls-files --others --directory to show output.' \ + 'git ls-files --others --directory >output' test_expect_success \ - 'git-ls-files --others --directory should not get confused.' \ + 'git ls-files --others --directory should not get confused.' \ 'diff output expected2' test_done diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index fcfcfbba7d..ae0639d8f3 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -3,9 +3,9 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-ls-files --others --exclude +test_description='git ls-files --others --exclude -This test runs git-ls-files --others and tests --exclude patterns. +This test runs git ls-files --others and tests --exclude patterns. ' . ./test-lib.sh @@ -59,8 +59,8 @@ echo '!*.2 !*.8' >one/two/.gitignore test_expect_success \ - 'git-ls-files --others with various exclude options.' \ - 'git-ls-files --others \ + 'git ls-files --others with various exclude options.' \ + 'git ls-files --others \ --exclude=\*.6 \ --exclude-per-directory=.gitignore \ --exclude-from=.git/ignore \ @@ -71,8 +71,8 @@ test_expect_success \ printf '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore test_expect_success \ - 'git-ls-files --others with \r\n line endings.' \ - 'git-ls-files --others \ + 'git ls-files --others with \r\n line endings.' \ + 'git ls-files --others \ --exclude=\*.6 \ --exclude-per-directory=.gitignore \ --exclude-from=.git/ignore \ @@ -84,9 +84,9 @@ cat > excludes-file << EOF e* EOF -git-config core.excludesFile excludes-file +git config core.excludesFile excludes-file -git-runstatus | grep "^# " > output +git runstatus | grep "^# " > output cat > expect << EOF # .gitignore diff --git a/t/t3002-ls-files-dashpath.sh b/t/t3002-ls-files-dashpath.sh index cc8967d76b..8687a01d2b 100755 --- a/t/t3002-ls-files-dashpath.sh +++ b/t/t3002-ls-files-dashpath.sh @@ -3,9 +3,9 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-ls-files test (-- to terminate the path list). +test_description='git ls-files test (-- to terminate the path list). -This test runs git-ls-files --others with the following on the +This test runs git ls-files --others with the following on the filesystem. path0 - a file @@ -21,8 +21,8 @@ test_expect_success \ echo frotz >./--' test_expect_success \ - 'git-ls-files without path restriction.' \ - 'git-ls-files --others >output && + 'git ls-files without path restriction.' \ + 'git ls-files --others >output && git diff output - <<EOF -- -foo @@ -32,32 +32,32 @@ EOF ' test_expect_success \ - 'git-ls-files with path restriction.' \ - 'git-ls-files --others path0 >output && + 'git ls-files with path restriction.' \ + 'git ls-files --others path0 >output && git diff output - <<EOF path0 EOF ' test_expect_success \ - 'git-ls-files with path restriction with --.' \ - 'git-ls-files --others -- path0 >output && + 'git ls-files with path restriction with --.' \ + 'git ls-files --others -- path0 >output && git diff output - <<EOF path0 EOF ' test_expect_success \ - 'git-ls-files with path restriction with -- --.' \ - 'git-ls-files --others -- -- >output && + 'git ls-files with path restriction with -- --.' \ + 'git ls-files --others -- -- >output && git diff output - <<EOF -- EOF ' test_expect_success \ - 'git-ls-files with no path restriction.' \ - 'git-ls-files --others -- >output && + 'git ls-files with no path restriction.' \ + 'git ls-files --others -- >output && git diff output - <<EOF -- -foo diff --git a/t/t3010-ls-files-killed-modified.sh b/t/t3010-ls-files-killed-modified.sh index 5fc1976711..ec14040637 100755 --- a/t/t3010-ls-files-killed-modified.sh +++ b/t/t3010-ls-files-killed-modified.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-ls-files -k and -m flags test. +test_description='git ls-files -k and -m flags test. This test prepares the following in the cache: @@ -22,7 +22,7 @@ and the following on the filesystem: path5 - a symlink path6/file6 - a file in a directory -git-ls-files -k should report that existing filesystem +git ls-files -k should report that existing filesystem objects except path4, path5 and path6/file6 to be killed. Also for modification test, the cache and working tree have: @@ -47,8 +47,8 @@ date >path8 : >path9 date >path10 test_expect_success \ - 'git-update-index --add to add various paths.' \ - "git-update-index --add -- path0 path1 path?/file? path7 path8 path9 path10" + 'git update-index --add to add various paths.' \ + "git update-index --add -- path0 path1 path?/file? path7 path8 path9 path10" rm -fr path? ;# leave path10 alone date >path2 @@ -64,8 +64,8 @@ date >path7 touch path10 test_expect_success \ - 'git-ls-files -k to show killed files.' \ - 'git-ls-files -k >.output' + 'git ls-files -k to show killed files.' \ + 'git ls-files -k >.output' cat >.expected <<EOF path0/file0 path1/file1 @@ -74,12 +74,12 @@ path3 EOF test_expect_success \ - 'validate git-ls-files -k output.' \ + 'validate git ls-files -k output.' \ 'diff .output .expected' test_expect_success \ - 'git-ls-files -m to show modified files.' \ - 'git-ls-files -m >.output' + 'git ls-files -m to show modified files.' \ + 'git ls-files -m >.output' cat >.expected <<EOF path0 path1 @@ -90,7 +90,7 @@ path8 EOF test_expect_success \ - 'validate git-ls-files -m output.' \ + 'validate git ls-files -m output.' \ 'diff .output .expected' test_done diff --git a/t/t3020-ls-files-error-unmatch.sh b/t/t3020-ls-files-error-unmatch.sh index d55559e553..c83f820ad2 100755 --- a/t/t3020-ls-files-error-unmatch.sh +++ b/t/t3020-ls-files-error-unmatch.sh @@ -3,25 +3,25 @@ # Copyright (c) 2006 Carl D. Worth # -test_description='git-ls-files test for --error-unmatch option +test_description='git ls-files test for --error-unmatch option -This test runs git-ls-files --error-unmatch to ensure it correctly +This test runs git ls-files --error-unmatch to ensure it correctly returns an error when a non-existent path is provided on the command line. ' . ./test-lib.sh touch foo bar -git-update-index --add foo bar +git update-index --add foo bar git-commit -m "add foo bar" test_expect_failure \ - 'git-ls-files --error-unmatch should fail with unmatched path.' \ - 'git-ls-files --error-unmatch foo bar-does-not-match' + 'git ls-files --error-unmatch should fail with unmatched path.' \ + 'git ls-files --error-unmatch foo bar-does-not-match' test_expect_success \ - 'git-ls-files --error-unmatch should succeed eith matched paths.' \ - 'git-ls-files --error-unmatch foo bar' + 'git ls-files --error-unmatch should succeed eith matched paths.' \ + 'git ls-files --error-unmatch foo bar' test_done 1 diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index 86ee2b0bd3..607f57ff94 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -525,4 +525,3 @@ test_expect_success 'reset and bind merge' ' ' test_done - diff --git a/t/t3100-ls-tree-restrict.sh b/t/t3100-ls-tree-restrict.sh index e10749245b..46427e3f36 100755 --- a/t/t3100-ls-tree-restrict.sh +++ b/t/t3100-ls-tree-restrict.sh @@ -3,9 +3,9 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-ls-tree test. +test_description='git ls-tree test. -This test runs git-ls-tree with the following in a tree. +This test runs git ls-tree with the following in a tree. path0 - a file path1 - a symlink @@ -27,8 +27,8 @@ test_expect_success \ ln -s ../path1 path2/bazbo && echo Mi >path2/baz/b && find path? \( -type f -o -type l \) -print | - xargs git-update-index --add && - tree=`git-write-tree` && + xargs git update-index --add && + tree=`git write-tree` && echo $tree' _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' @@ -40,7 +40,7 @@ test_output () { test_expect_success \ 'ls-tree plain' \ - 'git-ls-tree $tree >current && + 'git ls-tree $tree >current && cat >expected <<\EOF && 100644 blob X path0 120000 blob X path1 @@ -50,7 +50,7 @@ EOF test_expect_success \ 'ls-tree recursive' \ - 'git-ls-tree -r $tree >current && + 'git ls-tree -r $tree >current && cat >expected <<\EOF && 100644 blob X path0 120000 blob X path1 @@ -62,7 +62,7 @@ EOF test_expect_success \ 'ls-tree recursive with -t' \ - 'git-ls-tree -r -t $tree >current && + 'git ls-tree -r -t $tree >current && cat >expected <<\EOF && 100644 blob X path0 120000 blob X path1 @@ -76,7 +76,7 @@ EOF test_expect_success \ 'ls-tree recursive with -d' \ - 'git-ls-tree -r -d $tree >current && + 'git ls-tree -r -d $tree >current && cat >expected <<\EOF && 040000 tree X path2 040000 tree X path2/baz @@ -85,7 +85,7 @@ EOF test_expect_success \ 'ls-tree filtered with path' \ - 'git-ls-tree $tree path >current && + 'git ls-tree $tree path >current && cat >expected <<\EOF && EOF test_output' @@ -95,7 +95,7 @@ EOF # they are shown in canonical order. test_expect_success \ 'ls-tree filtered with path1 path0' \ - 'git-ls-tree $tree path1 path0 >current && + 'git ls-tree $tree path1 path0 >current && cat >expected <<\EOF && 100644 blob X path0 120000 blob X path1 @@ -104,7 +104,7 @@ EOF test_expect_success \ 'ls-tree filtered with path0/' \ - 'git-ls-tree $tree path0/ >current && + 'git ls-tree $tree path0/ >current && cat >expected <<\EOF && EOF test_output' @@ -113,7 +113,7 @@ EOF # with pathspec semantics it shows only path2 test_expect_success \ 'ls-tree filtered with path2' \ - 'git-ls-tree $tree path2 >current && + 'git ls-tree $tree path2 >current && cat >expected <<\EOF && 040000 tree X path2 EOF @@ -122,7 +122,7 @@ EOF # ... and path2/ shows the children. test_expect_success \ 'ls-tree filtered with path2/' \ - 'git-ls-tree $tree path2/ >current && + 'git ls-tree $tree path2/ >current && cat >expected <<\EOF && 040000 tree X path2/baz 120000 blob X path2/bazbo @@ -134,7 +134,7 @@ EOF # path2/baz test_expect_success \ 'ls-tree filtered with path2/baz' \ - 'git-ls-tree $tree path2/baz >current && + 'git ls-tree $tree path2/baz >current && cat >expected <<\EOF && 040000 tree X path2/baz EOF @@ -142,14 +142,14 @@ EOF test_expect_success \ 'ls-tree filtered with path2/bak' \ - 'git-ls-tree $tree path2/bak >current && + 'git ls-tree $tree path2/bak >current && cat >expected <<\EOF && EOF test_output' test_expect_success \ 'ls-tree -t filtered with path2/bak' \ - 'git-ls-tree -t $tree path2/bak >current && + 'git ls-tree -t $tree path2/bak >current && cat >expected <<\EOF && 040000 tree X path2 EOF diff --git a/t/t3101-ls-tree-dirname.sh b/t/t3101-ls-tree-dirname.sh index 087929a4bf..39fe2676dc 100755 --- a/t/t3101-ls-tree-dirname.sh +++ b/t/t3101-ls-tree-dirname.sh @@ -4,9 +4,9 @@ # Copyright (c) 2005 Robert Fitzsimons # -test_description='git-ls-tree directory and filenames handling. +test_description='git ls-tree directory and filenames handling. -This test runs git-ls-tree with the following in a tree. +This test runs git ls-tree with the following in a tree. 1.txt - a file 2.txt - a file @@ -35,8 +35,8 @@ test_expect_success \ echo 111 >path3/1.txt && echo 222 >path3/2.txt && find *.txt path* \( -type f -o -type l \) -print | - xargs git-update-index --add && - tree=`git-write-tree` && + xargs git update-index --add && + tree=`git write-tree` && echo $tree' _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' @@ -48,7 +48,7 @@ test_output () { test_expect_success \ 'ls-tree plain' \ - 'git-ls-tree $tree >current && + 'git ls-tree $tree >current && cat >expected <<\EOF && 100644 blob X 1.txt 100644 blob X 2.txt @@ -62,7 +62,7 @@ EOF # Recursive does not show tree nodes anymore... test_expect_success \ 'ls-tree recursive' \ - 'git-ls-tree -r $tree >current && + 'git ls-tree -r $tree >current && cat >expected <<\EOF && 100644 blob X 1.txt 100644 blob X 2.txt @@ -76,7 +76,7 @@ EOF test_expect_success \ 'ls-tree filter 1.txt' \ - 'git-ls-tree $tree 1.txt >current && + 'git ls-tree $tree 1.txt >current && cat >expected <<\EOF && 100644 blob X 1.txt EOF @@ -84,7 +84,7 @@ EOF test_expect_success \ 'ls-tree filter path1/b/c/1.txt' \ - 'git-ls-tree $tree path1/b/c/1.txt >current && + 'git ls-tree $tree path1/b/c/1.txt >current && cat >expected <<\EOF && 100644 blob X path1/b/c/1.txt EOF @@ -92,7 +92,7 @@ EOF test_expect_success \ 'ls-tree filter all 1.txt files' \ - 'git-ls-tree $tree 1.txt path0/a/b/c/1.txt path1/b/c/1.txt path2/1.txt path3/1.txt >current && + 'git ls-tree $tree 1.txt path0/a/b/c/1.txt path1/b/c/1.txt path2/1.txt path3/1.txt >current && cat >expected <<\EOF && 100644 blob X 1.txt 100644 blob X path0/a/b/c/1.txt @@ -107,7 +107,7 @@ EOF # it behaves as if path0/a/b/c, path1/b/c, path2 and path3 are specified. test_expect_success \ 'ls-tree filter directories' \ - 'git-ls-tree $tree path3 path2 path0/a/b/c path1/b/c path0/a >current && + 'git ls-tree $tree path3 path2 path0/a/b/c path1/b/c path0/a >current && cat >expected <<\EOF && 040000 tree X path0/a/b/c 040000 tree X path1/b/c @@ -120,7 +120,7 @@ EOF # having 1.txt and path3 test_expect_success \ 'ls-tree filter odd names' \ - 'git-ls-tree $tree 1.txt /1.txt //1.txt path3/1.txt /path3/1.txt //path3//1.txt path3 /path3/ path3// >current && + 'git ls-tree $tree 1.txt /1.txt //1.txt path3/1.txt /path3/1.txt //path3//1.txt path3 /path3/ path3// >current && cat >expected <<\EOF && 100644 blob X 1.txt 100644 blob X path3/1.txt @@ -130,7 +130,7 @@ EOF test_expect_success \ 'ls-tree filter missing files and extra slashes' \ - 'git-ls-tree $tree 1.txt/ abc.txt path3//23.txt path3/2.txt/// >current && + 'git ls-tree $tree 1.txt/ abc.txt path3//23.txt path3/2.txt/// >current && cat >expected <<\EOF && EOF test_output' diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 6f6d8844e8..ef1eeb7d8a 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -13,22 +13,22 @@ handled. Specifically, that a bogus branch is not created. test_expect_success \ 'prepare a trivial repository' \ 'echo Hello > A && - git-update-index --add A && + git update-index --add A && git-commit -m "Initial commit." && - HEAD=$(git-rev-parse --verify HEAD)' + HEAD=$(git rev-parse --verify HEAD)' test_expect_failure \ 'git branch --help should not have created a bogus branch' \ - 'git-branch --help </dev/null >/dev/null 2>/dev/null || : + 'git branch --help </dev/null >/dev/null 2>/dev/null || : test -f .git/refs/heads/--help' test_expect_success \ 'git branch abc should create a branch' \ - 'git-branch abc && test -f .git/refs/heads/abc' + 'git branch abc && test -f .git/refs/heads/abc' test_expect_success \ 'git branch a/b/c should create a branch' \ - 'git-branch a/b/c && test -f .git/refs/heads/a/b/c' + 'git branch a/b/c && test -f .git/refs/heads/a/b/c' cat >expect <<EOF 0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master @@ -36,140 +36,159 @@ EOF test_expect_success \ 'git branch -l d/e/f should create a branch and a log' \ 'GIT_COMMITTER_DATE="2005-05-26 23:30" \ - git-branch -l d/e/f && + git branch -l d/e/f && test -f .git/refs/heads/d/e/f && test -f .git/logs/refs/heads/d/e/f && diff expect .git/logs/refs/heads/d/e/f' test_expect_success \ 'git branch -d d/e/f should delete a branch and a log' \ - 'git-branch -d d/e/f && + 'git branch -d d/e/f && test ! -f .git/refs/heads/d/e/f && test ! -f .git/logs/refs/heads/d/e/f' test_expect_success \ 'git branch j/k should work after branch j has been deleted' \ - 'git-branch j && - git-branch -d j && - git-branch j/k' + 'git branch j && + git branch -d j && + git branch j/k' test_expect_success \ 'git branch l should work after branch l/m has been deleted' \ - 'git-branch l/m && - git-branch -d l/m && - git-branch l' + 'git branch l/m && + git branch -d l/m && + git branch l' test_expect_success \ 'git branch -m m m/m should work' \ - 'git-branch -l m && - git-branch -m m m/m && + 'git branch -l m && + git branch -m m m/m && test -f .git/logs/refs/heads/m/m' test_expect_success \ 'git branch -m n/n n should work' \ - 'git-branch -l n/n && - git-branch -m n/n n + 'git branch -l n/n && + git branch -m n/n n test -f .git/logs/refs/heads/n' test_expect_failure \ 'git branch -m o/o o should fail when o/p exists' \ - 'git-branch o/o && - git-branch o/p && - git-branch -m o/o o' + 'git branch o/o && + git branch o/p && + git branch -m o/o o' test_expect_failure \ 'git branch -m q r/q should fail when r exists' \ - 'git-branch q && - git-branch r && - git-branch -m q r/q' + 'git branch q && + git branch r && + git branch -m q r/q' mv .git/config .git/config-saved test_expect_success 'git branch -m q q2 without config should succeed' ' - git-branch -m q q2 && - git-branch -m q2 q + git branch -m q q2 && + git branch -m q2 q ' mv .git/config-saved .git/config -git-config branch.s/s.dummy Hello +git config branch.s/s.dummy Hello test_expect_success \ 'git branch -m s/s s should work when s/t is deleted' \ - 'git-branch -l s/s && + 'git branch -l s/s && test -f .git/logs/refs/heads/s/s && - git-branch -l s/t && + git branch -l s/t && test -f .git/logs/refs/heads/s/t && - git-branch -d s/t && - git-branch -m s/s s && + git branch -d s/t && + git branch -m s/s s && test -f .git/logs/refs/heads/s' test_expect_success 'config information was renamed, too' \ - "test $(git-config branch.s.dummy) = Hello && - ! git-config branch.s/s/dummy" + "test $(git config branch.s.dummy) = Hello && + ! git config branch.s/s/dummy" test_expect_failure \ - 'git-branch -m u v should fail when the reflog for u is a symlink' \ - 'git-branch -l u && + 'git branch -m u v should fail when the reflog for u is a symlink' \ + 'git branch -l u && mv .git/logs/refs/heads/u real-u && ln -s real-u .git/logs/refs/heads/u && - git-branch -m u v' + git branch -m u v' test_expect_success 'test tracking setup via --track' \ - 'git-config remote.local.url . && - git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && - (git-show-ref -q refs/remotes/local/master || git-fetch local) && - git-branch --track my1 local/master && - test $(git-config branch.my1.remote) = local && - test $(git-config branch.my1.merge) = refs/heads/master' + 'git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --track my1 local/master && + test $(git config branch.my1.remote) = local && + test $(git config branch.my1.merge) = refs/heads/master' test_expect_success 'test tracking setup (non-wildcard, matching)' \ - 'git-config remote.local.url . && - git-config remote.local.fetch refs/heads/master:refs/remotes/local/master && - (git-show-ref -q refs/remotes/local/master || git-fetch local) && - git-branch --track my4 local/master && - test $(git-config branch.my4.remote) = local && - test $(git-config branch.my4.merge) = refs/heads/master' + 'git config remote.local.url . && + git config remote.local.fetch refs/heads/master:refs/remotes/local/master && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --track my4 local/master && + test $(git config branch.my4.remote) = local && + test $(git config branch.my4.merge) = refs/heads/master' test_expect_success 'test tracking setup (non-wildcard, not matching)' \ - 'git-config remote.local.url . && - git-config remote.local.fetch refs/heads/s:refs/remotes/local/s && - (git-show-ref -q refs/remotes/local/master || git-fetch local) && - git-branch --track my5 local/master && - ! test "$(git-config branch.my5.remote)" = local && - ! test "$(git-config branch.my5.merge)" = refs/heads/master' + 'git config remote.local.url . && + git config remote.local.fetch refs/heads/s:refs/remotes/local/s && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --track my5 local/master && + ! test "$(git config branch.my5.remote)" = local && + ! test "$(git config branch.my5.merge)" = refs/heads/master' test_expect_success 'test tracking setup via config' \ - 'git-config branch.autosetupmerge true && - git-config remote.local.url . && - git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && - (git-show-ref -q refs/remotes/local/master || git-fetch local) && - git-branch my3 local/master && - test $(git-config branch.my3.remote) = local && - test $(git-config branch.my3.merge) = refs/heads/master' + 'git config branch.autosetupmerge true && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch my3 local/master && + test $(git config branch.my3.remote) = local && + test $(git config branch.my3.merge) = refs/heads/master' + +test_expect_success 'avoid ambiguous track' ' + git config branch.autosetupmerge true && + git config remote.ambi1.url = lalala && + git config remote.ambi1.fetch = refs/heads/lalala:refs/heads/master && + git config remote.ambi2.url = lilili && + git config remote.ambi2.fetch = refs/heads/lilili:refs/heads/master && + git branch all1 master && + test -z "$(git config branch.all1.merge)" +' test_expect_success 'test overriding tracking setup via --no-track' \ - 'git-config branch.autosetupmerge true && - git-config remote.local.url . && - git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && - (git-show-ref -q refs/remotes/local/master || git-fetch local) && - git-branch --no-track my2 local/master && - git-config branch.autosetupmerge false && - ! test "$(git-config branch.my2.remote)" = local && - ! test "$(git-config branch.my2.merge)" = refs/heads/master' - -test_expect_success 'test local tracking setup' \ + 'git config branch.autosetupmerge true && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track my2 local/master && + git config branch.autosetupmerge false && + ! test "$(git config branch.my2.remote)" = local && + ! test "$(git config branch.my2.merge)" = refs/heads/master' + +test_expect_success 'no tracking without .fetch entries' \ 'git branch --track my6 s && - test $(git-config branch.my6.remote) = . && - test $(git-config branch.my6.merge) = refs/heads/s' + test -z "$(git config branch.my6.remote)" && + test -z "$(git config branch.my6.merge)"' test_expect_success 'test tracking setup via --track but deeper' \ - 'git-config remote.local.url . && - git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && - (git-show-ref -q refs/remotes/local/o/o || git-fetch local) && - git-branch --track my7 local/o/o && - test "$(git-config branch.my7.remote)" = local && - test "$(git-config branch.my7.merge)" = refs/heads/o/o' + 'git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/o/o || git-fetch local) && + git branch --track my7 local/o/o && + test "$(git config branch.my7.remote)" = local && + test "$(git config branch.my7.merge)" = refs/heads/o/o' + +test_expect_success 'test deleting branch deletes branch config' \ + 'git branch -d my7 && + test -z "$(git config branch.my7.remote)" && + test -z "$(git config branch.my7.merge)"' + +test_expect_success 'test deleting branch without config' \ + 'git branch my7 s && + test "$(git branch -d my7 2>&1)" = "Deleted branch my7."' # Keep this test last, as it changes the current branch cat >expect <<EOF diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index f0c7e22b36..4ddc6342a9 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -16,92 +16,92 @@ echo '[core] logallrefupdates = true' >>.git/config test_expect_success \ 'prepare a trivial repository' \ 'echo Hello > A && - git-update-index --add A && + git update-index --add A && git-commit -m "Initial commit." && - HEAD=$(git-rev-parse --verify HEAD)' + HEAD=$(git rev-parse --verify HEAD)' SHA1= test_expect_success \ 'see if git show-ref works as expected' \ - 'git-branch a && + 'git branch a && SHA1=`cat .git/refs/heads/a` && echo "$SHA1 refs/heads/a" >expect && - git-show-ref a >result && + git show-ref a >result && diff expect result' test_expect_success \ 'see if a branch still exists when packed' \ - 'git-branch b && - git-pack-refs --all && + 'git branch b && + git pack-refs --all && rm -f .git/refs/heads/b && echo "$SHA1 refs/heads/b" >expect && - git-show-ref b >result && + git show-ref b >result && diff expect result' test_expect_failure \ 'git branch c/d should barf if branch c exists' \ - 'git-branch c && - git-pack-refs --all && + 'git branch c && + git pack-refs --all && rm .git/refs/heads/c && - git-branch c/d' + git branch c/d' test_expect_success \ 'see if a branch still exists after git pack-refs --prune' \ - 'git-branch e && - git-pack-refs --all --prune && + 'git branch e && + git pack-refs --all --prune && echo "$SHA1 refs/heads/e" >expect && - git-show-ref e >result && + git show-ref e >result && diff expect result' test_expect_failure \ 'see if git pack-refs --prune remove ref files' \ - 'git-branch f && - git-pack-refs --all --prune && + 'git branch f && + git pack-refs --all --prune && ls .git/refs/heads/f' test_expect_success \ 'git branch g should work when git branch g/h has been deleted' \ - 'git-branch g/h && - git-pack-refs --all --prune && - git-branch -d g/h && - git-branch g && - git-pack-refs --all && - git-branch -d g' + 'git branch g/h && + git pack-refs --all --prune && + git branch -d g/h && + git branch g && + git pack-refs --all && + git branch -d g' test_expect_failure \ 'git branch i/j/k should barf if branch i exists' \ - 'git-branch i && - git-pack-refs --all --prune && - git-branch i/j/k' + 'git branch i && + git pack-refs --all --prune && + git branch i/j/k' test_expect_success \ 'test git branch k after branch k/l/m and k/lm have been deleted' \ - 'git-branch k/l && - git-branch k/lm && - git-branch -d k/l && - git-branch k/l/m && - git-branch -d k/l/m && - git-branch -d k/lm && - git-branch k' + 'git branch k/l && + git branch k/lm && + git branch -d k/l && + git branch k/l/m && + git branch -d k/l/m && + git branch -d k/lm && + git branch k' test_expect_success \ 'test git branch n after some branch deletion and pruning' \ - 'git-branch n/o && - git-branch n/op && - git-branch -d n/o && - git-branch n/o/p && - git-branch -d n/op && - git-pack-refs --all --prune && - git-branch -d n/o/p && - git-branch n' + 'git branch n/o && + git branch n/op && + git branch -d n/o && + git branch n/o/p && + git branch -d n/op && + git pack-refs --all --prune && + git branch -d n/o/p && + git branch n' test_expect_success 'pack, prune and repack' ' git-tag foo && - git-pack-refs --all --prune && - git-show-ref >all-of-them && - git-pack-refs && - git-show-ref >again && + git pack-refs --all --prune && + git show-ref >all-of-them && + git pack-refs && + git show-ref >again && diff all-of-them again ' diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh index b5a1400e18..dc8c369310 100755 --- a/t/t3300-funny-names.sh +++ b/t/t3300-funny-names.sh @@ -32,12 +32,12 @@ test -f "$p1" && cmp "$p0" "$p1" || { echo 'just space no-funny' >expected -test_expect_success 'git-ls-files no-funny' \ - 'git-update-index --add "$p0" "$p2" && - git-ls-files >current && +test_expect_success 'git ls-files no-funny' \ + 'git update-index --add "$p0" "$p2" && + git ls-files >current && git diff expected current' -t0=`git-write-tree` +t0=`git write-tree` echo "$t0" >t0 cat > expected <<\EOF @@ -45,19 +45,19 @@ just space no-funny "tabs\t,\" (dq) and spaces" EOF -test_expect_success 'git-ls-files with-funny' \ - 'git-update-index --add "$p1" && - git-ls-files >current && +test_expect_success 'git ls-files with-funny' \ + 'git update-index --add "$p1" && + git ls-files >current && git diff expected current' echo 'just space no-funny tabs ," (dq) and spaces' >expected -test_expect_success 'git-ls-files -z with-funny' \ - 'git-ls-files -z | tr \\0 \\012 >current && +test_expect_success 'git ls-files -z with-funny' \ + 'git ls-files -z | tr \\0 \\012 >current && git diff expected current' -t1=`git-write-tree` +t1=`git write-tree` echo "$t1" >t1 cat > expected <<\EOF @@ -65,45 +65,45 @@ just space no-funny "tabs\t,\" (dq) and spaces" EOF -test_expect_success 'git-ls-tree with funny' \ - 'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current && +test_expect_success 'git ls-tree with funny' \ + 'git ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current && git diff expected current' 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 && +test_expect_success 'git diff-index with-funny' \ + 'git diff-index --name-status $t0 >current && git diff expected current' -test_expect_success 'git-diff-tree with-funny' \ - 'git-diff-tree --name-status $t0 $t1 >current && +test_expect_success 'git diff-tree with-funny' \ + 'git diff-tree --name-status $t0 $t1 >current && git diff expected current' echo 'A tabs ," (dq) and spaces' >expected -test_expect_success 'git-diff-index -z with-funny' \ - 'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current && +test_expect_success 'git diff-index -z with-funny' \ + 'git diff-index -z --name-status $t0 | tr \\0 \\012 >current && git diff expected current' -test_expect_success 'git-diff-tree -z with-funny' \ - 'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current && +test_expect_success 'git diff-tree -z with-funny' \ + 'git diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current && git diff expected current' 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 \ +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 && git diff expected current' 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 \ +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 && git diff expected current' @@ -113,8 +113,8 @@ similarity index NUM% rename from no-funny rename to "tabs\t,\" (dq) and spaces" EOF -test_expect_success 'git-diff-tree delete with-funny' \ - 'git-diff-index -M -p $t0 | +test_expect_success 'git diff-tree delete with-funny' \ + 'git diff-index -M -p $t0 | sed -e "s/index [0-9]*%/index NUM%/" >current && git diff expected current' @@ -127,8 +127,8 @@ similarity index NUM% rename from no-funny rename to "tabs\t,\" (dq) and spaces" EOF -test_expect_success 'git-diff-tree delete with-funny' \ - 'git-diff-index -M -p $t0 | +test_expect_success 'git diff-tree delete with-funny' \ + 'git diff-index -M -p $t0 | sed -e "s/index [0-9]*%/index NUM%/" >current && git diff expected current' @@ -136,9 +136,9 @@ 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 && +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 && git diff expected current' cat > expected <<\EOF @@ -146,15 +146,15 @@ cat > expected <<\EOF "tabs\t,\" (dq) and spaces" 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 && +test_expect_success 'git diff-tree delete with-funny applied' \ + 'git diff-index -p $t0 | + git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && git diff expected current' -test_expect_success 'git-apply non-git diff' \ - 'git-diff-index -p $t0 | +test_expect_success 'git apply non-git diff' \ + 'git diff-index -p $t0 | sed -ne "/^[-+@]/p" | - git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && + git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && git diff expected current' test_done diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index b9d3131cc2..62205b2531 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -12,23 +12,60 @@ This test runs git rebase and checks that the author information is not lost. export GIT_AUTHOR_EMAIL=bogus_email_address test_expect_success \ - 'prepare repository with topic branch, then rebase against master' \ + 'prepare repository with topic branches' \ 'echo First > A && - git-update-index --add A && + git update-index --add A && git-commit -m "Add A." && git checkout -b my-topic-branch && echo Second > B && - git-update-index --add B && + git update-index --add B && git-commit -m "Add B." && git checkout -f master && echo Third >> A && - git-update-index A && + git update-index A && git-commit -m "Modify A." && + git checkout -b side my-topic-branch && + echo Side >> C && + git add C && + git commit -m "Add C" && + git checkout -b nonlinear my-topic-branch && + echo Edit >> B && + git add B && + git commit -m "Modify B" && + git merge side && + git checkout -b upstream-merged-nonlinear && + git merge master && git checkout -f my-topic-branch && + git tag topic +' + +test_expect_success 'rebase against master' ' git rebase master' test_expect_failure \ 'the rebase operation should not have destroyed author information' \ 'git log | grep "Author:" | grep "<>"' +test_expect_success 'rebase after merge master' ' + git reset --hard topic && + git merge master && + git rebase master && + ! git show | grep "^Merge:" +' + +test_expect_success 'rebase of history with merges is linearized' ' + git checkout nonlinear && + test 4 = $(git rev-list master.. | wc -l) && + git rebase master && + test 3 = $(git rev-list master.. | wc -l) +' + +test_expect_success \ + 'rebase of history with merges after upstream merge is linearized' ' + git checkout upstream-merged-nonlinear && + test 5 = $(git rev-list master.. | wc -l) && + git rebase master && + test 3 = $(git rev-list master.. | wc -l) +' + test_done diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh index 8b19d3ccea..4934a4e010 100755 --- a/t/t3401-rebase-partial.sh +++ b/t/t3401-rebase-partial.sh @@ -14,37 +14,37 @@ local branch. test_expect_success \ 'prepare repository with topic branch' \ 'echo First > A && - git-update-index --add A && + git update-index --add A && git-commit -m "Add A." && git-checkout -b my-topic-branch && echo Second > B && - git-update-index --add B && + git update-index --add B && git-commit -m "Add B." && echo AnotherSecond > C && - git-update-index --add C && + git update-index --add C && git-commit -m "Add C." && git-checkout -f master && echo Third >> A && - git-update-index A && + git update-index A && git-commit -m "Modify A." ' test_expect_success \ 'pick top patch from topic branch into master' \ - 'git-cherry-pick my-topic-branch^0 && + 'git cherry-pick my-topic-branch^0 && git-checkout -f my-topic-branch && - git-branch master-merge master && - git-branch my-topic-branch-merge my-topic-branch + git branch master-merge master && + git branch my-topic-branch-merge my-topic-branch ' test_debug \ - 'git-cherry master && - git-format-patch -k --stdout --full-index master >/dev/null && + 'git cherry master && + git format-patch -k --stdout --full-index master >/dev/null && gitk --all & sleep 1 ' diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh index 977c498f00..eab053c3e0 100755 --- a/t/t3403-rebase-skip.sh +++ b/t/t3403-rebase-skip.sh @@ -49,9 +49,8 @@ test_expect_success 'rebase --skip with --merge' ' ' test_expect_success 'merge and reference trees equal' \ - 'test -z "`git-diff-tree skip-merge skip-reference`"' + 'test -z "`git diff-tree skip-merge skip-reference`"' test_debug 'gitk --all & sleep 1' test_done - diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh new file mode 100755 index 0000000000..a9b552ff08 --- /dev/null +++ b/t/t3404-rebase-interactive.sh @@ -0,0 +1,277 @@ +#!/bin/sh +# +# Copyright (c) 2007 Johannes E. Schindelin +# + +test_description='git rebase interactive + +This test runs git rebase "interactively", by faking an edit, and verifies +that the result still makes sense. +' +. ./test-lib.sh + +# set up two branches like this: +# +# A - B - C - D - E +# \ +# F - G - H +# \ +# I +# +# where B, D and G touch the same file. + +test_expect_success 'setup' ' + : > file1 && + git add file1 && + test_tick && + git commit -m A && + git tag A && + echo 1 > file1 && + test_tick && + git commit -m B file1 && + : > file2 && + git add file2 && + test_tick && + git commit -m C && + echo 2 > file1 && + test_tick && + git commit -m D file1 && + : > file3 && + git add file3 && + test_tick && + git commit -m E && + git checkout -b branch1 A && + : > file4 && + git add file4 && + test_tick && + git commit -m F && + git tag F && + echo 3 > file1 && + test_tick && + git commit -m G file1 && + : > file5 && + git add file5 && + test_tick && + git commit -m H && + git checkout -b branch2 F && + : > file6 && + git add file6 && + test_tick && + git commit -m I && + git tag I +' + +cat > fake-editor.sh << EOF +#!/bin/sh +test "\$1" = .git/COMMIT_EDITMSG && { + test -z "\$FAKE_COMMIT_MESSAGE" || echo "\$FAKE_COMMIT_MESSAGE" > "\$1" + test -z "\$FAKE_COMMIT_AMEND" || echo "\$FAKE_COMMIT_AMEND" >> "\$1" + exit +} +test -z "\$EXPECT_COUNT" || + test "\$EXPECT_COUNT" = \$(grep -ve "^#" -e "^$" < "\$1" | wc -l) || + exit +test -z "\$FAKE_LINES" && exit +grep -v "^#" < "\$1" > "\$1".tmp +rm "\$1" +cat "\$1".tmp +action=pick +for line in \$FAKE_LINES; do + case \$line in + squash) + action="\$line";; + *) + echo sed -n "\${line}s/^pick/\$action/p" + sed -n "\${line}p" < "\$1".tmp + sed -n "\${line}s/^pick/\$action/p" < "\$1".tmp >> "\$1" + action=pick;; + esac +done +EOF + +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 && + test $(git rev-parse I) = $(git rev-parse HEAD) +' + +test_expect_success 'test the [branch] option' ' + git checkout -b dead-end && + git rm file6 && + git commit -m "stop here" && + git rebase -i F branch2 && + test $(git rev-parse I) = $(git rev-parse HEAD) +' + +test_expect_success 'rebase on top of a non-conflicting commit' ' + git checkout branch1 && + git tag original-branch1 && + git rebase -i branch2 && + test file6 = $(git diff --name-only original-branch1) && + test $(git rev-parse I) = $(git rev-parse HEAD~2) +' + +test_expect_success 'reflog for the branch shows state before rebase' ' + test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1) +' + +test_expect_success 'exchange two commits' ' + FAKE_LINES="2 1" git rebase -i HEAD~2 && + test H = $(git cat-file commit HEAD^ | tail -n 1) && + test G = $(git cat-file commit HEAD | tail -n 1) +' + +cat > expect << EOF +diff --git a/file1 b/file1 +index e69de29..00750ed 100644 +--- a/file1 ++++ b/file1 +@@ -0,0 +1 @@ ++3 +EOF + +cat > expect2 << EOF +<<<<<<< HEAD:file1 +2 +======= +3 +>>>>>>> b7ca976... G:file1 +EOF + +test_expect_success 'stop on conflicting pick' ' + git tag new-branch1 && + ! git rebase -i master && + diff -u expect .git/.dotest-merge/patch && + diff -u expect2 file1 && + test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) && + test 0 = $(grep -v "^#" < .git/.dotest-merge/todo | wc -l) +' + +test_expect_success 'abort' ' + git rebase --abort && + test $(git rev-parse new-branch1) = $(git rev-parse HEAD) && + ! test -d .git/.dotest-merge +' + +test_expect_success 'retain authorship' ' + echo A > file7 && + git add file7 && + test_tick && + GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" && + git tag twerp && + git rebase -i --onto master HEAD^ && + git show HEAD | grep "^Author: Twerp Snog" +' + +test_expect_success 'squash' ' + git reset --hard twerp && + echo B > file7 && + test_tick && + GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 && + echo "******************************" && + FAKE_LINES="1 squash 2" git rebase -i --onto master HEAD~2 && + test B = $(cat file7) && + test $(git rev-parse HEAD^) = $(git rev-parse master) +' + +test_expect_success 'retain authorship when squashing' ' + git show HEAD | grep "^Author: Nitfol" +' + +test_expect_success 'preserve merges with -p' ' + git checkout -b to-be-preserved master^ && + : > unrelated-file && + git add unrelated-file && + test_tick && + git commit -m "unrelated" && + git checkout -b to-be-rebased master && + echo B > file1 && + test_tick && + git commit -m J file1 && + test_tick && + git merge to-be-preserved && + echo C > file1 && + test_tick && + git commit -m K file1 && + test_tick && + git rebase -i -p --onto branch1 master && + test $(git rev-parse HEAD^^2) = $(git rev-parse to-be-preserved) && + test $(git rev-parse HEAD~3) = $(git rev-parse branch1) && + test $(git show HEAD:file1) = C && + test $(git show HEAD~2:file1) = B +' + +test_expect_success '--continue tries to commit' ' + test_tick && + ! git rebase -i --onto new-branch1 HEAD^ && + echo resolved > file1 && + git add file1 && + FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue && + test $(git rev-parse HEAD^) = $(git rev-parse new-branch1) && + git show HEAD | grep chouette +' + +test_expect_success 'verbose flag is heeded, even after --continue' ' + git reset --hard HEAD@{1} && + test_tick && + ! git rebase -v -i --onto new-branch1 HEAD^ && + echo resolved > file1 && + git add file1 && + git rebase --continue > output && + grep "^ file1 | 2 +-$" output +' + +test_expect_success 'multi-squash only fires up editor once' ' + base=$(git rev-parse HEAD~4) && + FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 squash 2 squash 3 squash 4" \ + git rebase -i $base && + test $base = $(git rev-parse HEAD^) && + test 1 = $(git show | grep ONCE | wc -l) +' + +test_expect_success 'squash works as expected' ' + for n in one two three four + do + echo $n >> file$n && + git add file$n && + git commit -m $n + done && + one=$(git rev-parse HEAD~3) && + FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 && + test $one = $(git rev-parse HEAD~2) +' + +test_expect_success 'interrupted squash works as expected' ' + for n in one two three four + do + echo $n >> conflict && + git add conflict && + git commit -m $n + done && + one=$(git rev-parse HEAD~3) && + ! FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 && + (echo one; echo two; echo four) > conflict && + git add conflict && + ! git rebase --continue && + echo resolved > conflict && + git add conflict && + git rebase --continue && + test $one = $(git rev-parse HEAD~2) +' + +test_expect_success 'ignore patch if in upstream' ' + HEAD=$(git rev-parse HEAD) && + git checkout -b has-cherry-picked HEAD^ && + echo unrelated > file7 && + git add file7 && + test_tick && + git commit -m "unrelated change" && + git cherry-pick $HEAD && + EXPECT_COUNT=1 git rebase -i $HEAD && + test $HEAD = $(git rev-parse HEAD^) +' + +test_done diff --git a/t/t3405-rebase-malformed.sh b/t/t3405-rebase-malformed.sh new file mode 100755 index 0000000000..e4e2e649ed --- /dev/null +++ b/t/t3405-rebase-malformed.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +test_description='rebase should not insist on git message convention' + +. ./test-lib.sh + +cat >F <<\EOF +This is an example of a commit log message +that does not conform to git commit convention. + +It has two paragraphs, but its first paragraph is not friendly +to oneline summary format. +EOF + +test_expect_success setup ' + + >file1 && + >file2 && + git add file1 file2 && + test_tick && + git commit -m "Initial commit" && + + git checkout -b side && + cat F >file2 && + git add file2 && + test_tick && + git commit -F F && + + git cat-file commit HEAD | sed -e "1,/^\$/d" >F0 && + + git checkout master && + + echo One >file1 && + test_tick && + git add file1 && + git commit -m "Second commit" +' + +test_expect_success rebase ' + + git rebase master side && + git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 && + + diff -u F0 F1 && + diff -u F F0 +' + +test_done diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh index e83bbee074..d0a440feba 100755 --- a/t/t3500-cherry.sh +++ b/t/t3500-cherry.sh @@ -3,10 +3,10 @@ # Copyright (c) 2006 Yann Dirson, based on t3400 by Amos Waterland # -test_description='git-cherry should detect patches integrated upstream +test_description='git cherry should detect patches integrated upstream This test cherry-picks one local change of two into master branch, and -checks that git-cherry only returns the second patch in the local branch +checks that git cherry only returns the second patch in the local branch ' . ./test-lib.sh @@ -15,40 +15,40 @@ export GIT_AUTHOR_EMAIL=bogus_email_address test_expect_success \ 'prepare repository with topic branch, and check cherry finds the 2 patches from there' \ 'echo First > A && - git-update-index --add A && + git update-index --add A && git-commit -m "Add A." && git-checkout -b my-topic-branch && echo Second > B && - git-update-index --add B && + git update-index --add B && git-commit -m "Add B." && sleep 2 && echo AnotherSecond > C && - git-update-index --add C && + git update-index --add C && git-commit -m "Add C." && git-checkout -f master && rm -f B C && echo Third >> A && - git-update-index A && + git update-index A && git-commit -m "Modify A." && - expr "$(echo $(git-cherry master my-topic-branch) )" : "+ [^ ]* + .*" + expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* + .*" ' test_expect_success \ 'check that cherry with limit returns only the top patch'\ - 'expr "$(echo $(git-cherry master my-topic-branch my-topic-branch^1) )" : "+ [^ ]*" + 'expr "$(echo $(git cherry master my-topic-branch my-topic-branch^1) )" : "+ [^ ]*" ' test_expect_success \ 'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \ - 'git-cherry-pick my-topic-branch^0 && - echo $(git-cherry master my-topic-branch) && - expr "$(echo $(git-cherry master my-topic-branch) )" : "+ [^ ]* - .*" + 'git cherry-pick my-topic-branch^0 && + echo $(git cherry master my-topic-branch) && + expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* - .*" ' test_done diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 0a97b75288..5c001aa489 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Carl D. Worth # -test_description='Test of the various options to git-rm.' +test_description='Test of the various options to git rm.' . ./test-lib.sh @@ -11,13 +11,13 @@ test_description='Test of the various options to git-rm.' test_expect_success \ 'Initialize test directory' \ "touch -- foo bar baz 'space embedded' -q && - git-add -- foo bar baz 'space embedded' -q && + git add -- foo bar baz 'space embedded' -q && git-commit -m 'add normal files' && test_tabs=y && if touch -- 'tab embedded' 'newline embedded' then - git-add -- 'tab embedded' 'newline + git add -- 'tab embedded' 'newline embedded' && git-commit -m 'add files with tabs and newlines' else @@ -26,7 +26,7 @@ embedded' && fi" # Later we will try removing an unremovable path to make sure -# git-rm barfs, but if the test is run as root that cannot be +# git rm barfs, but if the test is run as root that cannot be # arranged. test_expect_success \ 'Determine rm behavior' \ @@ -38,51 +38,85 @@ test_expect_success \ rm -f test-file' test_expect_success \ - 'Pre-check that foo exists and is in index before git-rm foo' \ - '[ -f foo ] && git-ls-files --error-unmatch foo' + 'Pre-check that foo exists and is in index before git rm foo' \ + '[ -f foo ] && git ls-files --error-unmatch foo' test_expect_success \ - 'Test that git-rm foo succeeds' \ - 'git-rm --cached foo' + 'Test that git rm foo succeeds' \ + 'git rm --cached foo' test_expect_success \ - 'Post-check that foo exists but is not in index after git-rm foo' \ - '[ -f foo ] && ! git-ls-files --error-unmatch foo' + 'Test that git rm --cached foo succeeds if the index matches the file' \ + 'echo content > foo + git add foo + git rm --cached foo' test_expect_success \ - 'Pre-check that bar exists and is in index before "git-rm bar"' \ - '[ -f bar ] && git-ls-files --error-unmatch bar' + 'Test that git rm --cached foo succeeds if the index matches the file' \ + 'echo content > foo + git add foo + git commit -m foo + echo "other content" > foo + git rm --cached foo' + +test_expect_failure \ + 'Test that git rm --cached foo fails if the index matches neither the file nor HEAD' \ + 'echo content > foo + git add foo + git commit -m foo + echo "other content" > foo + git add foo + echo "yet another content" > foo + git rm --cached foo' + +test_expect_success \ + 'Test that git rm --cached -f foo works in case where --cached only did not' \ + 'echo content > foo + git add foo + git commit -m foo + echo "other content" > foo + git add foo + echo "yet another content" > foo + git rm --cached -f foo' + +test_expect_success \ + 'Post-check that foo exists but is not in index after git rm foo' \ + '[ -f foo ] && ! git ls-files --error-unmatch foo' + +test_expect_success \ + 'Pre-check that bar exists and is in index before "git rm bar"' \ + '[ -f bar ] && git ls-files --error-unmatch bar' test_expect_success \ - 'Test that "git-rm bar" succeeds' \ - 'git-rm bar' + 'Test that "git rm bar" succeeds' \ + 'git rm bar' test_expect_success \ - 'Post-check that bar does not exist and is not in index after "git-rm -f bar"' \ - '! [ -f bar ] && ! git-ls-files --error-unmatch bar' + 'Post-check that bar does not exist and is not in index after "git rm -f bar"' \ + '! [ -f bar ] && ! git ls-files --error-unmatch bar' test_expect_success \ - 'Test that "git-rm -- -q" succeeds (remove a file that looks like an option)' \ - 'git-rm -- -q' + 'Test that "git rm -- -q" succeeds (remove a file that looks like an option)' \ + 'git rm -- -q' test "$test_tabs" = y && test_expect_success \ - "Test that \"git-rm -f\" succeeds with embedded space, tab, or newline characters." \ - "git-rm -f 'space embedded' 'tab embedded' 'newline + "Test that \"git rm -f\" succeeds with embedded space, tab, or newline characters." \ + "git rm -f 'space embedded' 'tab embedded' 'newline embedded'" if test "$test_failed_remove" = y; then chmod a-w . test_expect_failure \ - 'Test that "git-rm -f" fails if its rm fails' \ - 'git-rm -f baz' + 'Test that "git rm -f" fails if its rm fails' \ + 'git rm -f baz' chmod 775 . else test_expect_success 'skipping removal failure (perhaps running as root?)' : fi test_expect_success \ - 'When the rm in "git-rm -f" fails, it should not remove the file from the index' \ - 'git-ls-files --error-unmatch baz' + 'When the rm in "git rm -f" fails, it should not remove the file from the index' \ + 'git ls-files --error-unmatch baz' test_expect_success 'Remove nonexistent file with --ignore-unmatch' ' git rm --ignore-unmatch nonexistent diff --git a/t/t3700-add.sh b/t/t3700-add.sh index ad8cc7d4ae..213e9249da 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -3,72 +3,72 @@ # Copyright (c) 2006 Carl D. Worth # -test_description='Test of git-add, including the -- option.' +test_description='Test of git add, including the -- option.' . ./test-lib.sh test_expect_success \ - 'Test of git-add' \ - 'touch foo && git-add foo' + 'Test of git add' \ + 'touch foo && git add foo' test_expect_success \ 'Post-check that foo is in the index' \ - 'git-ls-files foo | grep foo' + 'git ls-files foo | grep foo' test_expect_success \ - 'Test that "git-add -- -q" works' \ - 'touch -- -q && git-add -- -q' + 'Test that "git add -- -q" works' \ + 'touch -- -q && git add -- -q' test_expect_success \ - 'git-add: Test that executable bit is not used if core.filemode=0' \ + 'git add: Test that executable bit is not used if core.filemode=0' \ 'git config core.filemode 0 && echo foo >xfoo1 && chmod 755 xfoo1 && - git-add xfoo1 && - case "`git-ls-files --stage xfoo1`" in + git add xfoo1 && + case "`git ls-files --stage xfoo1`" in 100644" "*xfoo1) echo ok;; - *) echo fail; git-ls-files --stage xfoo1; (exit 1);; + *) echo fail; git ls-files --stage xfoo1; (exit 1);; esac' -test_expect_success 'git-add: filemode=0 should not get confused by symlink' ' +test_expect_success 'git add: filemode=0 should not get confused by symlink' ' rm -f xfoo1 && ln -s foo xfoo1 && - git-add xfoo1 && - case "`git-ls-files --stage xfoo1`" in + git add xfoo1 && + case "`git ls-files --stage xfoo1`" in 120000" "*xfoo1) echo ok;; - *) echo fail; git-ls-files --stage xfoo1; (exit 1);; + *) echo fail; git ls-files --stage xfoo1; (exit 1);; esac ' test_expect_success \ - 'git-update-index --add: Test that executable bit is not used...' \ + 'git update-index --add: Test that executable bit is not used...' \ 'git config core.filemode 0 && echo foo >xfoo2 && chmod 755 xfoo2 && - git-update-index --add xfoo2 && - case "`git-ls-files --stage xfoo2`" in + git update-index --add xfoo2 && + case "`git ls-files --stage xfoo2`" in 100644" "*xfoo2) echo ok;; - *) echo fail; git-ls-files --stage xfoo2; (exit 1);; + *) echo fail; git ls-files --stage xfoo2; (exit 1);; esac' -test_expect_success 'git-add: filemode=0 should not get confused by symlink' ' +test_expect_success 'git add: filemode=0 should not get confused by symlink' ' rm -f xfoo2 && ln -s foo xfoo2 && git update-index --add xfoo2 && - case "`git-ls-files --stage xfoo2`" in + case "`git ls-files --stage xfoo2`" in 120000" "*xfoo2) echo ok;; - *) echo fail; git-ls-files --stage xfoo2; (exit 1);; + *) echo fail; git ls-files --stage xfoo2; (exit 1);; esac ' test_expect_success \ - 'git-update-index --add: Test that executable bit is not used...' \ + 'git update-index --add: Test that executable bit is not used...' \ 'git config core.filemode 0 && ln -s xfoo2 xfoo3 && - git-update-index --add xfoo3 && - case "`git-ls-files --stage xfoo3`" in + git update-index --add xfoo3 && + case "`git ls-files --stage xfoo3`" in 120000" "*xfoo3) echo ok;; - *) echo fail; git-ls-files --stage xfoo3; (exit 1);; + *) echo fail; git ls-files --stage xfoo3; (exit 1);; esac' test_expect_success '.gitignore test setup' ' @@ -80,28 +80,28 @@ test_expect_success '.gitignore test setup' ' ' test_expect_success '.gitignore is honored' ' - git-add . && - ! git-ls-files | grep "\\.ig" + git add . && + ! git ls-files | grep "\\.ig" ' test_expect_success 'error out when attempting to add ignored ones without -f' ' - ! git-add a.?? && - ! git-ls-files | grep "\\.ig" + ! git add a.?? && + ! git ls-files | grep "\\.ig" ' test_expect_success 'error out when attempting to add ignored ones without -f' ' - ! git-add d.?? && - ! git-ls-files | grep "\\.ig" + ! git add d.?? && + ! git ls-files | grep "\\.ig" ' test_expect_success 'add ignored ones with -f' ' - git-add -f a.?? && - git-ls-files --error-unmatch a.ig + git add -f a.?? && + git ls-files --error-unmatch a.ig ' test_expect_success 'add ignored ones with -f' ' - git-add -f d.??/* && - git-ls-files --error-unmatch d.ig/d.if d.ig/d.ig + git add -f d.??/* && + git ls-files --error-unmatch d.ig/d.if d.ig/d.ig ' mkdir 1 1/2 1/3 @@ -110,4 +110,37 @@ test_expect_success 'check correct prefix detection' ' git add 1/2/a 1/3/b 1/2/c ' +test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries' ' + for s in 1 2 3 + do + echo $s > stage$s + echo "100755 $(git hash-object -w stage$s) $s file" + echo "120000 $(printf $s | git hash-object -w -t blob --stdin) $s symlink" + done | git update-index --index-info && + git config core.filemode 0 && + git config core.symlinks 0 && + echo new > file && + echo new > symlink && + git add file symlink && + git ls-files --stage | grep "^100755 .* 0 file$" && + git ls-files --stage | grep "^120000 .* 0 symlink$" +' + +test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over stage 1' ' + git rm --cached -f file symlink && + ( + echo "100644 $(git hash-object -w stage1) 1 file" + echo "100755 $(git hash-object -w stage2) 2 file" + echo "100644 $(printf 1 | git hash-object -w -t blob --stdin) 1 symlink" + echo "120000 $(printf 2 | git hash-object -w -t blob --stdin) 2 symlink" + ) | git update-index --index-info && + git config core.filemode 0 && + git config core.symlinks 0 && + echo new > file && + echo new > symlink && + git add file symlink && + git ls-files --stage | grep "^100755 .* 0 file$" && + git ls-files --stage | grep "^120000 .* 0 symlink$" +' + test_done diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 7c7e4335d6..261f199a0c 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -22,9 +22,9 @@ check_verify_failure () { # first create a commit, so we have a valid object/type # for the tag. echo Hello >A -git-update-index --add A +git update-index --add A git-commit -m "Initial commit" -head=$(git-rev-parse --verify HEAD) +head=$(git rev-parse --verify HEAD) ############################################################ # 1. length check diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh index ffddb68db3..fcbabe8ec3 100755 --- a/t/t3900-i18n-commit.sh +++ b/t/t3900-i18n-commit.sh @@ -8,28 +8,28 @@ test_description='commit and log output encodings' . ./test-lib.sh compare_with () { - git-show -s $1 | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current && + git show -s $1 | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current && git diff current "$2" } test_expect_success setup ' : >F && - git-add F && - T=$(git-write-tree) && - C=$(git-commit-tree $T <../t3900/1-UTF-8.txt) && - git-update-ref HEAD $C && + git add F && + T=$(git write-tree) && + C=$(git commit-tree $T <../t3900/1-UTF-8.txt) && + git update-ref HEAD $C && git-tag C0 ' test_expect_success 'no encoding header for base case' ' - E=$(git-cat-file commit C0 | sed -ne "s/^encoding //p") && + E=$(git cat-file commit C0 | sed -ne "s/^encoding //p") && test z = "z$E" ' for H in ISO-8859-1 EUCJP ISO-2022-JP do test_expect_success "$H setup" ' - git-config i18n.commitencoding $H && + git config i18n.commitencoding $H && git-checkout -b $H C0 && echo $H >F && git-commit -a -F ../t3900/$H.txt @@ -39,21 +39,21 @@ done for H in ISO-8859-1 EUCJP ISO-2022-JP do test_expect_success "check encoding header for $H" ' - E=$(git-cat-file commit '$H' | sed -ne "s/^encoding //p") && + E=$(git cat-file commit '$H' | sed -ne "s/^encoding //p") && test "z$E" = "z'$H'" ' done test_expect_success 'config to remove customization' ' - git-config --unset-all i18n.commitencoding && - if Z=$(git-config --get-all i18n.commitencoding) + git config --unset-all i18n.commitencoding && + if Z=$(git config --get-all i18n.commitencoding) then echo Oops, should have failed. false else test z = "z$Z" fi && - git-config i18n.commitencoding utf-8 + git config i18n.commitencoding utf-8 ' test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' @@ -68,8 +68,8 @@ do done test_expect_success 'config to add customization' ' - git-config --unset-all i18n.commitencoding && - if Z=$(git-config --get-all i18n.commitencoding) + git config --unset-all i18n.commitencoding && + if Z=$(git config --get-all i18n.commitencoding) then echo Oops, should have failed. false @@ -81,13 +81,13 @@ test_expect_success 'config to add customization' ' for H in ISO-8859-1 EUCJP ISO-2022-JP do test_expect_success "$H should be shown in itself now" ' - git-config i18n.commitencoding '$H' && + git config i18n.commitencoding '$H' && compare_with '$H' ../t3900/'$H'.txt ' done test_expect_success 'config to tweak customization' ' - git-config i18n.logoutputencoding utf-8 + git config i18n.logoutputencoding utf-8 ' test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' @@ -103,7 +103,7 @@ done for J in EUCJP ISO-2022-JP do - git-config i18n.logoutputencoding $J + git config i18n.logoutputencoding $J for H in EUCJP ISO-2022-JP do test_expect_success "$H should be shown in $J now" ' diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh index 24bf0ee018..28e9e372f3 100755 --- a/t/t3901-i18n-patch.sh +++ b/t/t3901-i18n-patch.sh @@ -14,7 +14,7 @@ check_encoding () { do git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j | grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" && - git-cat-file commit HEAD~$j | + git cat-file commit HEAD~$j | case "$header" in 8859) grep "^encoding ISO-8859-1" ;; @@ -31,7 +31,7 @@ check_encoding () { } test_expect_success setup ' - git-config i18n.commitencoding UTF-8 && + git config i18n.commitencoding UTF-8 && # use UTF-8 in author and committer name to match the # i18n.commitencoding settings @@ -55,7 +55,7 @@ test_expect_success setup ' git commit -s -m "Second on side" && # the second one on the side branch is ISO-8859-1 - git-config i18n.commitencoding ISO-8859-1 && + git config i18n.commitencoding ISO-8859-1 && # use author and committer name in ISO-8859-1 to match it. . ../t3901-8859-1.txt && test_tick && @@ -64,11 +64,11 @@ test_expect_success setup ' git commit -s -m "Third on side" && # Back to default - git-config i18n.commitencoding UTF-8 + git config i18n.commitencoding UTF-8 ' test_expect_success 'format-patch output (ISO-8859-1)' ' - git-config i18n.logoutputencoding ISO-8859-1 && + git config i18n.logoutputencoding ISO-8859-1 && git format-patch --stdout master..HEAD^ >out-l1 && git format-patch --stdout HEAD^ >out-l2 && @@ -91,7 +91,7 @@ test_expect_success 'format-patch output (UTF-8)' ' test_expect_success 'rebase (U/U)' ' # We want the result of rebase in UTF-8 - git-config i18n.commitencoding UTF-8 && + git config i18n.commitencoding UTF-8 && # The test is about logoutputencoding not affecting the # final outcome -- it is used internally to generate the @@ -109,7 +109,7 @@ test_expect_success 'rebase (U/U)' ' ' test_expect_success 'rebase (U/L)' ' - git-config i18n.commitencoding UTF-8 && + git config i18n.commitencoding UTF-8 && git config i18n.logoutputencoding ISO-8859-1 && . ../t3901-utf8.txt && @@ -121,7 +121,7 @@ test_expect_success 'rebase (U/L)' ' test_expect_success 'rebase (L/L)' ' # In this test we want ISO-8859-1 encoded commits as the result - git-config i18n.commitencoding ISO-8859-1 && + git config i18n.commitencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 && . ../t3901-8859-1.txt && @@ -134,7 +134,7 @@ test_expect_success 'rebase (L/L)' ' test_expect_success 'rebase (L/U)' ' # This is pathological -- use UTF-8 as intermediate form # to get ISO-8859-1 results. - git-config i18n.commitencoding ISO-8859-1 && + git config i18n.commitencoding ISO-8859-1 && git config i18n.logoutputencoding UTF-8 && . ../t3901-8859-1.txt && @@ -147,7 +147,7 @@ test_expect_success 'rebase (L/U)' ' test_expect_success 'cherry-pick(U/U)' ' # Both the commitencoding and logoutputencoding is set to UTF-8. - git-config i18n.commitencoding UTF-8 && + git config i18n.commitencoding UTF-8 && git config i18n.logoutputencoding UTF-8 && . ../t3901-utf8.txt && @@ -162,7 +162,7 @@ test_expect_success 'cherry-pick(U/U)' ' test_expect_success 'cherry-pick(L/L)' ' # Both the commitencoding and logoutputencoding is set to ISO-8859-1 - git-config i18n.commitencoding ISO-8859-1 && + git config i18n.commitencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 && . ../t3901-8859-1.txt && @@ -177,7 +177,7 @@ test_expect_success 'cherry-pick(L/L)' ' test_expect_success 'cherry-pick(U/L)' ' # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1 - git-config i18n.commitencoding UTF-8 && + git config i18n.commitencoding UTF-8 && git config i18n.logoutputencoding ISO-8859-1 && . ../t3901-utf8.txt && @@ -193,7 +193,7 @@ test_expect_success 'cherry-pick(L/U)' ' # Again, the commitencoding is set to ISO-8859-1 but # logoutputencoding is set to UTF-8. - git-config i18n.commitencoding ISO-8859-1 && + git config i18n.commitencoding ISO-8859-1 && git config i18n.logoutputencoding UTF-8 && . ../t3901-8859-1.txt && @@ -206,7 +206,7 @@ test_expect_success 'cherry-pick(L/U)' ' ' test_expect_success 'rebase --merge (U/U)' ' - git-config i18n.commitencoding UTF-8 && + git config i18n.commitencoding UTF-8 && git config i18n.logoutputencoding UTF-8 && . ../t3901-utf8.txt && @@ -217,7 +217,7 @@ test_expect_success 'rebase --merge (U/U)' ' ' test_expect_success 'rebase --merge (U/L)' ' - git-config i18n.commitencoding UTF-8 && + git config i18n.commitencoding UTF-8 && git config i18n.logoutputencoding ISO-8859-1 && . ../t3901-utf8.txt && @@ -229,7 +229,7 @@ test_expect_success 'rebase --merge (U/L)' ' test_expect_success 'rebase --merge (L/L)' ' # In this test we want ISO-8859-1 encoded commits as the result - git-config i18n.commitencoding ISO-8859-1 && + git config i18n.commitencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 && . ../t3901-8859-1.txt && @@ -242,7 +242,7 @@ test_expect_success 'rebase --merge (L/L)' ' test_expect_success 'rebase --merge (L/U)' ' # This is pathological -- use UTF-8 as intermediate form # to get ISO-8859-1 results. - git-config i18n.commitencoding ISO-8859-1 && + git config i18n.commitencoding ISO-8859-1 && git config i18n.logoutputencoding UTF-8 && . ../t3901-8859-1.txt && diff --git a/t/t3902-quoted.sh b/t/t3902-quoted.sh new file mode 100755 index 0000000000..63f950b179 --- /dev/null +++ b/t/t3902-quoted.sh @@ -0,0 +1,126 @@ +#!/bin/sh +# +# Copyright (c) 2006 Junio C Hamano +# + +test_description='quoted output' + +. ./test-lib.sh + +FN='濱野' +GN='純' +HT=' ' +LF=' +' +DQ='"' + +for_each_name () { + for name in \ + Name "Name and a${LF}LF" "Name and an${HT}HT" "Name${DQ}" \ + "$FN$HT$GN" "$FN$LF$GN" "$FN $GN" "$FN$GN" "$FN$DQ$GN" \ + "With SP in it" + do + eval "$1" + done +} + +test_expect_success setup ' + + for_each_name "echo initial >\"\$name\"" + git add . && + git commit -q -m Initial && + + for_each_name "echo second >\"\$name\"" && + git commit -a -m Second + + for_each_name "echo modified >\"\$name\"" + +' + +cat >expect.quoted <<\EOF +Name +"Name and a\nLF" +"Name and an\tHT" +"Name\"" +With SP in it +"\346\277\261\351\207\216\t\347\264\224" +"\346\277\261\351\207\216\n\347\264\224" +"\346\277\261\351\207\216 \347\264\224" +"\346\277\261\351\207\216\"\347\264\224" +"\346\277\261\351\207\216\347\264\224" +EOF + +cat >expect.raw <<\EOF +Name +"Name and a\nLF" +"Name and an\tHT" +"Name\"" +With SP in it +"濱野\t純" +"濱野\n純" +濱野 純 +"濱野\"純" +濱野純 +EOF + +test_expect_success 'check fully quoted output from ls-files' ' + + git ls-files >current && diff -u expect.quoted current + +' + +test_expect_success 'check fully quoted output from diff-files' ' + + git diff --name-only >current && + diff -u expect.quoted current + +' + +test_expect_success 'check fully quoted output from diff-index' ' + + git diff --name-only HEAD >current && + diff -u expect.quoted current + +' + +test_expect_success 'check fully quoted output from diff-tree' ' + + git diff --name-only HEAD^ HEAD >current && + diff -u expect.quoted current + +' + +test_expect_success 'setting core.quotepath' ' + + git config --bool core.quotepath false + +' + +test_expect_success 'check fully quoted output from ls-files' ' + + git ls-files >current && diff -u expect.raw current + +' + +test_expect_success 'check fully quoted output from diff-files' ' + + git diff --name-only >current && + diff -u expect.raw current + +' + +test_expect_success 'check fully quoted output from diff-index' ' + + git diff --name-only HEAD >current && + diff -u expect.raw current + +' + +test_expect_success 'check fully quoted output from diff-tree' ' + + git diff --name-only HEAD^ HEAD >current && + diff -u expect.raw current + +' + +test_done diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh new file mode 100755 index 0000000000..9a9a250d2c --- /dev/null +++ b/t/t3903-stash.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# +# Copyright (c) 2007 Johannes E Schindelin +# + +test_description='Test git-stash' + +. ./test-lib.sh + +test_expect_success 'stash some dirty working directory' ' + echo 1 > file && + git add file && + test_tick && + git commit -m initial && + echo 2 > file && + git add file && + echo 3 > file && + test_tick && + git stash && + git diff-files --quiet && + git diff-index --cached --quiet HEAD +' + +cat > expect << EOF +diff --git a/file b/file +index 0cfbf08..00750ed 100644 +--- a/file ++++ b/file +@@ -1 +1 @@ +-2 ++3 +EOF + +test_expect_success 'parents of stash' ' + test $(git rev-parse stash^) = $(git rev-parse HEAD) && + git diff stash^2..stash > output && + diff -u output expect +' + +test_expect_success 'apply needs clean working directory' ' + echo 4 > other-file && + git add other-file && + echo 5 > other-file + ! git stash apply +' + +test_expect_success 'apply stashed changes' ' + git add other-file && + test_tick && + git commit -m other-file && + git stash apply && + test 3 = $(cat file) && + test 1 = $(git show :file) && + test 1 = $(git show HEAD:file) +' + +test_expect_success 'apply stashed changes (including index)' ' + git reset --hard HEAD^ && + echo 6 > other-file && + git add other-file && + test_tick && + git commit -m other-file && + git stash apply --index && + test 3 = $(cat file) && + test 2 = $(git show :file) && + test 1 = $(git show HEAD:file) +' + +test_expect_success 'unstashing in a subdirectory' ' + git reset --hard HEAD && + mkdir subdir && + cd subdir && + git stash apply +' + +test_done diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh index 9c58d77cc2..7d92ae3e99 100755 --- a/t/t4000-diff-format.sh +++ b/t/t4000-diff-format.sh @@ -17,15 +17,15 @@ chmod +x path1 test_expect_success \ 'update-cache --add two files with and without +x.' \ - 'git-update-index --add path0 path1' + 'git update-index --add path0 path1' mv path0 path0- sed -e 's/line/Line/' <path0- >path0 chmod +x path0 rm -f path1 test_expect_success \ - 'git-diff-files -p after editing work tree.' \ - 'git-diff-files -p >current' + 'git diff-files -p after editing work tree.' \ + 'git diff-files -p >current' # that's as far as it comes if [ "$(git config --get core.filemode)" = false ] @@ -56,7 +56,7 @@ deleted file mode 100755 EOF test_expect_success \ - 'validate git-diff-files -p output.' \ + 'validate git diff-files -p output.' \ 'compare_diff_patch current expected' test_done diff --git a/t/t4001-diff-rename.sh b/t/t4001-diff-rename.sh index 2e3c20d6b9..063e79257a 100755 --- a/t/t4001-diff-rename.sh +++ b/t/t4001-diff-rename.sh @@ -28,21 +28,21 @@ Line 15 test_expect_success \ 'update-cache --add a file.' \ - 'git-update-index --add path0' + 'git update-index --add path0' test_expect_success \ 'write that tree.' \ - 'tree=$(git-write-tree) && echo $tree' + 'tree=$(git write-tree) && echo $tree' sed -e 's/line/Line/' <path0 >path1 rm -f path0 test_expect_success \ 'renamed and edited the file.' \ - 'git-update-index --add --remove path0 path1' + 'git update-index --add --remove path0 path1' test_expect_success \ - 'git-diff-index -p -M after rename and editing.' \ - 'git-diff-index -p -M $tree >current' + 'git diff-index -p -M after rename and editing.' \ + 'git diff-index -p -M $tree >current' cat >expected <<\EOF diff --git a/path0 b/path1 rename from path0 @@ -64,4 +64,17 @@ test_expect_success \ 'validate the output.' \ 'compare_diff_patch current expected' +test_expect_success 'favour same basenames over different ones' ' + cp path1 another-path && + git add another-path && + git commit -m 1 && + git rm path1 && + mkdir subdir && + git mv another-path subdir/path1 && + git runstatus | grep "renamed: .*path1 -> subdir/path1"' + +test_expect_success 'favour same basenames even with minor differences' ' + git show HEAD:path1 | sed "s/15/16/" > subdir/path1 && + git runstatus | grep "renamed: .*path1 -> subdir/path1"' + test_done diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh index 56eda63fc2..a4cfde6b29 100755 --- a/t/t4002-diff-basic.sh +++ b/t/t4002-diff-basic.sh @@ -140,80 +140,80 @@ cmp_diff_files_output () { test_expect_success \ 'diff-tree of known trees.' \ - 'git-diff-tree $tree_O $tree_A >.test-a && + 'git diff-tree $tree_O $tree_A >.test-a && cmp -s .test-a .test-plain-OA' test_expect_success \ 'diff-tree of known trees.' \ - 'git-diff-tree -r $tree_O $tree_A >.test-a && + 'git diff-tree -r $tree_O $tree_A >.test-a && cmp -s .test-a .test-recursive-OA' test_expect_success \ 'diff-tree of known trees.' \ - 'git-diff-tree $tree_O $tree_B >.test-a && + 'git diff-tree $tree_O $tree_B >.test-a && cmp -s .test-a .test-plain-OB' test_expect_success \ 'diff-tree of known trees.' \ - 'git-diff-tree -r $tree_O $tree_B >.test-a && + 'git diff-tree -r $tree_O $tree_B >.test-a && cmp -s .test-a .test-recursive-OB' test_expect_success \ 'diff-tree of known trees.' \ - 'git-diff-tree $tree_A $tree_B >.test-a && + 'git diff-tree $tree_A $tree_B >.test-a && cmp -s .test-a .test-plain-AB' test_expect_success \ 'diff-tree of known trees.' \ - 'git-diff-tree -r $tree_A $tree_B >.test-a && + 'git diff-tree -r $tree_A $tree_B >.test-a && cmp -s .test-a .test-recursive-AB' test_expect_success \ 'diff-cache O with A in cache' \ - 'git-read-tree $tree_A && - git-diff-index --cached $tree_O >.test-a && + 'git read-tree $tree_A && + git diff-index --cached $tree_O >.test-a && cmp -s .test-a .test-recursive-OA' test_expect_success \ 'diff-cache O with B in cache' \ - 'git-read-tree $tree_B && - git-diff-index --cached $tree_O >.test-a && + 'git read-tree $tree_B && + git diff-index --cached $tree_O >.test-a && cmp -s .test-a .test-recursive-OB' test_expect_success \ 'diff-cache A with B in cache' \ - 'git-read-tree $tree_B && - git-diff-index --cached $tree_A >.test-a && + 'git read-tree $tree_B && + git diff-index --cached $tree_A >.test-a && cmp -s .test-a .test-recursive-AB' test_expect_success \ 'diff-files with O in cache and A checked out' \ 'rm -fr Z [A-Z][A-Z] && - git-read-tree $tree_A && - git-checkout-index -f -a && - git-read-tree --reset $tree_O || return 1 - git-update-index --refresh >/dev/null ;# this can exit non-zero - git-diff-files >.test-a && + git read-tree $tree_A && + git checkout-index -f -a && + git read-tree --reset $tree_O || return 1 + git update-index --refresh >/dev/null ;# this can exit non-zero + git diff-files >.test-a && cmp_diff_files_output .test-a .test-recursive-OA' test_expect_success \ 'diff-files with O in cache and B checked out' \ 'rm -fr Z [A-Z][A-Z] && - git-read-tree $tree_B && - git-checkout-index -f -a && - git-read-tree --reset $tree_O || return 1 - git-update-index --refresh >/dev/null ;# this can exit non-zero - git-diff-files >.test-a && + git read-tree $tree_B && + git checkout-index -f -a && + git read-tree --reset $tree_O || return 1 + git update-index --refresh >/dev/null ;# this can exit non-zero + git diff-files >.test-a && cmp_diff_files_output .test-a .test-recursive-OB' test_expect_success \ 'diff-files with A in cache and B checked out' \ 'rm -fr Z [A-Z][A-Z] && - git-read-tree $tree_B && - git-checkout-index -f -a && - git-read-tree --reset $tree_A || return 1 - git-update-index --refresh >/dev/null ;# this can exit non-zero - git-diff-files >.test-a && + git read-tree $tree_B && + git checkout-index -f -a && + git read-tree --reset $tree_A || return 1 + git update-index --refresh >/dev/null ;# this can exit non-zero + git diff-files >.test-a && cmp_diff_files_output .test-a .test-recursive-AB' ################################################################ @@ -222,26 +222,26 @@ test_expect_success \ test_expect_success \ 'diff-tree O A == diff-tree -R A O' \ - 'git-diff-tree $tree_O $tree_A >.test-a && - git-diff-tree -R $tree_A $tree_O >.test-b && + 'git diff-tree $tree_O $tree_A >.test-a && + git diff-tree -R $tree_A $tree_O >.test-b && cmp -s .test-a .test-b' test_expect_success \ 'diff-tree -r O A == diff-tree -r -R A O' \ - 'git-diff-tree -r $tree_O $tree_A >.test-a && - git-diff-tree -r -R $tree_A $tree_O >.test-b && + 'git diff-tree -r $tree_O $tree_A >.test-a && + git diff-tree -r -R $tree_A $tree_O >.test-b && cmp -s .test-a .test-b' test_expect_success \ 'diff-tree B A == diff-tree -R A B' \ - 'git-diff-tree $tree_B $tree_A >.test-a && - git-diff-tree -R $tree_A $tree_B >.test-b && + 'git diff-tree $tree_B $tree_A >.test-a && + git diff-tree -R $tree_A $tree_B >.test-b && cmp -s .test-a .test-b' test_expect_success \ 'diff-tree -r B A == diff-tree -r -R A B' \ - 'git-diff-tree -r $tree_B $tree_A >.test-a && - git-diff-tree -r -R $tree_A $tree_B >.test-b && + 'git diff-tree -r $tree_B $tree_A >.test-a && + git diff-tree -r -R $tree_A $tree_B >.test-b && cmp -s .test-a .test-b' test_done diff --git a/t/t4003-diff-rename-1.sh b/t/t4003-diff-rename-1.sh index 27519704d4..8b1f875286 100755 --- a/t/t4003-diff-rename-1.sh +++ b/t/t4003-diff-rename-1.sh @@ -13,8 +13,8 @@ test_expect_success \ 'prepare reference tree' \ 'cat ../../COPYING >COPYING && echo frotz >rezrov && - git-update-index --add COPYING rezrov && - tree=$(git-write-tree) && + git update-index --add COPYING rezrov && + tree=$(git write-tree) && echo $tree' test_expect_success \ @@ -22,14 +22,14 @@ test_expect_success \ 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && rm -f COPYING && - git-update-index --add --remove COPYING COPYING.?' + git update-index --add --remove COPYING COPYING.?' # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, # both are slightly edited, and unchanged rezrov. So we say you # copy-and-edit one, and rename-and-edit the other. We do not say # anything about rezrov. -GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree >current +GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current cat >expected <<\EOF diff --git a/COPYING b/COPYING.1 copy from COPYING @@ -62,14 +62,14 @@ test_expect_success \ test_expect_success \ 'prepare work tree again' \ 'mv COPYING.2 COPYING && - git-update-index --add --remove COPYING COPYING.1 COPYING.2' + git update-index --add --remove COPYING COPYING.1 COPYING.2' # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, # both are slightly edited, and unchanged rezrov. So we say you # edited one, and copy-and-edit the other. We do not say # anything about rezrov. -GIT_DIFF_OPTS=--unified=0 git-diff-index -C -p $tree >current +GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current cat >expected <<\EOF diff --git a/COPYING b/COPYING --- a/COPYING @@ -100,16 +100,16 @@ test_expect_success \ test_expect_success \ 'prepare work tree once again' \ 'cat ../../COPYING >COPYING && - git-update-index --add --remove COPYING COPYING.1' + git update-index --add --remove COPYING COPYING.1' # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, # but COPYING is not edited. We say you copy-and-edit COPYING.1; this # is only possible because -C mode now reports the unmodified file to # the diff-core. Unchanged rezrov, although being fed to -# git-diff-index as well, should not be mentioned. +# git diff-index as well, should not be mentioned. GIT_DIFF_OPTS=--unified=0 \ - git-diff-index -C --find-copies-harder -p $tree >current + git diff-index -C --find-copies-harder -p $tree >current cat >expected <<\EOF diff --git a/COPYING b/COPYING.1 copy from COPYING diff --git a/t/t4004-diff-rename-symlink.sh b/t/t4004-diff-rename-symlink.sh index a23aaa0a94..3d25be7a67 100755 --- a/t/t4004-diff-rename-symlink.sh +++ b/t/t4004-diff-rename-symlink.sh @@ -16,8 +16,8 @@ test_expect_success \ 'prepare reference tree' \ 'echo xyzzy | tr -d '\\\\'012 >yomin && ln -s xyzzy frotz && - git-update-index --add frotz yomin && - tree=$(git-write-tree) && + git update-index --add frotz yomin && + tree=$(git write-tree) && echo $tree' test_expect_success \ @@ -26,7 +26,7 @@ test_expect_success \ rm -f yomin && ln -s xyzzy nitfol && ln -s xzzzy bozbar && - git-update-index --add --remove frotz rezrov nitfol bozbar yomin' + git update-index --add --remove frotz rezrov nitfol bozbar yomin' # tree has frotz pointing at xyzzy, and yomin that contains xyzzy to # confuse things. work tree has rezrov (xyzzy) nitfol (xyzzy) and @@ -34,7 +34,7 @@ test_expect_success \ # rezrov and nitfol are rename/copy of frotz and bozbar should be # a new creation. -GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree >current +GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current cat >expected <<\EOF diff --git a/bozbar b/bozbar new file mode 120000 diff --git a/t/t4005-diff-rename-2.sh b/t/t4005-diff-rename-2.sh index 684fd23a41..6630017312 100755 --- a/t/t4005-diff-rename-2.sh +++ b/t/t4005-diff-rename-2.sh @@ -13,8 +13,8 @@ test_expect_success \ 'prepare reference tree' \ 'cat ../../COPYING >COPYING && echo frotz >rezrov && - git-update-index --add COPYING rezrov && - tree=$(git-write-tree) && + git update-index --add COPYING rezrov && + tree=$(git write-tree) && echo $tree' test_expect_success \ @@ -22,14 +22,14 @@ test_expect_success \ 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && rm -f COPYING && - git-update-index --add --remove COPYING COPYING.?' + git update-index --add --remove COPYING COPYING.?' # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, # both are slightly edited, and unchanged rezrov. We say COPYING.1 # and COPYING.2 are based on COPYING, and do not say anything about # rezrov. -git-diff-index -M $tree >current +git diff-index -M $tree >current cat >expected <<\EOF :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 @@ -45,14 +45,14 @@ test_expect_success \ test_expect_success \ 'prepare work tree again' \ 'mv COPYING.2 COPYING && - git-update-index --add --remove COPYING COPYING.1 COPYING.2' + git update-index --add --remove COPYING COPYING.1 COPYING.2' # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, # both are slightly edited, and unchanged rezrov. We say COPYING.1 # is based on COPYING and COPYING is still there, and do not say anything # about rezrov. -git-diff-index -C $tree >current +git diff-index -C $tree >current cat >expected <<\EOF :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M COPYING :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 @@ -72,9 +72,9 @@ test_expect_success \ test_expect_success \ 'prepare work tree once again' \ 'cat ../../COPYING >COPYING && - git-update-index --add --remove COPYING COPYING.1' + git update-index --add --remove COPYING COPYING.1' -git-diff-index -C --find-copies-harder $tree >current +git diff-index -C --find-copies-harder $tree >current cat >expected <<\EOF :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 EOF diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh index e72c6fd1b4..ab5406dd9f 100755 --- a/t/t4006-diff-mode.sh +++ b/t/t4006-diff-mode.sh @@ -11,24 +11,24 @@ test_description='Test mode change diffs. test_expect_success \ 'setup' \ 'echo frotz >rezrov && - git-update-index --add rezrov && - tree=`git-write-tree` && + git update-index --add rezrov && + tree=`git write-tree` && echo $tree' if [ "$(git config --get core.filemode)" = false ] then say 'filemode disabled on the filesystem, using update-index --chmod=+x' test_expect_success \ - 'git-update-index --chmod=+x' \ - 'git-update-index rezrov && - git-update-index --chmod=+x rezrov && - git-diff-index $tree >current' + 'git update-index --chmod=+x' \ + 'git update-index rezrov && + git update-index --chmod=+x rezrov && + git diff-index $tree >current' else test_expect_success \ 'chmod' \ 'chmod +x rezrov && - git-update-index rezrov && - git-diff-index $tree >current' + git update-index rezrov && + git diff-index $tree >current' fi _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' @@ -41,4 +41,3 @@ test_expect_success \ 'git diff expected check' test_done - diff --git a/t/t4007-rename-3.sh b/t/t4007-rename-3.sh index bb6ba69258..104a4e1492 100755 --- a/t/t4007-rename-3.sh +++ b/t/t4007-rename-3.sh @@ -13,20 +13,20 @@ test_expect_success \ 'prepare reference tree' \ 'mkdir path0 path1 && cp ../../COPYING path0/COPYING && - git-update-index --add path0/COPYING && - tree=$(git-write-tree) && + git update-index --add path0/COPYING && + tree=$(git write-tree) && echo $tree' test_expect_success \ 'prepare work tree' \ 'cp path0/COPYING path1/COPYING && - git-update-index --add --remove path0/COPYING path1/COPYING' + git update-index --add --remove path0/COPYING path1/COPYING' # In the tree, there is only path0/COPYING. In the cache, path0 and # path1 both have COPYING and the latter is a copy of path0/COPYING. # Comparing the full tree with cache should tell us so. -git-diff-index -C --find-copies-harder $tree >current +git diff-index -C --find-copies-harder $tree >current cat >expected <<\EOF :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING @@ -42,7 +42,7 @@ test_expect_success \ # path1/COPYING suddenly appearing from nowhere, not detected as # a copy from path0/COPYING. -git-diff-index -C $tree path1 >current +git diff-index -C $tree path1 >current cat >expected <<\EOF :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING @@ -55,14 +55,14 @@ test_expect_success \ test_expect_success \ 'tweak work tree' \ 'rm -f path0/COPYING && - git-update-index --remove path0/COPYING' + git update-index --remove path0/COPYING' # In the tree, there is only path0/COPYING. In the cache, path0 does # not have COPYING anymore and path1 has COPYING which is a copy of # path0/COPYING. Showing the full tree with cache should tell us about # the rename. -git-diff-index -C $tree >current +git diff-index -C $tree >current cat >expected <<\EOF :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING @@ -77,7 +77,7 @@ test_expect_success \ # path0/COPYING. When we say we care only about path1, we should just # see path1/COPYING appearing from nowhere. -git-diff-index -C $tree path1 >current +git diff-index -C $tree path1 >current cat >expected <<\EOF :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING diff --git a/t/t4008-diff-break-rewrite.sh b/t/t4008-diff-break-rewrite.sh index 263ac1ebf7..5836e3a899 100755 --- a/t/t4008-diff-break-rewrite.sh +++ b/t/t4008-diff-break-rewrite.sh @@ -28,19 +28,19 @@ test_expect_success \ setup \ 'cat ../../README >file0 && cat ../../COPYING >file1 && - git-update-index --add file0 file1 && - tree=$(git-write-tree) && + git update-index --add file0 file1 && + tree=$(git write-tree) && echo "$tree"' test_expect_success \ 'change file1 with copy-edit of file0 and remove file0' \ 'sed -e "s/git/GIT/" file0 >file1 && rm -f file0 && - git-update-index --remove file0 file1' + git update-index --remove file0 file1' test_expect_success \ 'run diff with -B' \ - 'git-diff-index -B --cached "$tree" >current' + 'git diff-index -B --cached "$tree" >current' cat >expected <<\EOF :100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D file0 @@ -53,7 +53,7 @@ test_expect_success \ test_expect_success \ 'run diff with -B and -M' \ - 'git-diff-index -B -M "$tree" >current' + 'git diff-index -B -M "$tree" >current' cat >expected <<\EOF :100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c R100 file0 file1 @@ -66,16 +66,16 @@ test_expect_success \ test_expect_success \ 'swap file0 and file1' \ 'rm -f file0 file1 && - git-read-tree -m $tree && - git-checkout-index -f -u -a && + git read-tree -m $tree && + git checkout-index -f -u -a && mv file0 tmp && mv file1 file0 && mv tmp file1 && - git-update-index file0 file1' + git update-index file0 file1' test_expect_success \ 'run diff with -B' \ - 'git-diff-index -B "$tree" >current' + 'git diff-index -B "$tree" >current' cat >expected <<\EOF :100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 6ff87c4664981e4397625791c8ea3bbb5f2279a3 M100 file0 @@ -88,7 +88,7 @@ test_expect_success \ test_expect_success \ 'run diff with -B and -M' \ - 'git-diff-index -B -M "$tree" >current' + 'git diff-index -B -M "$tree" >current' cat >expected <<\EOF :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 file1 file0 @@ -103,11 +103,11 @@ test_expect_success \ 'make file0 into something completely different' \ 'rm -f file0 && ln -s frotz file0 && - git-update-index file0 file1' + git update-index file0 file1' test_expect_success \ 'run diff with -B' \ - 'git-diff-index -B "$tree" >current' + 'git diff-index -B "$tree" >current' cat >expected <<\EOF :100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T file0 @@ -120,7 +120,7 @@ test_expect_success \ test_expect_success \ 'run diff with -B' \ - 'git-diff-index -B -M "$tree" >current' + 'git diff-index -B -M "$tree" >current' # This should not mistake file0 as the copy source of new file1 # due to type differences. @@ -135,7 +135,7 @@ test_expect_success \ test_expect_success \ 'run diff with -M' \ - 'git-diff-index -M "$tree" >current' + 'git diff-index -M "$tree" >current' # This should not mistake file0 as the copy source of new file1 # due to type differences. @@ -151,16 +151,16 @@ test_expect_success \ test_expect_success \ 'file1 edited to look like file0 and file0 rename-edited to file2' \ 'rm -f file0 file1 && - git-read-tree -m $tree && - git-checkout-index -f -u -a && + git read-tree -m $tree && + git checkout-index -f -u -a && sed -e "s/git/GIT/" file0 >file1 && sed -e "s/git/GET/" file0 >file2 && rm -f file0 - git-update-index --add --remove file0 file1 file2' + git update-index --add --remove file0 file1 file2' test_expect_success \ 'run diff with -B' \ - 'git-diff-index -B "$tree" >current' + 'git diff-index -B "$tree" >current' cat >expected <<\EOF :100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D file0 @@ -174,7 +174,7 @@ test_expect_success \ test_expect_success \ 'run diff with -B -M' \ - 'git-diff-index -B -M "$tree" >current' + 'git diff-index -B -M "$tree" >current' cat >expected <<\EOF :100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c C095 file0 file1 diff --git a/t/t4009-diff-rename-4.sh b/t/t4009-diff-rename-4.sh index 2f2f8b1216..d2b45e7b8f 100755 --- a/t/t4009-diff-rename-4.sh +++ b/t/t4009-diff-rename-4.sh @@ -13,8 +13,8 @@ test_expect_success \ 'prepare reference tree' \ 'cat ../../COPYING >COPYING && echo frotz >rezrov && - git-update-index --add COPYING rezrov && - tree=$(git-write-tree) && + git update-index --add COPYING rezrov && + tree=$(git write-tree) && echo $tree' test_expect_success \ @@ -22,14 +22,14 @@ test_expect_success \ 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && rm -f COPYING && - git-update-index --add --remove COPYING COPYING.?' + git update-index --add --remove COPYING COPYING.?' # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, # both are slightly edited, and unchanged rezrov. We say COPYING.1 # and COPYING.2 are based on COPYING, and do not say anything about # rezrov. -git-diff-index -z -M $tree >current +git diff-index -z -M $tree >current cat >expected <<\EOF :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 @@ -49,14 +49,14 @@ test_expect_success \ test_expect_success \ 'prepare work tree again' \ 'mv COPYING.2 COPYING && - git-update-index --add --remove COPYING COPYING.1 COPYING.2' + git update-index --add --remove COPYING COPYING.1 COPYING.2' # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, # both are slightly edited, and unchanged rezrov. We say COPYING.1 # is based on COPYING and COPYING is still there, and do not say anything # about rezrov. -git-diff-index -z -C $tree >current +git diff-index -z -C $tree >current cat >expected <<\EOF :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M COPYING @@ -79,9 +79,9 @@ test_expect_success \ test_expect_success \ 'prepare work tree once again' \ 'cat ../../COPYING >COPYING && - git-update-index --add --remove COPYING COPYING.1' + git update-index --add --remove COPYING COPYING.1' -git-diff-index -z -C --find-copies-harder $tree >current +git diff-index -z -C --find-copies-harder $tree >current cat >expected <<\EOF :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh index 9e1544df9d..ad3d9e4845 100755 --- a/t/t4010-diff-pathspec.sh +++ b/t/t4010-diff-pathspec.sh @@ -17,18 +17,18 @@ test_expect_success \ 'echo frotz >file0 && mkdir path1 && echo rezrov >path1/file1 && - git-update-index --add file0 path1/file1 && - tree=`git-write-tree` && + git update-index --add file0 path1/file1 && + tree=`git write-tree` && echo "$tree" && echo nitfol >file0 && echo yomin >path1/file1 && - git-update-index file0 path1/file1' + git update-index file0 path1/file1' cat >expected <<\EOF EOF test_expect_success \ 'limit to path should show nothing' \ - 'git-diff-index --cached $tree -- path >current && + 'git diff-index --cached $tree -- path >current && compare_diff_raw current expected' cat >expected <<\EOF @@ -36,7 +36,7 @@ cat >expected <<\EOF EOF test_expect_success \ 'limit to path1 should show path1/file1' \ - 'git-diff-index --cached $tree -- path1 >current && + 'git diff-index --cached $tree -- path1 >current && compare_diff_raw current expected' cat >expected <<\EOF @@ -44,7 +44,7 @@ cat >expected <<\EOF EOF test_expect_success \ 'limit to path1/ should show path1/file1' \ - 'git-diff-index --cached $tree -- path1/ >current && + 'git diff-index --cached $tree -- path1/ >current && compare_diff_raw current expected' cat >expected <<\EOF @@ -52,14 +52,14 @@ cat >expected <<\EOF EOF test_expect_success \ 'limit to file0 should show file0' \ - 'git-diff-index --cached $tree -- file0 >current && + 'git diff-index --cached $tree -- file0 >current && compare_diff_raw current expected' cat >expected <<\EOF EOF test_expect_success \ 'limit to file0/ should emit nothing.' \ - 'git-diff-index --cached $tree -- file0/ >current && + 'git diff-index --cached $tree -- file0/ >current && compare_diff_raw current expected' test_done diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh index 379a831f0b..c6d13693ba 100755 --- a/t/t4011-diff-symlink.sh +++ b/t/t4011-diff-symlink.sh @@ -23,17 +23,17 @@ EOF test_expect_success \ 'diff new symlink' \ 'ln -s xyzzy frotz && - git-update-index && - tree=$(git-write-tree) && - git-update-index --add frotz && - GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree > current && + git update-index && + tree=$(git write-tree) && + git update-index --add frotz && + GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree > current && compare_diff_patch current expected' test_expect_success \ 'diff unchanged symlink' \ - 'tree=$(git-write-tree) && - git-update-index frotz && - test -z "$(git-diff-index --name-only $tree)"' + 'tree=$(git write-tree) && + git update-index frotz && + test -z "$(git diff-index --name-only $tree)"' cat > expected << EOF diff --git a/frotz b/frotz @@ -49,7 +49,7 @@ EOF test_expect_success \ 'diff removed symlink' \ 'rm frotz && - git-diff-index -M -p $tree > current && + git diff-index -M -p $tree > current && compare_diff_patch current expected' cat > expected << EOF @@ -60,7 +60,7 @@ test_expect_success \ 'diff identical, but newly created symlink' \ 'sleep 3 && ln -s xyzzy frotz && - git-diff-index -M -p $tree > current && + git diff-index -M -p $tree > current && compare_diff_patch current expected' cat > expected << EOF @@ -79,7 +79,7 @@ test_expect_success \ 'diff different symlink' \ 'rm frotz && ln -s yxyyz frotz && - git-diff-index -M -p $tree > current && + git diff-index -M -p $tree > current && compare_diff_patch current expected' test_done diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh index 323606c65c..eced1f30fb 100755 --- a/t/t4012-diff-binary.sh +++ b/t/t4012-diff-binary.sh @@ -10,7 +10,7 @@ test_description='Binary diff and apply test_expect_success 'prepare repository' \ 'echo AIT >a && echo BIT >b && echo CIT >c && echo DIT >d && - git-update-index --add a b c d && + git update-index --add a b c d && echo git >a && cat ../test4012.png >b && echo git >c && @@ -24,18 +24,18 @@ cat > expected <<\EOF 4 files changed, 2 insertions(+), 2 deletions(-) EOF test_expect_success 'diff without --binary' \ - 'git-diff | git-apply --stat --summary >current && + 'git diff | git apply --stat --summary >current && cmp current expected' test_expect_success 'diff with --binary' \ - 'git-diff --binary | git-apply --stat --summary >current && + 'git diff --binary | git apply --stat --summary >current && 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. test_expect_success 'apply detecting corrupt patch correctly' \ - 'git-diff | sed -e 's/-CIT/xCIT/' >broken && - if git-apply --stat --summary broken 2>detected + 'git diff | sed -e 's/-CIT/xCIT/' >broken && + if git apply --stat --summary broken 2>detected then echo unhappy - should have detected an error (exit 1) @@ -48,8 +48,8 @@ test_expect_success 'apply detecting corrupt patch correctly' \ test "$detected" = xCIT' test_expect_success 'apply detecting corrupt patch correctly' \ - 'git-diff --binary | sed -e 's/-CIT/xCIT/' >broken && - if git-apply --stat --summary broken 2>detected + 'git diff --binary | sed -e 's/-CIT/xCIT/' >broken && + if git apply --stat --summary broken 2>detected then echo unhappy - should have detected an error (exit 1) @@ -66,15 +66,15 @@ test_expect_success 'initial commit' 'git-commit -a -m initial' # Try removal (b), modification (d), and creation (e). test_expect_success 'diff-index with --binary' \ 'echo AIT >a && mv b e && echo CIT >c && cat e >d && - git-update-index --add --remove a b c d e && - tree0=`git-write-tree` && - git-diff --cached --binary >current && - git-apply --stat --summary current' + git update-index --add --remove a b c d e && + tree0=`git write-tree` && + git diff --cached --binary >current && + git apply --stat --summary current' test_expect_success 'apply binary patch' \ 'git-reset --hard && - git-apply --binary --index <current && - tree1=`git-write-tree` && + git apply --binary --index <current && + tree1=`git write-tree` && test "$tree1" = "$tree0"' test_done diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 4e7d68dda2..9eec754221 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -243,6 +243,8 @@ format-patch --inline --stdout initial..side format-patch --inline --stdout initial..master^ format-patch --inline --stdout initial..master format-patch --inline --stdout --subject-prefix=TESTCASE initial..master +config format.subjectprefix DIFFERENT_PREFIX +format-patch --inline --stdout initial..master^^ diff --abbrev initial..side diff -r initial..side diff --git a/t/t4013/diff.config_format.subjectprefix_DIFFERENT_PREFIX b/t/t4013/diff.config_format.subjectprefix_DIFFERENT_PREFIX new file mode 100644 index 0000000000..78f8970e2b --- /dev/null +++ b/t/t4013/diff.config_format.subjectprefix_DIFFERENT_PREFIX @@ -0,0 +1,2 @@ +$ git config format.subjectprefix DIFFERENT_PREFIX +$ diff --git a/t/t4013/diff.format-patch_--inline_--stdout_initial..master^^ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master^^ new file mode 100644 index 0000000000..b8e81e1552 --- /dev/null +++ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master^^ @@ -0,0 +1,60 @@ +$ git format-patch --inline --stdout initial..master^^ +From 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:01:00 +0000 +Subject: [DIFFERENT_PREFIX] Second +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit + + +This is the second commit. +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +--------------g-i-t--v-e-r-s-i-o-n-- + + +$ diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 930e209d31..79fdff3f3a 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -17,7 +17,7 @@ do { } while (0); EOF -git-update-index --add x +git update-index --add x cat << EOF > x do @@ -42,13 +42,13 @@ index adf3937..6edc172 100644 +while (0); EOF -git-diff > out +git diff > out test_expect_success "Ray's example without options" 'git diff expect out' -git-diff -w > out +git diff -w > out test_expect_success "Ray's example with -w" 'git diff expect out' -git-diff -b > out +git diff -b > out test_expect_success "Ray's example with -b" 'git diff expect out' tr 'Q' '\015' << EOF > x @@ -60,7 +60,7 @@ unchanged line CR at endQ EOF -git-update-index x +git update-index x cat << EOF > x whitespace at beginning @@ -89,14 +89,14 @@ index d99af23..8b32fb5 100644 -CR at endQ +CR at end EOF -git-diff > out +git diff > out test_expect_success 'another test, without options' 'git diff expect out' cat << EOF > expect diff --git a/x b/x index d99af23..8b32fb5 100644 EOF -git-diff -w > out +git diff -w > out test_expect_success 'another test, with -w' 'git diff expect out' tr 'Q' '\015' << EOF > expect @@ -114,7 +114,7 @@ index d99af23..8b32fb5 100644 unchanged line CR at endQ EOF -git-diff -b > out +git diff -b > out test_expect_success 'another test, with -b' 'git diff expect out' test_done diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh new file mode 100644 index 0000000000..f9db81d3ab --- /dev/null +++ b/t/t4018-diff-funcname.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# +# Copyright (c) 2007 Johannes E. Schindelin +# + +test_description='Test custom diff function name patterns' + +. ./test-lib.sh + +LF=' +' + +cat > Beer.java << EOF +public class Beer +{ + int special; + public static void main(String args[]) + { + String s=" "; + for(int x = 99; x > 0; x--) + { + System.out.print(x + " bottles of beer on the wall " + + x + " bottles of beer\n" + + "Take one down, pass it around, " + (x - 1) + + " bottles of beer on the wall.\n"); + } + System.out.print("Go to the store, buy some more,\n" + + "99 bottles of beer on the wall.\n"); + } +} +EOF + +sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java + +test_expect_success 'default behaviour' ' + git diff Beer.java Beer-correct.java | + grep "^@@.*@@ public class Beer" +' + +test_expect_success 'preset java pattern' ' + echo "*.java diff=java" >.gitattributes && + git diff Beer.java Beer-correct.java | + grep "^@@.*@@ public static void main(" +' + +git config diff.java.funcname '!static +!String +[^ ].*s.*' + +test_expect_success 'custom pattern' ' + git diff Beer.java Beer-correct.java | + grep "^@@.*@@ int special;$" +' + +test_expect_success 'last regexp must not be negated' ' + git config diff.java.funcname "!static" && + ! git diff Beer.java Beer-correct.java +' + +test_done diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh index f0045cd788..ed3bd5b3fe 100755 --- a/t/t4020-diff-external.sh +++ b/t/t4020-diff-external.sh @@ -94,4 +94,16 @@ test_expect_success 'diff attribute should apply only to diff' ' ' +test_expect_success 'no diff with -diff' ' + echo >.gitattributes "file -diff" && + git diff | grep Binary +' + +echo NULZbetweenZwords | tr Z '\0' > file + +test_expect_success 'force diff with "diff"' ' + echo >.gitattributes "file diff" && + git diff | grep -a second +' + test_done diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index 7b81c32e57..435f65b370 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -3,45 +3,44 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-apply --stat --summary test. +test_description='git apply --stat --summary test. ' . ./test-lib.sh test_expect_success \ 'rename' \ - 'git-apply --stat --summary <../t4100/t-apply-1.patch >current && + 'git apply --stat --summary <../t4100/t-apply-1.patch >current && git diff ../t4100/t-apply-1.expect current' test_expect_success \ 'copy' \ - 'git-apply --stat --summary <../t4100/t-apply-2.patch >current && + 'git apply --stat --summary <../t4100/t-apply-2.patch >current && git diff ../t4100/t-apply-2.expect current' test_expect_success \ 'rewrite' \ - 'git-apply --stat --summary <../t4100/t-apply-3.patch >current && + 'git apply --stat --summary <../t4100/t-apply-3.patch >current && git diff ../t4100/t-apply-3.expect current' test_expect_success \ 'mode' \ - 'git-apply --stat --summary <../t4100/t-apply-4.patch >current && + 'git apply --stat --summary <../t4100/t-apply-4.patch >current && git diff ../t4100/t-apply-4.expect current' test_expect_success \ 'non git' \ - 'git-apply --stat --summary <../t4100/t-apply-5.patch >current && + 'git apply --stat --summary <../t4100/t-apply-5.patch >current && git diff ../t4100/t-apply-5.expect current' test_expect_success \ 'non git' \ - 'git-apply --stat --summary <../t4100/t-apply-6.patch >current && + 'git apply --stat --summary <../t4100/t-apply-6.patch >current && git diff ../t4100/t-apply-6.expect current' test_expect_success \ 'non git' \ - 'git-apply --stat --summary <../t4100/t-apply-7.patch >current && + 'git apply --stat --summary <../t4100/t-apply-7.patch >current && git diff ../t4100/t-apply-7.expect current' test_done - diff --git a/t/t4101-apply-nonl.sh b/t/t4101-apply-nonl.sh index 026fac8c55..da8abcf364 100755 --- a/t/t4101-apply-nonl.sh +++ b/t/t4101-apply-nonl.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-apply should handle files with incomplete lines. +test_description='git apply should handle files with incomplete lines. ' . ./test-lib.sh @@ -23,7 +23,7 @@ do cat frotz.$i >frotz test_expect_success \ "apply diff between $i and $j" \ - "git-apply <../t4101/diff.$i-$j && diff frotz.$j frotz" + "git apply <../t4101/diff.$i-$j && diff frotz.$j frotz" done done diff --git a/t/t4102-apply-rename.sh b/t/t4102-apply-rename.sh index b4662b0364..d42abff1ad 100755 --- a/t/t4102-apply-rename.sh +++ b/t/t4102-apply-rename.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-apply handling copy/rename patch. +test_description='git apply handling copy/rename patch. ' . ./test-lib.sh @@ -26,10 +26,10 @@ echo 'This is foo' >foo chmod +x foo test_expect_success setup \ - 'git-update-index --add foo' + 'git update-index --add foo' test_expect_success apply \ - 'git-apply --index --stat --summary --apply test-patch' + 'git apply --index --stat --summary --apply test-patch' if [ "$(git config --get core.filemode)" = false ] then @@ -40,7 +40,7 @@ else fi test_expect_success 'apply reverse' \ - 'git-apply -R --index --stat --summary --apply test-patch && + 'git apply -R --index --stat --summary --apply test-patch && test "$(cat foo)" = "This is foo"' cat >test-patch <<\EOF @@ -56,7 +56,7 @@ copy to bar EOF test_expect_success 'apply copy' \ - 'git-apply --index --stat --summary --apply test-patch && + 'git apply --index --stat --summary --apply test-patch && test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"' test_done diff --git a/t/t4103-apply-binary.sh b/t/t4103-apply-binary.sh index e2b1124c78..011126f336 100755 --- a/t/t4103-apply-binary.sh +++ b/t/t4103-apply-binary.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-apply handling binary patches +test_description='git apply handling binary patches ' . ./test-lib.sh @@ -20,55 +20,55 @@ EOF cat file1 >file2 cat file1 >file4 -git-update-index --add --remove file1 file2 file4 +git update-index --add --remove file1 file2 file4 git-commit -m 'Initial Version' 2>/dev/null git-checkout -b binary tr 'x' '\0' <file1 >file3 cat file3 >file4 -git-add file2 +git add file2 tr '\0' 'v' <file3 >file1 rm -f file2 -git-update-index --add --remove file1 file2 file3 file4 +git update-index --add --remove file1 file2 file3 file4 git-commit -m 'Second Version' -git-diff-tree -p master binary >B.diff -git-diff-tree -p -C master binary >C.diff +git diff-tree -p master binary >B.diff +git diff-tree -p -C master binary >C.diff -git-diff-tree -p --binary master binary >BF.diff -git-diff-tree -p --binary -C master binary >CF.diff +git diff-tree -p --binary master binary >BF.diff +git diff-tree -p --binary -C master binary >CF.diff test_expect_success 'stat binary diff -- should not fail.' \ 'git-checkout master - git-apply --stat --summary B.diff' + git apply --stat --summary B.diff' test_expect_success 'stat binary diff (copy) -- should not fail.' \ 'git-checkout master - git-apply --stat --summary C.diff' + git apply --stat --summary C.diff' test_expect_failure 'check binary diff -- should fail.' \ 'git-checkout master - git-apply --check B.diff' + git apply --check B.diff' test_expect_failure 'check binary diff (copy) -- should fail.' \ 'git-checkout master - git-apply --check C.diff' + git apply --check C.diff' test_expect_failure 'check incomplete binary diff with replacement -- should fail.' \ 'git-checkout master - git-apply --check --allow-binary-replacement B.diff' + git apply --check --allow-binary-replacement B.diff' test_expect_failure 'check incomplete binary diff with replacement (copy) -- should fail.' \ 'git-checkout master - git-apply --check --allow-binary-replacement C.diff' + git apply --check --allow-binary-replacement C.diff' test_expect_success 'check binary diff with replacement.' \ 'git-checkout master - git-apply --check --allow-binary-replacement BF.diff' + git apply --check --allow-binary-replacement BF.diff' test_expect_success 'check binary diff with replacement (copy).' \ 'git-checkout master - git-apply --check --allow-binary-replacement CF.diff' + git apply --check --allow-binary-replacement CF.diff' # Now we start applying them. @@ -80,36 +80,36 @@ do_reset () { test_expect_failure 'apply binary diff -- should fail.' \ 'do_reset - git-apply B.diff' + git apply B.diff' test_expect_failure 'apply binary diff -- should fail.' \ 'do_reset - git-apply --index B.diff' + git apply --index B.diff' test_expect_failure 'apply binary diff (copy) -- should fail.' \ 'do_reset - git-apply C.diff' + git apply C.diff' test_expect_failure 'apply binary diff (copy) -- should fail.' \ 'do_reset - git-apply --index C.diff' + git apply --index C.diff' test_expect_success 'apply binary diff without replacement.' \ 'do_reset - git-apply BF.diff' + git apply BF.diff' test_expect_success 'apply binary diff without replacement (copy).' \ 'do_reset - git-apply CF.diff' + git apply CF.diff' test_expect_success 'apply binary diff.' \ 'do_reset - git-apply --allow-binary-replacement --index BF.diff && - test -z "$(git-diff --name-status binary)"' + git apply --allow-binary-replacement --index BF.diff && + test -z "$(git diff --name-status binary)"' test_expect_success 'apply binary diff (copy).' \ 'do_reset - git-apply --allow-binary-replacement --index CF.diff && - test -z "$(git-diff --name-status binary)"' + git apply --allow-binary-replacement --index CF.diff && + test -z "$(git diff --name-status binary)"' test_done diff --git a/t/t4104-apply-boundary.sh b/t/t4104-apply-boundary.sh index a5fb3ea40e..64f34e3298 100755 --- a/t/t4104-apply-boundary.sh +++ b/t/t4104-apply-boundary.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-apply boundary tests +test_description='git apply boundary tests ' . ./test-lib.sh diff --git a/t/t4109-apply-multifrag.sh b/t/t4109-apply-multifrag.sh index 5988e1ae4c..bd40a218cd 100755 --- a/t/t4109-apply-multifrag.sh +++ b/t/t4109-apply-multifrag.sh @@ -4,7 +4,7 @@ # Copyright (c) 2005 Robert Fitzsimons # -test_description='git-apply test patches with multiple fragments. +test_description='git apply test patches with multiple fragments. ' . ./test-lib.sh @@ -138,8 +138,8 @@ diff --git a/main.c b/main.c EOF -test_expect_success "S = git-apply (1)" \ - 'git-apply patch1.patch patch2.patch' +test_expect_success "S = git apply (1)" \ + 'git apply patch1.patch patch2.patch' mv main.c main.c.git test_expect_success "S = patch (1)" \ @@ -150,8 +150,8 @@ test_expect_success "S = cmp (1)" \ rm -f main.c main.c.git -test_expect_success "S = git-apply (2)" \ - 'git-apply patch1.patch patch2.patch patch3.patch' +test_expect_success "S = git apply (2)" \ + 'git apply patch1.patch patch2.patch patch3.patch' mv main.c main.c.git test_expect_success "S = patch (2)" \ @@ -162,8 +162,8 @@ test_expect_success "S = cmp (2)" \ rm -f main.c main.c.git -test_expect_success "S = git-apply (3)" \ - 'git-apply patch1.patch patch4.patch' +test_expect_success "S = git apply (3)" \ + 'git apply patch1.patch patch4.patch' mv main.c main.c.git test_expect_success "S = patch (3)" \ diff --git a/t/t4110-apply-scan.sh b/t/t4110-apply-scan.sh index 005f744816..db60652a37 100755 --- a/t/t4110-apply-scan.sh +++ b/t/t4110-apply-scan.sh @@ -4,7 +4,7 @@ # Copyright (c) 2005 Robert Fitzsimons # -test_description='git-apply test for patches which require scanning forwards and backwards. +test_description='git apply test for patches which require scanning forwards and backwards. ' . ./test-lib.sh @@ -86,8 +86,8 @@ diff --git a/new.txt b/new.txt +c2222 EOF -test_expect_success "S = git-apply scan" \ - 'git-apply patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch' +test_expect_success "S = git apply scan" \ + 'git apply patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch' mv new.txt apply.txt test_expect_success "S = patch scan" \ @@ -98,4 +98,3 @@ test_expect_success "S = cmp" \ 'cmp apply.txt patch.txt' test_done - diff --git a/t/t4112-apply-renames.sh b/t/t4112-apply-renames.sh index 69e9603c78..70a1859503 100755 --- a/t/t4112-apply-renames.sh +++ b/t/t4112-apply-renames.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-apply should not get confused with rename/copy. +test_description='git apply should not get confused with rename/copy. ' @@ -49,10 +49,10 @@ copy to include/arch/cris/klibc/archsetjmp.h - * arch/x86_64/include/klibc/archsetjmp.h + * arch/cris/include/klibc/archsetjmp.h */ - + #ifndef _KLIBC_ARCHSETJMP_H #define _KLIBC_ARCHSETJMP_H - + struct __jmp_buf { - unsigned long __rbx; - unsigned long __rsp; @@ -74,9 +74,9 @@ copy to include/arch/cris/klibc/archsetjmp.h + unsigned long __sp; + unsigned long __srp; }; - + typedef struct __jmp_buf jmp_buf[1]; - + -#endif /* _SETJMP_H */ +#endif /* _KLIBC_ARCHSETJMP_H */ diff --git a/klibc/arch/x86_64/include/klibc/archsetjmp.h b/include/arch/m32r/klibc/archsetjmp.h @@ -90,10 +90,10 @@ rename to include/arch/m32r/klibc/archsetjmp.h - * arch/x86_64/include/klibc/archsetjmp.h + * arch/m32r/include/klibc/archsetjmp.h */ - + #ifndef _KLIBC_ARCHSETJMP_H #define _KLIBC_ARCHSETJMP_H - + struct __jmp_buf { - unsigned long __rbx; - unsigned long __rsp; @@ -108,17 +108,17 @@ rename to include/arch/m32r/klibc/archsetjmp.h unsigned long __r15; - unsigned long __rip; }; - + typedef struct __jmp_buf jmp_buf[1]; - + -#endif /* _SETJMP_H */ +#endif /* _KLIBC_ARCHSETJMP_H */ EOF -find klibc -type f -print | xargs git-update-index --add -- +find klibc -type f -print | xargs git update-index --add -- -test_expect_success 'check rename/copy patch' 'git-apply --check patch' +test_expect_success 'check rename/copy patch' 'git apply --check patch' -test_expect_success 'apply rename/copy patch' 'git-apply --index patch' +test_expect_success 'apply rename/copy patch' 'git apply --index patch' test_done diff --git a/t/t4113-apply-ending.sh b/t/t4113-apply-ending.sh index 7fd0cf62ec..1c6bec044a 100755 --- a/t/t4113-apply-ending.sh +++ b/t/t4113-apply-ending.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Catalin Marinas # -test_description='git-apply trying to add an ending line. +test_description='git apply trying to add an ending line. ' . ./test-lib.sh @@ -25,12 +25,12 @@ echo 'b' >>file echo 'c' >>file test_expect_success setup \ - 'git-update-index --add file' + 'git update-index --add file' # test test_expect_failure 'apply at the end' \ - 'git-apply --index test-patch' + 'git apply --index test-patch' cat >test-patch <<\EOF diff a/file b/file @@ -45,9 +45,9 @@ EOF echo >file 'a b c' -git-update-index file +git update-index file test_expect_failure 'apply at the beginning' \ - 'git-apply --index test-patch' + 'git apply --index test-patch' test_done diff --git a/t/t4114-apply-typechange.sh b/t/t4114-apply-typechange.sh index ca81d72157..55334927ab 100755 --- a/t/t4114-apply-typechange.sh +++ b/t/t4114-apply-typechange.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Eric Wong # -test_description='git-apply should not get confused with type changes. +test_description='git apply should not get confused with type changes. ' diff --git a/t/t4115-apply-symlink.sh b/t/t4115-apply-symlink.sh index b947ed83bb..a07ff42c2f 100755 --- a/t/t4115-apply-symlink.sh +++ b/t/t4115-apply-symlink.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-apply symlinks and partial files +test_description='git apply symlinks and partial files ' diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh index 11e02807a5..9ae2b3a8ef 100755 --- a/t/t4116-apply-reverse.sh +++ b/t/t4116-apply-reverse.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-apply in reverse +test_description='git apply in reverse ' diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh index 91931f0e3f..659e17c92e 100755 --- a/t/t4117-apply-reject.sh +++ b/t/t4117-apply-reject.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-apply with rejects +test_description='git apply with rejects ' diff --git a/t/t4118-apply-empty-context.sh b/t/t4118-apply-empty-context.sh index 27cc6f2b88..1d531caf79 100755 --- a/t/t4118-apply-empty-context.sh +++ b/t/t4118-apply-empty-context.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Junio C Hamano # -test_description='git-apply with new style GNU diff with empty context +test_description='git apply with new style GNU diff with empty context ' @@ -53,4 +53,3 @@ test_expect_success 'apply --apply' ' ' test_done - diff --git a/t/t4119-apply-config.sh b/t/t4119-apply-config.sh index 620a9207bf..65571e0549 100755 --- a/t/t4119-apply-config.sh +++ b/t/t4119-apply-config.sh @@ -3,7 +3,7 @@ # Copyright (c) 2007 Junio C Hamano # -test_description='git-apply --whitespace=strip and configuration file. +test_description='git apply --whitespace=strip and configuration file. ' @@ -24,7 +24,7 @@ cat >gpatch.file <<\EOF && +++ file1+ 2007-02-21 01:07:44.000000000 -0800 @@ -1 +1 @@ -A -+B ++B EOF sed -e 's|file1|sub/&|' gpatch.file >gpatch-sub.file && diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh index 2f672f30d4..83d4ba6798 100755 --- a/t/t4120-apply-popt.sh +++ b/t/t4120-apply-popt.sh @@ -3,7 +3,7 @@ # Copyright (c) 2007 Shawn O. Pearce # -test_description='git-apply -p handling.' +test_description='git apply -p handling.' . ./test-lib.sh diff --git a/t/t4121-apply-diffs.sh b/t/t4121-apply-diffs.sh index 2b2f1eda21..aff551a1d7 100755 --- a/t/t4121-apply-diffs.sh +++ b/t/t4121-apply-diffs.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-apply for contextually independent diffs' +test_description='git apply for contextually independent diffs' . ./test-lib.sh echo '1 @@ -30,4 +30,3 @@ test_expect_success \ '( git diff test~2 test~1; git diff test~1 test~0 )| git apply' test_done - diff --git a/t/t4122-apply-symlink-inside.sh b/t/t4122-apply-symlink-inside.sh index 3ddfe64b02..841773f75f 100755 --- a/t/t4122-apply-symlink-inside.sh +++ b/t/t4122-apply-symlink-inside.sh @@ -53,4 +53,3 @@ test_expect_success 'check result' ' ' test_done - diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index c64ebbb2e9..cfcdb69dc8 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Johannes E. Schindelin # -test_description='git-rerere +test_description='git rerere ' . ./test-lib.sh @@ -39,15 +39,32 @@ sed -e 's/To die, t/To die! T/' > a1 echo "* END *" >>a1 git commit -q -a -m second -# activate rerere -mkdir .git/rr-cache +test_expect_success 'nothing recorded without rerere' ' + (rm -rf .git/rr-cache; git config rerere.enabled false) && + ! git merge first && + ! test -d .git/rr-cache +' -test_expect_failure 'conflicting merge' 'git pull . first' +# activate rerere, old style +test_expect_success 'conflicting merge' ' + git reset --hard && + mkdir .git/rr-cache && + git config --unset rerere.enabled && + ! git merge first +' sha1=$(sed -e 's/ .*//' .git/rr-cache/MERGE_RR) rr=.git/rr-cache/$sha1 test_expect_success 'recorded preimage' "grep ======= $rr/preimage" +test_expect_success 'rerere.enabled works, too' ' + rm -rf .git/rr-cache && + git config rerere.enabled true && + git reset --hard && + ! git merge first && + grep ======= $rr/preimage +' + test_expect_success 'no postimage or thisimage yet' \ "test ! -f $rr/postimage -a ! -f $rr/thisimage" @@ -99,11 +116,12 @@ test_expect_success 'commit succeeds' \ test_expect_success 'recorded postimage' "test -f $rr/postimage" -git checkout -b third master -git show second^:a1 | sed 's/To die: t/To die! T/' > a1 -git commit -q -a -m third - -test_expect_failure 'another conflicting merge' 'git pull . first' +test_expect_success 'another conflicting merge' ' + git checkout -b third master && + git show second^:a1 | sed "s/To die: t/To die! T/" > a1 && + git commit -q -a -m third && + ! git pull . first +' git show first:a1 | sed 's/To die: t/To die! T/' > expect test_expect_success 'rerere kicked in' "! grep ======= a1" @@ -147,6 +165,37 @@ test_expect_success 'garbage collection (part2)' 'git rerere gc' test_expect_success 'old records rest in peace' \ "test ! -f $rr/preimage && test ! -f $rr2/preimage" -test_done +test_expect_success 'file2 added differently in two branches' ' + git reset --hard && + git checkout -b fourth && + echo Hallo > file2 && + git add file2 && + git commit -m version1 && + git checkout third && + echo Bello > file2 && + git add file2 && + git commit -m version2 && + ! git merge fourth && + sha1=$(sed -e "s/ .*//" .git/rr-cache/MERGE_RR) && + rr=.git/rr-cache/$sha1 && + echo Cello > file2 && + git add file2 && + git commit -m resolution +' +test_expect_success 'resolution was recorded properly' ' + git reset --hard HEAD~2 && + git checkout -b fifth && + echo Hallo > file3 && + git add file3 && + git commit -m version1 && + git checkout third && + echo Bello > file3 && + git add file3 && + git commit -m version2 && + ! git merge fifth && + git diff-files -q && + test Cello = "$(cat file3)" +' +test_done diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index a48733cee0..10a5fa9a3a 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Johannes E. Schindelin # -test_description='git-shortlog +test_description='git shortlog ' . ./test-lib.sh diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index e223c074f0..1a4c53a031 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -3,7 +3,7 @@ # Copyright (C) 2005 Rene Scharfe # -test_description='git-tar-tree and git-get-tar-commit-id test +test_description='git tar-tree and git get-tar-commit-id test This test covers the topics of file contents, commit date handling and commit id embedding: @@ -13,13 +13,13 @@ commit id embedding: binary file (/bin/sh). Only paths shorter than 99 characters are used. - git-tar-tree applies the commit date to every file in the archive it + git tar-tree applies the commit date to every file in the archive it creates. The test sets the commit date to a specific value and checks if the tar archive contains that value. - When giving git-tar-tree a commit id (in contrast to a tree id) it + When giving git tar-tree a commit id (in contrast to a tree id) it embeds this commit id into the tar archive as a comment. The test - checks the ability of git-get-tar-commit-id to figure it out from the + checks the ability of git get-tar-commit-id to figure it out from the tar file. ' @@ -42,23 +42,23 @@ test_expect_success \ test_expect_success \ 'add files to repository' \ - 'find a -type f | xargs git-update-index --add && - find a -type l | xargs git-update-index --add && - treeid=`git-write-tree` && + 'find a -type f | xargs git update-index --add && + find a -type l | xargs git update-index --add && + treeid=`git write-tree` && echo $treeid >treeid && - git-update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \ - git-commit-tree $treeid </dev/null)' + git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \ + git commit-tree $treeid </dev/null)' test_expect_success \ - 'git-archive' \ - 'git-archive HEAD >b.tar' + 'git archive' \ + 'git archive HEAD >b.tar' test_expect_success \ - 'git-tar-tree' \ - 'git-tar-tree HEAD >b2.tar' + 'git tar-tree' \ + 'git tar-tree HEAD >b2.tar' test_expect_success \ - 'git-archive vs. git-tar-tree' \ + 'git archive vs. git tar-tree' \ 'diff b.tar b2.tar' test_expect_success \ @@ -70,9 +70,9 @@ test_expect_success \ diff expected.mtime b.mtime' test_expect_success \ - 'git-get-tar-commit-id' \ - 'git-get-tar-commit-id <b.tar >b.commitid && - diff .git/$(git-symbolic-ref HEAD) b.commitid' + 'git get-tar-commit-id' \ + 'git get-tar-commit-id <b.tar >b.commitid && + diff .git/$(git symbolic-ref HEAD) b.commitid' test_expect_success \ 'extract tar archive' \ @@ -88,8 +88,8 @@ test_expect_success \ 'diff -r a b/a' test_expect_success \ - 'git-tar-tree with prefix' \ - 'git-tar-tree HEAD prefix >c.tar' + 'git tar-tree with prefix' \ + 'git tar-tree HEAD prefix >c.tar' test_expect_success \ 'extract tar archive with prefix' \ @@ -105,8 +105,15 @@ test_expect_success \ 'diff -r a c/prefix/a' test_expect_success \ - 'git-archive --format=zip' \ - 'git-archive --format=zip HEAD >d.zip' + 'git archive --format=zip' \ + 'git archive --format=zip HEAD >d.zip' + +$UNZIP -v >/dev/null 2>&1 +if [ $? -eq 127 ]; then + echo "Skipping ZIP tests, because unzip was not found" + test_done + exit +fi test_expect_success \ 'extract ZIP archive' \ @@ -122,8 +129,8 @@ test_expect_success \ 'diff -r a d/a' test_expect_success \ - 'git-archive --format=zip with prefix' \ - 'git-archive --format=zip --prefix=prefix/ HEAD >e.zip' + 'git archive --format=zip with prefix' \ + 'git archive --format=zip --prefix=prefix/ HEAD >e.zip' test_expect_success \ 'extract ZIP archive with prefix' \ @@ -139,7 +146,7 @@ test_expect_success \ 'diff -r a e/prefix/a' test_expect_success \ - 'git-archive --list outside of a git repo' \ - 'GIT_DIR=some/non-existing/directory git-archive --list' + 'git archive --list outside of a git repo' \ + 'GIT_DIR=some/non-existing/directory git archive --list' test_done diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index ca96918da2..9b1a74542a 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -3,12 +3,12 @@ # Copyright (c) 2005 Junio C Hamano # -test_description='git-mailinfo and git-mailsplit test' +test_description='git mailinfo and git mailsplit test' . ./test-lib.sh test_expect_success 'split sample box' \ - 'git-mailsplit -o. ../t5100/sample.mbox >last && + 'git mailsplit -o. ../t5100/sample.mbox >last && last=`cat last` && echo total is $last && test `cat last` = 8' @@ -16,7 +16,7 @@ test_expect_success 'split sample box' \ for mail in `echo 00*` do test_expect_success "mailinfo $mail" \ - "git-mailinfo -u msg$mail patch$mail <$mail >info$mail && + "git mailinfo -u msg$mail patch$mail <$mail >info$mail && echo msg && diff ../t5100/msg$mail msg$mail && echo patch && diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index f336769836..ba7579c251 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -16,26 +16,26 @@ test_expect_success \ for i in a b c do dd if=/dev/zero bs=4k count=1 | tr "\\0" $i >$i && - git-update-index --add $i || return 1 + git update-index --add $i || return 1 done && - cat c >d && echo foo >>d && git-update-index --add d && - tree=`git-write-tree` && - commit=`git-commit-tree $tree </dev/null` && { + cat c >d && echo foo >>d && git update-index --add d && + tree=`git write-tree` && + commit=`git commit-tree $tree </dev/null` && { echo $tree && echo $commit && - git-ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/" + git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/" } >obj-list && { - git-diff-tree --root -p $commit && + git diff-tree --root -p $commit && while read object do - t=`git-cat-file -t $object` && - git-cat-file $t $object || return 1 + t=`git cat-file -t $object` && + git cat-file $t $object || return 1 done <obj-list } >expect' test_expect_success \ 'pack without delta' \ - 'packname_1=$(git-pack-objects --window=0 test-1 <obj-list)' + 'packname_1=$(git pack-objects --window=0 test-1 <obj-list)' rm -fr .git2 mkdir .git2 @@ -44,9 +44,9 @@ test_expect_success \ 'unpack without delta' \ "GIT_OBJECT_DIRECTORY=.git2/objects && export GIT_OBJECT_DIRECTORY && - git-init && - git-unpack-objects -n <test-1-${packname_1}.pack && - git-unpack-objects <test-1-${packname_1}.pack" + git init && + git unpack-objects -n <test-1-${packname_1}.pack && + git unpack-objects <test-1-${packname_1}.pack" unset GIT_OBJECT_DIRECTORY cd "$TRASH/.git2" @@ -66,7 +66,7 @@ cd "$TRASH" test_expect_success \ 'pack with REF_DELTA' \ 'pwd && - packname_2=$(git-pack-objects test-2 <obj-list)' + packname_2=$(git pack-objects test-2 <obj-list)' rm -fr .git2 mkdir .git2 @@ -75,9 +75,9 @@ test_expect_success \ 'unpack with REF_DELTA' \ 'GIT_OBJECT_DIRECTORY=.git2/objects && export GIT_OBJECT_DIRECTORY && - git-init && - git-unpack-objects -n <test-2-${packname_2}.pack && - git-unpack-objects <test-2-${packname_2}.pack' + git init && + git unpack-objects -n <test-2-${packname_2}.pack && + git unpack-objects <test-2-${packname_2}.pack' unset GIT_OBJECT_DIRECTORY cd "$TRASH/.git2" @@ -96,7 +96,7 @@ cd "$TRASH" test_expect_success \ 'pack with OFS_DELTA' \ 'pwd && - packname_3=$(git-pack-objects --delta-base-offset test-3 <obj-list)' + packname_3=$(git pack-objects --delta-base-offset test-3 <obj-list)' rm -fr .git2 mkdir .git2 @@ -105,9 +105,9 @@ test_expect_success \ 'unpack with OFS_DELTA' \ 'GIT_OBJECT_DIRECTORY=.git2/objects && export GIT_OBJECT_DIRECTORY && - git-init && - git-unpack-objects -n <test-3-${packname_3}.pack && - git-unpack-objects <test-3-${packname_3}.pack' + git init && + git unpack-objects -n <test-3-${packname_3}.pack && + git unpack-objects <test-3-${packname_3}.pack' unset GIT_OBJECT_DIRECTORY cd "$TRASH/.git2" @@ -137,13 +137,13 @@ test_expect_success \ 'use packed objects' \ 'GIT_OBJECT_DIRECTORY=.git2/objects && export GIT_OBJECT_DIRECTORY && - git-init && + git init && cp test-1-${packname_1}.pack test-1-${packname_1}.idx .git2/objects/pack && { - git-diff-tree --root -p $commit && + git diff-tree --root -p $commit && while read object do - t=`git-cat-file -t $object` && - git-cat-file $t $object || return 1 + t=`git cat-file -t $object` && + git cat-file $t $object || return 1 done <obj-list } >current && diff expect current' @@ -154,11 +154,11 @@ test_expect_success \ export GIT_OBJECT_DIRECTORY && rm -f .git2/objects/pack/test-* && cp test-2-${packname_2}.pack test-2-${packname_2}.idx .git2/objects/pack && { - git-diff-tree --root -p $commit && + git diff-tree --root -p $commit && while read object do - t=`git-cat-file -t $object` && - git-cat-file $t $object || return 1 + t=`git cat-file -t $object` && + git cat-file $t $object || return 1 done <obj-list } >current && diff expect current' @@ -169,11 +169,11 @@ test_expect_success \ export GIT_OBJECT_DIRECTORY && rm -f .git2/objects/pack/test-* && cp test-3-${packname_3}.pack test-3-${packname_3}.idx .git2/objects/pack && { - git-diff-tree --root -p $commit && + git diff-tree --root -p $commit && while read object do - t=`git-cat-file -t $object` && - git-cat-file $t $object || return 1 + t=`git cat-file -t $object` && + git cat-file $t $object || return 1 done <obj-list } >current && diff expect current' @@ -182,7 +182,7 @@ unset GIT_OBJECT_DIRECTORY test_expect_success \ 'verify pack' \ - 'git-verify-pack test-1-${packname_1}.idx \ + 'git verify-pack test-1-${packname_1}.idx \ test-2-${packname_2}.idx \ test-3-${packname_3}.idx' @@ -190,7 +190,7 @@ test_expect_success \ 'corrupt a pack and see if verify catches' \ 'cat test-1-${packname_1}.idx >test-3.idx && cat test-2-${packname_2}.pack >test-3.pack && - if git-verify-pack test-3.idx + if git verify-pack test-3.idx then false else :; fi && @@ -198,7 +198,7 @@ test_expect_success \ : PACK_SIGNATURE && cat test-1-${packname_1}.pack >test-3.pack && dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=2 && - if git-verify-pack test-3.idx + if git verify-pack test-3.idx then false else :; fi && @@ -206,7 +206,7 @@ test_expect_success \ : PACK_VERSION && cat test-1-${packname_1}.pack >test-3.pack && dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=7 && - if git-verify-pack test-3.idx + if git verify-pack test-3.idx then false else :; fi && @@ -214,7 +214,7 @@ test_expect_success \ : TYPE/SIZE byte of the first packed object data && cat test-1-${packname_1}.pack >test-3.pack && dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=12 && - if git-verify-pack test-3.idx + if git verify-pack test-3.idx then false else :; fi && @@ -224,7 +224,7 @@ test_expect_success \ l=`expr $l - 20` && cat test-1-${packname_1}.pack >test-3.pack && dd if=/dev/zero of=test-3.idx count=20 bs=1 conv=notrunc seek=$l && - if git-verify-pack test-3.pack + if git verify-pack test-3.pack then false else :; fi && diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh index fce77f1255..073ac0c6f9 100755 --- a/t/t5301-sliding-window.sh +++ b/t/t5301-sliding-window.sh @@ -13,48 +13,48 @@ test_expect_success \ do echo $i >$i && test-genrandom "$i" 32768 >>$i && - git-update-index --add $i || return 1 + git update-index --add $i || return 1 done && - echo d >d && cat c >>d && git-update-index --add d && - tree=`git-write-tree` && - commit1=`git-commit-tree $tree </dev/null` && - git-update-ref HEAD $commit1 && + echo d >d && cat c >>d && git update-index --add d && + tree=`git write-tree` && + commit1=`git commit-tree $tree </dev/null` && + git update-ref HEAD $commit1 && git-repack -a -d && - test "`git-count-objects`" = "0 objects, 0 kilobytes" && + test "`git count-objects`" = "0 objects, 0 kilobytes" && pack1=`ls .git/objects/pack/*.pack` && test -f "$pack1"' test_expect_success \ 'verify-pack -v, defaults' \ - 'git-verify-pack -v "$pack1"' + 'git verify-pack -v "$pack1"' test_expect_success \ 'verify-pack -v, packedGitWindowSize == 1 page' \ - 'git-config core.packedGitWindowSize 512 && - git-verify-pack -v "$pack1"' + 'git config core.packedGitWindowSize 512 && + git verify-pack -v "$pack1"' test_expect_success \ 'verify-pack -v, packedGit{WindowSize,Limit} == 1 page' \ - 'git-config core.packedGitWindowSize 512 && - git-config core.packedGitLimit 512 && - git-verify-pack -v "$pack1"' + 'git config core.packedGitWindowSize 512 && + git config core.packedGitLimit 512 && + git verify-pack -v "$pack1"' test_expect_success \ 'repack -a -d, packedGit{WindowSize,Limit} == 1 page' \ - 'git-config core.packedGitWindowSize 512 && - git-config core.packedGitLimit 512 && - commit2=`git-commit-tree $tree -p $commit1 </dev/null` && - git-update-ref HEAD $commit2 && + 'git config core.packedGitWindowSize 512 && + git config core.packedGitLimit 512 && + commit2=`git commit-tree $tree -p $commit1 </dev/null` && + git update-ref HEAD $commit2 && git-repack -a -d && - test "`git-count-objects`" = "0 objects, 0 kilobytes" && + test "`git count-objects`" = "0 objects, 0 kilobytes" && pack2=`ls .git/objects/pack/*.pack` && test -f "$pack2" test "$pack1" \!= "$pack2"' test_expect_success \ 'verify-pack -v, defaults' \ - 'git-config --unset core.packedGitWindowSize && - git-config --unset core.packedGitLimit && - git-verify-pack -v "$pack2"' + 'git config --unset core.packedGitWindowSize && + git config --unset core.packedGitLimit && + git verify-pack -v "$pack2"' test_done diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index 4d06eca6a5..4f58c4c3f9 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -9,34 +9,34 @@ test_description='pack index with 64-bit offsets and object CRC' test_expect_success \ 'setup' \ 'rm -rf .git - git-init && + git init && i=1 && while test $i -le 100 do i=`printf '%03i' $i` echo $i >file_$i && test-genrandom "$i" 8192 >>file_$i && - git-update-index --add file_$i && + git update-index --add file_$i && i=`expr $i + 1` || return 1 done && { echo 101 && test-genrandom 100 8192; } >file_101 && - git-update-index --add file_101 && - tree=`git-write-tree` && - commit=`git-commit-tree $tree </dev/null` && { + git update-index --add file_101 && + tree=`git write-tree` && + commit=`git commit-tree $tree </dev/null` && { echo $tree && - git-ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/" + git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/" } >obj-list && - git-update-ref HEAD $commit' + git update-ref HEAD $commit' test_expect_success \ 'pack-objects with index version 1' \ - 'pack1=$(git-pack-objects --index-version=1 test-1 <obj-list) && - git-verify-pack -v "test-1-${pack1}.pack"' + 'pack1=$(git pack-objects --index-version=1 test-1 <obj-list) && + git verify-pack -v "test-1-${pack1}.pack"' test_expect_success \ 'pack-objects with index version 2' \ - 'pack2=$(git-pack-objects --index-version=2 test-2 <obj-list) && - git-verify-pack -v "test-2-${pack2}.pack"' + 'pack2=$(git pack-objects --index-version=2 test-2 <obj-list) && + git verify-pack -v "test-2-${pack2}.pack"' test_expect_success \ 'both packs should be identical' \ @@ -61,8 +61,8 @@ test_expect_success \ test_expect_success \ 'index v2: force some 64-bit offsets with pack-objects' \ - 'pack3=$(git-pack-objects --index-version=2,0x40000 test-3 <obj-list) && - git-verify-pack -v "test-3-${pack3}.pack"' + 'pack3=$(git pack-objects --index-version=2,0x40000 test-3 <obj-list) && + git verify-pack -v "test-3-${pack3}.pack"' test_expect_failure \ '64-bit offsets: should be different from previous index v2 results' \ @@ -79,22 +79,22 @@ test_expect_success \ test_expect_success \ '[index v1] 1) stream pack to repository' \ 'git-index-pack --index-version=1 --stdin < "test-1-${pack1}.pack" && - git-prune-packed && - git-count-objects | ( read nr rest && test "$nr" -eq 1 ) && + git prune-packed && + git count-objects | ( read nr rest && test "$nr" -eq 1 ) && cmp "test-1-${pack1}.pack" ".git/objects/pack/pack-${pack1}.pack" && cmp "test-1-${pack1}.idx" ".git/objects/pack/pack-${pack1}.idx"' test_expect_success \ '[index v1] 2) create a stealth corruption in a delta base reference' \ '# this test assumes a delta smaller than 16 bytes at the end of the pack - git-show-index <1.idx | sort -n | tail -n 1 | ( + git show-index <1.idx | sort -n | tail -n 1 | ( read delta_offs delta_sha1 && - git-cat-file blob "$delta_sha1" > blob_1 && + git cat-file blob "$delta_sha1" > blob_1 && chmod +w ".git/objects/pack/pack-${pack1}.pack" && dd of=".git/objects/pack/pack-${pack1}.pack" seek=$(($delta_offs + 1)) \ if=".git/objects/pack/pack-${pack1}.idx" skip=$((256 * 4 + 4)) \ bs=1 count=20 conv=notrunc && - git-cat-file blob "$delta_sha1" > blob_2 )' + git cat-file blob "$delta_sha1" > blob_2 )' test_expect_failure \ '[index v1] 3) corrupted delta happily returned wrong data' \ @@ -102,37 +102,37 @@ test_expect_failure \ test_expect_failure \ '[index v1] 4) confirm that the pack is actually corrupted' \ - 'git-fsck --full $commit' + 'git fsck --full $commit' test_expect_success \ '[index v1] 5) pack-objects happily reuses corrupted data' \ - 'pack4=$(git-pack-objects test-4 <obj-list) && + 'pack4=$(git pack-objects test-4 <obj-list) && test -f "test-4-${pack1}.pack"' test_expect_failure \ '[index v1] 6) newly created pack is BAD !' \ - 'git-verify-pack -v "test-4-${pack1}.pack"' + 'git verify-pack -v "test-4-${pack1}.pack"' test_expect_success \ '[index v2] 1) stream pack to repository' \ 'rm -f .git/objects/pack/* && git-index-pack --index-version=2,0x40000 --stdin < "test-1-${pack1}.pack" && - git-prune-packed && - git-count-objects | ( read nr rest && test "$nr" -eq 1 ) && + git prune-packed && + git count-objects | ( read nr rest && test "$nr" -eq 1 ) && cmp "test-1-${pack1}.pack" ".git/objects/pack/pack-${pack1}.pack" && cmp "test-3-${pack1}.idx" ".git/objects/pack/pack-${pack1}.idx"' test_expect_success \ '[index v2] 2) create a stealth corruption in a delta base reference' \ '# this test assumes a delta smaller than 16 bytes at the end of the pack - git-show-index <1.idx | sort -n | tail -n 1 | ( + git show-index <1.idx | sort -n | tail -n 1 | ( read delta_offs delta_sha1 delta_crc && - git-cat-file blob "$delta_sha1" > blob_3 && + git cat-file blob "$delta_sha1" > blob_3 && chmod +w ".git/objects/pack/pack-${pack1}.pack" && dd of=".git/objects/pack/pack-${pack1}.pack" seek=$(($delta_offs + 1)) \ if=".git/objects/pack/pack-${pack1}.idx" skip=$((8 + 256 * 4)) \ bs=1 count=20 conv=notrunc && - git-cat-file blob "$delta_sha1" > blob_4 )' + git cat-file blob "$delta_sha1" > blob_4 )' test_expect_failure \ '[index v2] 3) corrupted delta happily returned wrong data' \ @@ -140,10 +140,10 @@ test_expect_failure \ test_expect_failure \ '[index v2] 4) confirm that the pack is actually corrupted' \ - 'git-fsck --full $commit' + 'git fsck --full $commit' test_expect_failure \ '[index v2] 5) pack-objects refuses to reuse corrupted data' \ - 'git-pack-objects test-5 <obj-list' + 'git pack-objects test-5 <obj-list' test_done diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index 477b267599..6c8767e1df 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -13,9 +13,9 @@ test_expect_success setup ' test_tick && mkdir mozart mozart/is && echo "Commit #0" >mozart/is/pink && - git-update-index --add mozart/is/pink && - tree=$(git-write-tree) && - commit=$(echo "Commit #0" | git-commit-tree $tree) && + git update-index --add mozart/is/pink && + tree=$(git write-tree) && + commit=$(echo "Commit #0" | git commit-tree $tree) && zero=$commit && parent=$zero && i=0 && @@ -24,18 +24,18 @@ test_expect_success setup ' i=$(($i+1)) && test_tick && echo "Commit #$i" >mozart/is/pink && - git-update-index --add mozart/is/pink && - tree=$(git-write-tree) && - commit=$(echo "Commit #$i" | git-commit-tree $tree -p $parent) && - git-update-ref refs/tags/commit$i $commit && + git update-index --add mozart/is/pink && + tree=$(git write-tree) && + commit=$(echo "Commit #$i" | git commit-tree $tree -p $parent) && + git update-ref refs/tags/commit$i $commit && parent=$commit || return 1 done && - git-update-ref HEAD "$commit" && + git update-ref HEAD "$commit" && git-clone ./. victim && cd victim && - git-log && + git log && cd .. && - git-update-ref HEAD "$zero" && + git update-ref HEAD "$zero" && parent=$zero && i=0 && while test $i -le $cnt @@ -43,15 +43,15 @@ test_expect_success setup ' i=$(($i+1)) && test_tick && echo "Rebase #$i" >mozart/is/pink && - git-update-index --add mozart/is/pink && - tree=$(git-write-tree) && - commit=$(echo "Rebase #$i" | git-commit-tree $tree -p $parent) && - git-update-ref refs/tags/rebase$i $commit && + git update-index --add mozart/is/pink && + tree=$(git write-tree) && + commit=$(echo "Rebase #$i" | git commit-tree $tree -p $parent) && + git update-ref refs/tags/rebase$i $commit && parent=$commit || return 1 done && - git-update-ref HEAD "$commit" && + git update-ref HEAD "$commit" && echo Rebase && - git-log' + git log' test_expect_success 'pack the source repository' ' git repack -a -d && @@ -66,7 +66,7 @@ test_expect_success 'pack the destination repository' ' ' test_expect_success \ - 'pushing rewound head should not barf but require --force' ' + 'pushing rewound head should not barf but require --force' ' # should not fail but refuse to update. if git-send-pack ./victim/.git/ master then @@ -106,9 +106,9 @@ export HOME ;# this way we force the victim/.git/config to be used. test_expect_success \ 'pushing with --force should be denied with denyNonFastforwards' ' cd victim && - git-config receive.denyNonFastforwards true && + git config receive.denyNonFastforwards true && cd .. && - git-update-ref refs/heads/master master^ || return 1 + git update-ref refs/heads/master master^ || return 1 git-send-pack --force ./victim/.git/ master && return 1 ! git diff .git/refs/heads/master victim/.git/refs/heads/master ' diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh index f1c7ff0c0a..c5dd30d0a4 100755 --- a/t/t5401-update-hooks.sh +++ b/t/t5401-update-hooks.sh @@ -8,19 +8,19 @@ test_description='Test the update hook infrastructure.' test_expect_success setup ' echo This is a test. >a && - git-update-index --add a && - tree0=$(git-write-tree) && - commit0=$(echo setup | git-commit-tree $tree0) && + git update-index --add a && + tree0=$(git write-tree) && + commit0=$(echo setup | git commit-tree $tree0) && echo We hope it works. >a && - git-update-index a && - tree1=$(git-write-tree) && - commit1=$(echo modify | git-commit-tree $tree1 -p $commit0) && - git-update-ref refs/heads/master $commit0 && - git-update-ref refs/heads/tofail $commit1 && + git update-index a && + tree1=$(git write-tree) && + commit1=$(echo modify | git commit-tree $tree1 -p $commit0) && + git update-ref refs/heads/master $commit0 && + git update-ref refs/heads/tofail $commit1 && git-clone ./. victim && - GIT_DIR=victim/.git git-update-ref refs/heads/tofail $commit1 && - git-update-ref refs/heads/master $commit1 && - git-update-ref refs/heads/tofail $commit0 + GIT_DIR=victim/.git git update-ref refs/heads/tofail $commit1 && + git update-ref refs/heads/master $commit1 && + git update-ref refs/heads/tofail $commit0 ' cat >victim/.git/hooks/pre-receive <<'EOF' @@ -65,8 +65,8 @@ test_expect_failure push ' ' test_expect_success 'updated as expected' ' - test $(GIT_DIR=victim/.git git-rev-parse master) = $commit1 && - test $(GIT_DIR=victim/.git git-rev-parse tofail) = $commit1 + test $(GIT_DIR=victim/.git git rev-parse master) = $commit1 && + test $(GIT_DIR=victim/.git git rev-parse tofail) = $commit1 ' test_expect_success 'hooks ran' ' diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 48e3d1705f..7da515361a 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -25,12 +25,12 @@ add () { done echo "$text" > test.txt - git-update-index --add test.txt - tree=$(git-write-tree) + git update-index --add test.txt + tree=$(git write-tree) # make sure timestamps are in correct order sec=$(($sec+1)) commit=$(echo "$text" | GIT_AUTHOR_DATE=$sec \ - git-commit-tree $tree $parents 2>>log2.txt) + git commit-tree $tree $parents 2>>log2.txt) export $name=$commit echo $commit > .git/refs/heads/$branch eval ${branch}TIP=$commit @@ -61,19 +61,19 @@ pull_to_client () { "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/`echo $heads | sed -e 's/^\(.\).*$/\1/'` + git symbolic-ref HEAD refs/heads/`echo $heads | sed -e 's/^\(.\).*$/\1/'` - test_expect_success "fsck" 'git-fsck --full > fsck.txt 2>&1' + test_expect_success "fsck" 'git fsck --full > fsck.txt 2>&1' test_expect_success 'check downloaded results' \ 'mv .git/objects/pack/pack-* . && p=`ls -1 pack-*.pack` && - git-unpack-objects <$p && - git-fsck --full' + git unpack-objects <$p && + git fsck --full' test_expect_success "new object count after $number pull" \ 'idx=`echo pack-*.idx` && - pack_count=`git-show-index <$idx | wc -l` && + pack_count=`git show-index <$idx | wc -l` && test $pack_count = $count' test -z "$pack_count" && pack_count=0 if [ -z "$no_strict_count_check" ]; then @@ -97,7 +97,7 @@ pull_to_client () { ( mkdir client && cd client && - git-init 2>> log2.txt && + git init 2>> log2.txt && git config transfer.unpacklimit 0 ) @@ -113,7 +113,7 @@ add B1 $A1 echo $ATIP > .git/refs/heads/A echo $BTIP > .git/refs/heads/B -git-symbolic-ref HEAD refs/heads/B +git symbolic-ref HEAD refs/heads/B pull_to_client 1st "B A" $((11*3)) @@ -131,7 +131,7 @@ pull_to_client 3rd "A" $((1*3)) # old fails test_expect_success "clone shallow" "git-clone --depth 2 . shallow" -(cd shallow; git-count-objects -v) > count.shallow +(cd shallow; git count-objects -v) > count.shallow test_expect_success "clone shallow object count" \ "test \"in-pack: 18\" = \"$(grep in-pack count.shallow)\"" @@ -145,7 +145,7 @@ test_expect_success "clone shallow object count (part 2)" ' ' test_expect_success "fsck in shallow repo" \ - "(cd shallow; git-fsck --full)" + "(cd shallow; git fsck --full)" #test_done; exit @@ -155,7 +155,7 @@ add B67 $B66 test_expect_success "pull in shallow repo" \ "(cd shallow; git pull .. B)" -(cd shallow; git-count-objects -v) > count.shallow +(cd shallow; git count-objects -v) > count.shallow test_expect_success "clone shallow object count" \ "test \"count: 6\" = \"$(grep count count.shallow)\"" @@ -165,14 +165,14 @@ add B69 $B68 test_expect_success "deepening pull in shallow repo" \ "(cd shallow; git pull --depth 4 .. B)" -(cd shallow; git-count-objects -v) > count.shallow +(cd shallow; git count-objects -v) > count.shallow test_expect_success "clone shallow object count" \ "test \"count: 12\" = \"$(grep count count.shallow)\"" test_expect_success "deepening fetch in shallow repo" \ "(cd shallow; git fetch --depth 4 .. A:A)" -(cd shallow; git-count-objects -v) > count.shallow +(cd shallow; git count-objects -v) > count.shallow test_expect_success "clone shallow object count" \ "test \"count: 18\" = \"$(grep count count.shallow)\"" diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh new file mode 100755 index 0000000000..ca46aafe72 --- /dev/null +++ b/t/t5516-fetch-push.sh @@ -0,0 +1,247 @@ +#!/bin/sh + +test_description='fetching and pushing, with or without wildcard' + +. ./test-lib.sh + +D=`pwd` + +mk_empty () { + rm -fr testrepo && + mkdir testrepo && + ( + cd testrepo && + git init && + mv .git/hooks .git/hooks-disabled + ) +} + +mk_test () { + mk_empty && + ( + for ref in "$@" + do + git push testrepo $the_first_commit:refs/$ref || { + echo "Oops, push refs/$ref failure" + exit 1 + } + done && + cd testrepo && + for ref in "$@" + do + r=$(git show-ref -s --verify refs/$ref) && + test "z$r" = "z$the_first_commit" || { + echo "Oops, refs/$ref is wrong" + exit 1 + } + done && + git fsck --full + ) +} + +check_push_result () { + ( + cd testrepo && + it="$1" && + shift + for ref in "$@" + do + r=$(git show-ref -s --verify refs/$ref) && + test "z$r" = "z$it" || { + echo "Oops, refs/$ref is wrong" + exit 1 + } + done && + git fsck --full + ) +} + +test_expect_success setup ' + + : >path1 && + git add path1 && + test_tick && + git commit -a -m repo && + the_first_commit=$(git show-ref -s --verify refs/heads/master) && + + : >path2 && + git add path2 && + test_tick && + git commit -a -m second && + the_commit=$(git show-ref -s --verify refs/heads/master) + +' + +test_expect_success 'fetch without wildcard' ' + mk_empty && + ( + cd testrepo && + git fetch .. refs/heads/master:refs/remotes/origin/master && + + r=$(git show-ref -s --verify refs/remotes/origin/master) && + test "z$r" = "z$the_commit" && + + test 1 = $(git for-each-ref refs/remotes/origin | wc -l) + ) +' + +test_expect_success 'fetch with wildcard' ' + mk_empty && + ( + cd testrepo && + git config remote.up.url .. && + git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && + git fetch up && + + r=$(git show-ref -s --verify refs/remotes/origin/master) && + test "z$r" = "z$the_commit" && + + test 1 = $(git for-each-ref refs/remotes/origin | wc -l) + ) +' + +test_expect_success 'push without wildcard' ' + mk_empty && + + git push testrepo refs/heads/master:refs/remotes/origin/master && + ( + cd testrepo && + r=$(git show-ref -s --verify refs/remotes/origin/master) && + test "z$r" = "z$the_commit" && + + test 1 = $(git for-each-ref refs/remotes/origin | wc -l) + ) +' + +test_expect_success 'push with wildcard' ' + mk_empty && + + git push testrepo "refs/heads/*:refs/remotes/origin/*" && + ( + cd testrepo && + r=$(git show-ref -s --verify refs/remotes/origin/master) && + test "z$r" = "z$the_commit" && + + test 1 = $(git for-each-ref refs/remotes/origin | wc -l) + ) +' + +test_expect_success 'push with matching heads' ' + + mk_test heads/master && + git push testrepo && + check_push_result $the_commit heads/master + +' + +test_expect_success 'push with no ambiguity (1)' ' + + mk_test heads/master && + git push testrepo master:master && + check_push_result $the_commit heads/master + +' + +test_expect_success 'push with no ambiguity (2)' ' + + mk_test remotes/origin/master && + git push testrepo master:master && + check_push_result $the_commit remotes/origin/master + +' + +test_expect_success 'push with weak ambiguity (1)' ' + + mk_test heads/master remotes/origin/master && + git push testrepo master:master && + check_push_result $the_commit heads/master && + check_push_result $the_first_commit remotes/origin/master + +' + +test_expect_success 'push with weak ambiguity (2)' ' + + mk_test heads/master remotes/origin/master remotes/another/master && + git push testrepo master:master && + check_push_result $the_commit heads/master && + check_push_result $the_first_commit remotes/origin/master remotes/another/master + +' + +test_expect_success 'push with ambiguity (1)' ' + + mk_test remotes/origin/master remotes/frotz/master && + if git push testrepo master:master + then + echo "Oops, should have failed" + false + else + check_push_result $the_first_commit remotes/origin/master remotes/frotz/master + fi +' + +test_expect_success 'push with ambiguity (2)' ' + + mk_test heads/frotz tags/frotz && + if git push testrepo master:frotz + then + echo "Oops, should have failed" + false + else + check_push_result $the_first_commit heads/frotz tags/frotz + fi + +' + +test_expect_success 'push with colon-less refspec (1)' ' + + mk_test heads/frotz tags/frotz && + git branch -f frotz master && + git push testrepo frotz && + check_push_result $the_commit heads/frotz && + check_push_result $the_first_commit tags/frotz + +' + +test_expect_success 'push with colon-less refspec (2)' ' + + mk_test heads/frotz tags/frotz && + if git show-ref --verify -q refs/heads/frotz + then + git branch -D frotz + fi && + git tag -f frotz && + git push testrepo frotz && + check_push_result $the_commit tags/frotz && + check_push_result $the_first_commit heads/frotz + +' + +test_expect_success 'push with colon-less refspec (3)' ' + + mk_test && + if git show-ref --verify -q refs/tags/frotz + then + git tag -d frotz + fi && + git branch -f frotz master && + git push testrepo frotz && + check_push_result $the_commit heads/frotz && + test 1 = $( cd testrepo && git show-ref | wc -l ) +' + +test_expect_success 'push with colon-less refspec (4)' ' + + mk_test && + if git show-ref --verify -q refs/heads/frotz + then + git branch -D frotz + fi && + git tag -f frotz && + git push testrepo frotz && + check_push_result $the_commit tags/frotz && + test 1 = $( cd testrepo && git show-ref | wc -l ) + +' + +test_done diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 243212d3da..93eaf2c154 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -54,4 +54,3 @@ test_expect_success 'the default remote . should not break explicit pull' ' ' test_done - diff --git a/t/t5710-info-alternate.sh b/t/t5710-info-alternate.sh index 2f8e97cb7e..699df6ebd8 100755 --- a/t/t5710-info-alternate.sh +++ b/t/t5710-info-alternate.sh @@ -104,4 +104,3 @@ test_valid_repo' cd "$base_dir" test_done - diff --git a/t/t6000lib.sh b/t/t6000lib.sh index d40262159b..180633e1e0 100755 --- a/t/t6000lib.sh +++ b/t/t6000lib.sh @@ -17,17 +17,17 @@ unique_commit() _text=$1 _tree=$2 shift 2 - echo $_text | git-commit-tree $(tag $_tree) "$@" + echo $_text | git commit-tree $(tag $_tree) "$@" } # Save the output of a command into the tag specified. Prepend # a substitution script for the tag onto the front of sed.script save_tag() { - _tag=$1 + _tag=$1 [ -n "$_tag" ] || error "usage: save_tag tag commit-args ..." shift 1 - "$@" >.git/refs/tags/$_tag + "$@" >.git/refs/tags/$_tag echo "s/$(tag $_tag)/$_tag/g" > sed.script.tmp cat sed.script >> sed.script.tmp @@ -35,7 +35,7 @@ save_tag() mv sed.script.tmp sed.script } -# Replace unhelpful sha1 hashses with their symbolic equivalents +# Replace unhelpful sha1 hashses with their symbolic equivalents entag() { sed -f sed.script @@ -62,7 +62,7 @@ as_author() commit_date() { _commit=$1 - git-cat-file commit $_commit | sed -n "s/^committer .*> \([0-9]*\) .*/\1/p" + git cat-file commit $_commit | sed -n "s/^committer .*> \([0-9]*\) .*/\1/p" } on_committer_date() @@ -103,14 +103,14 @@ name_from_description() # Execute the test described by the first argument, by eval'ing # command line specified in the 2nd argument. Check the status code -# is zero and that the output matches the stream read from +# is zero and that the output matches the stream read from # stdin. test_output_expect_success() -{ +{ _description=$1 _test=$2 [ $# -eq 2 ] || error "usage: test_output_expect_success description test <<EOF ... EOF" _name=$(echo $_description | name_from_description) cat > $_name.expected - test_expect_success "$_description" "check_output $_name \"$_test\"" + test_expect_success "$_description" "check_output $_name \"$_test\"" } diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh index fcb3302764..8f5de097ec 100755 --- a/t/t6002-rev-list-bisect.sh +++ b/t/t6002-rev-list-bisect.sh @@ -2,7 +2,7 @@ # # Copyright (c) 2005 Jon Seymour # -test_description='Tests git-rev-list --bisect functionality' +test_description='Tests git rev-list --bisect functionality' . ./test-lib.sh . ../t6000lib.sh # t6xxx specific functions @@ -16,17 +16,17 @@ test_bisection_diff() _max_diff=$1 _bisect_option=$2 shift 2 - _bisection=$(git-rev-list $_bisect_option "$@") - _list_size=$(git-rev-list "$@" | wc -l) + _bisection=$(git rev-list $_bisect_option "$@") + _list_size=$(git rev-list "$@" | wc -l) _head=$1 shift 1 - _bisection_size=$(git-rev-list $_bisection "$@" | wc -l) + _bisection_size=$(git rev-list $_bisection "$@" | wc -l) [ -n "$_list_size" -a -n "$_bisection_size" ] || error "test_bisection_diff failed" # Test if bisection size is close to half of list size within # tolerance. - # + # _bisect_err=`expr $_list_size - $_bisection_size \* 2` test "$_bisect_err" -lt 0 && _bisect_err=`expr 0 - $_bisect_err` _bisect_err=`expr $_bisect_err / 2` ; # floor @@ -37,8 +37,8 @@ test_bisection_diff() } date >path0 -git-update-index --add path0 -save_tag tree git-write-tree +git update-index --add path0 +save_tag tree git write-tree on_committer_date "1971-08-16 00:00:00" hide_error save_tag root unique_commit root tree on_committer_date "1971-08-16 00:00:01" save_tag l0 unique_commit l0 tree -p root on_committer_date "1971-08-16 00:00:02" save_tag l1 unique_commit l1 tree -p l0 @@ -58,7 +58,7 @@ on_committer_date "1971-08-16 00:00:15" save_tag a4 unique_commit a4 tree -p a3 on_committer_date "1971-08-16 00:00:16" save_tag l3 unique_commit l3 tree -p a4 on_committer_date "1971-08-16 00:00:17" save_tag l4 unique_commit l4 tree -p l3 on_committer_date "1971-08-16 00:00:18" save_tag l5 unique_commit l5 tree -p l4 -git-update-ref HEAD $(tag l5) +git update-ref HEAD $(tag l5) # E @@ -116,8 +116,8 @@ on_committer_date "1971-08-16 00:00:06" save_tag V unique_commit V tree -p u1 -p test_sequence() { - _bisect_option=$1 - + _bisect_option=$1 + test_bisection_diff 0 $_bisect_option l0 ^root test_bisection_diff 0 $_bisect_option l1 ^root test_bisection_diff 0 $_bisect_option l2 ^root @@ -152,7 +152,7 @@ test_sequence() test_bisection_diff 0 $_bisect_option u3 ^U test_bisection_diff 0 $_bisect_option u4 ^U test_bisection_diff 0 $_bisect_option u5 ^U - + # # the following illustrates Linus' binary bug blatt idea. # @@ -163,23 +163,23 @@ test_sequence() # the bisection point is the head - this is the bad point. # -test_output_expect_success "$_bisect_option l5 ^root" 'git-rev-list $_bisect_option l5 ^root' <<EOF +test_output_expect_success "$_bisect_option l5 ^root" 'git rev-list $_bisect_option l5 ^root' <<EOF c3 EOF -test_output_expect_success "$_bisect_option l5 ^root ^c3" 'git-rev-list $_bisect_option l5 ^root ^c3' <<EOF +test_output_expect_success "$_bisect_option l5 ^root ^c3" 'git rev-list $_bisect_option l5 ^root ^c3' <<EOF b4 EOF -test_output_expect_success "$_bisect_option l5 ^root ^c3 ^b4" 'git-rev-list $_bisect_option l5 ^c3 ^b4' <<EOF +test_output_expect_success "$_bisect_option l5 ^root ^c3 ^b4" 'git rev-list $_bisect_option l5 ^c3 ^b4' <<EOF l3 EOF -test_output_expect_success "$_bisect_option l3 ^root ^c3 ^b4" 'git-rev-list $_bisect_option l3 ^root ^c3 ^b4' <<EOF +test_output_expect_success "$_bisect_option l3 ^root ^c3 ^b4" 'git rev-list $_bisect_option l3 ^root ^c3 ^b4' <<EOF a4 EOF -test_output_expect_success "$_bisect_option l5 ^b3 ^a3 ^b4 ^a4" 'git-rev-list $_bisect_option l3 ^b3 ^a3 ^a4' <<EOF +test_output_expect_success "$_bisect_option l5 ^b3 ^a3 ^b4 ^a4" 'git rev-list $_bisect_option l3 ^b3 ^a3 ^a4' <<EOF l3 EOF @@ -187,11 +187,11 @@ EOF # if l3 is bad, then l4 is bad too - so advance the bad pointer by making b4 the known bad head # -test_output_expect_success "$_bisect_option l4 ^a2 ^a3 ^b ^a4" 'git-rev-list $_bisect_option l4 ^a2 ^a3 ^a4' <<EOF +test_output_expect_success "$_bisect_option l4 ^a2 ^a3 ^b ^a4" 'git rev-list $_bisect_option l4 ^a2 ^a3 ^a4' <<EOF l3 EOF -test_output_expect_success "$_bisect_option l3 ^a2 ^a3 ^b ^a4" 'git-rev-list $_bisect_option l3 ^a2 ^a3 ^a4' <<EOF +test_output_expect_success "$_bisect_option l3 ^a2 ^a3 ^b ^a4" 'git rev-list $_bisect_option l3 ^a2 ^a3 ^a4' <<EOF l3 EOF @@ -201,15 +201,15 @@ EOF # as another example, let's consider a4 to be the bad head, in which case # -test_output_expect_success "$_bisect_option a4 ^a2 ^a3 ^b4" 'git-rev-list $_bisect_option a4 ^a2 ^a3 ^b4' <<EOF +test_output_expect_success "$_bisect_option a4 ^a2 ^a3 ^b4" 'git rev-list $_bisect_option a4 ^a2 ^a3 ^b4' <<EOF c2 EOF -test_output_expect_success "$_bisect_option a4 ^a2 ^a3 ^b4 ^c2" 'git-rev-list $_bisect_option a4 ^a2 ^a3 ^b4 ^c2' <<EOF +test_output_expect_success "$_bisect_option a4 ^a2 ^a3 ^b4 ^c2" 'git rev-list $_bisect_option a4 ^a2 ^a3 ^b4 ^c2' <<EOF c3 EOF -test_output_expect_success "$_bisect_option a4 ^a2 ^a3 ^b4 ^c2 ^c3" 'git-rev-list $_bisect_option a4 ^a2 ^a3 ^b4 ^c2 ^c3' <<EOF +test_output_expect_success "$_bisect_option a4 ^a2 ^a3 ^b4 ^c2 ^c3" 'git rev-list $_bisect_option a4 ^a2 ^a3 ^b4 ^c2 ^c3' <<EOF a4 EOF @@ -219,11 +219,11 @@ EOF # or consider c3 to be the bad head # -test_output_expect_success "$_bisect_option a4 ^a2 ^a3 ^b4" 'git-rev-list $_bisect_option a4 ^a2 ^a3 ^b4' <<EOF +test_output_expect_success "$_bisect_option a4 ^a2 ^a3 ^b4" 'git rev-list $_bisect_option a4 ^a2 ^a3 ^b4' <<EOF c2 EOF -test_output_expect_success "$_bisect_option c3 ^a2 ^a3 ^b4 ^c2" 'git-rev-list $_bisect_option c3 ^a2 ^a3 ^b4 ^c2' <<EOF +test_output_expect_success "$_bisect_option c3 ^a2 ^a3 ^b4 ^c2" 'git rev-list $_bisect_option c3 ^a2 ^a3 ^b4 ^c2' <<EOF c3 EOF diff --git a/t/t6003-rev-list-topo-order.sh b/t/t6003-rev-list-topo-order.sh index d99a9ad39e..5daa0be8cc 100755 --- a/t/t6003-rev-list-topo-order.sh +++ b/t/t6003-rev-list-topo-order.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Jon Seymour # -test_description='Tests git-rev-list --topo-order functionality' +test_description='Tests git rev-list --topo-order functionality' . ./test-lib.sh . ../t6000lib.sh # t6xxx specific functions @@ -14,8 +14,8 @@ list_duplicates() } date >path0 -git-update-index --add path0 -save_tag tree git-write-tree +git update-index --add path0 +save_tag tree git write-tree on_committer_date "1971-08-16 00:00:00" hide_error save_tag root unique_commit root tree on_committer_date "1971-08-16 00:00:01" save_tag l0 unique_commit l0 tree -p root on_committer_date "1971-08-16 00:00:02" save_tag l1 unique_commit l1 tree -p l0 @@ -77,13 +77,13 @@ save_tag h2 unique_commit g4 tree -p g2 save_tag g3 unique_commit g5 tree -p g2 save_tag g4 unique_commit g6 tree -p g3 -p h2 -git-update-ref HEAD $(tag l5) +git update-ref HEAD $(tag l5) -test_output_expect_success 'rev-list has correct number of entries' 'git-rev-list HEAD | wc -l | tr -d \" \"' <<EOF +test_output_expect_success 'rev-list has correct number of entries' 'git rev-list HEAD | wc -l | tr -d \" \"' <<EOF 19 EOF -test_output_expect_success 'simple topo order' 'git-rev-list --topo-order HEAD' <<EOF +test_output_expect_success 'simple topo order' 'git rev-list --topo-order HEAD' <<EOF l5 l4 l3 @@ -105,7 +105,7 @@ l0 root EOF -test_output_expect_success 'two diamonds topo order (g6)' 'git-rev-list --topo-order g4' <<EOF +test_output_expect_success 'two diamonds topo order (g6)' 'git rev-list --topo-order g4' <<EOF g4 h2 g3 @@ -115,7 +115,7 @@ g1 g0 EOF -test_output_expect_success 'multiple heads' 'git-rev-list --topo-order a3 b3 c3' <<EOF +test_output_expect_success 'multiple heads' 'git rev-list --topo-order a3 b3 c3' <<EOF a3 a2 a1 @@ -132,7 +132,7 @@ l0 root EOF -test_output_expect_success 'multiple heads, prune at a1' 'git-rev-list --topo-order a3 b3 c3 ^a1' <<EOF +test_output_expect_success 'multiple heads, prune at a1' 'git rev-list --topo-order a3 b3 c3 ^a1' <<EOF a3 a2 c3 @@ -143,7 +143,7 @@ b2 b1 EOF -test_output_expect_success 'multiple heads, prune at l1' 'git-rev-list --topo-order a3 b3 c3 ^l1' <<EOF +test_output_expect_success 'multiple heads, prune at l1' 'git rev-list --topo-order a3 b3 c3 ^l1' <<EOF a3 a2 a1 @@ -157,7 +157,7 @@ a0 l2 EOF -test_output_expect_success 'cross-epoch, head at l5, prune at l1' 'git-rev-list --topo-order l5 ^l1' <<EOF +test_output_expect_success 'cross-epoch, head at l5, prune at l1' 'git rev-list --topo-order l5 ^l1' <<EOF l5 l4 l3 @@ -176,7 +176,7 @@ a0 l2 EOF -test_output_expect_success 'duplicated head arguments' 'git-rev-list --topo-order l5 l5 ^l1' <<EOF +test_output_expect_success 'duplicated head arguments' 'git rev-list --topo-order l5 l5 ^l1' <<EOF l5 l4 l3 @@ -195,7 +195,7 @@ a0 l2 EOF -test_output_expect_success 'prune near topo' 'git-rev-list --topo-order a4 ^c3' <<EOF +test_output_expect_success 'prune near topo' 'git rev-list --topo-order a4 ^c3' <<EOF a4 b4 a3 @@ -204,52 +204,52 @@ a1 b3 EOF -test_output_expect_success "head has no parent" 'git-rev-list --topo-order root' <<EOF +test_output_expect_success "head has no parent" 'git rev-list --topo-order root' <<EOF root EOF -test_output_expect_success "two nodes - one head, one base" 'git-rev-list --topo-order l0' <<EOF +test_output_expect_success "two nodes - one head, one base" 'git rev-list --topo-order l0' <<EOF l0 root EOF -test_output_expect_success "three nodes one head, one internal, one base" 'git-rev-list --topo-order l1' <<EOF +test_output_expect_success "three nodes one head, one internal, one base" 'git rev-list --topo-order l1' <<EOF l1 l0 root EOF -test_output_expect_success "linear prune l2 ^root" 'git-rev-list --topo-order l2 ^root' <<EOF +test_output_expect_success "linear prune l2 ^root" 'git rev-list --topo-order l2 ^root' <<EOF l2 l1 l0 EOF -test_output_expect_success "linear prune l2 ^l0" 'git-rev-list --topo-order l2 ^l0' <<EOF +test_output_expect_success "linear prune l2 ^l0" 'git rev-list --topo-order l2 ^l0' <<EOF l2 l1 EOF -test_output_expect_success "linear prune l2 ^l1" 'git-rev-list --topo-order l2 ^l1' <<EOF +test_output_expect_success "linear prune l2 ^l1" 'git rev-list --topo-order l2 ^l1' <<EOF l2 EOF -test_output_expect_success "linear prune l5 ^a4" 'git-rev-list --topo-order l5 ^a4' <<EOF +test_output_expect_success "linear prune l5 ^a4" 'git rev-list --topo-order l5 ^a4' <<EOF l5 l4 l3 EOF -test_output_expect_success "linear prune l5 ^l3" 'git-rev-list --topo-order l5 ^l3' <<EOF +test_output_expect_success "linear prune l5 ^l3" 'git rev-list --topo-order l5 ^l3' <<EOF l5 l4 EOF -test_output_expect_success "linear prune l5 ^l4" 'git-rev-list --topo-order l5 ^l4' <<EOF +test_output_expect_success "linear prune l5 ^l4" 'git rev-list --topo-order l5 ^l4' <<EOF l5 EOF -test_output_expect_success "max-count 10 - topo order" 'git-rev-list --topo-order --max-count=10 l5' <<EOF +test_output_expect_success "max-count 10 - topo order" 'git rev-list --topo-order --max-count=10 l5' <<EOF l5 l4 l3 @@ -262,7 +262,7 @@ a3 a2 EOF -test_output_expect_success "max-count 10 - non topo order" 'git-rev-list --max-count=10 l5' <<EOF +test_output_expect_success "max-count 10 - non topo order" 'git rev-list --max-count=10 l5' <<EOF l5 l4 l3 @@ -275,7 +275,7 @@ c2 b3 EOF -test_output_expect_success '--max-age=c3, no --topo-order' "git-rev-list --max-age=$(commit_date c3) l5" <<EOF +test_output_expect_success '--max-age=c3, no --topo-order' "git rev-list --max-age=$(commit_date c3) l5" <<EOF l5 l4 l3 @@ -289,7 +289,7 @@ EOF # # this test fails on --topo-order - a fix is required # -#test_output_expect_success '--max-age=c3, --topo-order' "git-rev-list --topo-order --max-age=$(commit_date c3) l5" <<EOF +#test_output_expect_success '--max-age=c3, --topo-order' "git rev-list --topo-order --max-age=$(commit_date c3) l5" <<EOF #l5 #l4 #l3 @@ -300,31 +300,31 @@ EOF #a2 #EOF -test_output_expect_success 'one specified head reachable from another a4, c3, --topo-order' "list_duplicates git-rev-list --topo-order a4 c3" <<EOF +test_output_expect_success 'one specified head reachable from another a4, c3, --topo-order' "list_duplicates git rev-list --topo-order a4 c3" <<EOF EOF -test_output_expect_success 'one specified head reachable from another c3, a4, --topo-order' "list_duplicates git-rev-list --topo-order c3 a4" <<EOF +test_output_expect_success 'one specified head reachable from another c3, a4, --topo-order' "list_duplicates git rev-list --topo-order c3 a4" <<EOF EOF -test_output_expect_success 'one specified head reachable from another a4, c3, no --topo-order' "list_duplicates git-rev-list a4 c3" <<EOF +test_output_expect_success 'one specified head reachable from another a4, c3, no --topo-order' "list_duplicates git rev-list a4 c3" <<EOF EOF -test_output_expect_success 'one specified head reachable from another c3, a4, no --topo-order' "list_duplicates git-rev-list c3 a4" <<EOF +test_output_expect_success 'one specified head reachable from another c3, a4, no --topo-order' "list_duplicates git rev-list c3 a4" <<EOF EOF -test_output_expect_success 'graph with c3 and a4 parents of head' "list_duplicates git-rev-list m1" <<EOF +test_output_expect_success 'graph with c3 and a4 parents of head' "list_duplicates git rev-list m1" <<EOF EOF -test_output_expect_success 'graph with a4 and c3 parents of head' "list_duplicates git-rev-list m2" <<EOF +test_output_expect_success 'graph with a4 and c3 parents of head' "list_duplicates git rev-list m2" <<EOF EOF -test_expect_success "head ^head --topo-order" 'git-rev-list --topo-order a3 ^a3' <<EOF +test_expect_success "head ^head --topo-order" 'git rev-list --topo-order a3 ^a3' <<EOF EOF -test_expect_success "head ^head no --topo-order" 'git-rev-list a3 ^a3' <<EOF +test_expect_success "head ^head no --topo-order" 'git rev-list a3 ^a3' <<EOF EOF -test_output_expect_success 'simple topo order (l5r1)' 'git-rev-list --topo-order l5r1' <<EOF +test_output_expect_success 'simple topo order (l5r1)' 'git rev-list --topo-order l5r1' <<EOF l5r1 r1 r0 @@ -350,7 +350,7 @@ l0 root EOF -test_output_expect_success 'simple topo order (r1l5)' 'git-rev-list --topo-order r1l5' <<EOF +test_output_expect_success 'simple topo order (r1l5)' 'git rev-list --topo-order r1l5' <<EOF r1l5 l5 l4 @@ -376,13 +376,13 @@ r0 alt_root EOF -test_output_expect_success "don't print things unreachable from one branch" "git-rev-list a3 ^b3 --topo-order" <<EOF +test_output_expect_success "don't print things unreachable from one branch" "git rev-list a3 ^b3 --topo-order" <<EOF a3 a2 a1 EOF -test_output_expect_success "--topo-order a4 l3" "git-rev-list --topo-order a4 l3" <<EOF +test_output_expect_success "--topo-order a4 l3" "git rev-list --topo-order a4 l3" <<EOF l3 a4 c3 diff --git a/t/t6004-rev-list-path-optim.sh b/t/t6004-rev-list-path-optim.sh index 761f09b1e5..80d71988b8 100755 --- a/t/t6004-rev-list-path-optim.sh +++ b/t/t6004-rev-list-path-optim.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-rev-list trivial path optimization test' +test_description='git rev-list trivial path optimization test' . ./test-lib.sh @@ -12,9 +12,9 @@ initial=$(git rev-parse --verify HEAD) ' test_expect_success path-optimization ' - commit=$(echo "Unchanged tree" | git-commit-tree "HEAD^{tree}" -p HEAD) && - test $(git-rev-list $commit | wc -l) = 2 && - test $(git-rev-list $commit -- . | wc -l) = 1 + commit=$(echo "Unchanged tree" | git commit-tree "HEAD^{tree}" -p HEAD) && + test $(git rev-list $commit | wc -l) = 2 && + test $(git rev-list $commit -- . | wc -l) = 1 ' test_expect_success 'further setup' ' diff --git a/t/t6005-rev-list-count.sh b/t/t6005-rev-list-count.sh index 334fccf58c..0b64822bf6 100755 --- a/t/t6005-rev-list-count.sh +++ b/t/t6005-rev-list-count.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-rev-list --max-count and --skip test' +test_description='git rev-list --max-count and --skip test' . ./test-lib.sh @@ -13,39 +13,39 @@ test_expect_success 'setup' ' ' test_expect_success 'no options' ' - test $(git-rev-list HEAD | wc -l) = 5 + test $(git rev-list HEAD | wc -l) = 5 ' test_expect_success '--max-count' ' - test $(git-rev-list HEAD --max-count=0 | wc -l) = 0 && - test $(git-rev-list HEAD --max-count=3 | wc -l) = 3 && - test $(git-rev-list HEAD --max-count=5 | wc -l) = 5 && - test $(git-rev-list HEAD --max-count=10 | wc -l) = 5 + test $(git rev-list HEAD --max-count=0 | wc -l) = 0 && + test $(git rev-list HEAD --max-count=3 | wc -l) = 3 && + test $(git rev-list HEAD --max-count=5 | wc -l) = 5 && + test $(git rev-list HEAD --max-count=10 | wc -l) = 5 ' test_expect_success '--max-count all forms' ' - test $(git-rev-list HEAD --max-count=1 | wc -l) = 1 && - test $(git-rev-list HEAD -1 | wc -l) = 1 && - test $(git-rev-list HEAD -n1 | wc -l) = 1 && - test $(git-rev-list HEAD -n 1 | wc -l) = 1 + test $(git rev-list HEAD --max-count=1 | wc -l) = 1 && + test $(git rev-list HEAD -1 | wc -l) = 1 && + test $(git rev-list HEAD -n1 | wc -l) = 1 && + test $(git rev-list HEAD -n 1 | wc -l) = 1 ' test_expect_success '--skip' ' - test $(git-rev-list HEAD --skip=0 | wc -l) = 5 && - test $(git-rev-list HEAD --skip=3 | wc -l) = 2 && - test $(git-rev-list HEAD --skip=5 | wc -l) = 0 && - test $(git-rev-list HEAD --skip=10 | wc -l) = 0 + test $(git rev-list HEAD --skip=0 | wc -l) = 5 && + test $(git rev-list HEAD --skip=3 | wc -l) = 2 && + test $(git rev-list HEAD --skip=5 | wc -l) = 0 && + test $(git rev-list HEAD --skip=10 | wc -l) = 0 ' test_expect_success '--skip --max-count' ' - test $(git-rev-list HEAD --skip=0 --max-count=0 | wc -l) = 0 && - test $(git-rev-list HEAD --skip=0 --max-count=10 | wc -l) = 5 && - test $(git-rev-list HEAD --skip=3 --max-count=0 | wc -l) = 0 && - test $(git-rev-list HEAD --skip=3 --max-count=1 | wc -l) = 1 && - test $(git-rev-list HEAD --skip=3 --max-count=2 | wc -l) = 2 && - test $(git-rev-list HEAD --skip=3 --max-count=10 | wc -l) = 2 && - test $(git-rev-list HEAD --skip=5 --max-count=10 | wc -l) = 0 && - test $(git-rev-list HEAD --skip=10 --max-count=10 | wc -l) = 0 + test $(git rev-list HEAD --skip=0 --max-count=0 | wc -l) = 0 && + test $(git rev-list HEAD --skip=0 --max-count=10 | wc -l) = 5 && + test $(git rev-list HEAD --skip=3 --max-count=0 | wc -l) = 0 && + test $(git rev-list HEAD --skip=3 --max-count=1 | wc -l) = 1 && + test $(git rev-list HEAD --skip=3 --max-count=2 | wc -l) = 2 && + test $(git rev-list HEAD --skip=3 --max-count=10 | wc -l) = 2 && + test $(git rev-list HEAD --skip=5 --max-count=10 | wc -l) = 0 && + test $(git rev-list HEAD --skip=10 --max-count=10 | wc -l) = 0 ' test_done diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index aab17face8..ad6d0b8c9d 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -1,12 +1,12 @@ #!/bin/sh -test_description='git-rev-list --pretty=format test' +test_description='git rev-list --pretty=format test' . ./test-lib.sh test_tick test_expect_success 'setup' ' -touch foo && git-add foo && git-commit -m "added foo" && +touch foo && git add foo && git-commit -m "added foo" && echo changed >foo && git-commit -a -m "changed foo" ' @@ -14,8 +14,8 @@ touch foo && git-add foo && git-commit -m "added foo" && test_format() { cat >expect.$1 test_expect_success "format $1" " -git-rev-list --pretty=format:$2 master >output.$1 && -git-diff expect.$1 output.$1 +git rev-list --pretty=format:$2 master >output.$1 && +git diff expect.$1 output.$1 " } @@ -113,7 +113,7 @@ and it will be encoded in iso8859-1. We should therefore include an iso8859 character: ¡bueno! EOF test_expect_success 'setup complex body' ' -git-config i18n.commitencoding iso8859-1 && +git config i18n.commitencoding iso8859-1 && echo change2 >foo && git-commit -a -F commit-msg ' diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh new file mode 100755 index 0000000000..3faeae6c01 --- /dev/null +++ b/t/t6007-rev-list-cherry-pick-file.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +test_description='test git rev-list --cherry-pick -- file' + +. ./test-lib.sh + +# A---B +# \ +# \ +# C +# +# B changes a file foo.c, adding a line of text. C changes foo.c as +# well as bar.c, but the change in foo.c was identical to change B. + +test_expect_success setup ' + echo Hallo > foo && + git add foo && + test_tick && + git commit -m "A" && + git tag A && + git checkout -b branch && + echo Bello > foo && + echo Cello > bar && + git add foo bar && + test_tick && + git commit -m "C" && + git tag C && + git checkout master && + git checkout branch foo && + test_tick && + git commit -m "B" && + git tag B +' + +test_expect_success '--cherry-pick foo comes up empty' ' + test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)" +' + +test_expect_success '--cherry-pick bar does not come up empty' ' + ! test -z "$(git rev-list --left-right --cherry-pick B...C -- bar)" +' + +test_done diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh index 22e0893056..96f3d35530 100755 --- a/t/t6010-merge-base.sh +++ b/t/t6010-merge-base.sh @@ -8,7 +8,7 @@ test_description='Merge base computation. . ./test-lib.sh -T=$(git-write-tree) +T=$(git write-tree) M=1130000000 Z=+0000 @@ -29,7 +29,7 @@ doit() { GIT_COMMITTER_DATE="$(($M + $OFFSET)) $Z" GIT_AUTHOR_DATE=$GIT_COMMITTER_DATE export GIT_COMMITTER_DATE GIT_AUTHOR_DATE - commit=$(echo $NAME | git-commit-tree $T $PARENTS) + commit=$(echo $NAME | git commit-tree $T $PARENTS) echo $commit >.git/refs/tags/$NAME echo $commit } @@ -51,16 +51,16 @@ G=$(doit 7 G $B $E) H=$(doit 8 H $A $F) test_expect_success 'compute merge-base (single)' \ - 'MB=$(git-merge-base G H) && - expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"' + 'MB=$(git merge-base G H) && + expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/B"' test_expect_success 'compute merge-base (all)' \ - 'MB=$(git-merge-base --all G H) && - expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"' + 'MB=$(git merge-base --all G H) && + expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/B"' test_expect_success 'compute merge-base with show-branch' \ - 'MB=$(git-show-branch --merge-base G H) && - expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/B"' + 'MB=$(git show-branch --merge-base G H) && + expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/B"' # Setup for second test to demonstrate that relying on timestamps in a # distributed SCM to provide a _consistent_ partial ordering of commits @@ -100,11 +100,11 @@ PL=$(doit 4 PL $L2 $C2) PR=$(doit 4 PR $C2 $R2) test_expect_success 'compute merge-base (single)' \ - 'MB=$(git-merge-base PL PR) && - expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/C2"' + 'MB=$(git merge-base PL PR) && + expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/C2"' test_expect_success 'compute merge-base (all)' \ - 'MB=$(git-merge-base --all PL PR) && - expr "$(git-name-rev "$MB")" : "[0-9a-f]* tags/C2"' + 'MB=$(git merge-base --all PL PR) && + expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/C2"' test_done diff --git a/t/t6021-merge-criss-cross.sh b/t/t6021-merge-criss-cross.sh index 499cafb882..0ab14a6e81 100755 --- a/t/t6021-merge-criss-cross.sh +++ b/t/t6021-merge-criss-cross.sh @@ -20,7 +20,7 @@ test_expect_success 'prepare repository' \ 7 8 9" > file && -git add file && +git add file && git commit -m "Initial commit" file && git branch A && git branch B && diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index c76fccfb5a..ae3b6f2831 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -56,18 +56,18 @@ printf "propter nomen suum." >> new4.txt cp new1.txt test.txt test_expect_success "merge without conflict" \ - "git-merge-file test.txt orig.txt new2.txt" + "git merge-file test.txt orig.txt new2.txt" cp new1.txt test2.txt test_expect_success "merge without conflict (missing LF at EOF)" \ - "git-merge-file test2.txt orig.txt new2.txt" + "git merge-file test2.txt orig.txt new2.txt" test_expect_success "merge result added missing LF" \ "git diff test.txt test2.txt" cp test.txt backup.txt test_expect_failure "merge with conflicts" \ - "git-merge-file test.txt orig.txt new3.txt" + "git merge-file test.txt orig.txt new3.txt" cat > expect.txt << EOF <<<<<<< test.txt @@ -90,7 +90,7 @@ test_expect_success "expected conflict markers" "git diff test.txt expect.txt" cp backup.txt test.txt test_expect_failure "merge with conflicts, using -L" \ - "git-merge-file -L 1 -L 2 test.txt orig.txt new3.txt" + "git merge-file -L 1 -L 2 test.txt orig.txt new3.txt" cat > expect.txt << EOF <<<<<<< 1 @@ -114,7 +114,7 @@ test_expect_success "expected conflict markers, with -L" \ sed "s/ tu / TU /" < new1.txt > new5.txt test_expect_failure "conflict in removed tail" \ - "git-merge-file -p orig.txt new1.txt new5.txt > out" + "git merge-file -p orig.txt new1.txt new5.txt > out" cat > expect << EOF Dominus regit me, @@ -134,5 +134,9 @@ EOF test_expect_success "expected conflict markers" "git diff expect out" -test_done +test_expect_success 'binary files cannot be merged' ' + ! git merge-file -p orig.txt ../test4012.png new1.txt 2> merge.err && + grep "Cannot merge binary files" merge.err +' +test_done diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh index 058db9cc52..c154f03cf5 100755 --- a/t/t6024-recursive-merge.sh +++ b/t/t6024-recursive-merge.sh @@ -28,7 +28,7 @@ echo B > a1 && GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 && git checkout -b D A && -git-rev-parse B > .git/MERGE_HEAD && +git rev-parse B > .git/MERGE_HEAD && echo D > a1 && git update-index a1 && GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D && @@ -42,19 +42,19 @@ echo C > a1 && GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 && git checkout -b E C && -git-rev-parse B > .git/MERGE_HEAD && +git rev-parse B > .git/MERGE_HEAD && echo E > a1 && git update-index a1 && GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E && git checkout -b G E && -git-rev-parse A > .git/MERGE_HEAD && +git rev-parse A > .git/MERGE_HEAD && echo G > a1 && git update-index a1 && GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G && git checkout -b F D && -git-rev-parse C > .git/MERGE_HEAD && +git rev-parse C > .git/MERGE_HEAD && echo F > a1 && git update-index a1 && GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F diff --git a/t/t6025-merge-symlinks.sh b/t/t6025-merge-symlinks.sh index 3c1a6972bd..950c2e9b63 100755 --- a/t/t6025-merge-symlinks.sh +++ b/t/t6025-merge-symlinks.sh @@ -12,22 +12,22 @@ if core.symlinks is false.' test_expect_success \ 'setup' ' -git-config core.symlinks false && +git config core.symlinks false && > file && -git-add file && +git add file && git-commit -m initial && -git-branch b-symlink && -git-branch b-file && +git branch b-symlink && +git branch b-file && l=$(echo -n file | git-hash-object -t blob -w --stdin) && -echo "120000 $l symlink" | git-update-index --index-info && +echo "120000 $l symlink" | git update-index --index-info && git-commit -m master && git-checkout b-symlink && l=$(echo -n file-different | git-hash-object -t blob -w --stdin) && -echo "120000 $l symlink" | git-update-index --index-info && +echo "120000 $l symlink" | git update-index --index-info && git-commit -m b-symlink && git-checkout b-file && echo plain-file > symlink && -git-add symlink && +git add symlink && git-commit -m b-file' test_expect_failure \ diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 30f6ade13f..03cdba5808 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -102,4 +102,3 @@ test_expect_success \ # # test_done - diff --git a/t/t6101-rev-parse-parents.sh b/t/t6101-rev-parse-parents.sh index 7d354a1fae..0724864e56 100755 --- a/t/t6101-rev-parse-parents.sh +++ b/t/t6101-rev-parse-parents.sh @@ -3,31 +3,40 @@ # Copyright (c) 2005 Johannes Schindelin # -test_description='Test git-rev-parse with different parent options' +test_description='Test git rev-parse with different parent options' . ./test-lib.sh . ../t6000lib.sh # t6xxx specific functions date >path0 -git-update-index --add path0 -save_tag tree git-write-tree +git update-index --add path0 +save_tag tree git write-tree hide_error save_tag start unique_commit "start" tree save_tag second unique_commit "second" tree -p start hide_error save_tag start2 unique_commit "start2" tree save_tag two_parents unique_commit "next" tree -p second -p start2 save_tag final unique_commit "final" tree -p two_parents -test_expect_success 'start is valid' 'git-rev-parse start | grep "^[0-9a-f]\{40\}$"' -test_expect_success 'start^0' "test $(cat .git/refs/tags/start) = $(git-rev-parse start^0)" -test_expect_success 'start^1 not valid' "if git-rev-parse --verify start^1; then false; else :; fi" -test_expect_success 'second^1 = second^' "test $(git-rev-parse second^1) = $(git-rev-parse second^)" -test_expect_success 'final^1^1^1' "test $(git-rev-parse start) = $(git-rev-parse final^1^1^1)" -test_expect_success 'final^1^1^1 = final^^^' "test $(git-rev-parse final^1^1^1) = $(git-rev-parse final^^^)" -test_expect_success 'final^1^2' "test $(git-rev-parse start2) = $(git-rev-parse final^1^2)" -test_expect_success 'final^1^2 != final^1^1' "test $(git-rev-parse final^1^2) != $(git-rev-parse final^1^1)" -test_expect_success 'final^1^3 not valid' "if git-rev-parse --verify final^1^3; then false; else :; fi" -test_expect_failure '--verify start2^1' 'git-rev-parse --verify start2^1' -test_expect_success '--verify start2^0' 'git-rev-parse --verify start2^0' +test_expect_success 'start is valid' 'git rev-parse start | grep "^[0-9a-f]\{40\}$"' +test_expect_success 'start^0' "test $(cat .git/refs/tags/start) = $(git rev-parse start^0)" +test_expect_success 'start^1 not valid' "if git rev-parse --verify start^1; then false; else :; fi" +test_expect_success 'second^1 = second^' "test $(git rev-parse second^1) = $(git rev-parse second^)" +test_expect_success 'final^1^1^1' "test $(git rev-parse start) = $(git rev-parse final^1^1^1)" +test_expect_success 'final^1^1^1 = final^^^' "test $(git rev-parse final^1^1^1) = $(git rev-parse final^^^)" +test_expect_success 'final^1^2' "test $(git rev-parse start2) = $(git rev-parse final^1^2)" +test_expect_success 'final^1^2 != final^1^1' "test $(git rev-parse final^1^2) != $(git rev-parse final^1^1)" +test_expect_success 'final^1^3 not valid' "if git rev-parse --verify final^1^3; then false; else :; fi" +test_expect_failure '--verify start2^1' 'git rev-parse --verify start2^1' +test_expect_success '--verify start2^0' 'git rev-parse --verify start2^0' -test_done +test_expect_success 'repack for next test' 'git repack -a -d' +test_expect_success 'short SHA-1 works' ' + start=`git rev-parse --verify start` && + echo $start && + abbrv=`echo $start | sed s/.\$//` && + echo $abbrv && + abbrv=`git rev-parse --verify $abbrv` && + echo $abbrv && + test $start = $abbrv' +test_done diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index 3e9edda1ca..ae8ee11183 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -28,39 +28,39 @@ check_describe () { test_expect_success setup ' test_tick && - echo one >file && git-add file && git-commit -m initial && - one=$(git-rev-parse HEAD) && + echo one >file && git add file && git-commit -m initial && + one=$(git rev-parse HEAD) && test_tick && - echo two >file && git-add file && git-commit -m second && - two=$(git-rev-parse HEAD) && + echo two >file && git add file && git-commit -m second && + two=$(git rev-parse HEAD) && test_tick && - echo three >file && git-add file && git-commit -m third && + echo three >file && git add file && git-commit -m third && test_tick && - echo A >file && git-add file && git-commit -m A && + echo A >file && git add file && git-commit -m A && test_tick && git-tag -a -m A A && test_tick && - echo c >file && git-add file && git-commit -m c && + echo c >file && git add file && git-commit -m c && test_tick && git-tag c && git reset --hard $two && test_tick && - echo B >side && git-add side && git-commit -m B && + echo B >side && git add side && git-commit -m B && test_tick && git-tag -a -m B B && test_tick && git-merge -m Merged c && - merged=$(git-rev-parse HEAD) && + merged=$(git rev-parse HEAD) && git reset --hard $two && test_tick && - echo D >another && git-add another && git-commit -m D && + echo D >another && git add another && git-commit -m D && test_tick && git-tag -a -m D D && @@ -77,7 +77,7 @@ test_expect_success setup ' git-merge -m Merged $merged && test_tick && - echo X >file && echo X >side && git-add file side && + echo X >file && echo X >side && git add file side && git-commit -m x ' diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index 344033249c..8b43fb5a27 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -1,18 +1,18 @@ #!/bin/sh -test_description='git-mv in subdirs' +test_description='git mv in subdirs' . ./test-lib.sh test_expect_success \ 'prepare reference tree' \ 'mkdir path0 path1 && cp ../../COPYING path0/COPYING && - git-add path0/COPYING && + git add path0/COPYING && git-commit -m add -a' test_expect_success \ 'moving the file out of subdirectory' \ - 'cd path0 && git-mv COPYING ../path1/COPYING' + 'cd path0 && git mv COPYING ../path1/COPYING' # in path0 currently test_expect_success \ @@ -21,12 +21,12 @@ test_expect_success \ test_expect_success \ 'checking the commit' \ - 'git-diff-tree -r -M --name-status HEAD^ HEAD | \ + 'git diff-tree -r -M --name-status HEAD^ HEAD | \ grep -E "^R100.+path0/COPYING.+path1/COPYING"' test_expect_success \ 'moving the file back into subdirectory' \ - 'cd path0 && git-mv ../path1/COPYING COPYING' + 'cd path0 && git mv ../path1/COPYING COPYING' # in path0 currently test_expect_success \ @@ -35,18 +35,18 @@ test_expect_success \ test_expect_success \ 'checking the commit' \ - 'git-diff-tree -r -M --name-status HEAD^ HEAD | \ + 'git diff-tree -r -M --name-status HEAD^ HEAD | \ grep -E "^R100.+path1/COPYING.+path0/COPYING"' test_expect_success \ 'adding another file' \ 'cp ../../README path0/README && - git-add path0/README && + git add path0/README && git-commit -m add2 -a' test_expect_success \ 'moving whole subdirectory' \ - 'git-mv path0 path2' + 'git mv path0 path2' test_expect_success \ 'commiting the change' \ @@ -54,18 +54,18 @@ test_expect_success \ test_expect_success \ 'checking the commit' \ - 'git-diff-tree -r -M --name-status HEAD^ HEAD | \ + 'git diff-tree -r -M --name-status HEAD^ HEAD | \ grep -E "^R100.+path0/COPYING.+path2/COPYING" && - git-diff-tree -r -M --name-status HEAD^ HEAD | \ + git diff-tree -r -M --name-status HEAD^ HEAD | \ grep -E "^R100.+path0/README.+path2/README"' test_expect_success \ 'succeed when source is a prefix of destination' \ - 'git-mv path2/COPYING path2/COPYING-renamed' + 'git mv path2/COPYING path2/COPYING-renamed' test_expect_success \ 'moving whole subdirectory into subdirectory' \ - 'git-mv path2 path1' + 'git mv path2 path1' test_expect_success \ 'commiting the change' \ @@ -73,18 +73,18 @@ test_expect_success \ test_expect_success \ 'checking the commit' \ - 'git-diff-tree -r -M --name-status HEAD^ HEAD | \ + 'git diff-tree -r -M --name-status HEAD^ HEAD | \ grep -E "^R100.+path2/COPYING.+path1/path2/COPYING" && - git-diff-tree -r -M --name-status HEAD^ HEAD | \ + git diff-tree -r -M --name-status HEAD^ HEAD | \ grep -E "^R100.+path2/README.+path1/path2/README"' test_expect_failure \ 'do not move directory over existing directory' \ - 'mkdir path0 && mkdir path0/path2 && git-mv path2 path0' + 'mkdir path0 && mkdir path0/path2 && git mv path2 path0' test_expect_success \ 'move into "."' \ - 'git-mv path1/path2/ .' + 'git mv path1/path2/ .' test_expect_success "Michael Cassar's test case" ' rm -fr .git papers partA && diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh new file mode 100755 index 0000000000..bc6e2ddb19 --- /dev/null +++ b/t/t7003-filter-branch.sh @@ -0,0 +1,162 @@ +#!/bin/sh + +test_description='git-filter-branch' +. ./test-lib.sh + +make_commit () { + lower=$(echo $1 | tr A-Z a-z) + echo $lower > $lower + git add $lower + test_tick + git commit -m $1 + git tag $1 +} + +test_expect_success 'setup' ' + make_commit A + make_commit B + git checkout -b branch B + make_commit D + make_commit E + git checkout master + make_commit C + git checkout branch + git merge C + git tag F + make_commit G + make_commit H +' + +H=$(git rev-parse H) + +test_expect_success 'rewrite identically' ' + git-filter-branch branch +' +test_expect_success 'result is really identical' ' + test $H = $(git rev-parse HEAD) +' + +test_expect_success 'rewrite, renaming a specific file' ' + git-filter-branch -f --tree-filter "mv d doh || :" HEAD +' + +test_expect_success 'test that the file was renamed' ' + test d = $(git show HEAD:doh) +' + +git tag oldD HEAD~4 +test_expect_success 'rewrite one branch, keeping a side branch' ' + git branch modD oldD && + git-filter-branch -f --tree-filter "mv b boh || :" D..modD +' + +test_expect_success 'common ancestor is still common (unchanged)' ' + test "$(git merge-base modD D)" = "$(git rev-parse B)" +' + +test_expect_success 'filter subdirectory only' ' + mkdir subdir && + touch subdir/new && + git add subdir/new && + test_tick && + git commit -m "subdir" && + echo H > a && + test_tick && + git commit -m "not subdir" a && + echo A > subdir/new && + test_tick && + git commit -m "again subdir" subdir/new && + git rm a && + test_tick && + git commit -m "again not subdir" && + git branch sub && + git-filter-branch -f --subdirectory-filter subdir refs/heads/sub +' + +test_expect_success 'subdirectory filter result looks okay' ' + test 2 = $(git rev-list sub | wc -l) && + git show sub:new && + ! git show sub:subdir +' + +test_expect_success 'setup and filter history that requires --full-history' ' + git checkout master && + mkdir subdir && + echo A > subdir/new && + git add subdir/new && + test_tick && + git commit -m "subdir on master" subdir/new && + git rm a && + test_tick && + git commit -m "again subdir on master" && + git merge branch && + git branch sub-master && + git-filter-branch -f --subdirectory-filter subdir sub-master +' + +test_expect_success 'subdirectory filter result looks okay' ' + test 3 = $(git rev-list -1 --parents sub-master | wc -w) && + git show sub-master^:new && + git show sub-master^2:new && + ! git show sub:subdir +' + +test_expect_success 'use index-filter to move into a subdirectory' ' + git branch directorymoved && + git-filter-branch -f --index-filter \ + "git ls-files -s | sed \"s-\\t-&newsubdir/-\" | + GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \ + git update-index --index-info && + mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE" directorymoved && + test -z "$(git diff HEAD directorymoved:newsubdir)"' + +test_expect_success 'stops when msg filter fails' ' + old=$(git rev-parse HEAD) && + ! git-filter-branch -f --msg-filter false && + test $old = $(git rev-parse HEAD) && + rm -rf .git-rewrite +' + +test_expect_success 'author information is preserved' ' + : > i && + git add i && + test_tick && + GIT_AUTHOR_NAME="B V Uips" git commit -m bvuips && + git branch preserved-author && + git-filter-branch -f --msg-filter "cat; \ + test \$GIT_COMMIT != $(git rev-parse master) || \ + echo Hallo" \ + preserved-author && + test 1 = $(git rev-list --author="B V Uips" preserved-author | wc -l) +' + +test_expect_success "remove a certain author's commits" ' + echo i > i && + test_tick && + git commit -m i i && + git branch removed-author && + git-filter-branch -f --commit-filter "\ + if [ \"\$GIT_AUTHOR_NAME\" = \"B V Uips\" ];\ + then\ + shift;\ + while [ -n \"\$1\" ];\ + do\ + shift;\ + echo \"\$1\";\ + shift;\ + done;\ + else\ + git commit-tree \"\$@\";\ + fi" removed-author && + cnt1=$(git rev-list master | wc -l) && + cnt2=$(git rev-list removed-author | wc -l) && + test $cnt1 -eq $(($cnt2 + 1)) && + test 0 = $(git rev-list --author="B V Uips" removed-author | wc -l) +' + +test_expect_success 'barf on invalid name' ' + ! git filter-branch -f master xy-problem && + ! git filter-branch -f HEAD^ +' + +test_done diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh new file mode 100755 index 0000000000..17de2a90e6 --- /dev/null +++ b/t/t7004-tag.sh @@ -0,0 +1,897 @@ +#!/bin/sh +# +# Copyright (c) 2007 Carlos Rica +# + +test_description='git-tag + +Basic tests for operations with tags.' + +. ./test-lib.sh + +# creating and listing lightweight tags: + +tag_exists () { + git show-ref --quiet --verify refs/tags/"$1" +} + +# todo: git tag -l now returns always zero, when fixed, change this test +test_expect_success 'listing all tags in an empty tree should succeed' \ + 'git tag -l' + +test_expect_success 'listing all tags in an empty tree should output nothing' \ + 'test `git-tag -l | wc -l` -eq 0' + +test_expect_failure 'looking for a tag in an empty tree should fail' \ + 'tag_exists mytag' + +test_expect_success 'creating a tag in an empty tree should fail' ' + ! git-tag mynotag && + ! tag_exists mynotag +' + +test_expect_success 'creating a tag for HEAD in an empty tree should fail' ' + ! git-tag mytaghead HEAD && + ! tag_exists mytaghead +' + +test_expect_success 'creating a tag for an unknown revision should fail' ' + ! git-tag mytagnorev aaaaaaaaaaa && + ! tag_exists mytagnorev +' + +# commit used in the tests, test_tick is also called here to freeze the date: +test_expect_success 'creating a tag using default HEAD should succeed' ' + test_tick && + echo foo >foo && + git add foo && + git commit -m Foo && + git tag mytag +' + +test_expect_success 'listing all tags if one exists should succeed' \ + 'git-tag -l' + +test_expect_success 'listing all tags if one exists should output that tag' \ + 'test `git-tag -l` = mytag' + +# pattern matching: + +test_expect_success 'listing a tag using a matching pattern should succeed' \ + 'git-tag -l mytag' + +test_expect_success \ + 'listing a tag using a matching pattern should output that tag' \ + 'test `git-tag -l mytag` = mytag' + +# todo: git tag -l now returns always zero, when fixed, change this test +test_expect_success \ + 'listing tags using a non-matching pattern should suceed' \ + 'git-tag -l xxx' + +test_expect_success \ + 'listing tags using a non-matching pattern should output nothing' \ + 'test `git-tag -l xxx | wc -l` -eq 0' + +# special cases for creating tags: + +test_expect_failure \ + 'trying to create a tag with the name of one existing should fail' \ + 'git tag mytag' + +test_expect_success \ + 'trying to create a tag with a non-valid name should fail' ' + test `git-tag -l | wc -l` -eq 1 && + ! git tag "" && + ! git tag .othertag && + ! git tag "other tag" && + ! git tag "othertag^" && + ! git tag "other~tag" && + test `git-tag -l | wc -l` -eq 1 +' + +test_expect_success 'creating a tag using HEAD directly should succeed' ' + git tag myhead HEAD && + tag_exists myhead +' + +# deleting tags: + +test_expect_success 'trying to delete an unknown tag should fail' ' + ! tag_exists unknown-tag && + ! git-tag -d unknown-tag +' + +cat >expect <<EOF +myhead +mytag +EOF +test_expect_success \ + 'trying to delete tags without params should succeed and do nothing' ' + git tag -l > actual && git diff expect actual && + git-tag -d && + git tag -l > actual && git diff expect actual +' + +test_expect_success \ + 'deleting two existing tags in one command should succeed' ' + tag_exists mytag && + tag_exists myhead && + git-tag -d mytag myhead && + ! tag_exists mytag && + ! tag_exists myhead +' + +test_expect_success \ + 'creating a tag with the name of another deleted one should succeed' ' + ! tag_exists mytag && + git-tag mytag && + tag_exists mytag +' + +test_expect_success \ + 'trying to delete two tags, existing and not, should fail in the 2nd' ' + tag_exists mytag && + ! tag_exists myhead && + ! git-tag -d mytag anothertag && + ! tag_exists mytag && + ! tag_exists myhead +' + +test_expect_failure 'trying to delete an already deleted tag should fail' \ + 'git-tag -d mytag' + +# listing various tags with pattern matching: + +cat >expect <<EOF +a1 +aa1 +cba +t210 +t211 +v0.2.1 +v1.0 +v1.0.1 +v1.1.3 +EOF +test_expect_success 'listing all tags should print them ordered' ' + git tag v1.0.1 && + git tag t211 && + git tag aa1 && + git tag v0.2.1 && + git tag v1.1.3 && + git tag cba && + git tag a1 && + git tag v1.0 && + git tag t210 && + git tag -l > actual && + git diff expect actual +' + +cat >expect <<EOF +a1 +aa1 +cba +EOF +test_expect_success \ + 'listing tags with substring as pattern must print those matching' ' + git-tag -l a > actual && + git diff expect actual +' + +cat >expect <<EOF +v0.2.1 +v1.0.1 +v1.1.3 +EOF +test_expect_success \ + 'listing tags with substring as pattern must print those matching' ' + git-tag -l .1 > actual && + git diff expect actual +' + +cat >expect <<EOF +t210 +t211 +EOF +test_expect_success \ + 'listing tags with substring as pattern must print those matching' ' + git-tag -l t21 > actual && + git diff expect actual +' + +cat >expect <<EOF +a1 +aa1 +EOF +test_expect_success \ + 'listing tags using a name as pattern must print those matching' ' + git-tag -l a1 > actual && + git diff expect actual +' + +cat >expect <<EOF +v1.0 +v1.0.1 +EOF +test_expect_success \ + 'listing tags using a name as pattern must print those matching' ' + git-tag -l v1.0 > actual && + git diff expect actual +' + +cat >expect <<EOF +v1.1.3 +EOF +test_expect_success \ + 'listing tags with ? in the pattern should print those matching' ' + git-tag -l "1.1?" > actual && + git diff expect actual +' + +>expect +test_expect_success \ + 'listing tags using v.* should print nothing because none have v.' ' + git-tag -l "v.*" > actual && + git diff expect actual +' + +cat >expect <<EOF +v0.2.1 +v1.0 +v1.0.1 +v1.1.3 +EOF +test_expect_success \ + 'listing tags using v* should print only those having v' ' + git-tag -l "v*" > actual && + git diff expect actual +' + +# creating and verifying lightweight tags: + +test_expect_success \ + 'a non-annotated tag created without parameters should point to HEAD' ' + git-tag non-annotated-tag && + test $(git cat-file -t non-annotated-tag) = commit && + test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD) +' + +test_expect_failure 'trying to verify an unknown tag should fail' \ + 'git-tag -v unknown-tag' + +test_expect_failure \ + 'trying to verify a non-annotated and non-signed tag should fail' \ + 'git-tag -v non-annotated-tag' + +# creating annotated tags: + +get_tag_msg () { + git cat-file tag "$1" | sed -e "/BEGIN PGP/q" +} + +# run test_tick before committing always gives the time in that timezone +get_tag_header () { +cat <<EOF +object $2 +type $3 +tag $1 +tagger C O Mitter <committer@example.com> $4 -0700 + +EOF +} + +commit=$(git rev-parse HEAD) +time=$test_tick + +get_tag_header annotated-tag $commit commit $time >expect +echo "A message" >>expect +test_expect_success \ + 'creating an annotated tag with -m message should succeed' ' + git-tag -m "A message" annotated-tag && + get_tag_msg annotated-tag >actual && + git diff expect actual +' + +cat >msgfile <<EOF +Another message +in a file. +EOF +get_tag_header file-annotated-tag $commit commit $time >expect +cat msgfile >>expect +test_expect_success \ + 'creating an annotated tag with -F messagefile should succeed' ' + git-tag -F msgfile file-annotated-tag && + get_tag_msg file-annotated-tag >actual && + git diff expect actual +' + +# blank and empty messages: + +get_tag_header empty-annotated-tag $commit commit $time >expect +test_expect_success \ + 'creating a tag with an empty -m message should succeed' ' + git-tag -m "" empty-annotated-tag && + get_tag_msg empty-annotated-tag >actual && + git diff expect actual +' + +>emptyfile +get_tag_header emptyfile-annotated-tag $commit commit $time >expect +test_expect_success \ + 'creating a tag with an empty -F messagefile should succeed' ' + git-tag -F emptyfile emptyfile-annotated-tag && + get_tag_msg emptyfile-annotated-tag >actual && + git diff expect actual +' + +printf '\n\n \n\t\nLeading blank lines\n' >blanksfile +printf '\n\t \t \nRepeated blank lines\n' >>blanksfile +printf '\n\n\nTrailing spaces \t \n' >>blanksfile +printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile +get_tag_header blanks-annotated-tag $commit commit $time >expect +cat >>expect <<EOF +Leading blank lines + +Repeated blank lines + +Trailing spaces + +Trailing blank lines +EOF +test_expect_success \ + 'extra blanks in the message for an annotated tag should be removed' ' + git-tag -F blanksfile blanks-annotated-tag && + get_tag_msg blanks-annotated-tag >actual && + git diff expect actual +' + +get_tag_header blank-annotated-tag $commit commit $time >expect +test_expect_success \ + 'creating a tag with blank -m message with spaces should succeed' ' + git-tag -m " " blank-annotated-tag && + get_tag_msg blank-annotated-tag >actual && + git diff expect actual +' + +echo ' ' >blankfile +echo '' >>blankfile +echo ' ' >>blankfile +get_tag_header blankfile-annotated-tag $commit commit $time >expect +test_expect_success \ + 'creating a tag with blank -F messagefile with spaces should succeed' ' + git-tag -F blankfile blankfile-annotated-tag && + get_tag_msg blankfile-annotated-tag >actual && + git diff expect actual +' + +printf ' ' >blanknonlfile +get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect +test_expect_success \ + 'creating a tag with -F file of spaces and no newline should succeed' ' + git-tag -F blanknonlfile blanknonlfile-annotated-tag && + get_tag_msg blanknonlfile-annotated-tag >actual && + git diff expect actual +' + +# messages with commented lines: + +cat >commentsfile <<EOF +# A comment + +############ +The message. +############ +One line. + + +# commented lines +# commented lines + +Another line. +# comments + +Last line. +EOF +get_tag_header comments-annotated-tag $commit commit $time >expect +cat >>expect <<EOF +The message. +One line. + +Another line. + +Last line. +EOF +test_expect_success \ + 'creating a tag using a -F messagefile with #comments should succeed' ' + git-tag -F commentsfile comments-annotated-tag && + get_tag_msg comments-annotated-tag >actual && + git diff expect actual +' + +get_tag_header comment-annotated-tag $commit commit $time >expect +test_expect_success \ + 'creating a tag with a #comment in the -m message should succeed' ' + git-tag -m "#comment" comment-annotated-tag && + get_tag_msg comment-annotated-tag >actual && + git diff expect actual +' + +echo '#comment' >commentfile +echo '' >>commentfile +echo '####' >>commentfile +get_tag_header commentfile-annotated-tag $commit commit $time >expect +test_expect_success \ + 'creating a tag with #comments in the -F messagefile should succeed' ' + git-tag -F commentfile commentfile-annotated-tag && + get_tag_msg commentfile-annotated-tag >actual && + git diff expect actual +' + +printf '#comment' >commentnonlfile +get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect +test_expect_success \ + 'creating a tag with a file of #comment and no newline should succeed' ' + git-tag -F commentnonlfile commentnonlfile-annotated-tag && + get_tag_msg commentnonlfile-annotated-tag >actual && + git diff expect actual +' + +# listing messages for annotated non-signed tags: + +test_expect_success \ + 'listing the one-line message of a non-signed tag should succeed' ' + git-tag -m "A msg" tag-one-line && + + echo "tag-one-line" >expect && + git-tag -l | grep "^tag-one-line" >actual && + git diff expect actual && + git-tag -n 0 -l | grep "^tag-one-line" >actual && + git diff expect actual && + git-tag -n 0 -l tag-one-line >actual && + git diff expect actual && + + echo "tag-one-line A msg" >expect && + git-tag -n xxx -l | grep "^tag-one-line" >actual && + git diff expect actual && + git-tag -n "" -l | grep "^tag-one-line" >actual && + git diff expect actual && + git-tag -n 1 -l | grep "^tag-one-line" >actual && + git diff expect actual && + git-tag -n -l | grep "^tag-one-line" >actual && + git diff expect actual && + git-tag -n 1 -l tag-one-line >actual && + git diff expect actual && + git-tag -n 2 -l tag-one-line >actual && + git diff expect actual && + git-tag -n 999 -l tag-one-line >actual && + git diff expect actual +' + +test_expect_success \ + 'listing the zero-lines message of a non-signed tag should succeed' ' + git-tag -m "" tag-zero-lines && + + echo "tag-zero-lines" >expect && + git-tag -l | grep "^tag-zero-lines" >actual && + git diff expect actual && + git-tag -n 0 -l | grep "^tag-zero-lines" >actual && + git diff expect actual && + git-tag -n 0 -l tag-zero-lines >actual && + git diff expect actual && + + echo "tag-zero-lines " >expect && + git-tag -n 1 -l | grep "^tag-zero-lines" >actual && + git diff expect actual && + git-tag -n -l | grep "^tag-zero-lines" >actual && + git diff expect actual && + git-tag -n 1 -l tag-zero-lines >actual && + git diff expect actual && + git-tag -n 2 -l tag-zero-lines >actual && + git diff expect actual && + git-tag -n 999 -l tag-zero-lines >actual && + git diff expect actual +' + +echo 'tag line one' >annotagmsg +echo 'tag line two' >>annotagmsg +echo 'tag line three' >>annotagmsg +test_expect_success \ + 'listing many message lines of a non-signed tag should succeed' ' + git-tag -F annotagmsg tag-lines && + + echo "tag-lines" >expect && + git-tag -l | grep "^tag-lines" >actual && + git diff expect actual && + git-tag -n 0 -l | grep "^tag-lines" >actual && + git diff expect actual && + git-tag -n 0 -l tag-lines >actual && + git diff expect actual && + + echo "tag-lines tag line one" >expect && + git-tag -n 1 -l | grep "^tag-lines" >actual && + git diff expect actual && + git-tag -n -l | grep "^tag-lines" >actual && + git diff expect actual && + git-tag -n 1 -l tag-lines >actual && + git diff expect actual && + + echo " tag line two" >>expect && + git-tag -n 2 -l | grep "^ *tag.line" >actual && + git diff expect actual && + git-tag -n 2 -l tag-lines >actual && + git diff expect actual && + + echo " tag line three" >>expect && + git-tag -n 3 -l | grep "^ *tag.line" >actual && + git diff expect actual && + git-tag -n 3 -l tag-lines >actual && + git diff expect actual && + git-tag -n 4 -l | grep "^ *tag.line" >actual && + git diff expect actual && + git-tag -n 4 -l tag-lines >actual && + git diff expect actual && + git-tag -n 99 -l | grep "^ *tag.line" >actual && + git diff expect actual && + git-tag -n 99 -l tag-lines >actual && + git diff expect actual +' + +# trying to verify annotated non-signed tags: + +test_expect_success \ + 'trying to verify an annotated non-signed tag should fail' ' + tag_exists annotated-tag && + ! git-tag -v annotated-tag +' + +test_expect_success \ + 'trying to verify a file-annotated non-signed tag should fail' ' + tag_exists file-annotated-tag && + ! git-tag -v file-annotated-tag +' + +# creating and verifying signed tags: + +gpg --version >/dev/null +if [ $? -eq 127 ]; then + echo "Skipping signed tags tests, because gpg was not found" + test_done + exit +fi + +# As said here: http://www.gnupg.org/documentation/faqs.html#q6.19 +# the gpg version 1.0.6 didn't parse trust packets correctly, so for +# that version, creation of signed tags using the generated key fails. +case "$(gpg --version)" in +'gpg (GnuPG) 1.0.6'*) + echo "Skipping signed tag tests, because a bug in 1.0.6 version" + test_done + exit + ;; +esac + +# key generation info: gpg --homedir t/t7004 --gen-key +# Type DSA and Elgamal, size 2048 bits, no expiration date. +# Name and email: C O Mitter <committer@example.com> +# No password given, to enable non-interactive operation. + +cp -R ../t7004 ./gpghome +chmod 0700 gpghome +export GNUPGHOME="$(pwd)/gpghome" + +get_tag_header signed-tag $commit commit $time >expect +echo 'A signed tag message' >>expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success 'creating a signed tag with -m message should succeed' ' + git-tag -s -m "A signed tag message" signed-tag && + get_tag_msg signed-tag >actual && + git diff expect actual +' + +test_expect_success 'verifying a signed tag should succeed' \ + 'git-tag -v signed-tag' + +test_expect_success 'verifying a forged tag should fail' ' + forged=$(git cat-file tag signed-tag | + sed -e "s/signed-tag/forged-tag/" | + git mktag) && + git tag forged-tag $forged && + ! git-tag -v forged-tag +' + +# blank and empty messages for signed tags: + +get_tag_header empty-signed-tag $commit commit $time >expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag with an empty -m message should succeed' ' + git-tag -s -m "" empty-signed-tag && + get_tag_msg empty-signed-tag >actual && + git diff expect actual && + git-tag -v empty-signed-tag +' + +>sigemptyfile +get_tag_header emptyfile-signed-tag $commit commit $time >expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag with an empty -F messagefile should succeed' ' + git-tag -s -F sigemptyfile emptyfile-signed-tag && + get_tag_msg emptyfile-signed-tag >actual && + git diff expect actual && + git-tag -v emptyfile-signed-tag +' + +printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile +printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile +printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile +printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile +get_tag_header blanks-signed-tag $commit commit $time >expect +cat >>expect <<EOF +Leading blank lines + +Repeated blank lines + +Trailing spaces + +Trailing blank lines +EOF +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'extra blanks in the message for a signed tag should be removed' ' + git-tag -s -F sigblanksfile blanks-signed-tag && + get_tag_msg blanks-signed-tag >actual && + git diff expect actual && + git-tag -v blanks-signed-tag +' + +get_tag_header blank-signed-tag $commit commit $time >expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag with a blank -m message should succeed' ' + git-tag -s -m " " blank-signed-tag && + get_tag_msg blank-signed-tag >actual && + git diff expect actual && + git-tag -v blank-signed-tag +' + +echo ' ' >sigblankfile +echo '' >>sigblankfile +echo ' ' >>sigblankfile +get_tag_header blankfile-signed-tag $commit commit $time >expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag with blank -F file with spaces should succeed' ' + git-tag -s -F sigblankfile blankfile-signed-tag && + get_tag_msg blankfile-signed-tag >actual && + git diff expect actual && + git-tag -v blankfile-signed-tag +' + +printf ' ' >sigblanknonlfile +get_tag_header blanknonlfile-signed-tag $commit commit $time >expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag with spaces and no newline should succeed' ' + git-tag -s -F sigblanknonlfile blanknonlfile-signed-tag && + get_tag_msg blanknonlfile-signed-tag >actual && + git diff expect actual && + git-tag -v signed-tag +' + +# messages with commented lines for signed tags: + +cat >sigcommentsfile <<EOF +# A comment + +############ +The message. +############ +One line. + + +# commented lines +# commented lines + +Another line. +# comments + +Last line. +EOF +get_tag_header comments-signed-tag $commit commit $time >expect +cat >>expect <<EOF +The message. +One line. + +Another line. + +Last line. +EOF +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag with a -F file with #comments should succeed' ' + git-tag -s -F sigcommentsfile comments-signed-tag && + get_tag_msg comments-signed-tag >actual && + git diff expect actual && + git-tag -v comments-signed-tag +' + +get_tag_header comment-signed-tag $commit commit $time >expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag with #commented -m message should succeed' ' + git-tag -s -m "#comment" comment-signed-tag && + get_tag_msg comment-signed-tag >actual && + git diff expect actual && + git-tag -v comment-signed-tag +' + +echo '#comment' >sigcommentfile +echo '' >>sigcommentfile +echo '####' >>sigcommentfile +get_tag_header commentfile-signed-tag $commit commit $time >expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag with #commented -F messagefile should succeed' ' + git-tag -s -F sigcommentfile commentfile-signed-tag && + get_tag_msg commentfile-signed-tag >actual && + git diff expect actual && + git-tag -v commentfile-signed-tag +' + +printf '#comment' >sigcommentnonlfile +get_tag_header commentnonlfile-signed-tag $commit commit $time >expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag with a #comment and no newline should succeed' ' + git-tag -s -F sigcommentnonlfile commentnonlfile-signed-tag && + get_tag_msg commentnonlfile-signed-tag >actual && + git diff expect actual && + git-tag -v commentnonlfile-signed-tag +' + +# listing messages for signed tags: + +test_expect_success \ + 'listing the one-line message of a signed tag should succeed' ' + git-tag -s -m "A message line signed" stag-one-line && + + echo "stag-one-line" >expect && + git-tag -l | grep "^stag-one-line" >actual && + git diff expect actual && + git-tag -n 0 -l | grep "^stag-one-line" >actual && + git diff expect actual && + git-tag -n 0 -l stag-one-line >actual && + git diff expect actual && + + echo "stag-one-line A message line signed" >expect && + git-tag -n xxx -l | grep "^stag-one-line" >actual && + git diff expect actual && + git-tag -n "" -l | grep "^stag-one-line" >actual && + git diff expect actual && + git-tag -n 1 -l | grep "^stag-one-line" >actual && + git diff expect actual && + git-tag -n -l | grep "^stag-one-line" >actual && + git diff expect actual && + git-tag -n 1 -l stag-one-line >actual && + git diff expect actual && + git-tag -n 2 -l stag-one-line >actual && + git diff expect actual && + git-tag -n 999 -l stag-one-line >actual && + git diff expect actual +' + +test_expect_success \ + 'listing the zero-lines message of a signed tag should succeed' ' + git-tag -s -m "" stag-zero-lines && + + echo "stag-zero-lines" >expect && + git-tag -l | grep "^stag-zero-lines" >actual && + git diff expect actual && + git-tag -n 0 -l | grep "^stag-zero-lines" >actual && + git diff expect actual && + git-tag -n 0 -l stag-zero-lines >actual && + git diff expect actual && + + echo "stag-zero-lines " >expect && + git-tag -n 1 -l | grep "^stag-zero-lines" >actual && + git diff expect actual && + git-tag -n -l | grep "^stag-zero-lines" >actual && + git diff expect actual && + git-tag -n 1 -l stag-zero-lines >actual && + git diff expect actual && + git-tag -n 2 -l stag-zero-lines >actual && + git diff expect actual && + git-tag -n 999 -l stag-zero-lines >actual && + git diff expect actual +' + +echo 'stag line one' >sigtagmsg +echo 'stag line two' >>sigtagmsg +echo 'stag line three' >>sigtagmsg +test_expect_success \ + 'listing many message lines of a signed tag should succeed' ' + git-tag -s -F sigtagmsg stag-lines && + + echo "stag-lines" >expect && + git-tag -l | grep "^stag-lines" >actual && + git diff expect actual && + git-tag -n 0 -l | grep "^stag-lines" >actual && + git diff expect actual && + git-tag -n 0 -l stag-lines >actual && + git diff expect actual && + + echo "stag-lines stag line one" >expect && + git-tag -n 1 -l | grep "^stag-lines" >actual && + git diff expect actual && + git-tag -n -l | grep "^stag-lines" >actual && + git diff expect actual && + git-tag -n 1 -l stag-lines >actual && + git diff expect actual && + + echo " stag line two" >>expect && + git-tag -n 2 -l | grep "^ *stag.line" >actual && + git diff expect actual && + git-tag -n 2 -l stag-lines >actual && + git diff expect actual && + + echo " stag line three" >>expect && + git-tag -n 3 -l | grep "^ *stag.line" >actual && + git diff expect actual && + git-tag -n 3 -l stag-lines >actual && + git diff expect actual && + git-tag -n 4 -l | grep "^ *stag.line" >actual && + git diff expect actual && + git-tag -n 4 -l stag-lines >actual && + git diff expect actual && + git-tag -n 99 -l | grep "^ *stag.line" >actual && + git diff expect actual && + git-tag -n 99 -l stag-lines >actual && + git diff expect actual +' + +# tags pointing to objects different from commits: + +tree=$(git rev-parse HEAD^{tree}) +blob=$(git rev-parse HEAD:foo) +tag=$(git rev-parse signed-tag) + +get_tag_header tree-signed-tag $tree tree $time >expect +echo "A message for a tree" >>expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag pointing to a tree should succeed' ' + git-tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} && + get_tag_msg tree-signed-tag >actual && + git diff expect actual +' + +get_tag_header blob-signed-tag $blob blob $time >expect +echo "A message for a blob" >>expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag pointing to a blob should succeed' ' + git-tag -s -m "A message for a blob" blob-signed-tag HEAD:foo && + get_tag_msg blob-signed-tag >actual && + git diff expect actual +' + +get_tag_header tag-signed-tag $tag tag $time >expect +echo "A message for another tag" >>expect +echo '-----BEGIN PGP SIGNATURE-----' >>expect +test_expect_success \ + 'creating a signed tag pointing to another tag should succeed' ' + git-tag -s -m "A message for another tag" tag-signed-tag signed-tag && + get_tag_msg tag-signed-tag >actual && + git diff expect actual +' + +# try to verify without gpg: + +rm -rf gpghome +test_expect_failure \ + 'verify signed tag fails when public key is not present' \ + 'git-tag -v signed-tag' + +test_done diff --git a/t/t7004/pubring.gpg b/t/t7004/pubring.gpg Binary files differnew file mode 100644 index 0000000000..83855fa4e1 --- /dev/null +++ b/t/t7004/pubring.gpg diff --git a/t/t7004/random_seed b/t/t7004/random_seed Binary files differnew file mode 100644 index 0000000000..8fed1339ed --- /dev/null +++ b/t/t7004/random_seed diff --git a/t/t7004/secring.gpg b/t/t7004/secring.gpg Binary files differnew file mode 100644 index 0000000000..d831cd9eb3 --- /dev/null +++ b/t/t7004/secring.gpg diff --git a/t/t7004/trustdb.gpg b/t/t7004/trustdb.gpg Binary files differnew file mode 100644 index 0000000000..abace962b8 --- /dev/null +++ b/t/t7004/trustdb.gpg diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh new file mode 100755 index 0000000000..28643b0da4 --- /dev/null +++ b/t/t7005-editor.sh @@ -0,0 +1,91 @@ +#!/bin/sh + +test_description='GIT_EDITOR, core.editor, and stuff' + +. ./test-lib.sh + +for i in GIT_EDITOR core_editor EDITOR VISUAL vi +do + cat >e-$i.sh <<-EOF + echo "Edited by $i" >"\$1" + EOF + chmod +x e-$i.sh +done +unset vi +mv e-vi.sh vi +PATH=".:$PATH" +unset EDITOR VISUAL GIT_EDITOR + +test_expect_success setup ' + + msg="Hand edited" && + echo "$msg" >expect && + git add vi && + test_tick && + git commit -m "$msg" && + git show -s --pretty=oneline | + sed -e "s/^[0-9a-f]* //" >actual && + diff actual expect + +' + +TERM=dumb +export TERM +test_expect_success 'dumb should error out when falling back on vi' ' + + if git commit --amend + then + echo "Oops?" + exit 1 + else + : happy + fi +' + +TERM=vt100 +export TERM +for i in vi EDITOR VISUAL core_editor GIT_EDITOR +do + echo "Edited by $i" >expect + unset EDITOR VISUAL GIT_EDITOR + git config --unset-all core.editor + case "$i" in + core_editor) + git config core.editor ./e-core_editor.sh + ;; + [A-Z]*) + eval "$i=./e-$i.sh" + export $i + ;; + esac + test_expect_success "Using $i" ' + git commit --amend && + git show -s --pretty=oneline | + sed -e "s/^[0-9a-f]* //" >actual && + diff actual expect + ' +done + +unset EDITOR VISUAL GIT_EDITOR +git config --unset-all core.editor +for i in vi EDITOR VISUAL core_editor GIT_EDITOR +do + echo "Edited by $i" >expect + case "$i" in + core_editor) + git config core.editor ./e-core_editor.sh + ;; + [A-Z]*) + eval "$i=./e-$i.sh" + export $i + ;; + esac + test_expect_success "Using $i (override)" ' + git commit --amend && + git show -s --pretty=oneline | + sed -e "s/^[0-9a-f]* //" >actual && + diff actual expect + ' +done + +test_done diff --git a/t/t7101-reset.sh b/t/t7101-reset.sh index a9191407f2..66d40430b2 100755 --- a/t/t7101-reset.sh +++ b/t/t7101-reset.sh @@ -10,7 +10,7 @@ test_expect_success \ 'creating initial files' \ 'mkdir path0 && cp ../../COPYING path0/COPYING && - git-add path0/COPYING && + git add path0/COPYING && git-commit -m add -a' test_expect_success \ @@ -21,10 +21,10 @@ test_expect_success \ cp ../../COPYING path1/COPYING && cp ../../COPYING COPYING && cp ../../COPYING path0/COPYING-TOO && - git-add path1/path2/COPYING && - git-add path1/COPYING && - git-add COPYING && - git-add path0/COPYING-TOO && + git add path1/path2/COPYING && + git add path1/COPYING && + git add COPYING && + git add path0/COPYING-TOO && git-commit -m change -a' test_expect_success \ diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index de70b38d1c..eb0847afe9 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -13,10 +13,10 @@ test_expect_success 'setup' ' touch src/part1.c Makefile && echo build >.gitignore && echo \*.o >>.gitignore && - git-add . && + git add . && git-commit -m setup && touch src/part2.c README && - git-add . + git add . ' @@ -141,7 +141,7 @@ test_expect_success 'git-clean -d -X' ' test_expect_success 'clean.requireForce' ' - git-config clean.requireForce true && + git config clean.requireForce true && ! git-clean ' diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh new file mode 100755 index 0000000000..e8ce7cdb83 --- /dev/null +++ b/t/t7400-submodule-basic.sh @@ -0,0 +1,178 @@ +#!/bin/sh +# +# Copyright (c) 2007 Lars Hjemli +# + +test_description='Basic porcelain support for submodules + +This test tries to verify basic sanity of the init, update and status +subcommands of git-submodule. +' + +. ./test-lib.sh + +# +# Test setup: +# -create a repository in directory lib +# -add a couple of files +# -add directory lib to 'superproject', this creates a DIRLINK entry +# -add a couple of regular files to enable testing of submodule filtering +# -mv lib subrepo +# -add an entry to .gitmodules for submodule 'example' +# +test_expect_success 'Prepare submodule testing' ' + : > t && + git-add t && + git-commit -m "initial commit" && + git branch initial HEAD && + mkdir lib && + cd lib && + git init && + echo a >a && + git add a && + git-commit -m "submodule commit 1" && + git-tag -a -m "rev-1" rev-1 && + rev1=$(git rev-parse HEAD) && + if test -z "$rev1" + then + echo "[OOPS] submodule git rev-parse returned nothing" + false + fi && + cd .. && + echo a >a && + echo z >z && + git add a lib z && + git-commit -m "super commit 1" && + mv lib .subrepo && + GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/lib.git +' + +test_expect_success 'status should fail for unmapped paths' ' + if git-submodule status + then + echo "[OOPS] submodule status succeeded" + false + elif ! GIT_CONFIG=.gitmodules git config submodule.example.path lib + then + echo "[OOPS] git config failed to update .gitmodules" + false + fi +' + +test_expect_success 'status should only print one line' ' + lines=$(git-submodule status | wc -l) && + test $lines = 1 +' + +test_expect_success 'status should initially be "missing"' ' + git-submodule status | grep "^-$rev1" +' + +test_expect_success 'init should register submodule url in .git/config' ' + git-submodule init && + url=$(git config submodule.example.url) && + if test "$url" != "git://example.com/lib.git" + then + echo "[OOPS] init succeeded but submodule url is wrong" + false + elif ! git config submodule.example.url ./.subrepo + then + echo "[OOPS] init succeeded but update of url failed" + false + fi +' + +test_expect_success 'update should fail when path is used by a file' ' + echo "hello" >lib && + if git-submodule update + then + echo "[OOPS] update should have failed" + false + elif test "$(cat lib)" != "hello" + then + echo "[OOPS] update failed but lib file was molested" + false + else + rm lib + fi +' + +test_expect_success 'update should fail when path is used by a nonempty directory' ' + mkdir lib && + echo "hello" >lib/a && + if git-submodule update + then + echo "[OOPS] update should have failed" + false + elif test "$(cat lib/a)" != "hello" + then + echo "[OOPS] update failed but lib/a was molested" + false + else + rm lib/a + fi +' + +test_expect_success 'update should work when path is an empty dir' ' + rm -rf lib && + mkdir lib && + git-submodule update && + head=$(cd lib && git rev-parse HEAD) && + if test -z "$head" + then + echo "[OOPS] Failed to obtain submodule head" + false + elif test "$head" != "$rev1" + then + echo "[OOPS] Submodule head is $head but should have been $rev1" + false + fi +' + +test_expect_success 'status should be "up-to-date" after update' ' + git-submodule status | grep "^ $rev1" +' + +test_expect_success 'status should be "modified" after submodule commit' ' + cd lib && + echo b >b && + git add b && + git-commit -m "submodule commit 2" && + rev2=$(git rev-parse HEAD) && + cd .. && + if test -z "$rev2" + then + echo "[OOPS] submodule git rev-parse returned nothing" + false + fi && + git-submodule status | grep "^+$rev2" +' + +test_expect_success 'the --cached sha1 should be rev1' ' + git-submodule --cached status | grep "^+$rev1" +' + +test_expect_success 'update should checkout rev1' ' + git-submodule update && + head=$(cd lib && git rev-parse HEAD) && + if test -z "$head" + then + echo "[OOPS] submodule git rev-parse returned nothing" + false + elif test "$head" != "$rev1" + then + echo "[OOPS] init did not checkout correct head" + false + fi +' + +test_expect_success 'status should be "up-to-date" after update' ' + git-submodule status | grep "^ $rev1" +' + +test_expect_success 'checkout superproject with subproject already present' ' + git-checkout initial && + git-checkout master +' + +test_done diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh new file mode 100755 index 0000000000..f11ada8617 --- /dev/null +++ b/t/t7500-commit.sh @@ -0,0 +1,96 @@ +#!/bin/sh +# +# Copyright (c) 2007 Steven Grimm +# + +test_description='git-commit + +Tests for selected commit options.' + +. ./test-lib.sh + +commit_msg_is () { + test "`git log --pretty=format:%s%b -1`" = "$1" +} + +# A sanity check to see if commit is working at all. +test_expect_success 'a basic commit in an empty tree should succeed' ' + echo content > foo && + git add foo && + git commit -m "initial commit" +' + +test_expect_success 'nonexistent template file should return error' ' + echo changes >> foo && + git add foo && + ! git commit --template "$PWD"/notexist +' + +test_expect_success 'nonexistent template file in config should return error' ' + git config commit.template "$PWD"/notexist && + ! git commit && + git config --unset commit.template +' + +# From now on we'll use a template file that exists. +TEMPLATE="$PWD"/template + +test_expect_success 'unedited template should not commit' ' + echo "template line" > "$TEMPLATE" && + ! git commit --template "$TEMPLATE" +' + +test_expect_success 'unedited template with comments should not commit' ' + echo "# comment in template" >> "$TEMPLATE" && + ! git commit --template "$TEMPLATE" +' + +test_expect_success 'a Signed-off-by line by itself should not commit' ' + ! GIT_EDITOR=../t7500/add-signed-off git commit --template "$TEMPLATE" +' + +test_expect_success 'adding comments to a template should not commit' ' + ! GIT_EDITOR=../t7500/add-comments git commit --template "$TEMPLATE" +' + +test_expect_success 'adding real content to a template should commit' ' + GIT_EDITOR=../t7500/add-content git commit --template "$TEMPLATE" && + commit_msg_is "template linecommit message" +' + +test_expect_success '-t option should be short for --template' ' + echo "short template" > "$TEMPLATE" && + echo "new content" >> foo && + git add foo && + GIT_EDITOR=../t7500/add-content git commit -t "$TEMPLATE" && + commit_msg_is "short templatecommit message" +' + +test_expect_success 'config-specified template should commit' ' + echo "new template" > "$TEMPLATE" && + git config commit.template "$TEMPLATE" && + echo "more content" >> foo && + git add foo && + GIT_EDITOR=../t7500/add-content git commit && + git config --unset commit.template && + commit_msg_is "new templatecommit message" +' + +test_expect_success 'explicit commit message should override template' ' + echo "still more content" >> foo && + git add foo && + GIT_EDITOR=../t7500/add-content git commit --template "$TEMPLATE" \ + -m "command line msg" && + commit_msg_is "command line msg<unknown>" +' + +test_expect_success 'commit message from file should override template' ' + echo "content galore" >> foo && + git add foo && + echo "standard input msg" | + GIT_EDITOR=../t7500/add-content git commit \ + --template "$TEMPLATE" --file - && + commit_msg_is "standard input msg<unknown>" +' + +test_done diff --git a/t/t7500/add-comments b/t/t7500/add-comments new file mode 100755 index 0000000000..a72e65c891 --- /dev/null +++ b/t/t7500/add-comments @@ -0,0 +1,4 @@ +#!/bin/sh +echo "# this is a new comment" >> "$1" +echo "# and so is this" >> "$1" +exit 0 diff --git a/t/t7500/add-content b/t/t7500/add-content new file mode 100755 index 0000000000..2fa3d86a10 --- /dev/null +++ b/t/t7500/add-content @@ -0,0 +1,3 @@ +#!/bin/sh +echo "commit message" >> "$1" +exit 0 diff --git a/t/t7500/add-signed-off b/t/t7500/add-signed-off new file mode 100755 index 0000000000..e1d856af6d --- /dev/null +++ b/t/t7500/add-signed-off @@ -0,0 +1,3 @@ +#!/bin/sh +echo "Signed-off-by: foo <bar@frotz>" >> "$1" +exit 0 diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh new file mode 100644 index 0000000000..6bd3c9e3e0 --- /dev/null +++ b/t/t7501-commit.sh @@ -0,0 +1,134 @@ +#!/bin/sh +# +# Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com> +# + +# FIXME: Test the various index usages, -i and -o, test reflog, +# signoff, hooks + +test_description='git-commit' +. ./test-lib.sh + +test_tick + +test_expect_success \ + "initial status" \ + "echo 'bongo bongo' >file && + git-add file && \ + git-status | grep 'Initial commit'" + +test_expect_failure \ + "fail initial amend" \ + "git-commit --amend" + +test_expect_success \ + "initial commit" \ + "git-commit -m initial" + +test_expect_failure \ + "invalid options 1" \ + "git-commit -m foo -m bar -F file" + +test_expect_failure \ + "invalid options 2" \ + "git-commit -C HEAD -m illegal" + +test_expect_failure \ + "using invalid commit with -C" \ + "git-commit -C bogus" + +test_expect_failure \ + "testing nothing to commit" \ + "git-commit -m initial" + +test_expect_success \ + "next commit" \ + "echo 'bongo bongo bongo' >file \ + git-commit -m next -a" + +test_expect_failure \ + "commit message from non-existing file" \ + "echo 'more bongo: bongo bongo bongo bongo' >file && \ + git-commit -F gah -a" + +# Empty except stray tabs and spaces on a few lines. +sed -e 's/@$//' >msg <<EOF + @ + + @ +Signed-off-by: hula +EOF +test_expect_failure \ + "empty commit message" \ + "git-commit -F msg -a" + +test_expect_success \ + "commit message from file" \ + "echo 'this is the commit message, coming from a file' >msg && \ + git-commit -F msg -a" + +cat >editor <<\EOF +#!/bin/sh +sed -i -e "s/a file/an amend commit/g" $1 +EOF +chmod 755 editor + +test_expect_success \ + "amend commit" \ + "VISUAL=./editor git-commit --amend" + +test_expect_failure \ + "passing -m and -F" \ + "echo 'enough with the bongos' >file && \ + git-commit -F msg -m amending ." + +test_expect_success \ + "using message from other commit" \ + "git-commit -C HEAD^ ." + +cat >editor <<\EOF +#!/bin/sh +sed -i -e "s/amend/older/g" $1 +EOF +chmod 755 editor + +test_expect_success \ + "editing message from other commit" \ + "echo 'hula hula' >file && \ + VISUAL=./editor git-commit -c HEAD^ -a" + +test_expect_success \ + "message from stdin" \ + "echo 'silly new contents' >file && \ + echo commit message from stdin | git-commit -F - -a" + +test_expect_success \ + "overriding author from command line" \ + "echo 'gak' >file && \ + git-commit -m 'author' --author 'Rubber Duck <rduck@convoy.org>' -a" + +test_expect_success \ + "interactive add" \ + "echo 7 | git-commit --interactive | grep 'What now'" + +test_expect_success \ + "showing committed revisions" \ + "git-rev-list HEAD >current" + +# We could just check the head sha1, but checking each commit makes it +# easier to isolate bugs. + +cat >expected <<\EOF +72c0dc9855b0c9dadcbfd5a31cab072e0cb774ca +9b88fc14ce6b32e3d9ee021531a54f18a5cf38a2 +3536bbb352c3a1ef9a420f5b4242d48578b92aa7 +d381ac431806e53f3dd7ac2f1ae0534f36d738b9 +4fd44095ad6334f3ef72e4c5ec8ddf108174b54a +402702b49136e7587daa9280e91e4bb7cb2179f7 +EOF + +test_expect_success \ + 'validate git-rev-list output.' \ + 'diff current expected' + +test_done diff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh index 3a6490e8f8..eabec2e06e 100755 --- a/t/t8001-annotate.sh +++ b/t/t8001-annotate.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-annotate' +test_description='git annotate' . ./test-lib.sh PROG='git annotate' diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh index 9777393996..92ece30fa9 100755 --- a/t/t8002-blame.sh +++ b/t/t8002-blame.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-blame' +test_description='git blame' . ./test-lib.sh PROG='git blame -c' diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 70c3669ee8..614cf50d19 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -86,10 +86,10 @@ test_expect_failure "$name" " rm -f '$GIT_DIR'/index && git checkout -f -b mybranch3 remotes/git-svn && rm bar/zzz && - git-update-index --remove bar/zzz && + git update-index --remove bar/zzz && mkdir bar/zzz && echo yyy > bar/zzz/yyy && - git-update-index --add bar/zzz/yyy && + git update-index --add bar/zzz/yyy && git commit -m '$name' && git-svn set-tree --find-copies-harder --rmdir \ remotes/git-svn..mybranch3" || true @@ -191,8 +191,8 @@ GIT_SVN_ID=alt export GIT_SVN_ID test_expect_success "$name" \ "git-svn init $svnrepo && git-svn fetch && - git-rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a && - git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b && + git rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a && + git rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b && git diff a b" name='check imported tree checksums expected tree checksums' @@ -214,7 +214,7 @@ EOF test_expect_success "$name" "git diff a expected" test_expect_failure 'exit if remote refs are ambigious' " - git-config --add svn-remote.svn.fetch \ + git config --add svn-remote.svn.fetch \ bar:refs/remotes/git-svn && git-svn migrate " @@ -222,7 +222,7 @@ test_expect_failure 'exit if remote refs are ambigious' " test_expect_failure 'exit if init-ing a would clobber a URL' " svnadmin create ${PWD}/svnrepo2 && svn mkdir -m 'mkdir bar' ${svnrepo}2/bar && - git-config --unset svn-remote.svn.fetch \ + git config --unset svn-remote.svn.fetch \ '^bar:refs/remotes/git-svn$' && git-svn init ${svnrepo}2/bar " diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index 35aa45cb9a..d8f9cab35d 100755 --- a/t/t9104-git-svn-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh @@ -30,31 +30,31 @@ test_expect_success 'initialize repo' " test_expect_success 'init and fetch a moved directory' " git-svn init --minimize-url -i thunk $svnrepo/thunk && git-svn fetch -i thunk && - test \"\`git-rev-parse --verify refs/remotes/thunk@2\`\" \ - = \"\`git-rev-parse --verify refs/remotes/thunk~1\`\" && - test \"\`git-cat-file blob refs/remotes/thunk:readme |\ + test \"\`git rev-parse --verify refs/remotes/thunk@2\`\" \ + = \"\`git rev-parse --verify refs/remotes/thunk~1\`\" && + test \"\`git cat-file blob refs/remotes/thunk:readme |\ sed -n -e '3p'\`\" = goodbye && - test -z \"\`git-config --get svn-remote.svn.fetch \ + test -z \"\`git config --get svn-remote.svn.fetch \ '^trunk:refs/remotes/thunk@2$'\`\" " test_expect_success 'init and fetch from one svn-remote' " - git-config svn-remote.svn.url $svnrepo && - git-config --add svn-remote.svn.fetch \ + git config svn-remote.svn.url $svnrepo && + git config --add svn-remote.svn.fetch \ trunk:refs/remotes/svn/trunk && - git-config --add svn-remote.svn.fetch \ + git config --add svn-remote.svn.fetch \ thunk:refs/remotes/svn/thunk && git-svn fetch -i svn/thunk && - test \"\`git-rev-parse --verify refs/remotes/svn/trunk\`\" \ - = \"\`git-rev-parse --verify refs/remotes/svn/thunk~1\`\" && - test \"\`git-cat-file blob refs/remotes/svn/thunk:readme |\ + test \"\`git rev-parse --verify refs/remotes/svn/trunk\`\" \ + = \"\`git rev-parse --verify refs/remotes/svn/thunk~1\`\" && + test \"\`git cat-file blob refs/remotes/svn/thunk:readme |\ sed -n -e '3p'\`\" = goodbye " test_expect_success 'follow deleted parent' " svn cp -m 'resurrecting trunk as junk' \ -r2 $svnrepo/trunk $svnrepo/junk && - git-config --add svn-remote.svn.fetch \ + git config --add svn-remote.svn.fetch \ junk:refs/remotes/svn/junk && git-svn fetch -i svn/thunk && git-svn fetch -i svn/junk && @@ -71,13 +71,13 @@ test_expect_success 'follow larger parent' " git-svn init --minimize-url -i larger \ $svnrepo/another-larger/trunk/thunk/bump/thud && git-svn fetch -i larger && - git-rev-parse --verify refs/remotes/larger && - git-rev-parse --verify \ + git rev-parse --verify refs/remotes/larger && + git rev-parse --verify \ refs/remotes/larger-parent/trunk/thunk/bump/thud && - test \"\`git-merge-base \ + test \"\`git merge-base \ refs/remotes/larger-parent/trunk/thunk/bump/thud \ refs/remotes/larger\`\" = \ - \"\`git-rev-parse refs/remotes/larger\`\" + \"\`git rev-parse refs/remotes/larger\`\" true " diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh index dc2afdaa45..67fdf7023f 100755 --- a/t/t9107-git-svn-migrate.sh +++ b/t/t9107-git-svn-migrate.sh @@ -19,9 +19,9 @@ test_expect_success 'setup old-looking metadata' " mv $GIT_DIR/svn/* $GIT_DIR/ && mv $GIT_DIR/svn/.metadata $GIT_DIR/ && rmdir $GIT_DIR/svn && - git-update-ref refs/heads/git-svn-HEAD refs/remotes/git-svn && - git-update-ref refs/heads/svn-HEAD refs/remotes/git-svn && - git-update-ref -d refs/remotes/git-svn refs/remotes/git-svn + git update-ref refs/heads/git-svn-HEAD refs/remotes/git-svn && + git update-ref refs/heads/svn-HEAD refs/remotes/git-svn && + git update-ref -d refs/remotes/git-svn refs/remotes/git-svn " head=`git rev-parse --verify refs/heads/git-svn-HEAD^0` @@ -33,8 +33,8 @@ test_expect_success 'initialize old-style (v0) git-svn layout' " echo $svnrepo > $GIT_DIR/svn/info/url && git-svn migrate && ! test -d $GIT_DIR/git-svn && - git-rev-parse --verify refs/remotes/git-svn^0 && - git-rev-parse --verify refs/remotes/svn^0 && + git rev-parse --verify refs/remotes/git-svn^0 && + git rev-parse --verify refs/remotes/svn^0 && test \`git config --get svn-remote.svn.url\` = '$svnrepo' && test \`git config --get svn-remote.svn.fetch\` = \ ':refs/remotes/git-svn' @@ -42,20 +42,20 @@ test_expect_success 'initialize old-style (v0) git-svn layout' " test_expect_success 'initialize a multi-repository repo' " git-svn init $svnrepo -T trunk -t tags -b branches && - git-config --get-all svn-remote.svn.fetch > fetch.out && + git config --get-all svn-remote.svn.fetch > fetch.out && grep '^trunk:refs/remotes/trunk$' fetch.out && - test -n \"\`git-config --get svn-remote.svn.branches \ + test -n \"\`git config --get svn-remote.svn.branches \ '^branches/\*:refs/remotes/\*$'\`\" && - test -n \"\`git-config --get svn-remote.svn.tags \ + test -n \"\`git config --get svn-remote.svn.tags \ '^tags/\*:refs/remotes/tags/\*$'\`\" && git config --unset svn-remote.svn.branches \ '^branches/\*:refs/remotes/\*$' && git config --unset svn-remote.svn.tags \ '^tags/\*:refs/remotes/tags/\*$' && - git-config --add svn-remote.svn.fetch 'branches/a:refs/remotes/a' && - git-config --add svn-remote.svn.fetch 'branches/b:refs/remotes/b' && + git config --add svn-remote.svn.fetch 'branches/a:refs/remotes/a' && + git config --add svn-remote.svn.fetch 'branches/b:refs/remotes/b' && for i in tags/0.1 tags/0.2 tags/0.3; do - git-config --add svn-remote.svn.fetch \ + git config --add svn-remote.svn.fetch \ \$i:refs/remotes/\$i || exit 1; done " @@ -86,8 +86,8 @@ test_expect_success 'migrate --minimize on old inited layout' " echo $svnrepo\$path > $GIT_DIR/svn/\$ref/info/url ) || exit 1; done && git-svn migrate --minimize && - test -z \"\`git-config -l |grep -v '^svn-remote\.git-svn\.'\`\" && - git-config --get-all svn-remote.svn.fetch > fetch.out && + test -z \"\`git config -l |grep -v '^svn-remote\.git-svn\.'\`\" && + git config --get-all svn-remote.svn.fetch > fetch.out && grep '^trunk:refs/remotes/trunk$' fetch.out && grep '^branches/a:refs/remotes/a$' fetch.out && grep '^branches/b:refs/remotes/b$' fetch.out && @@ -109,4 +109,3 @@ test_expect_success ".rev_db auto-converted to .rev_db.UUID" " " test_done - diff --git a/t/t9110-git-svn-use-svm-props.sh b/t/t9110-git-svn-use-svm-props.sh index 59e17f2663..6235af4db8 100755 --- a/t/t9110-git-svn-use-svm-props.sh +++ b/t/t9110-git-svn-use-svm-props.sh @@ -13,7 +13,7 @@ test_expect_success 'load svm repo' " git-svn init --minimize-url -R argh -i dir $svnrepo/mirror/argh && git-svn init --minimize-url -R argh -i e \ $svnrepo/mirror/argh/a/b/c/d/e && - git-config svn.useSvmProps true && + git config svn.useSvmProps true && git-svn fetch --all " @@ -21,31 +21,31 @@ uuid=161ce429-a9dd-4828-af4a-52023f968c89 bar_url=http://mayonaise/svnrepo/bar test_expect_success 'verify metadata for /bar' " - git-cat-file commit refs/remotes/bar | \ + git cat-file commit refs/remotes/bar | \ grep '^git-svn-id: $bar_url@12 $uuid$' && - git-cat-file commit refs/remotes/bar~1 | \ + git cat-file commit refs/remotes/bar~1 | \ grep '^git-svn-id: $bar_url@11 $uuid$' && - git-cat-file commit refs/remotes/bar~2 | \ + git cat-file commit refs/remotes/bar~2 | \ grep '^git-svn-id: $bar_url@10 $uuid$' && - git-cat-file commit refs/remotes/bar~3 | \ + git cat-file commit refs/remotes/bar~3 | \ grep '^git-svn-id: $bar_url@9 $uuid$' && - git-cat-file commit refs/remotes/bar~4 | \ + git cat-file commit refs/remotes/bar~4 | \ grep '^git-svn-id: $bar_url@6 $uuid$' && - git-cat-file commit refs/remotes/bar~5 | \ + git cat-file commit refs/remotes/bar~5 | \ grep '^git-svn-id: $bar_url@1 $uuid$' " e_url=http://mayonaise/svnrepo/dir/a/b/c/d/e test_expect_success 'verify metadata for /dir/a/b/c/d/e' " - git-cat-file commit refs/remotes/e | \ + git cat-file commit refs/remotes/e | \ grep '^git-svn-id: $e_url@1 $uuid$' " dir_url=http://mayonaise/svnrepo/dir test_expect_success 'verify metadata for /dir' " - git-cat-file commit refs/remotes/dir | \ + git cat-file commit refs/remotes/dir | \ grep '^git-svn-id: $dir_url@2 $uuid$' && - git-cat-file commit refs/remotes/dir~1 | \ + git cat-file commit refs/remotes/dir~1 | \ grep '^git-svn-id: $dir_url@1 $uuid$' " diff --git a/t/t9111-git-svn-use-svnsync-props.sh b/t/t9111-git-svn-use-svnsync-props.sh index e52321471a..ec7dedd48b 100755 --- a/t/t9111-git-svn-use-svnsync-props.sh +++ b/t/t9111-git-svn-use-svnsync-props.sh @@ -12,7 +12,7 @@ test_expect_success 'load svnsync repo' " git-svn init --minimize-url -R arr -i bar $svnrepo/bar && git-svn init --minimize-url -R argh -i dir $svnrepo/dir && git-svn init --minimize-url -R argh -i e $svnrepo/dir/a/b/c/d/e && - git-config svn.useSvnsyncProps true && + git config svn.useSvnsyncProps true && git-svn fetch --all " @@ -20,31 +20,31 @@ uuid=161ce429-a9dd-4828-af4a-52023f968c89 bar_url=http://mayonaise/svnrepo/bar test_expect_success 'verify metadata for /bar' " - git-cat-file commit refs/remotes/bar | \ + git cat-file commit refs/remotes/bar | \ grep '^git-svn-id: $bar_url@12 $uuid$' && - git-cat-file commit refs/remotes/bar~1 | \ + git cat-file commit refs/remotes/bar~1 | \ grep '^git-svn-id: $bar_url@11 $uuid$' && - git-cat-file commit refs/remotes/bar~2 | \ + git cat-file commit refs/remotes/bar~2 | \ grep '^git-svn-id: $bar_url@10 $uuid$' && - git-cat-file commit refs/remotes/bar~3 | \ + git cat-file commit refs/remotes/bar~3 | \ grep '^git-svn-id: $bar_url@9 $uuid$' && - git-cat-file commit refs/remotes/bar~4 | \ + git cat-file commit refs/remotes/bar~4 | \ grep '^git-svn-id: $bar_url@6 $uuid$' && - git-cat-file commit refs/remotes/bar~5 | \ + git cat-file commit refs/remotes/bar~5 | \ grep '^git-svn-id: $bar_url@1 $uuid$' " e_url=http://mayonaise/svnrepo/dir/a/b/c/d/e test_expect_success 'verify metadata for /dir/a/b/c/d/e' " - git-cat-file commit refs/remotes/e | \ + git cat-file commit refs/remotes/e | \ grep '^git-svn-id: $e_url@1 $uuid$' " dir_url=http://mayonaise/svnrepo/dir test_expect_success 'verify metadata for /dir' " - git-cat-file commit refs/remotes/dir | \ + git cat-file commit refs/remotes/dir | \ grep '^git-svn-id: $dir_url@2 $uuid$' && - git-cat-file commit refs/remotes/dir~1 | \ + git cat-file commit refs/remotes/dir~1 | \ grep '^git-svn-id: $dir_url@1 $uuid$' " diff --git a/t/t9111/svnsync.dump b/t/t9111/svnsync.dump index a9a46eeb29..499fa9594f 100644 --- a/t/t9111/svnsync.dump +++ b/t/t9111/svnsync.dump @@ -558,5 +558,3 @@ Text-content-md5: 7abb78de7f2756ca8b511cbc879fd5e7 Content-length: 4 cba - - diff --git a/t/t9113-git-svn-dcommit-new-file.sh b/t/t9113-git-svn-dcommit-new-file.sh new file mode 100755 index 0000000000..9ef0db9044 --- /dev/null +++ b/t/t9113-git-svn-dcommit-new-file.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (c) 2007 Eric Wong +# + +# Don't run this test by default unless the user really wants it +# I don't like the idea of taking a port and possibly leaving a +# daemon running on a users system if the test fails. +# Not all git users will need to interact with SVN. +test -z "$SVNSERVE_PORT" && exit 0 + +test_description='git-svn dcommit new files over svn:// test' + +. ./lib-git-svn.sh + +start_svnserve () { + svnserve --listen-port $SVNSERVE_PORT \ + --root $rawsvnrepo \ + --listen-once \ + --listen-host 127.0.0.1 & +} + +test_expect_success 'start tracking an empty repo' " + svn mkdir -m 'empty dir' $svnrepo/empty-dir && + echo anon-access = write >> $rawsvnrepo/conf/svnserve.conf && + start_svnserve && + git svn init svn://127.0.0.1:$SVNSERVE_PORT && + git svn fetch + " + +test_expect_success 'create files in new directory with dcommit' " + mkdir git-new-dir && + echo hello > git-new-dir/world && + git update-index --add git-new-dir/world && + git commit -m hello && + start_svnserve && + git svn dcommit + " + +test_done diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh new file mode 100755 index 0000000000..d6ca955081 --- /dev/null +++ b/t/t9114-git-svn-dcommit-merge.sh @@ -0,0 +1,89 @@ +#!/bin/sh +# +# Copyright (c) 2007 Eric Wong +# Based on a script by Joakim Tjernlund <joakim.tjernlund@transmode.se> + +test_description='git-svn dcommit handles merges' + +. ./lib-git-svn.sh + +big_text_block () { +cat << EOF +# +# (C) Copyright 2000 - 2005 +# Wolfgang Denk, DENX Software Engineering, wd@denx.de. +# +# See file CREDITS for list of people who contributed to this +# project. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +EOF +} + +test_expect_success 'setup svn repository' " + svn co $svnrepo mysvnwork && + mkdir -p mysvnwork/trunk && + cd mysvnwork && + big_text_block >> trunk/README && + svn add trunk && + svn ci -m 'first commit' trunk && + cd .. + " + +test_expect_success 'setup git mirror and merge' " + git svn init $svnrepo -t tags -T trunk -b branches && + git svn fetch && + git checkout --track -b svn remotes/trunk && + git checkout -b merge && + echo new file > new_file && + git add new_file && + git commit -a -m 'New file' && + echo hello >> README && + git commit -a -m 'hello' && + echo add some stuff >> new_file && + git commit -a -m 'add some stuff' && + git checkout svn && + mv -f README tmp && + echo friend > README && + cat tmp >> README && + git commit -a -m 'friend' && + git pull . merge + " + +test_debug 'gitk --all & sleep 1' + +test_expect_success 'verify pre-merge ancestry' " + test x\`git rev-parse --verify refs/heads/svn^2\` = \ + x\`git rev-parse --verify refs/heads/merge\` && + git cat-file commit refs/heads/svn^ | grep '^friend$' + " + +test_expect_success 'git svn dcommit merges' " + git svn dcommit + " + +test_debug 'gitk --all & sleep 1' + +test_expect_success 'verify post-merge ancestry' " + test x\`git rev-parse --verify refs/heads/svn\` = \ + x\`git rev-parse --verify refs/remotes/trunk \` && + test x\`git rev-parse --verify refs/heads/svn^2\` = \ + x\`git rev-parse --verify refs/heads/merge\` && + git cat-file commit refs/heads/svn^ | grep '^friend$' + " + +test_done diff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh new file mode 100755 index 0000000000..182299cbb5 --- /dev/null +++ b/t/t9115-git-svn-dcommit-funky-renames.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Copyright (c) 2007 Eric Wong + + +test_description='git-svn dcommit can commit renames of files with ugly names' + +. ./lib-git-svn.sh + +test_expect_success 'load repository with strange names' " + svnadmin load -q $rawsvnrepo < ../t9115/funky-names.dump && + start_httpd + " + +test_expect_success 'init and fetch repository' " + git svn init $svnrepo && + git svn fetch && + git reset --hard git-svn + " + +test_expect_success 'create file in existing ugly and empty dir' ' + mkdir "#{bad_directory_name}" && + echo hi > "#{bad_directory_name}/ foo" && + git update-index --add "#{bad_directory_name}/ foo" && + git commit -m "new file in ugly parent" && + git svn dcommit + ' + +test_expect_success 'rename ugly file' ' + git mv "#{bad_directory_name}/ foo" "file name with feces" && + git commit -m "rename ugly file" && + git svn dcommit + ' + +test_expect_success 'rename pretty file' ' + echo :x > pretty && + git update-index --add pretty && + git commit -m "pretty :x" && + git svn dcommit && + mkdir regular_dir_name && + git mv pretty regular_dir_name/pretty && + git commit -m "moved pretty file" && + git svn dcommit + ' + +test_expect_success 'rename pretty file into ugly one' ' + git mv regular_dir_name/pretty "#{bad_directory_name}/ booboo" && + git commit -m booboo && + git svn dcommit + ' + +stop_httpd + +test_done diff --git a/t/t9115/funky-names.dump b/t/t9115/funky-names.dump new file mode 100644 index 0000000000..42422f791e --- /dev/null +++ b/t/t9115/funky-names.dump @@ -0,0 +1,103 @@ +SVN-fs-dump-format-version: 2 + +UUID: 819c44fe-2bcc-4066-88e4-985e2bc0b418 + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2007-07-12T07:54:26.062914Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 152 +Content-length: 152 + +K 7 +svn:log +V 44 +what will those wacky people think of next? + +K 10 +svn:author +V 12 +normalperson +K 8 +svn:date +V 27 +2007-07-12T08:00:05.011573Z +PROPS-END + +Node-path: leading space +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: leading space file +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 5 +Text-content-md5: e4fa20c67542cdc21271e08d329397ab +Content-length: 15 + +PROPS-END +ugly + + +Node-path: #{bad_directory_name} +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: #{cool_name} +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 18 +Text-content-md5: 87dac40ca337dfa3dcc8911388c3ddda +Content-length: 28 + +PROPS-END +strange name here + + +Node-path: dir name with spaces +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: file name with spaces +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 7 +Text-content-md5: c1f10cfd640618484a2a475c11410fd3 +Content-length: 17 + +PROPS-END +spaces + + +Node-path: regular_dir_name +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh index 4efa0c926c..910c584f24 100755 --- a/t/t9200-git-cvsexportcommit.sh +++ b/t/t9200-git-cvsexportcommit.sh @@ -28,6 +28,18 @@ git add empty && git commit -q -a -m "Initial" 2>/dev/null || exit 1 +check_entries () { + # $1 == directory, $2 == expected + grep '^/' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual + if test -z "$2" + then + >expected + else + printf '%s\n' "$2" | tr '|' '\012' >expected + fi + diff -u expected actual +} + test_expect_success \ 'New file' \ 'mkdir A B C D E F && @@ -43,10 +55,10 @@ test_expect_success \ id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && git cvsexportcommit -c $id && - test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.1/" && - test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "newfile2.txt/1.1/" && - test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "newfile3.png/1.1/-kb" && - test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.1/-kb" && + check_entries A "newfile1.txt/1.1/" && + check_entries B "newfile2.txt/1.1/" && + check_entries C "newfile3.png/1.1/-kb" && + check_entries D "newfile4.png/1.1/-kb" && diff A/newfile1.txt ../A/newfile1.txt && diff B/newfile2.txt ../B/newfile2.txt && diff C/newfile3.png ../C/newfile3.png && @@ -67,12 +79,12 @@ test_expect_success \ id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && git cvsexportcommit -c $id && - test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" && - test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" && - test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" && - test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.2/-kb" && - test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" && - test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" && + check_entries A "newfile1.txt/1.2/" && + check_entries B "" && + check_entries C "" && + check_entries D "newfile4.png/1.2/-kb" && + check_entries E "newfile5.txt/1.1/" && + check_entries F "newfile6.png/1.1/-kb" && diff A/newfile1.txt ../A/newfile1.txt && diff D/newfile4.png ../D/newfile4.png && diff E/newfile5.txt ../E/newfile5.txt && @@ -115,12 +127,12 @@ test_expect_success \ id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && git cvsexportcommit -c $id && - test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" && - test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" && - test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" && - test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" && - test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" && - test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" && + check_entries A "newfile1.txt/1.2/" && + check_entries B "" && + check_entries C "" && + check_entries D "" && + check_entries E "newfile5.txt/1.1/" && + check_entries F "newfile6.png/1.1/-kb" && diff A/newfile1.txt ../A/newfile1.txt && diff E/newfile5.txt ../E/newfile5.txt && diff F/newfile6.png ../F/newfile6.png @@ -133,12 +145,12 @@ test_expect_success \ id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && git cvsexportcommit -c $id && - test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "" && - test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" && - test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" && - test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" && - test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" && - test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" && + check_entries A "" && + check_entries B "" && + check_entries C "" && + check_entries D "" && + check_entries E "newfile5.txt/1.1/" && + check_entries F "newfile6.png/1.1/-kb" && diff E/newfile5.txt ../E/newfile5.txt && diff F/newfile6.png ../F/newfile6.png )' @@ -154,7 +166,7 @@ test_expect_success \ id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && git-cvsexportcommit -c $id && - test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.1/-kb with spaces.txt/1.1/" + check_entries "G g" "with spaces.png/1.1/-kb|with spaces.txt/1.1/" )' test_expect_success \ @@ -166,7 +178,7 @@ test_expect_success \ id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && git-cvsexportcommit -c $id - test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.2/-kb with spaces.txt/1.2/" + check_entries "G g" "with spaces.png/1.2/-kb|with spaces.txt/1.2/" )' # Some filesystems mangle pathnames with UTF-8 characters -- @@ -191,7 +203,9 @@ test_expect_success \ id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && git-cvsexportcommit -v -c $id && - test "$(echo $(sort Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/CVS/Entries|cut -d/ -f2,3,5))" = "gårdetsågårdet.png/1.1/-kb gårdetsågårdet.txt/1.1/" + check_entries \ + "Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" \ + "gårdetsågårdet.png/1.1/-kb|gårdetsågårdet.txt/1.1/" )' fi diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 72e49f5d3b..6f95305bf4 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -60,10 +60,10 @@ INPUT_END test_expect_success \ 'A: create pack from stdin' \ 'git-fast-import --export-marks=marks.out <input && - git-whatchanged master' + git whatchanged master' test_expect_success \ 'A: verify pack' \ - 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done' + 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' cat >expect <<EOF author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE @@ -73,7 +73,7 @@ initial EOF test_expect_success \ 'A: verify commit' \ - 'git-cat-file commit master | sed 1d >actual && + 'git cat-file commit master | sed 1d >actual && git diff expect actual' cat >expect <<EOF @@ -83,29 +83,29 @@ cat >expect <<EOF EOF test_expect_success \ 'A: verify tree' \ - 'git-cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual && + 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual && git diff expect actual' echo "$file2_data" >expect test_expect_success \ 'A: verify file2' \ - 'git-cat-file blob master:file2 >actual && git diff expect actual' + 'git cat-file blob master:file2 >actual && git diff expect actual' echo "$file3_data" >expect test_expect_success \ 'A: verify file3' \ - 'git-cat-file blob master:file3 >actual && git diff expect actual' + 'git cat-file blob master:file3 >actual && git diff expect actual' printf "$file4_data" >expect test_expect_success \ 'A: verify file4' \ - 'git-cat-file blob master:file4 >actual && git diff expect actual' + 'git cat-file blob master:file4 >actual && git diff expect actual' cat >expect <<EOF -:2 `git-rev-parse --verify master:file2` -:3 `git-rev-parse --verify master:file3` -:4 `git-rev-parse --verify master:file4` -:5 `git-rev-parse --verify master^0` +:2 `git rev-parse --verify master:file2` +:3 `git rev-parse --verify master:file3` +:4 `git rev-parse --verify master:file4` +:5 `git rev-parse --verify master^0` EOF test_expect_success \ 'A: verify marks output' \ @@ -134,19 +134,19 @@ INPUT_END test_expect_success \ 'A: verify marks import does not crash' \ 'git-fast-import --import-marks=marks.out <input && - git-whatchanged verify--import-marks' + git whatchanged verify--import-marks' test_expect_success \ 'A: verify pack' \ - 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done' + 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' cat >expect <<EOF :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2 EOF -git-diff-tree -M -r master verify--import-marks >actual +git diff-tree -M -r master verify--import-marks >actual test_expect_success \ 'A: verify diff' \ 'compare_diff_raw expect actual && - test `git-rev-parse --verify master:file2` \ - = `git-rev-parse --verify verify--import-marks:copy-of-file2`' + test `git rev-parse --verify master:file2` \ + = `git rev-parse --verify verify--import-marks:copy-of-file2`' ### ### series B @@ -175,7 +175,7 @@ rm -f .git/objects/pack_* .git/objects/index_* ### newf=`echo hi newf | git-hash-object -w --stdin` -oldf=`git-rev-parse --verify master:file2` +oldf=`git rev-parse --verify master:file2` test_tick cat >input <<INPUT_END commit refs/heads/branch @@ -193,17 +193,17 @@ INPUT_END test_expect_success \ 'C: incremental import create pack from stdin' \ 'git-fast-import <input && - git-whatchanged branch' + git whatchanged branch' test_expect_success \ 'C: verify pack' \ - 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done' + 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' test_expect_success \ 'C: validate reuse existing blob' \ - 'test $newf = `git-rev-parse --verify branch:file2/newf` - test $oldf = `git-rev-parse --verify branch:file2/oldf`' + 'test $newf = `git rev-parse --verify branch:file2/newf` + test $oldf = `git rev-parse --verify branch:file2/oldf`' cat >expect <<EOF -parent `git-rev-parse --verify master^0` +parent `git rev-parse --verify master^0` author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE @@ -211,7 +211,7 @@ second EOF test_expect_success \ 'C: verify commit' \ - 'git-cat-file commit branch | sed 1d >actual && + 'git cat-file commit branch | sed 1d >actual && git diff expect actual' cat >expect <<EOF @@ -219,7 +219,7 @@ cat >expect <<EOF :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3 EOF -git-diff-tree -M -r master branch >actual +git diff-tree -M -r master branch >actual test_expect_success \ 'C: validate rename result' \ 'compare_diff_raw expect actual' @@ -251,16 +251,16 @@ INPUT_END test_expect_success \ 'D: inline data in commit' \ 'git-fast-import <input && - git-whatchanged branch' + git whatchanged branch' test_expect_success \ 'D: verify pack' \ - 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done' + 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' cat >expect <<EOF :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting EOF -git-diff-tree -M -r branch^ branch >actual +git diff-tree -M -r branch^ branch >actual test_expect_success \ 'D: validate new files added' \ 'compare_diff_raw expect actual' @@ -268,13 +268,13 @@ test_expect_success \ echo "$file5_data" >expect test_expect_success \ 'D: verify file5' \ - 'git-cat-file blob branch:newdir/interesting >actual && + 'git cat-file blob branch:newdir/interesting >actual && git diff expect actual' echo "$file6_data" >expect test_expect_success \ 'D: verify file6' \ - 'git-cat-file blob branch:newdir/exec.sh >actual && + 'git cat-file blob branch:newdir/exec.sh >actual && git diff expect actual' ### @@ -300,7 +300,7 @@ test_expect_success \ 'git-fast-import --date-format=rfc2822 <input' test_expect_success \ 'E: verify pack' \ - 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done' + 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' cat >expect <<EOF author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500 @@ -310,14 +310,14 @@ RFC 2822 type date EOF test_expect_success \ 'E: verify commit' \ - 'git-cat-file commit branch | sed 1,2d >actual && + 'git cat-file commit branch | sed 1,2d >actual && git diff expect actual' ### ### series F ### -old_branch=`git-rev-parse --verify branch^0` +old_branch=`git rev-parse --verify branch^0` test_tick cat >input <<INPUT_END commit refs/heads/branch @@ -339,7 +339,7 @@ test_expect_success \ echo BAD gfi did not fail return 1 else - if test $old_branch = `git-rev-parse --verify branch^0` + if test $old_branch = `git rev-parse --verify branch^0` then : branch unaffected and failure returned return 0 @@ -351,11 +351,11 @@ test_expect_success \ ' test_expect_success \ 'F: verify pack' \ - 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done' + 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' cat >expect <<EOF -tree `git-rev-parse branch~1^{tree}` -parent `git-rev-parse branch~1` +tree `git rev-parse branch~1^{tree}` +parent `git rev-parse branch~1` author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE @@ -363,14 +363,14 @@ losing things already? EOF test_expect_success \ 'F: verify other commit' \ - 'git-cat-file commit other >actual && + 'git cat-file commit other >actual && git diff expect actual' ### ### series G ### -old_branch=`git-rev-parse --verify branch^0` +old_branch=`git rev-parse --verify branch^0` test_tick cat >input <<INPUT_END commit refs/heads/branch @@ -387,11 +387,11 @@ test_expect_success \ 'git-fast-import --force <input' test_expect_success \ 'G: verify pack' \ - 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done' + 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' test_expect_success \ 'G: branch changed, but logged' \ - 'test $old_branch != `git-rev-parse --verify branch^0` && - test $old_branch = `git-rev-parse --verify branch@{1}`' + 'test $old_branch != `git rev-parse --verify branch^0` && + test $old_branch = `git rev-parse --verify branch@{1}`' ### ### series H @@ -421,10 +421,10 @@ INPUT_END test_expect_success \ 'H: deletall, add 1' \ 'git-fast-import <input && - git-whatchanged H' + git whatchanged H' test_expect_success \ 'H: verify pack' \ - 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done' + 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' cat >expect <<EOF :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf @@ -433,7 +433,7 @@ cat >expect <<EOF :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh EOF -git-diff-tree -M -r H^ H >actual +git diff-tree -M -r H^ H >actual test_expect_success \ 'H: validate old files removed, new files added' \ 'compare_diff_raw expect actual' @@ -441,7 +441,7 @@ test_expect_success \ echo "$file5_data" >expect test_expect_success \ 'H: verify file' \ - 'git-cat-file blob H:h/e/l/lo >actual && + 'git cat-file blob H:h/e/l/lo >actual && git diff expect actual' ### @@ -463,7 +463,7 @@ test_expect_success \ 'git-fast-import --export-pack-edges=edges.list <input' cat >expect <<EOF -.git/objects/pack/pack-.pack: `git-rev-parse --verify export-boundary` +.git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary` EOF test_expect_success \ 'I: verify edge list' \ @@ -497,7 +497,7 @@ test_expect_success \ 'git-fast-import <input' test_expect_success \ 'J: branch has 1 commit, empty tree' \ - 'test 1 = `git-rev-list J | wc -l` && + 'test 1 = `git rev-list J | wc -l` && test 0 = `git ls-tree J | wc -l`' ### @@ -527,8 +527,8 @@ test_expect_success \ 'git-fast-import <input' test_expect_success \ 'K: verify K^1 = branch^1' \ - 'test `git-rev-parse --verify branch^1` \ - = `git-rev-parse --verify K^1`' + 'test `git rev-parse --verify branch^1` \ + = `git rev-parse --verify K^1`' ### ### series L @@ -577,7 +577,158 @@ EXPECT_END test_expect_success \ 'L: verify internal tree sorting' \ 'git-fast-import <input && - git-diff --raw L^ L >output && + git diff-tree --abbrev --raw L^ L >output && git diff expect output' +### +### series M +### + +test_tick +cat >input <<INPUT_END +commit refs/heads/M1 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +file rename +COMMIT + +from refs/heads/branch^0 +R file2/newf file2/n.e.w.f + +INPUT_END + +cat >expect <<EOF +:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f +EOF +test_expect_success \ + 'M: rename file in same subdirectory' \ + 'git-fast-import <input && + git diff-tree -M -r M1^ M1 >actual && + compare_diff_raw expect actual' + +cat >input <<INPUT_END +commit refs/heads/M2 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +file rename +COMMIT + +from refs/heads/branch^0 +R file2/newf i/am/new/to/you + +INPUT_END + +cat >expect <<EOF +:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you +EOF +test_expect_success \ + 'M: rename file to new subdirectory' \ + 'git-fast-import <input && + git diff-tree -M -r M2^ M2 >actual && + compare_diff_raw expect actual' + +cat >input <<INPUT_END +commit refs/heads/M3 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +file rename +COMMIT + +from refs/heads/M2^0 +R i other/sub + +INPUT_END + +cat >expect <<EOF +:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you +EOF +test_expect_success \ + 'M: rename subdirectory to new subdirectory' \ + 'git-fast-import <input && + git diff-tree -M -r M3^ M3 >actual && + compare_diff_raw expect actual' + +### +### series N +### + +test_tick +cat >input <<INPUT_END +commit refs/heads/N1 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +file copy +COMMIT + +from refs/heads/branch^0 +C file2/newf file2/n.e.w.f + +INPUT_END + +cat >expect <<EOF +:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f +EOF +test_expect_success \ + 'N: copy file in same subdirectory' \ + 'git-fast-import <input && + git diff-tree -C --find-copies-harder -r N1^ N1 >actual && + compare_diff_raw expect actual' + +cat >input <<INPUT_END +commit refs/heads/N2 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +clean directory copy +COMMIT + +from refs/heads/branch^0 +C file2 file3 + +commit refs/heads/N2 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +modify directory copy +COMMIT + +M 644 inline file3/file5 +data <<EOF +$file5_data +EOF + +INPUT_END + +cat >expect <<EOF +:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5 +:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf +:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf +EOF +test_expect_success \ + 'N: copy then modify subdirectory' \ + 'git-fast-import <input && + git diff-tree -C --find-copies-harder -r N2^^ N2 >actual && + compare_diff_raw expect actual' + +cat >input <<INPUT_END +commit refs/heads/N3 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +dirty directory copy +COMMIT + +from refs/heads/branch^0 +M 644 inline file2/file5 +data <<EOF +$file5_data +EOF + +C file2 file3 +D file2/file5 + +INPUT_END + +test_expect_success \ + 'N: copy dirty subdirectory' \ + 'git-fast-import <input && + test `git-rev-parse N2^{tree}` = `git-rev-parse N3^{tree}`' + test_done diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index d406a8824a..641303e0a1 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -38,7 +38,7 @@ echo >empty && git commit -q -m "First Commit" && git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && - GIT_DIR="$SERVERDIR" git config --bool gitcvs.logfile "$SERVERDIR/gitcvs.log" || + GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" || exit 1 # note that cvs doesn't accept absolute pathnames @@ -47,6 +47,217 @@ test_expect_success 'basic checkout' \ 'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master && test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"' +#------------------------ +# PSERVER AUTHENTICATION +#------------------------ + +cat >request-anonymous <<EOF +BEGIN AUTH REQUEST +$SERVERDIR +anonymous + +END AUTH REQUEST +EOF + +cat >request-git <<EOF +BEGIN AUTH REQUEST +$SERVERDIR +git + +END AUTH REQUEST +EOF + +cat >login-anonymous <<EOF +BEGIN VERIFICATION REQUEST +$SERVERDIR +anonymous + +END VERIFICATION REQUEST +EOF + +cat >login-git <<EOF +BEGIN VERIFICATION REQUEST +$SERVERDIR +git + +END VERIFICATION REQUEST +EOF + +test_expect_success 'pserver authentication' \ + 'cat request-anonymous | git-cvsserver pserver >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_success 'pserver authentication failure (non-anonymous user)' \ + 'if cat request-git | git-cvsserver pserver >log 2>&1 + then + false + else + true + fi && + tail -n1 log | grep -q "^I HATE YOU$"' + +test_expect_success 'pserver authentication (login)' \ + 'cat login-anonymous | git-cvsserver pserver >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_success 'pserver authentication failure (login/non-anonymous user)' \ + 'if cat login-git | git-cvsserver pserver >log 2>&1 + then + false + else + true + fi && + tail -n1 log | grep -q "^I HATE YOU$"' + + +# misuse pserver authentication for testing of req_Root + +cat >request-relative <<EOF +BEGIN AUTH REQUEST +gitcvs.git +anonymous + +END AUTH REQUEST +EOF + +cat >request-conflict <<EOF +BEGIN AUTH REQUEST +$SERVERDIR +anonymous + +END AUTH REQUEST +Root $WORKDIR +EOF + +test_expect_success 'req_Root failure (relative pathname)' \ + 'if cat request-relative | git-cvsserver pserver >log 2>&1 + then + echo unexpected success + false + else + true + fi && + tail log | grep -q "^error 1 Root must be an absolute pathname$"' + +test_expect_success 'req_Root failure (conflicting roots)' \ + 'cat request-conflict | git-cvsserver pserver >log 2>&1 && + tail log | grep -q "^error 1 Conflicting roots specified$"' + +test_expect_success 'req_Root (strict paths)' \ + 'cat request-anonymous | git-cvsserver --strict-paths pserver $SERVERDIR >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_failure 'req_Root failure (strict-paths)' \ + 'cat request-anonymous | git-cvsserver --strict-paths pserver $WORKDIR >log 2>&1' + +test_expect_success 'req_Root (w/o strict-paths)' \ + 'cat request-anonymous | git-cvsserver pserver $WORKDIR/ >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_failure 'req_Root failure (w/o strict-paths)' \ + 'cat request-anonymous | git-cvsserver pserver $WORKDIR/gitcvs >log 2>&1' + +cat >request-base <<EOF +BEGIN AUTH REQUEST +/gitcvs.git +anonymous + +END AUTH REQUEST +Root /gitcvs.git +EOF + +test_expect_success 'req_Root (base-path)' \ + 'cat request-base | git-cvsserver --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_failure 'req_Root failure (base-path)' \ + 'cat request-anonymous | git-cvsserver --strict-paths --base-path $WORKDIR pserver $SERVERDIR >log 2>&1' + +GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1 + +test_expect_success 'req_Root (export-all)' \ + 'cat request-anonymous | git-cvsserver --export-all pserver $WORKDIR >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_failure 'req_Root failure (export-all w/o whitelist)' \ + 'cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || + false' + +test_expect_success 'req_Root (everything together)' \ + 'cat request-base | git-cvsserver --export-all --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1 + +#-------------- +# CONFIG TESTS +#-------------- + +test_expect_success 'gitcvs.enabled = false' \ + 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && + if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 + then + echo unexpected cvs success + false + else + true + fi && + cat cvs.log | grep -q "GITCVS emulation disabled" && + test ! -d cvswork2' + +rm -fr cvswork2 +test_expect_success 'gitcvs.ext.enabled = true' \ + 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && + GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && + diff -q cvswork cvswork2' + +rm -fr cvswork2 +test_expect_success 'gitcvs.ext.enabled = false' \ + 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false && + GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && + if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 + then + echo unexpected cvs success + false + else + true + fi && + cat cvs.log | grep -q "GITCVS emulation disabled" && + test ! -d cvswork2' + +rm -fr cvswork2 +test_expect_success 'gitcvs.dbname' \ + 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && + GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && + diff -q cvswork cvswork2 && + test -f "$SERVERDIR/gitcvs.ext.master.sqlite" && + cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"' + +rm -fr cvswork2 +test_expect_success 'gitcvs.ext.dbname' \ + 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && + GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && + GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && + diff -q cvswork cvswork2 && + test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" && + test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" && + cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"' + + +#------------ +# CVS UPDATE +#------------ + +rm -fr "$SERVERDIR" +cd "$WORKDIR" && +git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && +GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && +GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" || +exit 1 + test_expect_success 'cvs update (create new file)' \ 'echo testfile1 >testfile1 && git add testfile1 && @@ -123,4 +334,75 @@ test_expect_success 'cvs update (re-add deleted file)' \ test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" && diff -q testfile1 ../testfile1' +cd "$WORKDIR" +test_expect_success 'cvs update (merge)' \ + 'echo Line 0 >expected && + for i in 1 2 3 4 5 6 7 + do + echo Line $i >>merge + echo Line $i >>expected + done && + echo Line 8 >>expected && + git add merge && + git commit -q -m "Merge test (pre-merge)" && + git push gitcvs.git >/dev/null && + cd cvswork && + GIT_CONFIG="$git_config" cvs -Q update && + test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" && + diff -q merge ../merge && + ( echo Line 0; cat merge ) >merge.tmp && + mv merge.tmp merge && + cd "$WORKDIR" && + echo Line 8 >>merge && + git add merge && + git commit -q -m "Merge test (merge)" && + git push gitcvs.git >/dev/null && + cd cvswork && + sleep 1 && touch merge && + GIT_CONFIG="$git_config" cvs -Q update && + diff -q merge ../expected' + +cd "$WORKDIR" + +cat >expected.C <<EOF +<<<<<<< merge.mine +Line 0 +======= +LINE 0 +>>>>>>> merge.3 +EOF + +for i in 1 2 3 4 5 6 7 8 +do + echo Line $i >>expected.C +done + +test_expect_success 'cvs update (conflict merge)' \ + '( echo LINE 0; cat merge ) >merge.tmp && + mv merge.tmp merge && + git add merge && + git commit -q -m "Merge test (conflict)" && + git push gitcvs.git >/dev/null && + cd cvswork && + GIT_CONFIG="$git_config" cvs -Q update && + diff -q merge ../expected.C' + +cd "$WORKDIR" +test_expect_success 'cvs update (-C)' \ + 'cd cvswork && + GIT_CONFIG="$git_config" cvs -Q update -C && + diff -q merge ../merge' + +cd "$WORKDIR" +test_expect_success 'cvs update (merge no-op)' \ + 'echo Line 9 >>merge && + cp merge cvswork/merge && + git add merge && + git commit -q -m "Merge test (no-op)" && + git push gitcvs.git >/dev/null && + cd cvswork && + sleep 1 && touch merge && + GIT_CONFIG="$git_config" cvs -Q update && + diff -q merge ../merge' + test_done diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh new file mode 100755 index 0000000000..fa32598b0c --- /dev/null +++ b/t/t9500-gitweb-standalone-no-errors.sh @@ -0,0 +1,552 @@ +#!/bin/sh +# +# Copyright (c) 2007 Jakub Narebski +# + +test_description='gitweb as standalone script (basic tests). + +This test runs gitweb (git web interface) as CGI script from +commandline, and checks that it would not write any errors +or warnings to log.' + +gitweb_init () { + cat >gitweb_config.perl <<EOF +#!/usr/bin/perl + +# gitweb configuration for tests + +our \$version = "current"; +our \$GIT = "git"; +our \$projectroot = "$(pwd)"; +our \$home_link_str = "projects"; +our \$site_name = "[localhost]"; +our \$site_header = ""; +our \$site_footer = ""; +our \$home_text = "indextext.html"; +our @stylesheets = ("file:///$(pwd)/../../gitweb/gitweb.css"); +our \$logo = "file:///$(pwd)/../../gitweb/git-logo.png"; +our \$favicon = "file:///$(pwd)/../../gitweb/git-favicon.png"; +our \$projects_list = ""; +our \$export_ok = ""; +our \$strict_export = ""; + +CGI::Carp::set_programname("gitweb/gitweb.cgi"); +EOF + + cat >.git/description <<EOF +$0 test repository +EOF +} + +gitweb_run () { + export GATEWAY_INTERFACE="CGI/1.1" + export HTTP_ACCEPT="*/*" + export REQUEST_METHOD="GET" + export QUERY_STRING=""$1"" + export PATH_INFO=""$2"" + + export GITWEB_CONFIG=$(pwd)/gitweb_config.perl + + # some of git commands write to STDERR on error, but this is not + # written to web server logs, so we are not interested in that: + # we are interested only in properly formatted errors/warnings + rm -f gitweb.log && + perl -- $(pwd)/../../gitweb/gitweb.perl \ + >/dev/null 2>gitweb.log && + if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi + + # gitweb.log is left for debugging +} + +. ./test-lib.sh + +perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || { + test_expect_success 'skipping gitweb tests, perl version is too old' : + test_done + exit +} + +gitweb_init + +# ---------------------------------------------------------------------- +# no commits (empty, just initialized repository) + +test_expect_success \ + 'no commits: projects_list (implicit)' \ + 'gitweb_run' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'no commits: projects_index' \ + 'gitweb_run "a=project_index"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'no commits: .git summary (implicit)' \ + 'gitweb_run "p=.git"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'no commits: .git commit (implicit HEAD)' \ + 'gitweb_run "p=.git;a=commit"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'no commits: .git commitdiff (implicit HEAD)' \ + 'gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'no commits: .git tree (implicit HEAD)' \ + 'gitweb_run "p=.git;a=tree"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'no commits: .git heads' \ + 'gitweb_run "p=.git;a=heads"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'no commits: .git tags' \ + 'gitweb_run "p=.git;a=tags"' +test_debug 'cat gitweb.log' + + +# ---------------------------------------------------------------------- +# initial commit + +test_expect_success \ + 'Make initial commit' \ + 'echo "Not an empty file." > file && + git add file && + git commit -a -m "Initial commit." && + git branch b' + +test_expect_success \ + 'projects_list (implicit)' \ + 'gitweb_run' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'projects_index' \ + 'gitweb_run "a=project_index"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git summary (implicit)' \ + 'gitweb_run "p=.git"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git commit (implicit HEAD)' \ + 'gitweb_run "p=.git;a=commit"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git commitdiff (implicit HEAD, root commit)' \ + 'gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git commitdiff_plain (implicit HEAD, root commit)' \ + 'gitweb_run "p=.git;a=commitdiff_plain"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git commit (HEAD)' \ + 'gitweb_run "p=.git;a=commit;h=HEAD"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git tree (implicit HEAD)' \ + 'gitweb_run "p=.git;a=tree"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git blob (file)' \ + 'gitweb_run "p=.git;a=blob;f=file"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git blob_plain (file)' \ + 'gitweb_run "p=.git;a=blob_plain;f=file"' +test_debug 'cat gitweb.log' + +# ---------------------------------------------------------------------- +# nonexistent objects + +test_expect_success \ + '.git commit (non-existent)' \ + 'gitweb_run "p=.git;a=commit;h=non-existent"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git commitdiff (non-existent)' \ + 'gitweb_run "p=.git;a=commitdiff;h=non-existent"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git commitdiff (non-existent vs HEAD)' \ + 'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git tree (0000000000000000000000000000000000000000)' \ + 'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git tag (0000000000000000000000000000000000000000)' \ + 'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git blob (non-existent)' \ + 'gitweb_run "p=.git;a=blob;f=non-existent"' +test_debug 'cat gitweb.log' + +test_expect_success \ + '.git blob_plain (non-existent)' \ + 'gitweb_run "p=.git;a=blob_plain;f=non-existent"' +test_debug 'cat gitweb.log' + + +# ---------------------------------------------------------------------- +# commitdiff testing (implicit, one implicit tree-ish) + +test_expect_success \ + 'commitdiff(0): root' \ + 'gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(0): file added' \ + 'echo "New file" > new_file && + git add new_file && + git commit -a -m "File added." && + gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(0): mode change' \ + 'chmod a+x new_file && + git commit -a -m "Mode changed." && + gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(0): file renamed' \ + 'git mv new_file renamed_file && + git commit -a -m "File renamed." && + gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(0): file to symlink' \ + 'rm renamed_file && + ln -s file renamed_file && + git commit -a -m "File to symlink." && + gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(0): file deleted' \ + 'git rm renamed_file && + rm -f renamed_file && + git commit -a -m "File removed." && + gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(0): file copied / new file' \ + 'cp file file2 && + git add file2 && + git commit -a -m "File copied." && + gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(0): mode change and modified' \ + 'echo "New line" >> file2 && + chmod a+x file2 && + git commit -a -m "Mode change and modification." && + gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(0): renamed and modified' \ + 'cat >file2<<EOF && +Dominus regit me, +et nihil mihi deerit. +In loco pascuae ibi me collocavit, +super aquam refectionis educavit me; +animam meam convertit, +deduxit me super semitas jusitiae, +propter nomen suum. +EOF + git commit -a -m "File added." && + git mv file2 file3 && + echo "Propter nomen suum." >> file3 && + git commit -a -m "File rename and modification." && + gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(0): renamed, mode change and modified' \ + 'git mv file3 file2 && + echo "Propter nomen suum." >> file2 && + chmod a+x file2 && + git commit -a -m "File rename, mode change and modification." && + gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +# ---------------------------------------------------------------------- +# commitdiff testing (taken from t4114-apply-typechange.sh) + +test_expect_success 'setup typechange commits' ' + echo "hello world" > foo && + echo "hi planet" > bar && + git update-index --add foo bar && + git commit -m initial && + git branch initial && + rm -f foo && + ln -s bar foo && + git update-index foo && + git commit -m "foo symlinked to bar" && + git branch foo-symlinked-to-bar && + rm -f foo && + echo "how far is the sun?" > foo && + git update-index foo && + git commit -m "foo back to file" && + git branch foo-back-to-file && + rm -f foo && + git update-index --remove foo && + mkdir foo && + echo "if only I knew" > foo/baz && + git update-index --add foo/baz && + git commit -m "foo becomes a directory" && + git branch "foo-becomes-a-directory" && + echo "hello world" > foo/baz && + git update-index foo/baz && + git commit -m "foo/baz is the original foo" && + git branch foo-baz-renamed-from-foo + ' + +test_expect_success \ + 'commitdiff(2): file renamed from foo to foo/baz' \ + 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(2): file renamed from foo/baz to foo' \ + 'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(2): directory becomes file' \ + 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(2): file becomes directory' \ + 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(2): file becomes symlink' \ + 'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(2): symlink becomes file' \ + 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(2): symlink becomes directory' \ + 'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(2): directory becomes symlink' \ + 'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"' +test_debug 'cat gitweb.log' + +# ---------------------------------------------------------------------- +# commit, commitdiff: merge, large +test_expect_success \ + 'Create a merge' \ + 'git checkout b && + echo "Branch" >> b && + git add b && + git commit -a -m "On branch" && + git checkout master && + git pull . b' + +test_expect_success \ + 'commit(0): merge commit' \ + 'gitweb_run "p=.git;a=commit"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(0): merge commit' \ + 'gitweb_run "p=.git;a=commitdiff"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'Prepare large commit' \ + 'git checkout b && + echo "To be changed" > 01-change && + echo "To be renamed" > 02-pure-rename-from && + echo "To be deleted" > 03-delete && + echo "To be renamed and changed" > 04-rename-from && + echo "To have mode changed" > 05-mode-change && + echo "File to symlink" > 06-file-or-symlink && + echo "To be changed and have mode changed" > 07-change-mode-change && + git add 0* && + git commit -a -m "Prepare large commit" && + echo "Changed" > 01-change && + git mv 02-pure-rename-from 02-pure-rename-to && + git rm 03-delete && rm -f 03-delete && + echo "A new file" > 03-new && + git add 03-new && + git mv 04-rename-from 04-rename-to && + echo "Changed" >> 04-rename-to && + chmod a+x 05-mode-change && + rm -f 06-file-or-symlink && ln -s 01-change 06-file-or-symlink && + echo "Changed and have mode changed" > 07-change-mode-change && + chmod a+x 07-change-mode-change && + git commit -a -m "Large commit" && + git checkout master' + +test_expect_success \ + 'commit(1): large commit' \ + 'gitweb_run "p=.git;a=commit;h=b"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'commitdiff(1): large commit' \ + 'gitweb_run "p=.git;a=commitdiff;h=b"' +test_debug 'cat gitweb.log' + +# ---------------------------------------------------------------------- +# tags testing + +test_expect_success \ + 'tags: list of different types of tags' \ + 'git checkout master && + git tag -a -m "Tag commit object" tag-commit HEAD && + git tag -a -m "" tag-commit-nomessage HEAD && + git tag -a -m "Tag tag object" tag-tag tag-commit && + git tag -a -m "Tag tree object" tag-tree HEAD^{tree} && + git tag -a -m "Tag blob object" tag-blob HEAD:file && + git tag lightweight/tag-commit HEAD && + git tag lightweight/tag-tag tag-commit && + git tag lightweight/tag-tree HEAD^{tree} && + git tag lightweight/tag-blob HEAD:file && + gitweb_run "p=.git;a=tags"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'tag: Tag to commit object' \ + 'gitweb_run "p=.git;a=tag;h=tag-commit"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'tag: on lightweight tag (invalid)' \ + 'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"' +test_debug 'cat gitweb.log' + +# ---------------------------------------------------------------------- +# logs + +test_expect_success \ + 'logs: log (implicit HEAD)' \ + 'gitweb_run "p=.git;a=log"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'logs: shortlog (implicit HEAD)' \ + 'gitweb_run "p=.git;a=shortlog"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'logs: history (implicit HEAD, file)' \ + 'gitweb_run "p=.git;a=history;f=file"' +test_debug 'cat gitweb.log' + +# ---------------------------------------------------------------------- +# feed generation + +test_expect_success \ + 'feeds: OPML' \ + 'gitweb_run "a=opml"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'feed: RSS' \ + 'gitweb_run "p=.git;a=rss"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'feed: Atom' \ + 'gitweb_run "p=.git;a=atom"' +test_debug 'cat gitweb.log' + +# ---------------------------------------------------------------------- +# encoding/decoding + +test_expect_success \ + 'encode(commit): utf8' \ + '. ../t3901-utf8.txt && + echo "UTF-8" >> file && + git add file && + git commit -F ../t3900/1-UTF-8.txt && + gitweb_run "p=.git;a=commit"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'encode(commit): iso-8859-1' \ + '. ../t3901-8859-1.txt && + echo "ISO-8859-1" >> file && + git add file && + git config i18n.commitencoding ISO-8859-1 && + git commit -F ../t3900/ISO-8859-1.txt && + git config --unset i18n.commitencoding && + gitweb_run "p=.git;a=commit"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'encode(log): utf-8 and iso-8859-1' \ + 'gitweb_run "p=.git;a=log"' +test_debug 'cat gitweb.log' + +# ---------------------------------------------------------------------- +# extra options + +test_expect_success \ + 'opt: log --no-merges' \ + 'gitweb_run "p=.git;a=log;opt=--no-merges"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'opt: atom --no-merges' \ + 'gitweb_run "p=.git;a=log;opt=--no-merges"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'opt: "file" history --no-merges' \ + 'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'opt: log --no-such-option (invalid option)' \ + 'gitweb_run "p=.git;a=log;opt=--no-such-option"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'opt: tree --no-merges (invalid option for action)' \ + 'gitweb_run "p=.git;a=tree;opt=--no-merges"' +test_debug 'cat gitweb.log' + +test_done diff --git a/t/test-lib.sh b/t/test-lib.sh index dee3ad7621..cc1253ccab 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -11,6 +11,7 @@ TZ=UTC export LANG LC_ALL PAGER TZ EDITOR=: VISUAL=: +unset GIT_EDITOR unset AUTHOR_DATE unset AUTHOR_EMAIL unset AUTHOR_NAME @@ -26,6 +27,7 @@ GIT_COMMITTER_EMAIL=committer@example.com GIT_COMMITTER_NAME='C O Mitter' unset GIT_DIFF_OPTS unset GIT_DIR +unset GIT_WORK_TREE unset GIT_EXTERNAL_DIFF unset GIT_INDEX_FILE unset GIT_OBJECT_DIRECTORY @@ -232,7 +234,7 @@ test_create_repo () { mv .git/hooks .git/hooks-disabled cd "$owd" } - + test_done () { trap - exit case "$test_failure" in |