diff options
Diffstat (limited to 't')
258 files changed, 8056 insertions, 927 deletions
diff --git a/t/.gitignore b/t/.gitignore index b27e280083..7dcbb232cd 100644 --- a/t/.gitignore +++ b/t/.gitignore @@ -1,2 +1,2 @@ -/trash directory +/trash directory* /test-results diff --git a/t/Makefile b/t/Makefile index 0d65cedaa6..9149373032 100644 --- a/t/Makefile +++ b/t/Makefile @@ -14,7 +14,8 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) TSVN = $(wildcard t91[0-9][0-9]-*.sh) -all: pre-clean $(T) aggregate-results clean +all: pre-clean + $(MAKE) aggregate-results-and-cleanup $(T): @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS) @@ -23,7 +24,11 @@ pre-clean: $(RM) -r test-results clean: - $(RM) -r 'trash directory' test-results + $(RM) -r 'trash directory'.* test-results + +aggregate-results-and-cleanup: $(T) + $(MAKE) aggregate-results + $(MAKE) clean aggregate-results: '$(SHELL_PATH_SQ)' ./aggregate-results.sh test-results/t*-* @@ -34,4 +39,3 @@ full-svn-test: $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8 .PHONY: pre-clean $(T) aggregate-results clean -.NOTPARALLEL: @@ -212,6 +212,24 @@ library for your script to use. is to summarize successes and failures in the test script and exit with an appropriate error code. + - test_tick + + Make commit and tag names consistent by setting the author and + committer times to defined stated. Subsequent calls will + advance the times by a fixed amount. + + - test_commit <message> [<filename> [<contents>]] + + Creates a commit with the given message, committing the given + file with the given contents (default for both is to reuse the + message string), and adds a tag (again reusing the message + string as name). Calls test_tick to make the SHA-1s + reproducible. + + - test_merge <message> <commit-or-tag> + + Merges the given rev using the given message. Like test_commit, + creates a tag and calls test_tick before committing. Tips for Writing Tests ---------------------- diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index 5b5f288809..67c431d4eb 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -1,8 +1,11 @@ . ./test-lib.sh +remotes_git_svn=remotes/git""-svn +git_svn_id=git""-svn-id + if test -n "$NO_SVN_TESTS" then - test_expect_success 'skipping git-svn tests, NO_SVN_TESTS defined' : + test_expect_success 'skipping git svn tests, NO_SVN_TESTS defined' : test_done exit fi @@ -14,7 +17,7 @@ SVN_TREE=$GIT_SVN_DIR/svn-tree svn >/dev/null 2>&1 if test $? -ne 1 then - test_expect_success 'skipping git-svn tests, svn not found' : + test_expect_success 'skipping git svn tests, svn not found' : test_done exit fi @@ -88,7 +91,7 @@ start_httpd () { mkdir "$GIT_DIR"/logs cat > "$GIT_DIR/httpd.conf" <<EOF -ServerName "git-svn test" +ServerName "git svn test" ServerRoot "$GIT_DIR" DocumentRoot "$GIT_DIR" PidFile "$GIT_DIR/httpd.pid" diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index dc473dfb53..86cdebc727 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -11,18 +11,32 @@ then exit fi -LIB_HTTPD_PATH=${LIB_HTTPD_PATH-'/usr/sbin/apache2'} +HTTPD_PARA="" + +case $(uname) in + Darwin) + DEFAULT_HTTPD_PATH='/usr/sbin/httpd' + DEFAULT_HTTPD_MODULE_PATH='/usr/libexec/apache2' + HTTPD_PARA="$HTTPD_PARA -DDarwin" + ;; + *) + DEFAULT_HTTPD_PATH='/usr/sbin/apache2' + DEFAULT_HTTPD_MODULE_PATH='/usr/lib/apache2/modules' + ;; +esac + +LIB_HTTPD_PATH=${LIB_HTTPD_PATH-"$DEFAULT_HTTPD_PATH"} LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'8111'} -TEST_PATH="$PWD"/../lib-httpd +TEST_PATH="$TEST_DIRECTORY"/lib-httpd HTTPD_ROOT_PATH="$PWD"/httpd HTTPD_DOCUMENT_ROOT_PATH=$HTTPD_ROOT_PATH/www if ! test -x "$LIB_HTTPD_PATH" then - say "skipping test, no web server found at '$LIB_HTTPD_PATH'" - test_done - exit + say "skipping test, no web server found at '$LIB_HTTPD_PATH'" + test_done + exit fi HTTPD_VERSION=`$LIB_HTTPD_PATH -v | \ @@ -39,14 +53,12 @@ then exit fi - LIB_HTTPD_MODULE_PATH='/usr/lib/apache2/modules' + LIB_HTTPD_MODULE_PATH="$DEFAULT_HTTPD_MODULE_PATH" fi else error "Could not identify web server at '$LIB_HTTPD_PATH'" fi -HTTPD_PARA="" - prepare_httpd() { mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH" @@ -84,7 +96,7 @@ prepare_httpd() { start_httpd() { prepare_httpd - trap 'stop_httpd; die' exit + trap 'stop_httpd; die' EXIT "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \ -f "$TEST_PATH/apache.conf" $HTTPD_PARA \ @@ -92,8 +104,8 @@ start_httpd() { } stop_httpd() { - trap 'die' exit + trap 'die' EXIT "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \ - -f "$TEST_PATH/apache.conf" -k stop + -f "$TEST_PATH/apache.conf" $HTTPD_PARA -k stop } diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf index 4717c2d33b..af6e5e1d6a 100644 --- a/t/lib-httpd/apache.conf +++ b/t/lib-httpd/apache.conf @@ -1,8 +1,16 @@ ServerName dummy PidFile httpd.pid DocumentRoot www +LogFormat "%h %l %u %t \"%r\" %>s %b" common +CustomLog access.log common ErrorLog error.log +<IfDefine Darwin> + LoadModule log_config_module modules/mod_log_config.so + LockFile accept.lock + PidFile httpd.pid +</IfDefine> + <IfDefine SSL> LoadModule ssl_module modules/mod_ssl.so diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh new file mode 100644 index 0000000000..260a231933 --- /dev/null +++ b/t/lib-rebase.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# After setting the fake editor with this function, you can +# +# - override the commit message with $FAKE_COMMIT_MESSAGE, +# - amend the commit message with $FAKE_COMMIT_AMEND +# - check that non-commit messages have a certain line count with $EXPECT_COUNT +# - rewrite a rebase -i script with $FAKE_LINES in the form +# +# "[<lineno1>] [<lineno2>]..." +# +# If a line number is prefixed with "squash" or "edit", the respective line's +# command will be replaced with the specified one. + +set_fake_editor () { + echo "#!$SHELL_PATH" >fake-editor.sh + cat >> fake-editor.sh <<\EOF +case "$1" in +*/COMMIT_EDITMSG) + test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1" + test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1" + exit + ;; +esac +test -z "$EXPECT_COUNT" || + test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) || + exit +test -z "$FAKE_LINES" && exit +grep -v '^#' < "$1" > "$1".tmp +rm -f "$1" +cat "$1".tmp +action=pick +for line in $FAKE_LINES; do + case $line in + squash|edit) + 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 + + test_set_editor "$(pwd)/fake-editor.sh" + chmod a+x fake-editor.sh +} diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh index 4db4ac44c9..cb144258cc 100755 --- a/t/t0002-gitfile.sh +++ b/t/t0002-gitfile.sh @@ -32,7 +32,7 @@ test_expect_success 'bad setup: invalid .git file format' ' echo "git rev-parse accepted an invalid .git file" false fi && - if ! grep -qe "Invalid gitfile format" .err + if ! grep "Invalid gitfile format" .err then echo "git rev-parse returned wrong error" false @@ -46,7 +46,7 @@ test_expect_success 'bad setup: invalid .git file path' ' echo "git rev-parse accepted an invalid .git file path" false fi && - if ! grep -qe "Not a git repository" .err + if ! grep "Not a git repository" .err then echo "git rev-parse returned wrong error" false diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index 3d8e06a20f..1c77192eb3 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -47,6 +47,23 @@ test_expect_success 'attribute test' ' ' +test_expect_success 'attribute test: read paths from stdin' ' + + cat <<EOF > expect +f: test: f +a/f: test: f +a/c/f: test: f +a/g: test: a/g +a/b/g: test: a/b/g +b/g: test: unspecified +a/b/h: test: a/b/h +a/b/d/g: test: a/b/d/* +EOF + + sed -e "s/:.*//" < expect | git check-attr --stdin test > actual && + test_cmp expect actual +' + test_expect_success 'root subdir attribute test' ' attr_check a/i a/i && diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh new file mode 100755 index 0000000000..09f855af3e --- /dev/null +++ b/t/t0005-signals.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +test_description='signals work as we expect' +. ./test-lib.sh + +cat >expect <<EOF +three +two +one +EOF + +test_expect_success 'sigchain works' ' + test-sigchain >actual + case "$?" in + 143) true ;; # POSIX w/ SIGTERM=15 + 3) true ;; # Windows + *) false ;; + esac && + test_cmp expect actual +' + +test_done diff --git a/t/t0022-crlf-rename.sh b/t/t0022-crlf-rename.sh index 7d1ce2d056..f1e1d48869 100755 --- a/t/t0022-crlf-rename.sh +++ b/t/t0022-crlf-rename.sh @@ -6,13 +6,13 @@ test_description='ignore CR in CRLF sequence while computing similiarity' test_expect_success setup ' - cat ../t0022-crlf-rename.sh >sample && + cat "$TEST_DIRECTORY"/t0022-crlf-rename.sh >sample && git add sample && test_tick && git commit -m Initial && - sed -e "s/\$/
/" ../t0022-crlf-rename.sh >elpmas && + sed -e "s/\$/
/" "$TEST_DIRECTORY"/t0022-crlf-rename.sh >elpmas && git add elpmas && rm -f sample && diff --git a/t/t0055-beyond-symlinks.sh b/t/t0055-beyond-symlinks.sh new file mode 100755 index 0000000000..b29c37a5a4 --- /dev/null +++ b/t/t0055-beyond-symlinks.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +test_description='update-index and add refuse to add beyond symlinks' + +. ./test-lib.sh + +test_expect_success setup ' + >a && + mkdir b && + ln -s b c && + >c/d && + git update-index --add a b/d +' + +test_expect_success 'update-index --add beyond symlinks' ' + test_must_fail git update-index --add c/d && + ! ( git ls-files | grep c/d ) +' + +test_expect_success 'add beyond symlinks' ' + test_must_fail git add c/d && + ! ( git ls-files | grep c/d ) +' + +test_done diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 6e7501f352..8336114f98 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -8,36 +8,37 @@ test_description='Test various path utilities' . ./test-lib.sh norm_abs() { - test_expect_success "normalize absolute" \ - "test \$(test-path-utils normalize_absolute_path '$1') = '$2'" + test_expect_success "normalize absolute: $1 => $2" \ + "test \"\$(test-path-utils normalize_path_copy '$1')\" = '$2'" } ancestor() { - test_expect_success "longest ancestor" \ - "test \$(test-path-utils longest_ancestor_length '$1' '$2') = '$3'" + test_expect_success "longest ancestor: $1 $2 => $3" \ + "test \"\$(test-path-utils longest_ancestor_length '$1' '$2')\" = '$3'" } -norm_abs "" / +norm_abs "" "" norm_abs / / norm_abs // / norm_abs /// / norm_abs /. / norm_abs /./ / -norm_abs /./.. / -norm_abs /../. / -norm_abs /./../.// / +norm_abs /./.. ++failed++ +norm_abs /../. ++failed++ +norm_abs /./../.// ++failed++ norm_abs /dir/.. / norm_abs /dir/sub/../.. / +norm_abs /dir/sub/../../.. ++failed++ norm_abs /dir /dir -norm_abs /dir// /dir +norm_abs /dir// /dir/ norm_abs /./dir /dir -norm_abs /dir/. /dir -norm_abs /dir///./ /dir -norm_abs /dir//sub/.. /dir -norm_abs /dir/sub/../ /dir -norm_abs //dir/sub/../. /dir -norm_abs /dir/s1/../s2/ /dir/s2 -norm_abs /d1/s1///s2/..//../s3/ /d1/s3 +norm_abs /dir/. /dir/ +norm_abs /dir///./ /dir/ +norm_abs /dir//sub/.. /dir/ +norm_abs /dir/sub/../ /dir/ +norm_abs //dir/sub/../. /dir/ +norm_abs /dir/s1/../s2/ /dir/s2/ +norm_abs /d1/s1///s2/..//../s3/ /d1/s3/ norm_abs /d1/s1//../s2/../../d2 /d2 norm_abs /d1/.../d2 /d1/.../d2 norm_abs /d1/..././../d2 /d1/d2 @@ -84,4 +85,8 @@ ancestor /foo/bar :://foo/.:: 4 ancestor /foo/bar //foo/./::/bar 4 ancestor /foo/bar ::/bar -1 +test_expect_success 'strip_path_suffix' ' + test c:/msysgit = $(test-path-utils strip_path_suffix \ + c:/msysgit/libexec//git-core libexec/git-core) +' test_done diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh new file mode 100755 index 0000000000..680d7d6861 --- /dev/null +++ b/t/t0070-fundamental.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +test_description='check that the most basic functions work + + +Verify wrappers and compatibility functions. +' + +. ./test-lib.sh + +test_expect_success 'character classes (isspace, isalpha etc.)' ' + test-ctype +' + +test_done diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh new file mode 100755 index 0000000000..315b9b3f10 --- /dev/null +++ b/t/t0100-previous.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +test_description='previous branch syntax @{-n}' + +. ./test-lib.sh + +test_expect_success 'branch -d @{-1}' ' + test_commit A && + git checkout -b junk && + git checkout - && + test "$(git symbolic-ref HEAD)" = refs/heads/master && + git branch -d @{-1} && + test_must_fail git rev-parse --verify refs/heads/junk +' + +test_expect_success 'branch -d @{-12} when there is not enough switches yet' ' + git reflog expire --expire=now && + git checkout -b junk2 && + git checkout - && + test "$(git symbolic-ref HEAD)" = refs/heads/master && + test_must_fail git branch -d @{-12} && + git rev-parse --verify refs/heads/master +' + +test_expect_success 'merge @{-1}' ' + git checkout A && + test_commit B && + git checkout A && + test_commit C && + git branch -f master B && + git branch -f other && + git checkout other && + git checkout master && + git merge @{-1} && + git cat-file commit HEAD | grep "Merge branch '\''other'\''" +' + +test_expect_success 'merge @{-1} when there is not enough switches yet' ' + git reflog expire --expire=now && + git checkout -f master && + git reset --hard B && + git branch -f other C && + git checkout other && + git checkout master && + test_must_fail git merge @{-12} +' + +test_done + diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh index 807fb83af8..22ba7a5442 100755 --- a/t/t1000-read-tree-m-3way.sh +++ b/t/t1000-read-tree-m-3way.sh @@ -72,7 +72,7 @@ In addition: ' . ./test-lib.sh -. ../lib-read-tree-m-3way.sh +. "$TEST_DIRECTORY"/lib-read-tree-m-3way.sh ################################################################ # Trivial "majority when 3 stages exist" merge plus #2ALT, #3ALT diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh index 4b44e131b2..271bc4e17f 100755 --- a/t/t1001-read-tree-m-2way.sh +++ b/t/t1001-read-tree-m-2way.sh @@ -341,4 +341,55 @@ test_expect_success \ check_cache_at DF/DF dirty && :' +test_expect_success \ + 'a/b (untracked) vs a case setup.' \ + 'rm -f .git/index && + : >a && + git update-index --add a && + treeM=`git write-tree` && + echo treeM $treeM && + git ls-tree $treeM && + git ls-files --stage >treeM.out && + + rm -f a && + git update-index --remove a && + mkdir a && + : >a/b && + treeH=`git write-tree` && + echo treeH $treeH && + git ls-tree $treeH' + +test_expect_success \ + 'a/b (untracked) vs a, plus c/d case test.' \ + '! git read-tree -u -m "$treeH" "$treeM" && + git ls-files --stage && + test -f a/b' + +test_expect_success \ + 'a/b vs a, plus c/d case setup.' \ + 'rm -f .git/index && + rm -fr a && + : >a && + mkdir c && + : >c/d && + git update-index --add a c/d && + treeM=`git write-tree` && + echo treeM $treeM && + git ls-tree $treeM && + git ls-files --stage >treeM.out && + + rm -f a && + mkdir a + : >a/b && + git update-index --add --remove a a/b && + treeH=`git write-tree` && + echo treeH $treeH && + git ls-tree $treeH' + +test_expect_success \ + 'a/b vs a, plus c/d case test.' \ + 'git read-tree -u -m "$treeH" "$treeM" && + git ls-files --stage | tee >treeMcheck.out && + test_cmp treeM.out treeMcheck.out' + test_done diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh index 076b08292d..fd98e445bf 100755 --- a/t/t1007-hash-object.sh +++ b/t/t1007-hash-object.sh @@ -49,16 +49,28 @@ setup_repo # Argument checking test_expect_success "multiple '--stdin's are rejected" ' - test_must_fail git hash-object --stdin --stdin < example + echo example | test_must_fail git hash-object --stdin --stdin ' test_expect_success "Can't use --stdin and --stdin-paths together" ' - test_must_fail git hash-object --stdin --stdin-paths && - test_must_fail git hash-object --stdin-paths --stdin + echo example | test_must_fail git hash-object --stdin --stdin-paths && + echo example | test_must_fail git hash-object --stdin-paths --stdin ' test_expect_success "Can't pass filenames as arguments with --stdin-paths" ' - test_must_fail git hash-object --stdin-paths hello < example + echo example | test_must_fail git hash-object --stdin-paths hello +' + +test_expect_success "Can't use --path with --stdin-paths" ' + echo example | test_must_fail git hash-object --stdin-paths --path=foo +' + +test_expect_success "Can't use --stdin-paths with --no-filters" ' + echo example | test_must_fail git hash-object --stdin-paths --no-filters +' + +test_expect_success "Can't use --path with --no-filters" ' + test_must_fail git hash-object --no-filters --path=foo ' # Behavior @@ -93,6 +105,42 @@ test_expect_success 'git hash-object --stdin file1 <file0 first operates on file test "$obname1" = "$obname1new" ' +test_expect_success 'check that appropriate filter is invoke when --path is used' ' + echo fooQ | tr Q "\\015" >file0 && + cp file0 file1 && + echo "file0 -crlf" >.gitattributes && + echo "file1 crlf" >>.gitattributes && + git config core.autocrlf true && + file0_sha=$(git hash-object file0) && + file1_sha=$(git hash-object file1) && + test "$file0_sha" != "$file1_sha" && + path1_sha=$(git hash-object --path=file1 file0) && + path0_sha=$(git hash-object --path=file0 file1) && + test "$file0_sha" = "$path0_sha" && + test "$file1_sha" = "$path1_sha" && + path1_sha=$(cat file0 | git hash-object --path=file1 --stdin) && + path0_sha=$(cat file1 | git hash-object --path=file0 --stdin) && + test "$file0_sha" = "$path0_sha" && + test "$file1_sha" = "$path1_sha" && + git config --unset core.autocrlf +' + +test_expect_success 'check that --no-filters option works' ' + echo fooQ | tr Q "\\015" >file0 && + cp file0 file1 && + echo "file0 -crlf" >.gitattributes && + echo "file1 crlf" >>.gitattributes && + git config core.autocrlf true && + file0_sha=$(git hash-object file0) && + file1_sha=$(git hash-object file1) && + test "$file0_sha" != "$file1_sha" && + nofilters_file1=$(git hash-object --no-filters file1) && + test "$file0_sha" = "$nofilters_file1" && + nofilters_file1=$(cat file1 | git hash-object --stdin) && + test "$file0_sha" = "$nofilters_file1" && + git config --unset core.autocrlf +' + pop_repo for args in "-w --stdin" "--stdin -w"; do diff --git a/t/t1008-read-tree-overlay.sh b/t/t1008-read-tree-overlay.sh new file mode 100755 index 0000000000..f9e00285db --- /dev/null +++ b/t/t1008-read-tree-overlay.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +test_description='test multi-tree read-tree without merging' + +. ./test-lib.sh + +test_expect_success setup ' + echo one >a && + git add a && + git commit -m initial && + git tag initial && + echo two >b && + git add b && + git commit -m second && + git checkout -b side initial && + echo three >a && + mkdir b && + echo four >b/c && + git add b/c && + git commit -m third +' + +test_expect_success 'multi-read' ' + git read-tree initial master side && + (echo a; echo b/c) >expect && + git ls-files >actual && + test_cmp expect actual +' + +test_done + diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 11b82f43dd..3c06842d99 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -336,10 +336,10 @@ test_expect_success 'get bool variable with empty value' \ 'git config --bool emptyvalue.variable > output && cmp output expect' -git config > output 2>&1 - -test_expect_success 'no arguments, but no crash' \ - "test $? = 129 && grep usage output" +test_expect_success 'no arguments, but no crash' ' + test_must_fail git config >output 2>&1 && + grep usage output +' cat > .git/config << EOF [a.b] @@ -373,7 +373,7 @@ 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' + 'test_must_fail git config --file non-existing-config -l' cat > other-config << EOF [ein] diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh new file mode 100755 index 0000000000..7fa5f5b22a --- /dev/null +++ b/t/t1401-symbolic-ref.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +test_description='basic symbolic-ref tests' +. ./test-lib.sh + +# If the tests munging HEAD fail, they can break detection of +# the git repo, meaning that further tests will operate on +# the surrounding git repo instead of the trash directory. +reset_to_sane() { + echo ref: refs/heads/foo >.git/HEAD +} + +test_expect_success 'symbolic-ref writes HEAD' ' + git symbolic-ref HEAD refs/heads/foo && + echo ref: refs/heads/foo >expect && + test_cmp expect .git/HEAD +' + +test_expect_success 'symbolic-ref reads HEAD' ' + echo refs/heads/foo >expect && + git symbolic-ref HEAD >actual && + test_cmp expect actual +' + +test_expect_success 'symbolic-ref refuses non-ref for HEAD' ' + test_must_fail git symbolic-ref HEAD foo +' +reset_to_sane + +test_expect_success 'symbolic-ref refuses bare sha1' ' + echo content >file && git add file && git commit -m one + test_must_fail git symbolic-ref HEAD `git rev-parse HEAD` +' +reset_to_sane + +test_done diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh new file mode 100755 index 0000000000..4597af0eb6 --- /dev/null +++ b/t/t1450-fsck.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +test_description='git fsck random collection of tests' + +. ./test-lib.sh + +test_expect_success setup ' + test_commit A fileA one && + git checkout HEAD^0 && + test_commit B fileB two && + git tag -d A B && + git reflog expire --expire=now --all +' + +test_expect_success 'HEAD is part of refs' ' + test 0 = $(git fsck | wc -l) +' + +test_expect_success 'loose objects borrowed from alternate are not missing' ' + mkdir another && + ( + cd another && + git init && + echo ../../../.git/objects >.git/objects/info/alternates && + test_commit C fileC one && + git fsck >out && + ! grep "missing blob" out + ) +' + +test_done diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 85da4caa7e..48ee07779d 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -26,21 +26,28 @@ test_rev_parse() { "test '$1' = \"\$(git rev-parse --show-prefix)\"" shift [ $# -eq 0 ] && return + + test_expect_success "$name: git-dir" \ + "test '$1' = \"\$(git rev-parse --git-dir)\"" + shift + [ $# -eq 0 ] && return } -# label is-bare is-inside-git is-inside-work prefix +# label is-bare is-inside-git is-inside-work prefix git-dir + +ROOT=$(pwd) -test_rev_parse toplevel false false true '' +test_rev_parse toplevel false false true '' .git cd .git || exit 1 -test_rev_parse .git/ false true false '' +test_rev_parse .git/ false true false '' . cd objects || exit 1 -test_rev_parse .git/objects/ false true false '' +test_rev_parse .git/objects/ false true false '' "$ROOT/.git" cd ../.. || exit 1 mkdir -p sub/dir || exit 1 cd sub/dir || exit 1 -test_rev_parse subdirectory false false true sub/dir/ +test_rev_parse subdirectory false false true sub/dir/ "$ROOT/.git" cd ../.. || exit 1 git config core.bare true diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index c039ee3fd8..f6a6f839a1 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -171,7 +171,7 @@ test_expect_success 'git diff' ' test_expect_success 'git grep' ' (cd repo.git/work/sub && - GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep -q dir/tracked) + GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep dir/tracked) ' test_done diff --git a/t/t1504-ceiling-dirs.sh b/t/t1504-ceiling-dirs.sh index 91b704a3a4..e377d48902 100755 --- a/t/t1504-ceiling-dirs.sh +++ b/t/t1504-ceiling-dirs.sh @@ -93,13 +93,13 @@ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi" test_prefix subdir_ceil_at_subdi_slash "sub/dir/" -GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub" +GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub" test_fail second_of_two -GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:bar" +GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar" test_fail first_of_two -GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar" +GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar" test_fail second_of_three diff --git a/t/t1505-rev-parse-last.sh b/t/t1505-rev-parse-last.sh new file mode 100755 index 0000000000..d709ecf8df --- /dev/null +++ b/t/t1505-rev-parse-last.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +test_description='test @{-N} syntax' + +. ./test-lib.sh + + +make_commit () { + echo "$1" > "$1" && + git add "$1" && + git commit -m "$1" +} + + +test_expect_success 'setup' ' + + make_commit 1 && + git branch side && + make_commit 2 && + make_commit 3 && + git checkout side && + make_commit 4 && + git merge master && + git checkout master + +' + +# 1 -- 2 -- 3 master +# \ \ +# \ \ +# --- 4 --- 5 side +# +# and 'side' should be the last branch + +test_rev_equivalent () { + + git rev-parse "$1" > expect && + git rev-parse "$2" > output && + test_cmp expect output + +} + +test_expect_success '@{-1} works' ' + test_rev_equivalent side @{-1} +' + +test_expect_success '@{-1}~2 works' ' + test_rev_equivalent side~2 @{-1}~2 +' + +test_expect_success '@{-1}^2 works' ' + test_rev_equivalent side^2 @{-1}^2 +' + +test_expect_success '@{-1}@{1} works' ' + test_rev_equivalent side@{1} @{-1}@{1} +' + +test_expect_success '@{-2} works' ' + test_rev_equivalent master @{-2} +' + +test_expect_success '@{-3} fails' ' + test_must_fail git rev-parse @{-3} +' + +test_done + + diff --git a/t/t2005-checkout-index-symlinks.sh b/t/t2005-checkout-index-symlinks.sh index ed12c4d782..9fa5610474 100755 --- a/t/t2005-checkout-index-symlinks.sh +++ b/t/t2005-checkout-index-symlinks.sh @@ -13,7 +13,7 @@ file if core.symlinks is false.' test_expect_success \ 'preparation' ' git config core.symlinks false && -l=$(echo -n file | git hash-object -t blob -w --stdin) && +l=$(printf file | git hash-object -t blob -w --stdin) && echo "120000 $l symlink" | git update-index --index-info' test_expect_success \ diff --git a/t/t2011-checkout-invalid-head.sh b/t/t2011-checkout-invalid-head.sh index 764bb0a6bc..15ebdc26eb 100755 --- a/t/t2011-checkout-invalid-head.sh +++ b/t/t2011-checkout-invalid-head.sh @@ -10,6 +10,10 @@ test_expect_success 'setup' ' git commit -m initial ' +test_expect_success 'checkout should not start branch from a tree' ' + test_must_fail git checkout -b newbranch master^{tree} +' + test_expect_success 'checkout master from invalid HEAD' ' echo 0000000000000000000000000000000000000000 >.git/HEAD && git checkout master -- diff --git a/t/t2012-checkout-last.sh b/t/t2012-checkout-last.sh new file mode 100755 index 0000000000..87b30a268c --- /dev/null +++ b/t/t2012-checkout-last.sh @@ -0,0 +1,94 @@ +#!/bin/sh + +test_description='checkout can switch to last branch' + +. ./test-lib.sh + +test_expect_success 'setup' ' + echo hello >world && + git add world && + git commit -m initial && + git branch other && + echo "hello again" >>world && + git add world && + git commit -m second +' + +test_expect_success '"checkout -" does not work initially' ' + test_must_fail git checkout - +' + +test_expect_success 'first branch switch' ' + git checkout other +' + +test_expect_success '"checkout -" switches back' ' + git checkout - && + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" +' + +test_expect_success '"checkout -" switches forth' ' + git checkout - && + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/other" +' + +test_expect_success 'detach HEAD' ' + git checkout $(git rev-parse HEAD) +' + +test_expect_success '"checkout -" attaches again' ' + git checkout - && + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/other" +' + +test_expect_success '"checkout -" detaches again' ' + git checkout - && + test "z$(git rev-parse HEAD)" = "z$(git rev-parse other)" && + test_must_fail git symbolic-ref HEAD +' + +test_expect_success 'more switches' ' + for i in 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 + do + git checkout -b branch$i + done +' + +more_switches () { + for i in 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 + do + git checkout branch$i + done +} + +test_expect_success 'switch to the last' ' + more_switches && + git checkout @{-1} && + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/branch2" +' + +test_expect_success 'switch to second from the last' ' + more_switches && + git checkout @{-2} && + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/branch3" +' + +test_expect_success 'switch to third from the last' ' + more_switches && + git checkout @{-3} && + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/branch4" +' + +test_expect_success 'switch to fourth from the last' ' + more_switches && + git checkout @{-4} && + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/branch5" +' + +test_expect_success 'switch to twelfth from the last' ' + more_switches && + git checkout @{-12} && + test "z$(git symbolic-ref HEAD)" = "zrefs/heads/branch13" +' + +test_done diff --git a/t/t2102-update-index-symlinks.sh b/t/t2102-update-index-symlinks.sh index f195aefe3a..1ed44ee503 100755 --- a/t/t2102-update-index-symlinks.sh +++ b/t/t2102-update-index-symlinks.sh @@ -13,12 +13,12 @@ even if a plain file is in the working tree if core.symlinks is false.' test_expect_success \ 'preparation' ' git config core.symlinks false && -l=$(echo -n file | git hash-object -t blob -w --stdin) && +l=$(printf file | git hash-object -t blob -w --stdin) && echo "120000 $l symlink" | git update-index --index-info' test_expect_success \ 'modify the symbolic link' ' -echo -n new-file > symlink && +printf new-file > symlink && git update-index symlink' test_expect_success \ diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index cd9231cf61..b2ddf5ace3 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -12,7 +12,7 @@ and issues a git add -u with path limiting on "dir" to add only the updates to dir/sub. Also tested are "git add -u" without limiting, and "git add -u" -without contents changes.' +without contents changes, and other conditions' . ./test-lib.sh @@ -128,4 +128,52 @@ test_expect_success 'add -n -u should not add but just report' ' ' +test_expect_success 'add -u resolves unmerged paths' ' + git reset --hard && + one=$(echo 1 | git hash-object -w --stdin) && + two=$(echo 2 | git hash-object -w --stdin) && + three=$(echo 3 | git hash-object -w --stdin) && + { + for path in path1 path2 + do + echo "100644 $one 1 $path" + echo "100644 $two 2 $path" + echo "100644 $three 3 $path" + done + echo "100644 $one 1 path3" + echo "100644 $one 1 path4" + echo "100644 $one 3 path5" + echo "100644 $one 3 path6" + } | + git update-index --index-info && + echo 3 >path1 && + echo 2 >path3 && + echo 2 >path5 && + git add -u && + git ls-files -s "path?" >actual && + { + echo "100644 $three 0 path1" + echo "100644 $one 1 path3" + echo "100644 $one 1 path4" + echo "100644 $one 3 path5" + echo "100644 $one 3 path6" + } >expect && + test_cmp expect actual && + + # Bonus tests. Explicit resolving + git add path3 path5 && + test_must_fail git add path4 && + test_must_fail git add path6 && + git rm path4 && + git rm path6 && + + git ls-files -s "path?" >actual && + { + echo "100644 $three 0 path1" + echo "100644 $two 0 path3" + echo "100644 $two 0 path5" + } >expect + +' + test_done diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh new file mode 100755 index 0000000000..58a329961e --- /dev/null +++ b/t/t2203-add-intent.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +test_description='Intent to add' + +. ./test-lib.sh + +test_expect_success 'intent to add' ' + echo hello >file && + echo hello >elif && + git add -N file && + git add elif +' + +test_expect_success 'check result of "add -N"' ' + git ls-files -s file >actual && + empty=$(git hash-object --stdin </dev/null) && + echo "100644 $empty 0 file" >expect && + test_cmp expect actual +' + +test_expect_success 'intent to add is just an ordinary empty blob' ' + git add -u && + git ls-files -s file >actual && + git ls-files -s elif | sed -e "s/elif/file/" >expect && + test_cmp expect actual +' + +test_expect_success 'intent to add does not clobber existing paths' ' + git add -N file elif && + empty=$(git hash-object --stdin </dev/null) && + git ls-files -s >actual && + ! grep "$empty" actual +' + +test_expect_success 'cannot commit with i-t-a entry' ' + test_tick && + git commit -a -m initial && + git reset --hard && + + echo xyzzy >rezrov && + echo frotz >nitfol && + git add rezrov && + git add -N nitfol && + test_must_fail git commit +' + +test_expect_success 'can commit with an unrelated i-t-a entry in index' ' + git reset --hard && + echo xyzzy >rezrov && + echo frotz >nitfol && + git add rezrov && + git add -N nitfol && + git commit -m partial rezrov +' + +test_expect_success 'can "commit -a" with an i-t-a entry' ' + git reset --hard && + : >nitfol && + git add -N nitfol && + git commit -a -m all +' + +test_done + diff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh new file mode 100755 index 0000000000..293dc353b1 --- /dev/null +++ b/t/t2300-cd-to-toplevel.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +test_description='cd_to_toplevel' + +. ./test-lib.sh + +test_cd_to_toplevel () { + test_expect_success "$2" ' + ( + cd '"'$1'"' && + . git-sh-setup && + cd_to_toplevel && + [ "$(pwd -P)" = "$TOPLEVEL" ] + ) + ' +} + +TOPLEVEL="$(pwd -P)/repo" +mkdir -p repo/sub/dir +mv .git repo/ +SUBDIRECTORY_OK=1 + +test_cd_to_toplevel repo 'at physical root' + +test_cd_to_toplevel repo/sub/dir 'at physical subdir' + +ln -s repo symrepo +test_cd_to_toplevel symrepo 'at symbolic root' + +ln -s repo/sub/dir subdir-link +test_cd_to_toplevel subdir-link 'at symbolic subdir' + +cd repo +ln -s sub/dir internal-link +test_cd_to_toplevel internal-link 'at internal symbolic subdir' + +test_done diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 8666946b02..c65bca8388 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -19,6 +19,9 @@ do >$dir/a.$i done done +>"#ignore1" +>"#ignore2" +>"#hidden" cat >expect <<EOF a.2 @@ -42,6 +45,9 @@ three/a.8 EOF echo '.gitignore +\#ignore1 +\#ignore2* +\#hid*n output expect .gitignore @@ -79,9 +85,10 @@ test_expect_success \ >output && test_cmp expect output' -cat > excludes-file << EOF +cat > excludes-file <<\EOF *.[1-8] e* +\#* EOF git config core.excludesFile excludes-file @@ -140,4 +147,10 @@ test_expect_success 'trailing slash in exclude forces directory match (2)' ' ' +test_expect_success 'negated exclude matches can override previous ones' ' + + git ls-files --others --exclude="a.*" --exclude="!a.1" >output && + grep "^a.1" output +' + test_done diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 25e9971fd8..1b1e9ece57 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -194,7 +194,8 @@ test_expect_success 'test deleting branch deletes branch config' \ test_expect_success 'test deleting branch without config' \ 'git branch my7 s && - test "$(git branch -d my7 2>&1)" = "Deleted branch my7."' + sha1=$(git rev-parse my7 | cut -c 1-7) && + test "$(git branch -d my7 2>&1)" = "Deleted branch my7 (was $sha1)."' test_expect_success 'test --track without .fetch entries' \ 'git branch --track my8 && diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index b7a670ef40..be7ae5a004 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -14,7 +14,8 @@ export GIT_AUTHOR_EMAIL test_expect_success \ 'prepare repository with topic branches' \ - 'echo First > A && + 'git config core.logAllRefUpdates true && + echo First > A && git update-index --add A && git commit -m "Add A." && git checkout -b my-topic-branch && @@ -47,6 +48,10 @@ test_expect_success \ 'the rebase operation should not have destroyed author information' \ '! (git log | grep "Author:" | grep "<>")' +test_expect_success 'HEAD was detached during rebase' ' + test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1}) +' + test_expect_success 'rebase after merge master' ' git reset --hard topic && git merge master && @@ -84,4 +89,10 @@ test_expect_success 'rebase a single mode change' ' GIT_TRACE=1 git rebase master ' +test_expect_success 'Show verbose error when HEAD could not be detached' ' + : > B && + test_must_fail git rebase topic 2> output.err > output.out && + grep "Untracked working tree file .B. would be overwritten" output.err +' + test_done diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 7d10a27f1d..603b003edf 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -10,6 +10,10 @@ that the result still makes sense. ' . ./test-lib.sh +. ../lib-rebase.sh + +set_fake_editor + # set up two branches like this: # # A - B - C - D - E @@ -61,39 +65,6 @@ test_expect_success 'setup' ' git tag I ' -echo "#!$SHELL_PATH" >fake-editor.sh -cat >> fake-editor.sh <<\EOF -case "$1" in -*/COMMIT_EDITMSG) - test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1" - test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1" - exit - ;; -esac -test -z "$EXPECT_COUNT" || - test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) || - exit -test -z "$FAKE_LINES" && exit -grep -v '^#' < "$1" > "$1".tmp -rm -f "$1" -cat "$1".tmp -action=pick -for line in $FAKE_LINES; do - case $line in - squash|edit) - 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 - -test_set_editor "$(pwd)/fake-editor.sh" -chmod a+x fake-editor.sh - test_expect_success 'no changes are a nop' ' git rebase -i F && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" && @@ -373,6 +344,38 @@ test_expect_success '--continue tries to commit, even for "edit"' ' test $parent = $(git rev-parse HEAD^) ' +test_expect_success 'aborted --continue does not squash commits after "edit"' ' + old=$(git rev-parse HEAD) && + test_tick && + FAKE_LINES="edit 1" git rebase -i HEAD^ && + echo "edited again" > file7 && + git add file7 && + ( + FAKE_COMMIT_MESSAGE=" " && + export FAKE_COMMIT_MESSAGE && + test_must_fail git rebase --continue + ) && + test $old = $(git rev-parse HEAD) && + git rebase --abort +' + +test_expect_success 'auto-amend only edited commits after "edit"' ' + test_tick && + FAKE_LINES="edit 1" git rebase -i HEAD^ && + echo "edited again" > file7 && + git add file7 && + FAKE_COMMIT_MESSAGE="edited file7 again" git commit && + echo "and again" > file7 && + git add file7 && + test_tick && + ( + FAKE_COMMIT_MESSAGE="and again" && + export FAKE_COMMIT_MESSAGE && + test_must_fail git rebase --continue + ) && + git rebase --abort +' + test_expect_success 'rebase a detached HEAD' ' grandparent=$(git rev-parse HEAD~2) && git checkout $(git rev-parse HEAD) && @@ -430,4 +433,30 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' ' ' +test_expect_success 'submodule rebase setup' ' + git checkout A && + mkdir sub && + ( + cd sub && git init && >elif && + git add elif && git commit -m "submodule initial" + ) && + echo 1 >file1 && + git add file1 sub + test_tick && + git commit -m "One" && + echo 2 >file1 && + test_tick && + git commit -a -m "Two" && + ( + cd sub && echo 3 >elif && + git commit -a -m "submodule second" + ) && + test_tick && + git commit -a -m "Three changes submodule" +' + +test_expect_success 'submodule rebase -i' ' + FAKE_LINES="1 squash 2 3" git rebase -i A +' + test_done diff --git a/t/t3409-rebase-hook.sh b/t/t3409-rebase-hook.sh index bc93dda8fd..098b75507b 100755 --- a/t/t3409-rebase-hook.sh +++ b/t/t3409-rebase-hook.sh @@ -118,9 +118,29 @@ test_expect_success 'pre-rebase hook stops rebase (1)' ' test_expect_success 'pre-rebase hook stops rebase (2)' ' git checkout test && git reset --hard side && - EDITOR=true test_must_fail git rebase -i master && + ( + EDITOR=: + export EDITOR + test_must_fail git rebase -i master + ) && test "z$(git symbolic-ref HEAD)" = zrefs/heads/test && test 0 = $(git rev-list HEAD...side | wc -l) ' +test_expect_success 'rebase --no-verify overrides pre-rebase (1)' ' + git checkout test && + git reset --hard side && + git rebase --no-verify master && + test "z$(git symbolic-ref HEAD)" = zrefs/heads/test && + test "z$(cat git)" = zworld +' + +test_expect_success 'rebase --no-verify overrides pre-rebase (2)' ' + git checkout test && + git reset --hard side && + EDITOR=true git rebase --no-verify -i master && + test "z$(git symbolic-ref HEAD)" = zrefs/heads/test && + test "z$(cat git)" = zworld +' + test_done diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh new file mode 100755 index 0000000000..e6c832780f --- /dev/null +++ b/t/t3409-rebase-preserve-merges.sh @@ -0,0 +1,95 @@ +#!/bin/sh +# +# Copyright(C) 2008 Stephen Habermann & Andreas Ericsson +# +test_description='git rebase -p should preserve merges + +Run "git rebase -p" and check that merges are properly carried along +' +. ./test-lib.sh + +GIT_AUTHOR_EMAIL=bogus_email_address +export GIT_AUTHOR_EMAIL + +# Clone 1 (trivial merge): +# +# A1--A2 <-- origin/master +# \ \ +# B1--M <-- topic +# \ +# B2 <-- origin/topic +# +# Clone 2 (conflicting merge): +# +# A1--A2--B3 <-- origin/master +# \ \ +# B1------M <-- topic +# \ +# B2 <-- origin/topic +# +# In both cases, 'topic' is rebased onto 'origin/topic'. + +test_expect_success 'setup for merge-preserving rebase' \ + 'echo First > A && + git add A && + git-commit -m "Add A1" && + git checkout -b topic && + echo Second > B && + git add B && + git-commit -m "Add B1" && + git checkout -f master && + echo Third >> A && + git-commit -a -m "Modify A2" && + + git clone ./. clone1 && + cd clone1 && + git checkout -b topic origin/topic && + git merge origin/master && + cd .. && + + echo Fifth > B && + git add B && + git commit -m "Add different B" && + + git clone ./. clone2 && + cd clone2 && + git checkout -b topic origin/topic && + test_must_fail git merge origin/master && + echo Resolved > B && + git add B && + git commit -m "Merge origin/master into topic" && + cd .. && + + git checkout topic && + echo Fourth >> B && + git commit -a -m "Modify B2" +' + +test_expect_success 'rebase -p fakes interactive rebase' ' + ( + cd clone1 && + git fetch && + git rebase -p origin/topic && + test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) && + test 1 = $(git rev-list --all --pretty=oneline | grep "Merge commit" | wc -l) + ) +' + +test_expect_success '--continue works after a conflict' ' + ( + cd clone2 && + git fetch && + test_must_fail git rebase -p origin/topic && + test 2 = $(git ls-files B | wc -l) && + echo Resolved again > B && + test_must_fail git rebase --continue && + grep "^@@@ " .git/rebase-merge/patch && + git add B && + git rebase --continue && + test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) && + test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) && + test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l) + ) +' + +test_done diff --git a/t/t3410-rebase-preserve-dropped-merges.sh b/t/t3410-rebase-preserve-dropped-merges.sh new file mode 100755 index 0000000000..c49143a1a4 --- /dev/null +++ b/t/t3410-rebase-preserve-dropped-merges.sh @@ -0,0 +1,85 @@ +#!/bin/sh +# +# Copyright (c) 2008 Stephen Haberman +# + +test_description='git rebase preserve merges + +This test runs git rebase with preserve merges and ensures commits +dropped by the --cherry-pick flag have their childrens parents +rewritten. +' +. ./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' ' + test_commit A file1 && + test_commit B file1 1 && + test_commit C file2 && + test_commit D file1 2 && + test_commit E file3 && + git checkout A && + test_commit F file4 && + test_commit G file1 3 && + test_commit H file5 && + git checkout F && + test_commit I file6 +' + +# A - B - C - D - E +# \ \ \ +# F - G - H -- L \ --> L +# \ | \ +# I -- G2 -- J -- K I -- K +# G2 = same changes as G +test_expect_success 'skip same-resolution merges with -p' ' + git checkout H && + ! git merge E && + test_commit L file1 23 && + git checkout I && + test_commit G2 file1 3 && + ! git merge E && + test_commit J file1 23 && + test_commit K file7 file7 && + git rebase -i -p L && + test $(git rev-parse HEAD^^) = $(git rev-parse L) && + test "23" = "$(cat file1)" && + test "I" = "$(cat file6)" && + test "file7" = "$(cat file7)" +' + +# A - B - C - D - E +# \ \ \ +# F - G - H -- L2 \ --> L2 +# \ | \ +# I -- G3 --- J2 -- K2 I -- G3 -- K2 +# G2 = different changes as G +test_expect_success 'keep different-resolution merges with -p' ' + git checkout H && + ! git merge E && + test_commit L2 file1 23 && + git checkout I && + test_commit G3 file1 4 && + ! git merge E && + test_commit J2 file1 24 && + test_commit K2 file7 file7 && + test_must_fail git rebase -i -p L2 && + echo 234 > file1 && + git add file1 && + git rebase --continue && + test $(git rev-parse HEAD^^^) = $(git rev-parse L2) && + test "234" = "$(cat file1)" && + test "I" = "$(cat file6)" && + test "file7" = "$(cat file7)" +' + +test_done diff --git a/t/t3411-rebase-preserve-around-merges.sh b/t/t3411-rebase-preserve-around-merges.sh new file mode 100755 index 0000000000..6533505218 --- /dev/null +++ b/t/t3411-rebase-preserve-around-merges.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# +# Copyright (c) 2008 Stephen Haberman +# + +test_description='git rebase preserve merges + +This test runs git rebase with -p and tries to squash a commit from after +a merge to before the merge. +' +. ./test-lib.sh + +. ../lib-rebase.sh + +set_fake_editor + +# set up two branches like this: +# +# A1 - B1 - D1 - E1 - F1 +# \ / +# -- C1 -- + +test_expect_success 'setup' ' + test_commit A1 && + test_commit B1 && + test_commit C1 && + git reset --hard B1 && + test_commit D1 && + test_merge E1 C1 && + test_commit F1 +' + +# Should result in: +# +# A1 - B1 - D2 - E2 +# \ / +# -- C1 -- +# +test_expect_success 'squash F1 into D1' ' + FAKE_LINES="1 squash 3 2" git rebase -i -p B1 && + test "$(git rev-parse HEAD^2)" = "$(git rev-parse C1)" && + test "$(git rev-parse HEAD~2)" = "$(git rev-parse B1)" && + git tag E2 +' + +# Start with: +# +# A1 - B1 - D2 - E2 +# \ +# G1 ---- L1 ---- M1 +# \ / +# H1 -- J1 -- K1 +# \ / +# -- I1 -- +# +# And rebase G1..M1 onto E2 + +test_expect_success 'rebase two levels of merge' ' + test_commit G1 && + test_commit H1 && + test_commit I1 && + git checkout -b branch3 H1 && + test_commit J1 && + test_merge K1 I1 && + git checkout -b branch2 G1 && + test_commit L1 && + test_merge M1 K1 && + GIT_EDITOR=: git rebase -i -p E2 && + test "$(git rev-parse HEAD~3)" = "$(git rev-parse E2)" && + test "$(git rev-parse HEAD~2)" = "$(git rev-parse HEAD^2^2~2)" && + test "$(git rev-parse HEAD^2^1^1)" = "$(git rev-parse HEAD^2^2^1)" +' + +test_done diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh new file mode 100755 index 0000000000..5869061c5b --- /dev/null +++ b/t/t3412-rebase-root.sh @@ -0,0 +1,280 @@ +#!/bin/sh + +test_description='git rebase --root + +Tests if git rebase --root --onto <newparent> can rebase the root commit. +' +. ./test-lib.sh + +log_with_names () { + git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | + git name-rev --stdin --name-only --refs=refs/heads/$1 +} + + +test_expect_success 'prepare repository' ' + test_commit 1 A && + test_commit 2 A && + git symbolic-ref HEAD refs/heads/other && + rm .git/index && + test_commit 3 B && + test_commit 1b A 1 && + test_commit 4 B +' + +test_expect_success 'rebase --root expects --onto' ' + test_must_fail git rebase --root +' + +test_expect_success 'setup pre-rebase hook' ' + mkdir -p .git/hooks && + cat >.git/hooks/pre-rebase <<EOF && +#!$SHELL_PATH +echo "\$1,\$2" >.git/PRE-REBASE-INPUT +EOF + chmod +x .git/hooks/pre-rebase +' +cat > expect <<EOF +4 +3 +2 +1 +EOF + +test_expect_success 'rebase --root --onto <newbase>' ' + git checkout -b work && + git rebase --root --onto master && + git log --pretty=tformat:"%s" > rebased && + test_cmp expect rebased +' + +test_expect_success 'pre-rebase got correct input (1)' ' + test "z$(cat .git/PRE-REBASE-INPUT)" = z--root, +' + +test_expect_success 'rebase --root --onto <newbase> <branch>' ' + git branch work2 other && + git rebase --root --onto master work2 && + git log --pretty=tformat:"%s" > rebased2 && + test_cmp expect rebased2 +' + +test_expect_success 'pre-rebase got correct input (2)' ' + test "z$(cat .git/PRE-REBASE-INPUT)" = z--root,work2 +' + +test_expect_success 'rebase -i --root --onto <newbase>' ' + git checkout -b work3 other && + git rebase -i --root --onto master && + git log --pretty=tformat:"%s" > rebased3 && + test_cmp expect rebased3 +' + +test_expect_success 'pre-rebase got correct input (3)' ' + test "z$(cat .git/PRE-REBASE-INPUT)" = z--root, +' + +test_expect_success 'rebase -i --root --onto <newbase> <branch>' ' + git branch work4 other && + git rebase -i --root --onto master work4 && + git log --pretty=tformat:"%s" > rebased4 && + test_cmp expect rebased4 +' + +test_expect_success 'pre-rebase got correct input (4)' ' + test "z$(cat .git/PRE-REBASE-INPUT)" = z--root,work4 +' + +test_expect_success 'rebase -i -p with linear history' ' + git checkout -b work5 other && + git rebase -i -p --root --onto master && + git log --pretty=tformat:"%s" > rebased5 && + test_cmp expect rebased5 +' + +test_expect_success 'pre-rebase got correct input (5)' ' + test "z$(cat .git/PRE-REBASE-INPUT)" = z--root, +' + +test_expect_success 'set up merge history' ' + git checkout other^ && + git checkout -b side && + test_commit 5 C && + git checkout other && + git merge side +' + +cat > expect-side <<'EOF' +commit work6 work6~1 work6^2 +Merge branch 'side' into other +commit work6^2 work6~2 +5 +commit work6~1 work6~2 +4 +commit work6~2 work6~3 +3 +commit work6~3 work6~4 +2 +commit work6~4 +1 +EOF + +test_expect_success 'rebase -i -p with merge' ' + git checkout -b work6 other && + git rebase -i -p --root --onto master && + log_with_names work6 > rebased6 && + test_cmp expect-side rebased6 +' + +test_expect_success 'set up second root and merge' ' + git symbolic-ref HEAD refs/heads/third && + rm .git/index && + rm A B C && + test_commit 6 D && + git checkout other && + git merge third +' + +cat > expect-third <<'EOF' +commit work7 work7~1 work7^2 +Merge branch 'third' into other +commit work7^2 work7~4 +6 +commit work7~1 work7~2 work7~1^2 +Merge branch 'side' into other +commit work7~1^2 work7~3 +5 +commit work7~2 work7~3 +4 +commit work7~3 work7~4 +3 +commit work7~4 work7~5 +2 +commit work7~5 +1 +EOF + +test_expect_success 'rebase -i -p with two roots' ' + git checkout -b work7 other && + git rebase -i -p --root --onto master && + log_with_names work7 > rebased7 && + test_cmp expect-third rebased7 +' + +test_expect_success 'setup pre-rebase hook that fails' ' + mkdir -p .git/hooks && + cat >.git/hooks/pre-rebase <<EOF && +#!$SHELL_PATH +false +EOF + chmod +x .git/hooks/pre-rebase +' + +test_expect_success 'pre-rebase hook stops rebase' ' + git checkout -b stops1 other && + test_must_fail git rebase --root --onto master && + test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops1 + test 0 = $(git rev-list other...stops1 | wc -l) +' + +test_expect_success 'pre-rebase hook stops rebase -i' ' + git checkout -b stops2 other && + test_must_fail git rebase --root --onto master && + test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops2 + test 0 = $(git rev-list other...stops2 | wc -l) +' + +test_expect_success 'remove pre-rebase hook' ' + rm -f .git/hooks/pre-rebase +' + +test_expect_success 'set up a conflict' ' + git checkout master && + echo conflict > B && + git add B && + git commit -m conflict +' + +test_expect_success 'rebase --root with conflict (first part)' ' + git checkout -b conflict1 other && + test_must_fail git rebase --root --onto master && + git ls-files -u | grep "B$" +' + +test_expect_success 'fix the conflict' ' + echo 3 > B && + git add B +' + +cat > expect-conflict <<EOF +6 +5 +4 +3 +conflict +2 +1 +EOF + +test_expect_success 'rebase --root with conflict (second part)' ' + git rebase --continue && + git log --pretty=tformat:"%s" > conflict1 && + test_cmp expect-conflict conflict1 +' + +test_expect_success 'rebase -i --root with conflict (first part)' ' + git checkout -b conflict2 other && + test_must_fail git rebase -i --root --onto master && + git ls-files -u | grep "B$" +' + +test_expect_success 'fix the conflict' ' + echo 3 > B && + git add B +' + +test_expect_success 'rebase -i --root with conflict (second part)' ' + git rebase --continue && + git log --pretty=tformat:"%s" > conflict2 && + test_cmp expect-conflict conflict2 +' + +cat >expect-conflict-p <<\EOF +commit conflict3 conflict3~1 conflict3^2 +Merge branch 'third' into other +commit conflict3^2 conflict3~4 +6 +commit conflict3~1 conflict3~2 conflict3~1^2 +Merge branch 'side' into other +commit conflict3~1^2 conflict3~3 +5 +commit conflict3~2 conflict3~3 +4 +commit conflict3~3 conflict3~4 +3 +commit conflict3~4 conflict3~5 +conflict +commit conflict3~5 conflict3~6 +2 +commit conflict3~6 +1 +EOF + +test_expect_success 'rebase -i -p --root with conflict (first part)' ' + git checkout -b conflict3 other && + test_must_fail git rebase -i -p --root --onto master && + git ls-files -u | grep "B$" +' + +test_expect_success 'fix the conflict' ' + echo 3 > B && + git add B +' + +test_expect_success 'rebase -i -p --root with conflict (second part)' ' + git rebase --continue && + log_with_names conflict3 >out && + test_cmp expect-conflict-p out +' + +test_done diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index 6da212825a..bb4cf00d78 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -45,6 +45,7 @@ test_expect_success 'cherry-pick after renaming branch' ' git checkout rename2 && git cherry-pick added && + test $(git rev-parse HEAD^) = $(git rev-parse rename2) && test -f opos && grep "Add extra line at the end" opos @@ -54,6 +55,7 @@ test_expect_success 'revert after renaming branch' ' git checkout rename1 && git revert added && + test $(git rev-parse HEAD^) = $(git rev-parse rename1) && test -f spoo && ! grep "Add extra line at the end" spoo diff --git a/t/t3504-cherry-pick-rerere.sh b/t/t3504-cherry-pick-rerere.sh new file mode 100755 index 0000000000..f7b3518a32 --- /dev/null +++ b/t/t3504-cherry-pick-rerere.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +test_description='cherry-pick should rerere for conflicts' + +. ./test-lib.sh + +test_expect_success setup ' + echo foo >foo && + git add foo && test_tick && git commit -q -m 1 && + echo foo-master >foo && + git add foo && test_tick && git commit -q -m 2 && + + git checkout -b dev HEAD^ && + echo foo-dev >foo && + git add foo && test_tick && git commit -q -m 3 && + git config rerere.enabled true +' + +test_expect_success 'conflicting merge' ' + test_must_fail git merge master +' + +test_expect_success 'fixup' ' + echo foo-dev >foo && + git add foo && test_tick && git commit -q -m 4 && + git reset --hard HEAD^ + echo foo-dev >expect +' + +test_expect_success 'cherry-pick conflict' ' + test_must_fail git cherry-pick master && + test_cmp expect foo +' + +test_expect_success 'reconfigure' ' + git config rerere.enabled false + git reset --hard +' + +test_expect_success 'cherry-pick conflict without rerere' ' + test_must_fail git cherry-pick master && + test_must_fail test_cmp expect foo +' + +test_done diff --git a/t/t3505-cherry-pick-empty.sh b/t/t3505-cherry-pick-empty.sh new file mode 100755 index 0000000000..9aaeabd972 --- /dev/null +++ b/t/t3505-cherry-pick-empty.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +test_description='test cherry-picking an empty commit' + +. ./test-lib.sh + +test_expect_success setup ' + + echo first > file1 && + git add file1 && + test_tick && + git commit -m "first" && + + git checkout -b empty-branch && + test_tick && + git commit --allow-empty -m "empty" + +' + +test_expect_code 1 'cherry-pick an empty commit' ' + + git checkout master && + git cherry-pick empty-branch + +' + +test_expect_success 'index lockfile was removed' ' + + test ! -f .git/index.lock + +' + +test_done diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 66aca99fd3..95542e9cfe 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -187,6 +187,19 @@ test_expect_success 'but with -f it should work.' ' test_must_fail git ls-files --error-unmatch baz ' +test_expect_success 'refuse to remove cached empty file with modifications' ' + >empty && + git add empty && + echo content >empty && + test_must_fail git rm --cached empty +' + +test_expect_success 'remove intent-to-add file without --force' ' + echo content >intent-to-add && + git add -N intent-to-add + git rm --cached intent-to-add +' + test_expect_success 'Recursive test setup' ' mkdir -p frotz && echo qfwfq >frotz/nitfol && @@ -238,4 +251,21 @@ test_expect_success 'refresh index before checking if it is up-to-date' ' ' +test_expect_success 'choking "git rm" should not let it die with cruft' ' + git reset -q --hard && + H=0000000000000000000000000000000000000000 && + i=0 && + while test $i -lt 12000 + do + echo "100644 $H 0 some-file-$i" + i=$(( $i + 1 )) + done | git update-index --index-info && + git rm -n "some-file-*" | :; + test -f .git/index.lock + status=$? + rm -f .git/index.lock + git reset -q --hard + test "$status" != 0 +' + test_done diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 2ac93a346d..9f6454d2ff 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -226,7 +226,7 @@ test_expect_success 'git add '\''fo\[ou\]bar'\'' ignores foobar' ' git reset --hard && touch fo\[ou\]bar foobar && git add '\''fo\[ou\]bar'\'' && - git ls-files fo\[ou\]bar | grep -F fo\[ou\]bar && + git ls-files fo\[ou\]bar | fgrep fo\[ou\]bar && ! ( git ls-files foobar | grep foobar ) ' diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh index f31353323b..784c31aec9 100755 --- a/t/t3900-i18n-commit.sh +++ b/t/t3900-i18n-commit.sh @@ -16,7 +16,7 @@ test_expect_success setup ' : >F && git add F && T=$(git write-tree) && - C=$(git commit-tree $T <../t3900/1-UTF-8.txt) && + C=$(git commit-tree $T <"$TEST_DIRECTORY"/t3900/1-UTF-8.txt) && git update-ref HEAD $C && git tag C0 ' @@ -32,7 +32,7 @@ do git config i18n.commitencoding $H && git checkout -b $H C0 && echo $H >F && - git commit -a -F ../t3900/$H.txt + git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt ' done @@ -57,13 +57,13 @@ test_expect_success 'config to remove customization' ' ' test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' - compare_with ISO-8859-1 ../t3900/1-UTF-8.txt + compare_with ISO-8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt ' for H in EUCJP ISO-2022-JP do test_expect_success "$H should be shown in UTF-8 now" ' - compare_with '$H' ../t3900/2-UTF-8.txt + compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt ' done @@ -82,7 +82,7 @@ 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' && - compare_with '$H' ../t3900/'$H'.txt + compare_with '$H' "$TEST_DIRECTORY"/t3900/'$H'.txt ' done @@ -91,13 +91,13 @@ test_expect_success 'config to tweak customization' ' ' test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' - compare_with ISO-8859-1 ../t3900/1-UTF-8.txt + compare_with ISO-8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt ' for H in EUCJP ISO-2022-JP do test_expect_success "$H should be shown in UTF-8 now" ' - compare_with '$H' ../t3900/2-UTF-8.txt + compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt ' done @@ -107,7 +107,7 @@ do for H in EUCJP ISO-2022-JP do test_expect_success "$H should be shown in $J now" ' - compare_with '$H' ../t3900/'$J'.txt + compare_with '$H' "$TEST_DIRECTORY"/t3900/'$J'.txt ' done done @@ -115,7 +115,7 @@ done for H in ISO-8859-1 EUCJP ISO-2022-JP do test_expect_success "No conversion with $H" ' - compare_with "--encoding=none '$H'" ../t3900/'$H'.txt + compare_with "--encoding=none '$H'" "$TEST_DIRECTORY"/t3900/'$H'.txt ' done diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh index 567760e1d2..7655da3f8d 100755 --- a/t/t3901-i18n-patch.sh +++ b/t/t3901-i18n-patch.sh @@ -35,7 +35,7 @@ test_expect_success setup ' # use UTF-8 in author and committer name to match the # i18n.commitencoding settings - . ../t3901-utf8.txt && + . "$TEST_DIRECTORY"/t3901-utf8.txt && test_tick && echo "$GIT_AUTHOR_NAME" >mine && @@ -57,7 +57,7 @@ test_expect_success setup ' # the second one on the side branch is 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_DIRECTORY"/t3901-8859-1.txt && test_tick && echo Yet another >theirs && git add theirs && @@ -101,7 +101,7 @@ test_expect_success 'rebase (U/U)' ' # The result will be committed by GIT_COMMITTER_NAME -- # we want UTF-8 encoded name. - . ../t3901-utf8.txt && + . "$TEST_DIRECTORY"/t3901-utf8.txt && git checkout -b test && git rebase master && @@ -111,7 +111,7 @@ test_expect_success 'rebase (U/U)' ' test_expect_success 'rebase (U/L)' ' git config i18n.commitencoding UTF-8 && git config i18n.logoutputencoding ISO-8859-1 && - . ../t3901-utf8.txt && + . "$TEST_DIRECTORY"/t3901-utf8.txt && git reset --hard side && git rebase master && @@ -123,7 +123,7 @@ 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.logoutputencoding ISO-8859-1 && - . ../t3901-8859-1.txt && + . "$TEST_DIRECTORY"/t3901-8859-1.txt && git reset --hard side && git rebase master && @@ -136,7 +136,7 @@ test_expect_success 'rebase (L/U)' ' # to get ISO-8859-1 results. git config i18n.commitencoding ISO-8859-1 && git config i18n.logoutputencoding UTF-8 && - . ../t3901-8859-1.txt && + . "$TEST_DIRECTORY"/t3901-8859-1.txt && git reset --hard side && git rebase master && @@ -149,7 +149,7 @@ test_expect_success 'cherry-pick(U/U)' ' git config i18n.commitencoding UTF-8 && git config i18n.logoutputencoding UTF-8 && - . ../t3901-utf8.txt && + . "$TEST_DIRECTORY"/t3901-utf8.txt && git reset --hard master && git cherry-pick side^ && @@ -164,7 +164,7 @@ test_expect_success 'cherry-pick(L/L)' ' git config i18n.commitencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 && - . ../t3901-8859-1.txt && + . "$TEST_DIRECTORY"/t3901-8859-1.txt && git reset --hard master && git cherry-pick side^ && @@ -179,7 +179,7 @@ test_expect_success 'cherry-pick(U/L)' ' git config i18n.commitencoding UTF-8 && git config i18n.logoutputencoding ISO-8859-1 && - . ../t3901-utf8.txt && + . "$TEST_DIRECTORY"/t3901-utf8.txt && git reset --hard master && git cherry-pick side^ && @@ -195,7 +195,7 @@ test_expect_success 'cherry-pick(L/U)' ' git config i18n.commitencoding ISO-8859-1 && git config i18n.logoutputencoding UTF-8 && - . ../t3901-8859-1.txt && + . "$TEST_DIRECTORY"/t3901-8859-1.txt && git reset --hard master && git cherry-pick side^ && @@ -208,7 +208,7 @@ test_expect_success 'cherry-pick(L/U)' ' test_expect_success 'rebase --merge (U/U)' ' git config i18n.commitencoding UTF-8 && git config i18n.logoutputencoding UTF-8 && - . ../t3901-utf8.txt && + . "$TEST_DIRECTORY"/t3901-utf8.txt && git reset --hard side && git rebase --merge master && @@ -219,7 +219,7 @@ test_expect_success 'rebase --merge (U/U)' ' test_expect_success 'rebase --merge (U/L)' ' git config i18n.commitencoding UTF-8 && git config i18n.logoutputencoding ISO-8859-1 && - . ../t3901-utf8.txt && + . "$TEST_DIRECTORY"/t3901-utf8.txt && git reset --hard side && git rebase --merge master && @@ -231,7 +231,7 @@ 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.logoutputencoding ISO-8859-1 && - . ../t3901-8859-1.txt && + . "$TEST_DIRECTORY"/t3901-8859-1.txt && git reset --hard side && git rebase --merge master && @@ -244,7 +244,7 @@ test_expect_success 'rebase --merge (L/U)' ' # to get ISO-8859-1 results. git config i18n.commitencoding ISO-8859-1 && git config i18n.logoutputencoding UTF-8 && - . ../t3901-8859-1.txt && + . "$TEST_DIRECTORY"/t3901-8859-1.txt && git reset --hard side && git rebase --merge master && diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh index c44b27aeb2..6ddd46915d 100755 --- a/t/t4000-diff-format.sh +++ b/t/t4000-diff-format.sh @@ -7,7 +7,7 @@ test_description='Test built-in diff output engine. ' . ./test-lib.sh -. ../diff-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh echo >path0 'Line 1 Line 2 diff --git a/t/t4001-diff-rename.sh b/t/t4001-diff-rename.sh index a32692417d..71bac83dd5 100755 --- a/t/t4001-diff-rename.sh +++ b/t/t4001-diff-rename.sh @@ -7,7 +7,7 @@ test_description='Test rename detection in diff engine. ' . ./test-lib.sh -. ../diff-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh echo >path0 'Line 1 Line 2 diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh index a4cfde6b29..cc3681f161 100755 --- a/t/t4002-diff-basic.sh +++ b/t/t4002-diff-basic.sh @@ -7,7 +7,7 @@ test_description='Test diff raw-output. ' . ./test-lib.sh -. ../lib-read-tree-m-3way.sh +. "$TEST_DIRECTORY"/lib-read-tree-m-3way.sh cat >.test-plain-OA <<\EOF :000000 100644 0000000000000000000000000000000000000000 ccba72ad3888a3520b39efcf780b9ee64167535d A AA @@ -169,6 +169,20 @@ test_expect_success \ cmp -s .test-a .test-recursive-AB' test_expect_success \ + 'diff-tree --stdin of known trees.' \ + 'echo $tree_A $tree_B | git diff-tree --stdin > .test-a && + echo $tree_A $tree_B > .test-plain-ABx && + cat .test-plain-AB >> .test-plain-ABx && + cmp -s .test-a .test-plain-ABx' + +test_expect_success \ + 'diff-tree --stdin of known trees.' \ + 'echo $tree_A $tree_B | git diff-tree -r --stdin > .test-a && + echo $tree_A $tree_B > .test-recursive-ABx && + cat .test-recursive-AB >> .test-recursive-ABx && + cmp -s .test-a .test-recursive-ABx' + +test_expect_success \ 'diff-cache O with A in cache' \ 'git read-tree $tree_A && git diff-index --cached $tree_O >.test-a && diff --git a/t/t4003-diff-rename-1.sh b/t/t4003-diff-rename-1.sh index 8b1f875286..c6130c4019 100755 --- a/t/t4003-diff-rename-1.sh +++ b/t/t4003-diff-rename-1.sh @@ -7,11 +7,11 @@ test_description='More rename detection ' . ./test-lib.sh -. ../diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash test_expect_success \ 'prepare reference tree' \ - 'cat ../../COPYING >COPYING && + 'cat "$TEST_DIRECTORY"/../COPYING >COPYING && echo frotz >rezrov && git update-index --add COPYING rezrov && tree=$(git write-tree) && @@ -99,7 +99,7 @@ test_expect_success \ test_expect_success \ 'prepare work tree once again' \ - 'cat ../../COPYING >COPYING && + 'cat "$TEST_DIRECTORY"/../COPYING >COPYING && git update-index --add --remove COPYING COPYING.1' # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, diff --git a/t/t4004-diff-rename-symlink.sh b/t/t4004-diff-rename-symlink.sh index 3d25be7a67..b35af9b42d 100755 --- a/t/t4004-diff-rename-symlink.sh +++ b/t/t4004-diff-rename-symlink.sh @@ -10,7 +10,7 @@ copy of symbolic links, but should not produce rename/copy followed by an edit for them. ' . ./test-lib.sh -. ../diff-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh test_expect_success \ 'prepare reference tree' \ diff --git a/t/t4005-diff-rename-2.sh b/t/t4005-diff-rename-2.sh index 6630017312..1ba359d478 100755 --- a/t/t4005-diff-rename-2.sh +++ b/t/t4005-diff-rename-2.sh @@ -7,11 +7,11 @@ test_description='Same rename detection as t4003 but testing diff-raw. ' . ./test-lib.sh -. ../diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash test_expect_success \ 'prepare reference tree' \ - 'cat ../../COPYING >COPYING && + 'cat "$TEST_DIRECTORY"/../COPYING >COPYING && echo frotz >rezrov && git update-index --add COPYING rezrov && tree=$(git write-tree) && @@ -71,7 +71,7 @@ test_expect_success \ test_expect_success \ 'prepare work tree once again' \ - 'cat ../../COPYING >COPYING && + 'cat "$TEST_DIRECTORY"/../COPYING >COPYING && git update-index --add --remove COPYING COPYING.1' git diff-index -C --find-copies-harder $tree >current diff --git a/t/t4007-rename-3.sh b/t/t4007-rename-3.sh index 104a4e1492..42072d724e 100755 --- a/t/t4007-rename-3.sh +++ b/t/t4007-rename-3.sh @@ -7,12 +7,12 @@ test_description='Rename interaction with pathspec. ' . ./test-lib.sh -. ../diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash test_expect_success \ 'prepare reference tree' \ 'mkdir path0 path1 && - cp ../../COPYING path0/COPYING && + cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && git update-index --add path0/COPYING && tree=$(git write-tree) && echo $tree' diff --git a/t/t4008-diff-break-rewrite.sh b/t/t4008-diff-break-rewrite.sh index 26c2e4aa65..7e343a9cd1 100755 --- a/t/t4008-diff-break-rewrite.sh +++ b/t/t4008-diff-break-rewrite.sh @@ -22,12 +22,12 @@ four changes in total. Further, with -B and -M together, these should turn into two renames. ' . ./test-lib.sh -. ../diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash test_expect_success \ setup \ - 'cat ../../README >file0 && - cat ../../COPYING >file1 && + 'cat "$TEST_DIRECTORY"/../README >file0 && + cat "$TEST_DIRECTORY"/../COPYING >file1 && git update-index --add file0 file1 && tree=$(git write-tree) && echo "$tree"' diff --git a/t/t4009-diff-rename-4.sh b/t/t4009-diff-rename-4.sh index d2b45e7b8f..de3f17478e 100755 --- a/t/t4009-diff-rename-4.sh +++ b/t/t4009-diff-rename-4.sh @@ -7,11 +7,11 @@ test_description='Same rename detection as t4003 but testing diff-raw -z. ' . ./test-lib.sh -. ../diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash test_expect_success \ 'prepare reference tree' \ - 'cat ../../COPYING >COPYING && + 'cat "$TEST_DIRECTORY"/../COPYING >COPYING && echo frotz >rezrov && git update-index --add COPYING rezrov && tree=$(git write-tree) && @@ -78,7 +78,7 @@ test_expect_success \ test_expect_success \ 'prepare work tree once again' \ - 'cat ../../COPYING >COPYING && + 'cat "$TEST_DIRECTORY"/../COPYING >COPYING && git update-index --add --remove COPYING COPYING.1' git diff-index -z -C --find-copies-harder $tree >current diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh index ad3d9e4845..9322298ecc 100755 --- a/t/t4010-diff-pathspec.sh +++ b/t/t4010-diff-pathspec.sh @@ -10,7 +10,7 @@ Prepare: path1/file1 ' . ./test-lib.sh -. ../diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash test_expect_success \ setup \ diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh index c6d13693ba..9055c8b318 100755 --- a/t/t4011-diff-symlink.sh +++ b/t/t4011-diff-symlink.sh @@ -7,7 +7,7 @@ test_description='Test diff of symlinks. ' . ./test-lib.sh -. ../diff-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh cat > expected << EOF diff --git a/frotz b/frotz @@ -82,4 +82,11 @@ test_expect_success \ git diff-index -M -p $tree > current && compare_diff_patch current expected' +test_expect_success \ + 'diff symlinks with non-existing targets' \ + 'ln -s narf pinky && + ln -s take\ over brain && + test_must_fail git diff --no-index pinky brain > output 2> output.err && + grep narf output && + ! grep error output.err' test_done diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh index eac12712db..3cf5b5c4ea 100755 --- a/t/t4012-diff-binary.sh +++ b/t/t4012-diff-binary.sh @@ -12,7 +12,7 @@ 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 && echo git >a && - cat ../test4012.png >b && + cat "$TEST_DIRECTORY"/test4012.png >b && echo git >c && cat b b >d' @@ -25,11 +25,11 @@ cat > expected <<\EOF EOF test_expect_success 'diff without --binary' \ 'git diff | git apply --stat --summary >current && - cmp current expected' + test_cmp expected current' test_expect_success 'diff with --binary' \ 'git diff --binary | git apply --stat --summary >current && - cmp current expected' + test_cmp expected current' # apply needs to be able to skip the binary material correctly # in order to report the line number of a corrupt patch. diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 99d9e0ba13..9c709022ef 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -74,6 +74,10 @@ test_expect_success setup ' for i in 1 2; do echo $i; done >>dir/sub && git update-index file0 dir/sub && + mkdir dir3 && + cp dir/sub dir3/sub && + test-chmtime +1 dir3/sub && + git config log.showroot false && git commit --amend && git show-branch @@ -99,7 +103,7 @@ do test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'` cnt=`expr $test_count + 1` pfx=`printf "%04d" $cnt` - expect="../t4013/diff.$test" + expect="$TEST_DIRECTORY/t4013/diff.$test" actual="$pfx-diff.$test" test_expect_success "git $cmd" ' @@ -236,12 +240,15 @@ show --patch-with-stat --summary side format-patch --stdout initial..side format-patch --stdout initial..master^ format-patch --stdout initial..master +format-patch --stdout --no-numbered initial..master +format-patch --stdout --numbered initial..master format-patch --attach --stdout initial..side format-patch --attach --stdout initial..master^ format-patch --attach --stdout initial..master format-patch --inline --stdout initial..side format-patch --inline --stdout initial..master^ 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^^ @@ -258,6 +265,8 @@ diff --patch-with-stat -r initial..side diff --patch-with-raw -r initial..side diff --name-status dir2 dir diff --no-index --name-status dir2 dir +diff --no-index --name-status -- dir2 dir +diff --no-index dir dir3 diff master master^ side EOF diff --git a/t/t4013/diff.diff_--no-index_--name-status_--_dir2_dir b/t/t4013/diff.diff_--no-index_--name-status_--_dir2_dir new file mode 100644 index 0000000000..6756f8de67 --- /dev/null +++ b/t/t4013/diff.diff_--no-index_--name-status_--_dir2_dir @@ -0,0 +1,3 @@ +$ git diff --no-index --name-status -- dir2 dir +A dir/sub +$ diff --git a/t/t4013/diff.diff_--no-index_dir_dir3 b/t/t4013/diff.diff_--no-index_dir_dir3 new file mode 100644 index 0000000000..2142c2b9ad --- /dev/null +++ b/t/t4013/diff.diff_--no-index_dir_dir3 @@ -0,0 +1,2 @@ +$ git diff --no-index dir dir3 +$ diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master b/t/t4013/diff.format-patch_--attach_--stdout_initial..master index 43346b9ba4..e5ab74437e 100644 --- a/t/t4013/diff.format-patch_--attach_--stdout_initial..master +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master @@ -2,7 +2,7 @@ $ git format-patch --attach --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: [PATCH] Second +Subject: [PATCH 1/3] Second MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" @@ -63,7 +63,7 @@ index 01e79c3..0000000 From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:02:00 +0000 -Subject: [PATCH] Third +Subject: [PATCH 2/3] Third MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" @@ -111,7 +111,7 @@ index 0000000..b1e6722 From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:03:00 +0000 -Subject: [PATCH] Side +Subject: [PATCH 3/3] Side MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ index d7490a9fd7..2c71d20d37 100644 --- a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ @@ -2,7 +2,7 @@ $ git format-patch --attach --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: [PATCH] Second +Subject: [PATCH 1/2] Second MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" @@ -63,7 +63,7 @@ index 01e79c3..0000000 From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:02:00 +0000 -Subject: [PATCH] Third +Subject: [PATCH 2/2] Third MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" diff --git a/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master b/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master index fca5cce373..58f8a7b7d6 100644 --- a/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master +++ b/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master @@ -2,7 +2,7 @@ $ git format-patch --inline --stdout --subject-prefix=TESTCASE 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: [TESTCASE] Second +Subject: [TESTCASE 1/3] Second MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" @@ -63,7 +63,7 @@ index 01e79c3..0000000 From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:02:00 +0000 -Subject: [TESTCASE] Third +Subject: [TESTCASE 2/3] Third MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" @@ -111,7 +111,7 @@ index 0000000..b1e6722 From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:03:00 +0000 -Subject: [TESTCASE] Side +Subject: [TESTCASE 3/3] Side MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" diff --git a/t/t4013/diff.format-patch_--inline_--stdout_initial..master b/t/t4013/diff.format-patch_--inline_--stdout_initial..master index 6d6fac3908..9e7bbdffa2 100644 --- a/t/t4013/diff.format-patch_--inline_--stdout_initial..master +++ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master @@ -2,7 +2,7 @@ $ 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: [PATCH] Second +Subject: [PATCH 1/3] Second MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" @@ -63,7 +63,7 @@ index 01e79c3..0000000 From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:02:00 +0000 -Subject: [PATCH] Third +Subject: [PATCH 2/3] Third MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" @@ -111,7 +111,7 @@ index 0000000..b1e6722 From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:03:00 +0000 -Subject: [PATCH] Side +Subject: [PATCH 3/3] Side MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" diff --git a/t/t4013/diff.format-patch_--inline_--stdout_initial..master^ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master^ index 18a1110def..f881f644cc 100644 --- a/t/t4013/diff.format-patch_--inline_--stdout_initial..master^ +++ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master^ @@ -2,7 +2,7 @@ $ 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: [PATCH] Second +Subject: [PATCH 1/2] Second MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" @@ -63,7 +63,7 @@ index 01e79c3..0000000 From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:02:00 +0000 -Subject: [PATCH] Third +Subject: [PATCH 2/2] Third MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" diff --git a/t/t4013/diff.format-patch_--stdout_--no-numbered_initial..master b/t/t4013/diff.format-patch_--stdout_--no-numbered_initial..master new file mode 100644 index 0000000000..f7752ebbea --- /dev/null +++ b/t/t4013/diff.format-patch_--stdout_--no-numbered_initial..master @@ -0,0 +1,127 @@ +$ git format-patch --stdout --no-numbered 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: [PATCH] Second + +This is the second commit. +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 + +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 + + +From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:02:00 +0000 +Subject: [PATCH] Third + +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C +-- +g-i-t--v-e-r-s-i-o-n + + +From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:03:00 +0000 +Subject: [PATCH] Side + +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +-- +g-i-t--v-e-r-s-i-o-n + +$ diff --git a/t/t4013/diff.format-patch_--stdout_--numbered_initial..master b/t/t4013/diff.format-patch_--stdout_--numbered_initial..master new file mode 100644 index 0000000000..8e67dbf76f --- /dev/null +++ b/t/t4013/diff.format-patch_--stdout_--numbered_initial..master @@ -0,0 +1,127 @@ +$ git format-patch --stdout --numbered 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: [PATCH 1/3] Second + +This is the second commit. +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 + +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 + + +From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:02:00 +0000 +Subject: [PATCH 2/3] Third + +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C +-- +g-i-t--v-e-r-s-i-o-n + + +From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:03:00 +0000 +Subject: [PATCH 3/3] Side + +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 +-- +g-i-t--v-e-r-s-i-o-n + +$ diff --git a/t/t4013/diff.format-patch_--stdout_initial..master b/t/t4013/diff.format-patch_--stdout_initial..master index 8b88ca4927..7b89978e32 100644 --- a/t/t4013/diff.format-patch_--stdout_initial..master +++ b/t/t4013/diff.format-patch_--stdout_initial..master @@ -2,7 +2,7 @@ $ git format-patch --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: [PATCH] Second +Subject: [PATCH 1/3] Second This is the second commit. --- @@ -48,7 +48,7 @@ g-i-t--v-e-r-s-i-o-n From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:02:00 +0000 -Subject: [PATCH] Third +Subject: [PATCH 2/3] Third --- dir/sub | 2 ++ @@ -82,7 +82,7 @@ g-i-t--v-e-r-s-i-o-n From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:03:00 +0000 -Subject: [PATCH] Side +Subject: [PATCH 3/3] Side --- dir/sub | 2 ++ diff --git a/t/t4013/diff.format-patch_--stdout_initial..master^ b/t/t4013/diff.format-patch_--stdout_initial..master^ index 47a4b88637..b7f9725dc4 100644 --- a/t/t4013/diff.format-patch_--stdout_initial..master^ +++ b/t/t4013/diff.format-patch_--stdout_initial..master^ @@ -2,7 +2,7 @@ $ git format-patch --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: [PATCH] Second +Subject: [PATCH 1/2] Second This is the second commit. --- @@ -48,7 +48,7 @@ g-i-t--v-e-r-s-i-o-n From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:02:00 +0000 -Subject: [PATCH] Third +Subject: [PATCH 2/2] Third --- dir/sub | 2 ++ diff --git a/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ b/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ index 3ceb8e73c5..bd7f5c0f70 100644 --- a/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ +++ b/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ @@ -1,6 +1,6 @@ $ git log --patch-with-stat --summary master -- dir/ commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.log_--patch-with-stat_master b/t/t4013/diff.log_--patch-with-stat_master index 43d77761f9..14595a614c 100644 --- a/t/t4013/diff.log_--patch-with-stat_master +++ b/t/t4013/diff.log_--patch-with-stat_master @@ -1,6 +1,6 @@ $ git log --patch-with-stat master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.log_--patch-with-stat_master_--_dir_ b/t/t4013/diff.log_--patch-with-stat_master_--_dir_ index 5187a26816..5a4e72765d 100644 --- a/t/t4013/diff.log_--patch-with-stat_master_--_dir_ +++ b/t/t4013/diff.log_--patch-with-stat_master_--_dir_ @@ -1,6 +1,6 @@ $ git log --patch-with-stat master -- dir/ commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master index c9640976a8..df0aaa9f2c 100644 --- a/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master +++ b/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master @@ -1,6 +1,6 @@ $ git log --root --cc --patch-with-stat --summary master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.log_--root_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_--patch-with-stat_--summary_master index ad050af55f..c11b5f2c7f 100644 --- a/t/t4013/diff.log_--root_--patch-with-stat_--summary_master +++ b/t/t4013/diff.log_--root_--patch-with-stat_--summary_master @@ -1,6 +1,6 @@ $ git log --root --patch-with-stat --summary master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.log_--root_--patch-with-stat_master b/t/t4013/diff.log_--root_--patch-with-stat_master index 628c6c03bc..5f0c98f9ce 100644 --- a/t/t4013/diff.log_--root_--patch-with-stat_master +++ b/t/t4013/diff.log_--root_--patch-with-stat_master @@ -1,6 +1,6 @@ $ git log --root --patch-with-stat master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master index 5d4e0f13b5..e62c368dc6 100644 --- a/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master +++ b/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master @@ -1,6 +1,6 @@ $ git log --root -c --patch-with-stat --summary master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.log_--root_-p_master b/t/t4013/diff.log_--root_-p_master index 217a2eb203..b42c334439 100644 --- a/t/t4013/diff.log_--root_-p_master +++ b/t/t4013/diff.log_--root_-p_master @@ -1,6 +1,6 @@ $ git log --root -p master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.log_--root_master b/t/t4013/diff.log_--root_master index e17ccfc234..e8f46159da 100644 --- a/t/t4013/diff.log_--root_master +++ b/t/t4013/diff.log_--root_master @@ -1,6 +1,6 @@ $ git log --root master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.log_-p_master b/t/t4013/diff.log_-p_master index f8fefef2c3..bf1326dc36 100644 --- a/t/t4013/diff.log_-p_master +++ b/t/t4013/diff.log_-p_master @@ -1,6 +1,6 @@ $ git log -p master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.log_master b/t/t4013/diff.log_master index e9d9e7b40a..a8f6ce5abd 100644 --- a/t/t4013/diff.log_master +++ b/t/t4013/diff.log_master @@ -1,6 +1,6 @@ $ git log master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.show_master b/t/t4013/diff.show_master index 9e6e1f2710..fb08ce0e46 100644 --- a/t/t4013/diff.show_master +++ b/t/t4013/diff.show_master @@ -1,6 +1,6 @@ $ git show master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master b/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master index 5facf2543d..e96ff1fb8c 100644 --- a/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master +++ b/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master @@ -1,6 +1,6 @@ $ git whatchanged --root --cc --patch-with-stat --summary master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master b/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master index 10f6767e49..c0aff68ef6 100644 --- a/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master +++ b/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master @@ -1,6 +1,6 @@ $ git whatchanged --root -c --patch-with-stat --summary master commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 -Merge: 9a6d494... c7a2ab9... +Merge: 9a6d494 c7a2ab9 Author: A U Thor <author@example.com> Date: Mon Jun 26 00:04:00 2006 +0000 diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 7fe853c20d..f045898fe3 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Junio C Hamano # -test_description='Format-patch skipping already incorporated patches' +test_description='various format-patch tests' . ./test-lib.sh @@ -230,4 +230,79 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' ' ' +cat > expect << EOF +--- + file | 16 ++++++++++++++++ + 1 files changed, 16 insertions(+), 0 deletions(-) + +diff --git a/file b/file +index 40f36c6..2dc5c23 100644 +--- a/file ++++ b/file +@@ -13,4 +13,20 @@ C + 10 + D + E + F ++5 +EOF + +test_expect_success 'format-patch respects -U' ' + + git format-patch -U4 -2 && + sed -e "1,/^$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && + test_cmp expect output + +' + +test_expect_success 'format-patch from a subdirectory (1)' ' + filename=$( + rm -rf sub && + mkdir -p sub/dir && + cd sub/dir && + git format-patch -1 + ) && + case "$filename" in + 0*) + ;; # ok + *) + echo "Oops? $filename" + false + ;; + esac && + test -f "$filename" +' + +test_expect_success 'format-patch from a subdirectory (2)' ' + filename=$( + rm -rf sub && + mkdir -p sub/dir && + cd sub/dir && + git format-patch -1 -o .. + ) && + case "$filename" in + ../0*) + ;; # ok + *) + echo "Oops? $filename" + false + ;; + esac && + basename=$(expr "$filename" : ".*/\(.*\)") && + test -f "sub/$basename" +' + +test_expect_success 'format-patch from a subdirectory (3)' ' + here="$TEST_DIRECTORY/$test" && + rm -f 0* && + filename=$( + rm -rf sub && + mkdir -p sub/dir && + cd sub/dir && + git format-patch -1 -o "$here" + ) && + basename=$(expr "$filename" : ".*/\(.*\)") && + test -f "$basename" +' + test_done diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index b1cbd36d17..6d13da30da 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -7,7 +7,7 @@ test_description='Test special whitespace in diff engine. ' . ./test-lib.sh -. ../diff-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh # Ray Lehtiniemi's example @@ -98,6 +98,12 @@ index d99af23..8b32fb5 100644 EOF git diff -w > out test_expect_success 'another test, with -w' 'test_cmp expect out' +git diff -w -b > out +test_expect_success 'another test, with -w -b' 'test_cmp expect out' +git diff -w --ignore-space-at-eol > out +test_expect_success 'another test, with -w --ignore-space-at-eol' 'test_cmp expect out' +git diff -w -b --ignore-space-at-eol > out +test_expect_success 'another test, with -w -b --ignore-space-at-eol' 'test_cmp expect out' tr 'Q' '\015' << EOF > expect diff --git a/x b/x @@ -116,6 +122,27 @@ index d99af23..8b32fb5 100644 EOF git diff -b > out test_expect_success 'another test, with -b' 'test_cmp expect out' +git diff -b --ignore-space-at-eol > out +test_expect_success 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out' + +tr 'Q' '\015' << EOF > expect +diff --git a/x b/x +index d99af23..8b32fb5 100644 +--- a/x ++++ b/x +@@ -1,6 +1,6 @@ +-whitespace at beginning +-whitespace change +-whitespace in the middle ++ whitespace at beginning ++whitespace change ++white space in the middle + whitespace at end + unchanged line + CR at endQ +EOF +git diff --ignore-space-at-eol > out +test_expect_success 'another test, with --ignore-space-at-eol' 'test_cmp expect out' test_expect_success 'check mixed spaces and tabs in indent' ' diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 398bf4b5d8..be541348c6 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -32,7 +32,7 @@ EOF sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java -builtin_patterns="bibtex java pascal ruby tex" +builtin_patterns="bibtex html java objc pascal php python ruby tex" for p in $builtin_patterns do test_expect_success "builtin $p pattern compiles" ' diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh index 22ef7d44b0..f8c99f1a98 100755 --- a/t/t4020-diff-external.sh +++ b/t/t4020-diff-external.sh @@ -125,7 +125,31 @@ echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file test_expect_success 'force diff with "diff"' ' echo >.gitattributes "file diff" && git diff >actual && - test_cmp ../t4020/diff.NUL actual + test_cmp "$TEST_DIRECTORY"/t4020/diff.NUL actual +' + +test_expect_success 'GIT_EXTERNAL_DIFF with more than one changed files' ' + echo anotherfile > file2 && + git add file2 && + git commit -m "added 2nd file" && + echo modified >file2 && + GIT_EXTERNAL_DIFF=echo git diff +' + +echo "#!$SHELL_PATH" >fake-diff.sh +cat >> fake-diff.sh <<\EOF +cat $2 >> crlfed.txt +EOF +chmod a+x fake-diff.sh + +keep_only_cr () { + tr -dc '\015' +} + +test_expect_success 'external diff with autocrlf = true' ' + git config core.autocrlf true && + GIT_EXTERNAL_DIFF=./fake-diff.sh git diff && + test $(wc -l < crlfed.txt) = $(cat crlfed.txt | keep_only_cr | wc -c) ' test_done diff --git a/t/t4021-format-patch-numbered.sh b/t/t4021-format-patch-numbered.sh index 43d64bbd82..390af2389f 100755 --- a/t/t4021-format-patch-numbered.sh +++ b/t/t4021-format-patch-numbered.sh @@ -45,17 +45,22 @@ test_numbered() { grep "^Subject: \[PATCH 2/2\]" $1 } -test_expect_success 'Default: no numbered' ' +test_expect_success 'single patch defaults to no numbers' ' + git format-patch --stdout HEAD~1 >patch0.single && + test_single_no_numbered patch0.single +' + +test_expect_success 'multiple patch defaults to numbered' ' - git format-patch --stdout HEAD~2 >patch0 && - test_no_numbered patch0 + git format-patch --stdout HEAD~2 >patch0.multiple && + test_numbered patch0.multiple ' test_expect_success 'Use --numbered' ' - git format-patch --numbered --stdout HEAD~2 >patch1 && - test_numbered patch1 + git format-patch --numbered --stdout HEAD~1 >patch1 && + test_single_numbered patch1 ' diff --git a/t/t4022-diff-rewrite.sh b/t/t4022-diff-rewrite.sh index bf996fc414..2a537a21e8 100755 --- a/t/t4022-diff-rewrite.sh +++ b/t/t4022-diff-rewrite.sh @@ -6,12 +6,12 @@ test_description='rewrite diff' test_expect_success setup ' - cat ../../COPYING >test && + cat "$TEST_DIRECTORY"/../COPYING >test && git add test && tr \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \ "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" \ - <../../COPYING >test + <"$TEST_DIRECTORY"/../COPYING >test ' diff --git a/t/t4023-diff-rename-typechange.sh b/t/t4023-diff-rename-typechange.sh index 4dbfc6e8b7..297ddb5a25 100755 --- a/t/t4023-diff-rename-typechange.sh +++ b/t/t4023-diff-rename-typechange.sh @@ -7,21 +7,21 @@ test_description='typechange rename detection' test_expect_success setup ' rm -f foo bar && - cat ../../COPYING >foo && + cat "$TEST_DIRECTORY"/../COPYING >foo && ln -s linklink bar && git add foo bar && git commit -a -m Initial && git tag one && rm -f foo bar && - cat ../../COPYING >bar && + cat "$TEST_DIRECTORY"/../COPYING >bar && ln -s linklink foo && git add foo bar && git commit -a -m Second && git tag two && rm -f foo bar && - cat ../../COPYING >foo && + cat "$TEST_DIRECTORY"/../COPYING >foo && git add foo && git commit -a -m Third && git tag three && @@ -35,15 +35,15 @@ test_expect_success setup ' # This is purely for sanity check rm -f foo bar && - cat ../../COPYING >foo && - cat ../../Makefile >bar && + cat "$TEST_DIRECTORY"/../COPYING >foo && + cat "$TEST_DIRECTORY"/../Makefile >bar && git add foo bar && git commit -a -m Fifth && git tag five && rm -f foo bar && - cat ../../Makefile >foo && - cat ../../COPYING >bar && + cat "$TEST_DIRECTORY"/../Makefile >foo && + cat "$TEST_DIRECTORY"/../COPYING >bar && git add foo bar && git commit -a -m Sixth && git tag six diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh index ba6679c6e4..1c2edebb09 100755 --- a/t/t4027-diff-submodule.sh +++ b/t/t4027-diff-submodule.sh @@ -3,7 +3,7 @@ test_description='difference in submodules' . ./test-lib.sh -. ../diff-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh _z40=0000000000000000000000000000000000000000 test_expect_success setup ' diff --git a/t/t4029-diff-trailing-space.sh b/t/t4029-diff-trailing-space.sh new file mode 100755 index 0000000000..9ddbbcde57 --- /dev/null +++ b/t/t4029-diff-trailing-space.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Copyright (c) Jim Meyering +# +test_description='diff honors config option, diff.suppressBlankEmpty' + +. ./test-lib.sh + +cat <<\EOF > exp || +diff --git a/f b/f +index 5f6a263..8cb8bae 100644 +--- a/f ++++ b/f +@@ -1,2 +1,2 @@ + +-x ++y +EOF +exit 1 + +test_expect_success \ + "$test_description" \ + 'printf "\nx\n" > f && + git add f && + git commit -q -m. f && + printf "\ny\n" > f && + git config --bool diff.suppressBlankEmpty true && + git diff f > actual && + test_cmp exp actual && + perl -i.bak -p -e "s/^\$/ /" exp && + git config --bool diff.suppressBlankEmpty false && + git diff f > actual && + test_cmp exp actual && + git config --bool --unset diff.suppressBlankEmpty && + git diff f > actual && + test_cmp exp actual + ' + +test_done diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh new file mode 100755 index 0000000000..a3f0897a52 --- /dev/null +++ b/t/t4030-diff-textconv.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +test_description='diff.*.textconv tests' +. ./test-lib.sh + +find_diff() { + sed '1,/^index /d' | sed '/^-- $/,$d' +} + +cat >expect.binary <<'EOF' +Binary files a/file and b/file differ +EOF + +cat >expect.text <<'EOF' +--- a/file ++++ b/file +@@ -1 +1,2 @@ + 0 ++1 +EOF + +cat >hexdump <<'EOF' +#!/bin/sh +perl -e '$/ = undef; $_ = <>; s/./ord($&)/ge; print $_' < "$1" +EOF +chmod +x hexdump + +test_expect_success 'setup binary file with history' ' + printf "\\0\\n" >file && + git add file && + git commit -m one && + printf "\\01\\n" >>file && + git add file && + git commit -m two +' + +test_expect_success 'file is considered binary by porcelain' ' + git diff HEAD^ HEAD >diff && + find_diff <diff >actual && + test_cmp expect.binary actual +' + +test_expect_success 'file is considered binary by plumbing' ' + git diff-tree -p HEAD^ HEAD >diff && + find_diff <diff >actual && + test_cmp expect.binary actual +' + +test_expect_success 'setup textconv filters' ' + echo file diff=foo >.gitattributes && + git config diff.foo.textconv "$PWD"/hexdump && + git config diff.fail.textconv false +' + +test_expect_success 'diff produces text' ' + git diff HEAD^ HEAD >diff && + find_diff <diff >actual && + test_cmp expect.text actual +' + +test_expect_success 'diff-tree produces binary' ' + git diff-tree -p HEAD^ HEAD >diff && + find_diff <diff >actual && + test_cmp expect.binary actual +' + +test_expect_success 'log produces text' ' + git log -1 -p >log && + find_diff <log >actual && + test_cmp expect.text actual +' + +test_expect_success 'format-patch produces binary' ' + git format-patch --no-binary --stdout HEAD^ >patch && + find_diff <patch >actual && + test_cmp expect.binary actual +' + +test_expect_success 'status -v produces text' ' + git reset --soft HEAD^ && + git status -v >diff && + find_diff <diff >actual && + test_cmp expect.text actual && + git reset --soft HEAD@{1} +' + +cat >expect.stat <<'EOF' + file | Bin 2 -> 4 bytes + 1 files changed, 0 insertions(+), 0 deletions(-) +EOF +test_expect_success 'diffstat does not run textconv' ' + echo file diff=fail >.gitattributes && + git diff --stat HEAD^ HEAD >actual && + test_cmp expect.stat actual +' +# restore working setup +echo file diff=foo >.gitattributes + +cat >expect.typechange <<'EOF' +--- a/file ++++ /dev/null +@@ -1,2 +0,0 @@ +-0 +-1 +diff --git a/file b/file +new file mode 120000 +index 0000000..67be421 +--- /dev/null ++++ b/file +@@ -0,0 +1 @@ ++frotz +\ No newline at end of file +EOF +# make a symlink the hard way that works on symlink-challenged file systems +test_expect_success 'textconv does not act on symlinks' ' + printf frotz > file && + git add file && + git ls-files -s | sed -e s/100644/120000/ | + git update-index --index-info && + git commit -m typechange && + git show >diff && + find_diff <diff >actual && + test_cmp expect.typechange actual +' + +test_done diff --git a/t/t4031-diff-rewrite-binary.sh b/t/t4031-diff-rewrite-binary.sh new file mode 100755 index 0000000000..a894c60622 --- /dev/null +++ b/t/t4031-diff-rewrite-binary.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +test_description='rewrite diff on binary file' + +. ./test-lib.sh + +# We must be large enough to meet the MINIMUM_BREAK_SIZE +# requirement. +make_file() { + # common first line to help identify rewrite versus regular diff + printf "=\n" >file + for i in 1 2 3 4 5 6 7 8 9 10 + do + for j in 1 2 3 4 5 6 7 8 9 + do + for k in 1 2 3 4 5 + do + printf "$1\n" + done + done + done >>file +} + +test_expect_success 'create binary file with changes' ' + make_file "\\0" && + git add file && + make_file "\\01" +' + +test_expect_success 'vanilla diff is binary' ' + git diff >diff && + grep "Binary files a/file and b/file differ" diff +' + +test_expect_success 'rewrite diff is binary' ' + git diff -B >diff && + grep "dissimilarity index" diff && + grep "Binary files a/file and b/file differ" diff +' + +test_expect_success 'rewrite diff can show binary patch' ' + git diff -B --binary >diff && + grep "dissimilarity index" diff && + grep "GIT binary patch" diff +' + +{ + echo "#!$SHELL_PATH" + cat <<'EOF' +perl -e '$/ = undef; $_ = <>; s/./ord($&)/ge; print $_' < "$1" +EOF +} >dump +chmod +x dump + +test_expect_success 'setup textconv' ' + echo file diff=foo >.gitattributes && + git config diff.foo.textconv "$PWD"/dump +' + +test_expect_success 'rewrite diff respects textconv' ' + git diff -B >diff && + grep "dissimilarity index" diff && + grep "^-61" diff && + grep "^-0" diff +' + +test_done diff --git a/t/t4032-diff-inter-hunk-context.sh b/t/t4032-diff-inter-hunk-context.sh new file mode 100755 index 0000000000..e4e3e28fc7 --- /dev/null +++ b/t/t4032-diff-inter-hunk-context.sh @@ -0,0 +1,92 @@ +#!/bin/sh + +test_description='diff hunk fusing' + +. ./test-lib.sh + +f() { + echo $1 + i=1 + while test $i -le $2 + do + echo $i + i=$(expr $i + 1) + done + echo $3 +} + +t() { + case $# in + 4) hunks=$4; cmd="diff -U$3";; + 5) hunks=$5; cmd="diff -U$3 --inter-hunk-context=$4";; + esac + label="$cmd, $1 common $2" + file=f$1 + expected=expected.$file.$3.$hunks + + if ! test -f $file + then + f A $1 B >$file + git add $file + git commit -q -m. $file + f X $1 Y >$file + fi + + test_expect_success "$label: count hunks ($hunks)" " + test $(git $cmd $file | grep '^@@ ' | wc -l) = $hunks + " + + test -f $expected && + test_expect_success "$label: check output" " + git $cmd $file | grep -v '^index ' >actual && + test_cmp $expected actual + " +} + +cat <<EOF >expected.f1.0.1 || exit 1 +diff --git a/f1 b/f1 +--- a/f1 ++++ b/f1 +@@ -1,3 +1,3 @@ +-A ++X + 1 +-B ++Y +EOF + +cat <<EOF >expected.f1.0.2 || exit 1 +diff --git a/f1 b/f1 +--- a/f1 ++++ b/f1 +@@ -1 +1 @@ +-A ++X +@@ -3 +3 @@ A +-B ++Y +EOF + +# common lines ctx intrctx hunks +t 1 line 0 2 +t 1 line 0 0 2 +t 1 line 0 1 1 +t 1 line 0 2 1 +t 1 line 1 1 + +t 2 lines 0 2 +t 2 lines 0 0 2 +t 2 lines 0 1 2 +t 2 lines 0 2 1 +t 2 lines 1 1 + +t 3 lines 1 2 +t 3 lines 1 0 2 +t 3 lines 1 1 1 +t 3 lines 1 2 1 + +t 9 lines 3 2 +t 9 lines 3 2 2 +t 9 lines 3 3 1 + +test_done diff --git a/t/t4033-diff-patience.sh b/t/t4033-diff-patience.sh new file mode 100755 index 0000000000..1eb14989df --- /dev/null +++ b/t/t4033-diff-patience.sh @@ -0,0 +1,168 @@ +#!/bin/sh + +test_description='patience diff algorithm' + +. ./test-lib.sh + +cat >file1 <<\EOF +#include <stdio.h> + +// Frobs foo heartily +int frobnitz(int foo) +{ + int i; + for(i = 0; i < 10; i++) + { + printf("Your answer is: "); + printf("%d\n", foo); + } +} + +int fact(int n) +{ + if(n > 1) + { + return fact(n-1) * n; + } + return 1; +} + +int main(int argc, char **argv) +{ + frobnitz(fact(10)); +} +EOF + +cat >file2 <<\EOF +#include <stdio.h> + +int fib(int n) +{ + if(n > 2) + { + return fib(n-1) + fib(n-2); + } + return 1; +} + +// Frobs foo heartily +int frobnitz(int foo) +{ + int i; + for(i = 0; i < 10; i++) + { + printf("%d\n", foo); + } +} + +int main(int argc, char **argv) +{ + frobnitz(fib(10)); +} +EOF + +cat >expect <<\EOF +diff --git a/file1 b/file2 +index 6faa5a3..e3af329 100644 +--- a/file1 ++++ b/file2 +@@ -1,26 +1,25 @@ + #include <stdio.h> + ++int fib(int n) ++{ ++ if(n > 2) ++ { ++ return fib(n-1) + fib(n-2); ++ } ++ return 1; ++} ++ + // Frobs foo heartily + int frobnitz(int foo) + { + int i; + for(i = 0; i < 10; i++) + { +- printf("Your answer is: "); + printf("%d\n", foo); + } + } + +-int fact(int n) +-{ +- if(n > 1) +- { +- return fact(n-1) * n; +- } +- return 1; +-} +- + int main(int argc, char **argv) + { +- frobnitz(fact(10)); ++ frobnitz(fib(10)); + } +EOF + +test_expect_success 'patience diff' ' + + test_must_fail git diff --no-index --patience file1 file2 > output && + test_cmp expect output + +' + +test_expect_success 'patience diff output is valid' ' + + mv file2 expect && + git apply < output && + test_cmp expect file2 + +' + +cat >uniq1 <<\EOF +1 +2 +3 +4 +5 +6 +EOF + +cat >uniq2 <<\EOF +a +b +c +d +e +f +EOF + +cat >expect <<\EOF +diff --git a/uniq1 b/uniq2 +index b414108..0fdf397 100644 +--- a/uniq1 ++++ b/uniq2 +@@ -1,6 +1,6 @@ +-1 +-2 +-3 +-4 +-5 +-6 ++a ++b ++c ++d ++e ++f +EOF + +test_expect_success 'completely different files' ' + + test_must_fail git diff --no-index --patience uniq1 uniq2 > output && + test_cmp expect output + +' + +test_done diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh new file mode 100755 index 0000000000..4508effcaa --- /dev/null +++ b/t/t4034-diff-words.sh @@ -0,0 +1,200 @@ +#!/bin/sh + +test_description='word diff colors' + +. ./test-lib.sh + +test_expect_success setup ' + + git config diff.color.old red + git config diff.color.new green + +' + +decrypt_color () { + sed \ + -e 's/.\[1m/<WHITE>/g' \ + -e 's/.\[31m/<RED>/g' \ + -e 's/.\[32m/<GREEN>/g' \ + -e 's/.\[36m/<BROWN>/g' \ + -e 's/.\[m/<RESET>/g' +} + +word_diff () { + test_must_fail git diff --no-index "$@" pre post > output && + decrypt_color < output > output.decrypted && + test_cmp expect output.decrypted +} + +cat > pre <<\EOF +h(4) + +a = b + c +EOF + +cat > post <<\EOF +h(4),hh[44] + +a = b + c + +aa = a + +aeff = aeff * ( aaa ) +EOF + +cat > expect <<\EOF +<WHITE>diff --git a/pre b/post<RESET> +<WHITE>index 330b04f..5ed8eff 100644<RESET> +<WHITE>--- a/pre<RESET> +<WHITE>+++ b/post<RESET> +<BROWN>@@ -1,3 +1,7 @@<RESET> +<RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET> +<RESET> +a = b + c<RESET> + +<GREEN>aa = a<RESET> + +<GREEN>aeff = aeff * ( aaa )<RESET> +EOF + +test_expect_success 'word diff with runs of whitespace' ' + + word_diff --color-words + +' + +cat > expect <<\EOF +<WHITE>diff --git a/pre b/post<RESET> +<WHITE>index 330b04f..5ed8eff 100644<RESET> +<WHITE>--- a/pre<RESET> +<WHITE>+++ b/post<RESET> +<BROWN>@@ -1,3 +1,7 @@<RESET> +h(4),<GREEN>hh<RESET>[44] +<RESET> +a = b + c<RESET> + +<GREEN>aa = a<RESET> + +<GREEN>aeff = aeff * ( aaa<RESET> ) +EOF +cp expect expect.letter-runs-are-words + +test_expect_success 'word diff with a regular expression' ' + + word_diff --color-words="[a-z]+" + +' + +test_expect_success 'set a diff driver' ' + git config diff.testdriver.wordRegex "[^[:space:]]" && + cat <<EOF > .gitattributes +pre diff=testdriver +post diff=testdriver +EOF +' + +test_expect_success 'option overrides .gitattributes' ' + + word_diff --color-words="[a-z]+" + +' + +cat > expect <<\EOF +<WHITE>diff --git a/pre b/post<RESET> +<WHITE>index 330b04f..5ed8eff 100644<RESET> +<WHITE>--- a/pre<RESET> +<WHITE>+++ b/post<RESET> +<BROWN>@@ -1,3 +1,7 @@<RESET> +h(4)<GREEN>,hh[44]<RESET> +<RESET> +a = b + c<RESET> + +<GREEN>aa = a<RESET> + +<GREEN>aeff = aeff * ( aaa )<RESET> +EOF +cp expect expect.non-whitespace-is-word + +test_expect_success 'use regex supplied by driver' ' + + word_diff --color-words + +' + +test_expect_success 'set diff.wordRegex option' ' + git config diff.wordRegex "[[:alnum:]]+" +' + +cp expect.letter-runs-are-words expect + +test_expect_success 'command-line overrides config' ' + word_diff --color-words="[a-z]+" +' + +cp expect.non-whitespace-is-word expect + +test_expect_success '.gitattributes override config' ' + word_diff --color-words +' + +test_expect_success 'remove diff driver regex' ' + git config --unset diff.testdriver.wordRegex +' + +cat > expect <<\EOF +<WHITE>diff --git a/pre b/post<RESET> +<WHITE>index 330b04f..5ed8eff 100644<RESET> +<WHITE>--- a/pre<RESET> +<WHITE>+++ b/post<RESET> +<BROWN>@@ -1,3 +1,7 @@<RESET> +h(4),<GREEN>hh[44<RESET>] +<RESET> +a = b + c<RESET> + +<GREEN>aa = a<RESET> + +<GREEN>aeff = aeff * ( aaa<RESET> ) +EOF + +test_expect_success 'use configured regex' ' + word_diff --color-words +' + +echo 'aaa (aaa)' > pre +echo 'aaa (aaa) aaa' > post + +cat > expect <<\EOF +<WHITE>diff --git a/pre b/post<RESET> +<WHITE>index c29453b..be22f37 100644<RESET> +<WHITE>--- a/pre<RESET> +<WHITE>+++ b/post<RESET> +<BROWN>@@ -1 +1 @@<RESET> +aaa (aaa) <GREEN>aaa<RESET> +EOF + +test_expect_success 'test parsing words for newline' ' + + word_diff --color-words="a+" + + +' + +echo '(:' > pre +echo '(' > post + +cat > expect <<\EOF +<WHITE>diff --git a/pre b/post<RESET> +<WHITE>index 289cb9d..2d06f37 100644<RESET> +<WHITE>--- a/pre<RESET> +<WHITE>+++ b/post<RESET> +<BROWN>@@ -1 +1 @@<RESET> +(<RED>:<RESET> +EOF + +test_expect_success 'test when words are only removed at the end' ' + + word_diff --color-words=. + +' + +test_done diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index e0c67740a5..9b433de836 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -17,13 +17,13 @@ do test_expect_success "$title" ' git apply --stat --summary \ <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" >current && - test_cmp ../t4100/t-apply-$num.expect current + test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current ' test_expect_success "$title with recount" ' sed -e "$UNC" <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" | git apply --recount --stat --summary >current && - test_cmp ../t4100/t-apply-$num.expect current + test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current ' done <<\EOF rename diff --git a/t/t4101-apply-nonl.sh b/t/t4101-apply-nonl.sh index da8abcf364..e3443d004d 100755 --- a/t/t4101-apply-nonl.sh +++ b/t/t4101-apply-nonl.sh @@ -21,9 +21,10 @@ do do test $i -eq $j && continue cat frotz.$i >frotz - test_expect_success \ - "apply diff between $i and $j" \ - "git apply <../t4101/diff.$i-$j && diff frotz.$j frotz" + test_expect_success "apply diff between $i and $j" ' + git apply <"$TEST_DIRECTORY"/t4101/diff.$i-$j && + test_cmp frotz.$j frotz + ' done done diff --git a/t/t4106-apply-stdin.sh b/t/t4106-apply-stdin.sh new file mode 100755 index 0000000000..72467a1e8e --- /dev/null +++ b/t/t4106-apply-stdin.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +test_description='git apply --numstat - <patch' + +. ./test-lib.sh + +test_expect_success setup ' + echo hello >text && + git add text && + echo goodbye >text && + git diff >patch +' + +test_expect_success 'git apply --numstat - < patch' ' + echo "1 1 text" >expect && + git apply --numstat - <patch >actual && + test_cmp expect actual +' + +test_expect_success 'git apply --numstat - < patch patch' ' + for i in 1 2; do echo "1 1 text"; done >expect && + git apply --numstat - < patch patch >actual && + test_cmp expect actual +' + +test_done diff --git a/t/t4114-apply-typechange.sh b/t/t4114-apply-typechange.sh index 55334927ab..0f185caa44 100755 --- a/t/t4114-apply-typechange.sh +++ b/t/t4114-apply-typechange.sh @@ -25,6 +25,10 @@ test_expect_success 'setup repository and commits' ' git update-index foo && git commit -m "foo back to file" && git branch foo-back-to-file && + printf "\0" > foo && + git update-index foo && + git commit -m "foo becomes binary" && + git branch foo-becomes-binary && rm -f foo && git update-index --remove foo && mkdir foo && @@ -85,6 +89,20 @@ test_expect_success 'symlink becomes file' ' ' test_debug 'cat patch' +test_expect_success 'binary file becomes symlink' ' + git checkout -f foo-becomes-binary && + git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch && + git apply --index < patch + ' +test_debug 'cat patch' + +test_expect_success 'symlink becomes binary file' ' + git checkout -f foo-symlinked-to-bar && + git diff-tree -p --binary HEAD foo-becomes-binary > patch && + git apply --index < patch + ' +test_debug 'cat patch' + test_expect_success 'symlink becomes directory' ' git checkout -f foo-symlinked-to-bar && diff --git a/t/t4129-apply-samemode.sh b/t/t4129-apply-samemode.sh new file mode 100755 index 0000000000..adfcbb5a3b --- /dev/null +++ b/t/t4129-apply-samemode.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +test_description='applying patch with mode bits' + +. ./test-lib.sh + +test_expect_success setup ' + echo original >file && + git add file && + test_tick && + git commit -m initial && + git tag initial && + echo modified >file && + git diff --stat -p >patch-0.txt && + chmod +x file && + git diff --stat -p >patch-1.txt +' + +test_expect_success 'same mode (no index)' ' + git reset --hard && + chmod +x file && + git apply patch-0.txt && + test -x file +' + +test_expect_success 'same mode (with index)' ' + git reset --hard && + chmod +x file && + git add file && + git apply --index patch-0.txt && + test -x file && + git diff --exit-code +' + +test_expect_success 'same mode (index only)' ' + git reset --hard && + chmod +x file && + git add file && + git apply --cached patch-0.txt && + git ls-files -s file | grep "^100755" +' + +test_expect_success 'mode update (no index)' ' + git reset --hard && + git apply patch-1.txt && + test -x file +' + +test_expect_success 'mode update (with index)' ' + git reset --hard && + git apply --index patch-1.txt && + test -x file && + git diff --exit-code +' + +test_expect_success 'mode update (index only)' ' + git reset --hard && + git apply --cached patch-1.txt && + git ls-files -s file | grep "^100755" +' + +test_done diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 1be5fb3f9d..5e65afa0c1 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -165,7 +165,7 @@ test_expect_success 'am --keep really keeps the subject' ' git am --keep patch4 && ! test -d .git/rebase-apply && git cat-file commit HEAD | - grep -q -F "Re: Re: Re: [PATCH 1/5 v2] third" + fgrep "Re: Re: Re: [PATCH 1/5 v2] third" ' test_expect_success 'am -3 falls back to 3-way merge' ' @@ -257,4 +257,37 @@ test_expect_success 'am works from file (absolute path given) in subdirectory' ' test -z "$(git diff second)" ' +test_expect_success 'am --committer-date-is-author-date' ' + git checkout first && + test_tick && + git am --committer-date-is-author-date patch1 && + git cat-file commit HEAD | sed -e "/^$/q" >head1 && + at=$(sed -ne "/^author /s/.*> //p" head1) && + ct=$(sed -ne "/^committer /s/.*> //p" head1) && + test "$at" = "$ct" +' + +test_expect_success 'am without --committer-date-is-author-date' ' + git checkout first && + test_tick && + git am patch1 && + git cat-file commit HEAD | sed -e "/^$/q" >head1 && + at=$(sed -ne "/^author /s/.*> //p" head1) && + ct=$(sed -ne "/^committer /s/.*> //p" head1) && + test "$at" != "$ct" +' + +# This checks for +0000 because TZ is set to UTC and that should +# show up when the current time is used. The date in message is set +# by test_tick that uses -0700 timezone; if this feature does not +# work, we will see that instead of +0000. +test_expect_success 'am --ignore-date' ' + git checkout first && + test_tick && + git am --ignore-date patch1 && + git cat-file commit HEAD | sed -e "/^$/q" >head1 && + at=$(sed -ne "/^author /s/.*> //p" head1) && + echo "$at" | grep "+0000" +' + test_done diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh index 4448aba7e0..2b912d7728 100755 --- a/t/t4151-am-abort.sh +++ b/t/t4151-am-abort.sh @@ -22,7 +22,7 @@ test_expect_success setup ' test_tick && git commit -a -m $i || break done && - git format-patch initial && + git format-patch --no-numbered initial && git checkout -b side initial && echo local change >file-2-expect ' diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 0ab925c4e4..7b976ee36d 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -16,27 +16,31 @@ test_expect_success setup ' test_tick && git commit -m second && - mkdir a && - echo ni >a/two && - git add a/two && + git mv one ichi && test_tick && git commit -m third && - echo san >a/three && - git add a/three && + cp ichi ein && + git add ein && test_tick && git commit -m fourth && - git rm a/three && + mkdir a && + echo ni >a/two && + git add a/two && + test_tick && + git commit -m fifth && + + git rm a/two && test_tick && - git commit -m fifth + git commit -m sixth ' test_expect_success 'diff-filter=A' ' actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) && - expect=$(echo fourth ; echo third ; echo initial) && + expect=$(echo fifth ; echo fourth ; echo third ; echo initial) && test "$actual" = "$expect" || { echo Oops echo "Actual: $actual" @@ -60,7 +64,43 @@ test_expect_success 'diff-filter=M' ' test_expect_success 'diff-filter=D' ' actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) && - expect=$(echo fifth) && + expect=$(echo sixth ; echo third) && + test "$actual" = "$expect" || { + echo Oops + echo "Actual: $actual" + false + } + +' + +test_expect_success 'diff-filter=R' ' + + actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) && + expect=$(echo third) && + test "$actual" = "$expect" || { + echo Oops + echo "Actual: $actual" + false + } + +' + +test_expect_success 'diff-filter=C' ' + + actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) && + expect=$(echo fourth) && + test "$actual" = "$expect" || { + echo Oops + echo "Actual: $actual" + false + } + +' + +test_expect_success 'git log --follow' ' + + actual=$(git log --follow --pretty="format:%s" ichi) && + expect=$(echo third ; echo second ; echo initial) && test "$actual" = "$expect" || { echo Oops echo "Actual: $actual" @@ -72,6 +112,7 @@ test_expect_success 'diff-filter=D' ' test_expect_success 'setup case sensitivity tests' ' echo case >one && test_tick && + git add one git commit -a -m Second ' diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh new file mode 100755 index 0000000000..9a7d1b4466 --- /dev/null +++ b/t/t4203-mailmap.sh @@ -0,0 +1,215 @@ +#!/bin/sh + +test_description='.mailmap configurations' + +. ./test-lib.sh + +test_expect_success setup ' + echo one >one && + git add one && + test_tick && + git commit -m initial && + echo two >>one && + git add one && + git commit --author "nick1 <bugs@company.xx>" -m second +' + +cat >expect <<\EOF +A U Thor (1): + initial + +nick1 (1): + second + +EOF + +test_expect_success 'No mailmap' ' + git shortlog HEAD >actual && + test_cmp expect actual +' + +cat >expect <<\EOF +Repo Guy (1): + initial + +nick1 (1): + second + +EOF + +test_expect_success 'default .mailmap' ' + echo "Repo Guy <author@example.com>" > .mailmap && + git shortlog HEAD >actual && + test_cmp expect actual +' + +# Using a mailmap file in a subdirectory of the repo here, but +# could just as well have been a file outside of the repository +cat >expect <<\EOF +Internal Guy (1): + second + +Repo Guy (1): + initial + +EOF +test_expect_success 'mailmap.file set' ' + mkdir internal_mailmap && + echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap && + git config mailmap.file internal_mailmap/.mailmap && + git shortlog HEAD >actual && + test_cmp expect actual +' + +cat >expect <<\EOF +External Guy (1): + initial + +Internal Guy (1): + second + +EOF +test_expect_success 'mailmap.file override' ' + echo "External Guy <author@example.com>" >> internal_mailmap/.mailmap && + git config mailmap.file internal_mailmap/.mailmap && + git shortlog HEAD >actual && + test_cmp expect actual +' + +cat >expect <<\EOF +Repo Guy (1): + initial + +nick1 (1): + second + +EOF + +test_expect_success 'mailmap.file non-existant' ' + rm internal_mailmap/.mailmap && + rmdir internal_mailmap && + git shortlog HEAD >actual && + test_cmp expect actual +' + +cat >expect <<\EOF +A U Thor (1): + initial + +nick1 (1): + second + +EOF +test_expect_success 'No mailmap files, but configured' ' + rm .mailmap && + git shortlog HEAD >actual && + test_cmp expect actual +' + +# Extended mailmap configurations should give us the following output for shortlog +cat >expect <<\EOF +A U Thor <author@example.com> (1): + initial + +CTO <cto@company.xx> (1): + seventh + +Other Author <other@author.xx> (2): + third + fourth + +Santa Claus <santa.claus@northpole.xx> (2): + fifth + sixth + +Some Dude <some@dude.xx> (1): + second + +EOF + +test_expect_success 'Shortlog output (complex mapping)' ' + echo three >>one && + git add one && + test_tick && + git commit --author "nick2 <bugs@company.xx>" -m third && + + echo four >>one && + git add one && + test_tick && + git commit --author "nick2 <nick2@company.xx>" -m fourth && + + echo five >>one && + git add one && + test_tick && + git commit --author "santa <me@company.xx>" -m fifth && + + echo six >>one && + git add one && + test_tick && + git commit --author "claus <me@company.xx>" -m sixth && + + echo seven >>one && + git add one && + test_tick && + git commit --author "CTO <cto@coompany.xx>" -m seventh && + + mkdir internal_mailmap && + echo "Committed <committer@example.com>" > internal_mailmap/.mailmap && + echo "<cto@company.xx> <cto@coompany.xx>" >> internal_mailmap/.mailmap && + echo "Some Dude <some@dude.xx> nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap && + echo "Other Author <other@author.xx> nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap && + echo "Other Author <other@author.xx> <nick2@company.xx>" >> internal_mailmap/.mailmap && + echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap && + echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap && + + git shortlog -e HEAD >actual && + test_cmp expect actual + +' + +# git log with --pretty format which uses the name and email mailmap placemarkers +cat >expect <<\EOF +Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx> +Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> + +Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx> +Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> + +Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx> +Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> + +Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx> +Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> + +Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx> +Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> + +Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx> +Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> + +Author A U Thor <author@example.com> maps to A U Thor <author@example.com> +Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> +EOF + +test_expect_success 'Log output (complex mapping)' ' + git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual && + test_cmp expect actual +' + +# git blame +cat >expect <<\EOF +^3a2fdcb (A U Thor 2005-04-07 15:13:13 -0700 1) one +7de6f99b (Some Dude 2005-04-07 15:13:13 -0700 2) two +5815879d (Other Author 2005-04-07 15:14:13 -0700 3) three +ff859d96 (Other Author 2005-04-07 15:15:13 -0700 4) four +5ab6d4fa (Santa Claus 2005-04-07 15:16:13 -0700 5) five +38a42d8b (Santa Claus 2005-04-07 15:17:13 -0700 6) six +8ddc0386 (CTO 2005-04-07 15:18:13 -0700 7) seven +EOF + +test_expect_success 'Blame output (complex mapping)' ' + git blame one >actual && + test_cmp expect actual +' + +test_done diff --git a/t/t4252-am-options.sh b/t/t4252-am-options.sh new file mode 100755 index 0000000000..f603c1b133 --- /dev/null +++ b/t/t4252-am-options.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +test_description='git am with options and not losing them' +. ./test-lib.sh + +tm="$TEST_DIRECTORY/t4252" + +test_expect_success setup ' + cp "$tm/file-1-0" file-1 && + cp "$tm/file-2-0" file-2 && + git add file-1 file-2 && + test_tick && + git commit -m initial && + git tag initial +' + +test_expect_success 'interrupted am --whitespace=fix' ' + rm -rf .git/rebase-apply && + git reset --hard initial && + test_must_fail git am --whitespace=fix "$tm"/am-test-1-? && + git am --skip && + grep 3 file-1 && + grep "^Six$" file-2 +' + +test_expect_success 'interrupted am -C1' ' + rm -rf .git/rebase-apply && + git reset --hard initial && + test_must_fail git am -C1 "$tm"/am-test-2-? && + git am --skip && + grep 3 file-1 && + grep "^Three$" file-2 +' + +test_expect_success 'interrupted am -p2' ' + rm -rf .git/rebase-apply && + git reset --hard initial && + test_must_fail git am -p2 "$tm"/am-test-3-? && + git am --skip && + grep 3 file-1 && + grep "^Three$" file-2 +' + +test_expect_success 'interrupted am -C1 -p2' ' + rm -rf .git/rebase-apply && + git reset --hard initial && + test_must_fail git am -p2 -C1 "$tm"/am-test-4-? && + git am --skip && + grep 3 file-1 && + grep "^Three$" file-2 +' + +test_expect_success 'interrupted am --directory="frotz nitfol"' ' + rm -rf .git/rebase-apply && + git reset --hard initial && + test_must_fail git am --directory="frotz nitfol" "$tm"/am-test-5-? && + git am --skip && + grep One "frotz nitfol/file-5" +' + +test_expect_success 'apply to a funny path' ' + with_sq="with'\''sq" + rm -fr .git/rebase-apply && + git reset --hard initial && + git am --directory="$with_sq" "$tm"/am-test-5-2 && + test -f "$with_sq/file-5" +' + +test_expect_success 'am --reject' ' + rm -rf .git/rebase-apply && + git reset --hard initial && + test_must_fail git am --reject "$tm"/am-test-6-1 && + grep "@@ -1,3 +1,3 @@" file-2.rej && + test_must_fail git diff-files --exit-code --quiet file-2 && + grep "[-]-reject" .git/rebase-apply/apply-opt +' + +test_done diff --git a/t/t4252/am-test-1-1 b/t/t4252/am-test-1-1 new file mode 100644 index 0000000000..b0c09dc965 --- /dev/null +++ b/t/t4252/am-test-1-1 @@ -0,0 +1,19 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Three + +Application of this should be rejected because the first line in the +context does not match. + +diff --git i/file-1 w/file-1 +index 06e567b..10f8342 100644 +--- i/file-1 ++++ w/file-1 +@@ -1,6 +1,6 @@ + One + 2 +-3 ++Three + 4 + 5 + 6 diff --git a/t/t4252/am-test-1-2 b/t/t4252/am-test-1-2 new file mode 100644 index 0000000000..1b874ae115 --- /dev/null +++ b/t/t4252/am-test-1-2 @@ -0,0 +1,21 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Six + +Applying this patch with --whitespace=fix should lose +the trailing whitespace after "Six". + +diff --git i/file-2 w/file-2 +index 06e567b..b6f3a16 100644 +--- i/file-2 ++++ w/file-2 +@@ -1,7 +1,7 @@ + 1 + 2 +-3 ++Three + 4 + 5 +-6 ++Six + 7 diff --git a/t/t4252/am-test-2-1 b/t/t4252/am-test-2-1 new file mode 100644 index 0000000000..feda94a0cc --- /dev/null +++ b/t/t4252/am-test-2-1 @@ -0,0 +1,19 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Three + +Application of this should be rejected even with -C1 because the +preimage line in the context does not match. + +diff --git i/file-1 w/file-1 +index 06e567b..10f8342 100644 +--- i/file-1 ++++ w/file-1 +@@ -1,6 +1,6 @@ + 1 + 2 +-Tres ++Three + 4 + 5 + 6 diff --git a/t/t4252/am-test-2-2 b/t/t4252/am-test-2-2 new file mode 100644 index 0000000000..2ac6600976 --- /dev/null +++ b/t/t4252/am-test-2-2 @@ -0,0 +1,21 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Six + +Applying this patch with -C1 should be successful even though +the first line in the context does not match. + +diff --git i/file-2 w/file-2 +index 06e567b..b6f3a16 100644 +--- i/file-2 ++++ w/file-2 +@@ -1,7 +1,7 @@ + One + 2 +-3 ++Three + 4 + 5 +-6 ++Six + 7 diff --git a/t/t4252/am-test-3-1 b/t/t4252/am-test-3-1 new file mode 100644 index 0000000000..608e5abba4 --- /dev/null +++ b/t/t4252/am-test-3-1 @@ -0,0 +1,19 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Three + +Application of this should be rejected even with -p2 because the +preimage line in the context does not match. + +diff --git i/junk/file-1 w/junk/file-1 +index 06e567b..10f8342 100644 +--- i/junk/file-1 ++++ w/junk/file-1 +@@ -1,6 +1,6 @@ + 1 + 2 +-Tres ++Three + 4 + 5 + 6 diff --git a/t/t4252/am-test-3-2 b/t/t4252/am-test-3-2 new file mode 100644 index 0000000000..0081b96f2a --- /dev/null +++ b/t/t4252/am-test-3-2 @@ -0,0 +1,21 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Six + +Applying this patch with -p2 should be successful even though +the patch is against a wrong level. + +diff --git i/junk/file-2 w/junk/file-2 +index 06e567b..b6f3a16 100644 +--- i/junk/file-2 ++++ w/junk/file-2 +@@ -1,7 +1,7 @@ + 1 + 2 +-3 ++Three + 4 + 5 +-6 ++Six + 7 diff --git a/t/t4252/am-test-4-1 b/t/t4252/am-test-4-1 new file mode 100644 index 0000000000..e48cd6cbde --- /dev/null +++ b/t/t4252/am-test-4-1 @@ -0,0 +1,19 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Three + +Application of this should be rejected even with -C1 -p2 because +the preimage line in the context does not match. + +diff --git i/junk/file-1 w/junk/file-1 +index 06e567b..10f8342 100644 +--- i/junk/file-1 ++++ w/junk/file-1 +@@ -1,6 +1,6 @@ + 1 + 2 +-Tres ++Three + 4 + 5 + 6 diff --git a/t/t4252/am-test-4-2 b/t/t4252/am-test-4-2 new file mode 100644 index 0000000000..0e69bfa55b --- /dev/null +++ b/t/t4252/am-test-4-2 @@ -0,0 +1,22 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Six + +Applying this patch with -C1 -p2 should be successful even though +the patch is against a wrong level and the first context line does +not match. + +diff --git i/junk/file-2 w/junk/file-2 +index 06e567b..b6f3a16 100644 +--- i/junk/file-2 ++++ w/junk/file-2 +@@ -1,7 +1,7 @@ + One + 2 +-3 ++Three + 4 + 5 +-6 ++Six + 7 diff --git a/t/t4252/am-test-5-1 b/t/t4252/am-test-5-1 new file mode 100644 index 0000000000..da7bf29cbe --- /dev/null +++ b/t/t4252/am-test-5-1 @@ -0,0 +1,20 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Six + +Applying this patch with --directory='frotz nitfol' should fail + +diff --git i/junk/file-2 w/junk/file-2 +index 06e567b..b6f3a16 100644 +--- i/junk/file-2 ++++ w/junk/file-2 +@@ -1,7 +1,7 @@ + One + 2 +-3 ++Three + 4 + 5 +-6 ++Six + 7 diff --git a/t/t4252/am-test-5-2 b/t/t4252/am-test-5-2 new file mode 100644 index 0000000000..373025bcf6 --- /dev/null +++ b/t/t4252/am-test-5-2 @@ -0,0 +1,15 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Six + +Applying this patch with --directory='frotz nitfol' should succeed + +diff --git i/file-5 w/file-5 +new file mode 100644 +index 000000..1d6ed9f +--- /dev/null ++++ w/file-5 +@@ -0,0 +1,3 @@ ++One ++two ++three diff --git a/t/t4252/am-test-6-1 b/t/t4252/am-test-6-1 new file mode 100644 index 0000000000..a8859e9b8f --- /dev/null +++ b/t/t4252/am-test-6-1 @@ -0,0 +1,21 @@ +From: A U Thor <au.thor@example.com> +Date: Thu Dec 4 16:00:00 2008 -0800 +Subject: Huh + +Should fail and leave rejects + +diff --git i/file-2 w/file-2 +index 06e567b..b6f3a16 100644 +--- i/file-2 ++++ w/file-2 +@@ -1,3 +1,3 @@ +-0 ++One + 2 + 3 +@@ -4,4 +4,4 @@ + 4 + 5 +-6 ++Six + 7 diff --git a/t/t4252/file-1-0 b/t/t4252/file-1-0 new file mode 100644 index 0000000000..06e567b11d --- /dev/null +++ b/t/t4252/file-1-0 @@ -0,0 +1,7 @@ +1 +2 +3 +4 +5 +6 +7 diff --git a/t/t4252/file-2-0 b/t/t4252/file-2-0 new file mode 100644 index 0000000000..06e567b11d --- /dev/null +++ b/t/t4252/file-2-0 @@ -0,0 +1,7 @@ +1 +2 +3 +4 +5 +6 +7 diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 198e3503d5..e70ea94a13 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -8,27 +8,50 @@ 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. "$TEST_DIRECTORY"/t5100/sample.mbox >last && last=`cat last` && echo total is $last && - test `cat last` = 11' + test `cat last` = 13' for mail in `echo 00*` do - test_expect_success "mailinfo $mail" \ - "git mailinfo -u msg$mail patch$mail <$mail >info$mail && + test_expect_success "mailinfo $mail" ' + git mailinfo -u msg$mail patch$mail <$mail >info$mail && echo msg && - diff ../t5100/msg$mail msg$mail && + test_cmp "$TEST_DIRECTORY"/t5100/msg$mail msg$mail && echo patch && - diff ../t5100/patch$mail patch$mail && + test_cmp "$TEST_DIRECTORY"/t5100/patch$mail patch$mail && echo info && - diff ../t5100/info$mail info$mail" + test_cmp "$TEST_DIRECTORY"/t5100/info$mail info$mail + ' +done + + +test_expect_success 'split box with rfc2047 samples' \ + 'mkdir rfc2047 && + git mailsplit -orfc2047 "$TEST_DIRECTORY"/t5100/rfc2047-samples.mbox \ + >rfc2047/last && + last=`cat rfc2047/last` && + echo total is $last && + test `cat rfc2047/last` = 11' + +for mail in `echo rfc2047/00*` +do + test_expect_success "mailinfo $mail" ' + git mailinfo -u $mail-msg $mail-patch <$mail >$mail-info && + echo msg && + test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-msg && + echo patch && + test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-patch && + echo info && + test_cmp "$TEST_DIRECTORY"/t5100/rfc2047-info-$(basename $mail) $mail-info + ' done test_expect_success 'respect NULs' ' - git mailsplit -d3 -o. ../t5100/nul-plain && - cmp ../t5100/nul-plain 001 && + git mailsplit -d3 -o. "$TEST_DIRECTORY"/t5100/nul-plain && + test_cmp "$TEST_DIRECTORY"/t5100/nul-plain 001 && (cat 001 | git mailinfo msg patch) && test 4 = $(wc -l < patch) @@ -36,10 +59,10 @@ test_expect_success 'respect NULs' ' test_expect_success 'Preserve NULs out of MIME encoded message' ' - git mailsplit -d5 -o. ../t5100/nul-b64.in && - cmp ../t5100/nul-b64.in 00001 && + git mailsplit -d5 -o. "$TEST_DIRECTORY"/t5100/nul-b64.in && + test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.in 00001 && git mailinfo msg patch <00001 && - cmp ../t5100/nul-b64.expect patch + test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.expect patch ' diff --git a/t/t5100/empty b/t/t5100/empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/t/t5100/empty diff --git a/t/t5100/info0001 b/t/t5100/info0001 index 8c052777e0..f951538acc 100644 --- a/t/t5100/info0001 +++ b/t/t5100/info0001 @@ -1,4 +1,4 @@ -Author: A U Thor +Author: A (zzz) U Thor (Comment) Email: a.u.thor@example.com Subject: a commit. Date: Fri, 9 Jun 2006 00:44:16 -0700 diff --git a/t/t5100/info0012 b/t/t5100/info0012 new file mode 100644 index 0000000000..ac1216ff75 --- /dev/null +++ b/t/t5100/info0012 @@ -0,0 +1,5 @@ +Author: Dmitriy Blinov +Email: bda@mnsspb.ru +Subject: Изменён список пакетов необходимых для сборки +Date: Wed, 12 Nov 2008 17:54:41 +0300 + diff --git a/t/t5100/info0013 b/t/t5100/info0013 new file mode 100644 index 0000000000..bbe049e20e --- /dev/null +++ b/t/t5100/info0013 @@ -0,0 +1,5 @@ +Author: A U Thor +Email: a.u.thor@example.com +Subject: a patch +Date: Fri, 9 Jun 2006 00:44:16 -0700 + diff --git a/t/t5100/msg0012 b/t/t5100/msg0012 new file mode 100644 index 0000000000..1dc2bf7f7f --- /dev/null +++ b/t/t5100/msg0012 @@ -0,0 +1,7 @@ +textlive-* исправлены на texlive-* +docutils заменён на python-docutils + +Действительно, оказалось, что rest2web вытягивает за собой +python-docutils. В то время как сам rest2web не нужен. + +Signed-off-by: Dmitriy Blinov <bda@mnsspb.ru> diff --git a/t/t5100/msg0013 b/t/t5100/msg0013 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/t/t5100/msg0013 diff --git a/t/t5100/patch0012 b/t/t5100/patch0012 new file mode 100644 index 0000000000..36a0b68161 --- /dev/null +++ b/t/t5100/patch0012 @@ -0,0 +1,30 @@ +--- + howto/build_navy.txt | 6 +++--- + 1 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/howto/build_navy.txt b/howto/build_navy.txt +index 3fd3afb..0ee807e 100644 +--- a/howto/build_navy.txt ++++ b/howto/build_navy.txt +@@ -119,8 +119,8 @@ + - libxv-dev + - libusplash-dev + - latex-make +- - textlive-lang-cyrillic +- - textlive-latex-extra ++ - texlive-lang-cyrillic ++ - texlive-latex-extra + - dia + - python-pyrex + - libtool +@@ -128,7 +128,7 @@ + - sox + - cython + - imagemagick +- - docutils ++ - python-docutils + + #. на машине dinar: добавить свой открытый ssh-ключ в authorized_keys2 пользователя ddev + #. на своей машине: отредактировать /etc/sudoers (команда ``visudo``) примерно следующим образом:: +-- +1.5.6.5 diff --git a/t/t5100/patch0013 b/t/t5100/patch0013 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/t/t5100/patch0013 diff --git a/t/t5100/rfc2047-info-0001 b/t/t5100/rfc2047-info-0001 new file mode 100644 index 0000000000..0a383b07e3 --- /dev/null +++ b/t/t5100/rfc2047-info-0001 @@ -0,0 +1,4 @@ +Author: Keith Moore +Email: moore@cs.utk.edu +Subject: If you can read this you understand the example. + diff --git a/t/t5100/rfc2047-info-0002 b/t/t5100/rfc2047-info-0002 new file mode 100644 index 0000000000..881be75d6f --- /dev/null +++ b/t/t5100/rfc2047-info-0002 @@ -0,0 +1,4 @@ +Author: Olle Järnefors +Email: ojarnef@admin.kth.se +Subject: Time for ISO 10646? + diff --git a/t/t5100/rfc2047-info-0003 b/t/t5100/rfc2047-info-0003 new file mode 100644 index 0000000000..d0f789177c --- /dev/null +++ b/t/t5100/rfc2047-info-0003 @@ -0,0 +1,4 @@ +Author: Patrik Fältström +Email: paf@nada.kth.se +Subject: RFC-HDR care and feeding + diff --git a/t/t5100/rfc2047-info-0004 b/t/t5100/rfc2047-info-0004 new file mode 100644 index 0000000000..f67a90a974 --- /dev/null +++ b/t/t5100/rfc2047-info-0004 @@ -0,0 +1,4 @@ +Author: Nathaniel Borenstein (םולש ןב ילטפנ) +Email: nsb@thumper.bellcore.com +Subject: Test of new header generator + diff --git a/t/t5100/rfc2047-info-0005 b/t/t5100/rfc2047-info-0005 new file mode 100644 index 0000000000..c27be3bf24 --- /dev/null +++ b/t/t5100/rfc2047-info-0005 @@ -0,0 +1,2 @@ +Subject: (a) + diff --git a/t/t5100/rfc2047-info-0006 b/t/t5100/rfc2047-info-0006 new file mode 100644 index 0000000000..9dad474456 --- /dev/null +++ b/t/t5100/rfc2047-info-0006 @@ -0,0 +1,2 @@ +Subject: (a b) + diff --git a/t/t5100/rfc2047-info-0007 b/t/t5100/rfc2047-info-0007 new file mode 100644 index 0000000000..294f195a57 --- /dev/null +++ b/t/t5100/rfc2047-info-0007 @@ -0,0 +1,2 @@ +Subject: (ab) + diff --git a/t/t5100/rfc2047-info-0008 b/t/t5100/rfc2047-info-0008 new file mode 100644 index 0000000000..294f195a57 --- /dev/null +++ b/t/t5100/rfc2047-info-0008 @@ -0,0 +1,2 @@ +Subject: (ab) + diff --git a/t/t5100/rfc2047-info-0009 b/t/t5100/rfc2047-info-0009 new file mode 100644 index 0000000000..294f195a57 --- /dev/null +++ b/t/t5100/rfc2047-info-0009 @@ -0,0 +1,2 @@ +Subject: (ab) + diff --git a/t/t5100/rfc2047-info-0010 b/t/t5100/rfc2047-info-0010 new file mode 100644 index 0000000000..9dad474456 --- /dev/null +++ b/t/t5100/rfc2047-info-0010 @@ -0,0 +1,2 @@ +Subject: (a b) + diff --git a/t/t5100/rfc2047-info-0011 b/t/t5100/rfc2047-info-0011 new file mode 100644 index 0000000000..9dad474456 --- /dev/null +++ b/t/t5100/rfc2047-info-0011 @@ -0,0 +1,2 @@ +Subject: (a b) + diff --git a/t/t5100/rfc2047-samples.mbox b/t/t5100/rfc2047-samples.mbox new file mode 100644 index 0000000000..3ca2470da2 --- /dev/null +++ b/t/t5100/rfc2047-samples.mbox @@ -0,0 +1,48 @@ +From nobody Mon Sep 17 00:00:00 2001 +From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu> +To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk> +CC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be> +Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= + =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?= + +From nobody Mon Sep 17 00:00:00 2001 +From: =?ISO-8859-1?Q?Olle_J=E4rnefors?= <ojarnef@admin.kth.se> +To: ietf-822@dimacs.rutgers.edu, ojarnef@admin.kth.se +Subject: Time for ISO 10646? + +From nobody Mon Sep 17 00:00:00 2001 +To: Dave Crocker <dcrocker@mordor.stanford.edu> +Cc: ietf-822@dimacs.rutgers.edu, paf@comsol.se +From: =?ISO-8859-1?Q?Patrik_F=E4ltstr=F6m?= <paf@nada.kth.se> +Subject: Re: RFC-HDR care and feeding + +From nobody Mon Sep 17 00:00:00 2001 +From: Nathaniel Borenstein <nsb@thumper.bellcore.com> + (=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=) +To: Greg Vaudreuil <gvaudre@NRI.Reston.VA.US>, Ned Freed + <ned@innosoft.com>, Keith Moore <moore@cs.utk.edu> +Subject: Test of new header generator +MIME-Version: 1.0 +Content-type: text/plain; charset=ISO-8859-1 + +From nobody Mon Sep 17 00:00:00 2001 +Subject: (=?ISO-8859-1?Q?a?=) + +From nobody Mon Sep 17 00:00:00 2001 +Subject: (=?ISO-8859-1?Q?a?= b) + +From nobody Mon Sep 17 00:00:00 2001 +Subject: (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) + +From nobody Mon Sep 17 00:00:00 2001 +Subject: (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) + +From nobody Mon Sep 17 00:00:00 2001 +Subject: (=?ISO-8859-1?Q?a?= + =?ISO-8859-1?Q?b?=) + +From nobody Mon Sep 17 00:00:00 2001 +Subject: (=?ISO-8859-1?Q?a_b?=) + +From nobody Mon Sep 17 00:00:00 2001 +Subject: (=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=) diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox index 4bf7947b41..c5ad206b40 100644 --- a/t/t5100/sample.mbox +++ b/t/t5100/sample.mbox @@ -2,7 +2,10 @@ From nobody Mon Sep 17 00:00:00 2001 -From: A U Thor <a.u.thor@example.com> +From: A (zzz) + U + Thor + <a.u.thor@example.com> (Comment) Date: Fri, 9 Jun 2006 00:44:16 -0700 Subject: [PATCH] a commit. @@ -501,3 +504,60 @@ index 3e5fe51..aabfe5c 100644 --=-=-=-- +From bda@mnsspb.ru Wed Nov 12 17:54:41 2008 +From: Dmitriy Blinov <bda@mnsspb.ru> +To: navy-patches@dinar.mns.mnsspb.ru +Date: Wed, 12 Nov 2008 17:54:41 +0300 +Message-Id: <1226501681-24923-1-git-send-email-bda@mnsspb.ru> +X-Mailer: git-send-email 1.5.6.5 +MIME-Version: 1.0 +Content-Type: text/plain; + charset=utf-8 +Content-Transfer-Encoding: 8bit +Subject: [Navy-patches] [PATCH] + =?utf-8?b?0JjQt9C80LXQvdGR0L0g0YHQv9C40YHQvtC6INC/0LA=?= + =?utf-8?b?0LrQtdGC0L7QsiDQvdC10L7QsdGF0L7QtNC40LzRi9GFINC00LvRjyA=?= + =?utf-8?b?0YHQsdC+0YDQutC4?= + +textlive-* исправлены на texlive-* +docutils заменён на python-docutils + +Действительно, оказалось, что rest2web вытягивает за собой +python-docutils. В то время как сам rest2web не нужен. + +Signed-off-by: Dmitriy Blinov <bda@mnsspb.ru> +--- + howto/build_navy.txt | 6 +++--- + 1 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/howto/build_navy.txt b/howto/build_navy.txt +index 3fd3afb..0ee807e 100644 +--- a/howto/build_navy.txt ++++ b/howto/build_navy.txt +@@ -119,8 +119,8 @@ + - libxv-dev + - libusplash-dev + - latex-make +- - textlive-lang-cyrillic +- - textlive-latex-extra ++ - texlive-lang-cyrillic ++ - texlive-latex-extra + - dia + - python-pyrex + - libtool +@@ -128,7 +128,7 @@ + - sox + - cython + - imagemagick +- - docutils ++ - python-docutils + + #. на машине dinar: добавить свой открытый ssh-ключ в authorized_keys2 пользователя ddev + #. на своей машине: отредактировать /etc/sudoers (команда ``visudo``) примерно следующим образом:: +-- +1.5.6.5 +From nobody Mon Sep 17 00:00:00 2001 +From: <a.u.thor@example.com> (A U Thor) +Date: Fri, 9 Jun 2006 00:44:16 -0700 +Subject: [PATCH] a patch + diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 2852a03265..ccfc64c6ee 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -180,6 +180,23 @@ test_expect_success \ unset GIT_OBJECT_DIRECTORY +test_expect_success 'survive missing objects/pack directory' ' + ( + rm -fr missing-pack && + mkdir missing-pack && + cd missing-pack && + git init && + GOP=.git/objects/pack + rm -fr $GOP && + git index-pack --stdin --keep=test <../test-3-${packname_3}.pack && + test -f $GOP/pack-${packname_3}.pack && + test_cmp $GOP/pack-${packname_3}.pack ../test-3-${packname_3}.pack && + test -f $GOP/pack-${packname_3}.idx && + test_cmp $GOP/pack-${packname_3}.idx ../test-3-${packname_3}.idx && + test -f $GOP/pack-${packname_3}.keep + ) +' + test_expect_success \ 'verify pack' \ 'git verify-pack test-1-${packname_1}.idx \ @@ -272,7 +289,8 @@ test_expect_success \ test_expect_success \ 'make sure index-pack detects the SHA1 collision' \ - 'test_must_fail git index-pack -o bad.idx test-3.pack' + 'test_must_fail git index-pack -o bad.idx test-3.pack 2>msg && + grep "SHA1 COLLISION FOUND" msg' test_expect_success \ 'honor pack.packSizeLimit' \ diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index 344ab25b8b..e6f70d474f 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -10,14 +10,20 @@ test_expect_success \ 'setup' \ 'rm -rf .git git init && + git config pack.threads 1 && i=1 && - while test $i -le 100 + 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 && - i=`expr $i + 1` || return 1 + iii=`printf '%03i' $i` + test-genrandom "bar" 200 > wide_delta_$iii && + test-genrandom "baz $iii" 50 >> wide_delta_$iii && + test-genrandom "foo"$i 100 > deep_delta_$iii && + test-genrandom "foo"`expr $i + 1` 100 >> deep_delta_$iii && + test-genrandom "foo"`expr $i + 2` 100 >> deep_delta_$iii && + echo $iii >file_$iii && + test-genrandom "$iii" 8192 >>file_$iii && + git update-index --add file_$iii deep_delta_$iii wide_delta_$iii && + i=`expr $i + 1` || return 1 done && { echo 101 && test-genrandom 100 8192; } >file_101 && git update-index --add file_101 && @@ -92,6 +98,31 @@ test_expect_success \ '64-bit offsets: index-pack result should match pack-objects one' \ 'cmp "test-3-${pack3}.idx" "3.idx"' +# returns the object number for given object in given pack index +index_obj_nr() +{ + idx_file=$1 + object_sha1=$2 + nr=0 + git show-index < $idx_file | + while read offs sha1 extra + do + nr=$(($nr + 1)) + test "$sha1" = "$object_sha1" || continue + echo "$(($nr - 1))" + break + done +} + +# returns the pack offset for given object as found in given pack index +index_obj_offset() +{ + idx_file=$1 + object_sha1=$2 + git show-index < $idx_file | grep $object_sha1 | + ( read offs extra && echo "$offs" ) +} + test_expect_success \ '[index v1] 1) stream pack to repository' \ 'git index-pack --index-version=1 --stdin < "test-1-${pack1}.pack" && @@ -102,19 +133,22 @@ test_expect_success \ 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 | sed -ne \$p | ( - read delta_offs delta_sha1 && - 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 )' + '# This test assumes file_101 is a delta smaller than 16 bytes. + # It should be against file_100 but we substitute its base for file_099 + sha1_101=`git hash-object file_101` && + sha1_099=`git hash-object file_099` && + offs_101=`index_obj_offset 1.idx $sha1_101` && + nr_099=`index_obj_nr 1.idx $sha1_099` && + chmod +w ".git/objects/pack/pack-${pack1}.pack" && + dd of=".git/objects/pack/pack-${pack1}.pack" seek=$(($offs_101 + 1)) \ + if=".git/objects/pack/pack-${pack1}.idx" \ + skip=$((4 + 256 * 4 + $nr_099 * 24)) \ + bs=1 count=20 conv=notrunc && + git cat-file blob $sha1_101 > file_101_foo1' test_expect_success \ '[index v1] 3) corrupted delta happily returned wrong data' \ - '! cmp blob_1 blob_2' + 'test -f file_101_foo1 && ! cmp file_101 file_101_foo1' test_expect_success \ '[index v1] 4) confirm that the pack is actually corrupted' \ @@ -140,19 +174,22 @@ test_expect_success \ 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 | sed -ne \$p | ( - read delta_offs delta_sha1 delta_crc && - 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 )' + '# This test assumes file_101 is a delta smaller than 16 bytes. + # It should be against file_100 but we substitute its base for file_099 + sha1_101=`git hash-object file_101` && + sha1_099=`git hash-object file_099` && + offs_101=`index_obj_offset 1.idx $sha1_101` && + nr_099=`index_obj_nr 1.idx $sha1_099` && + chmod +w ".git/objects/pack/pack-${pack1}.pack" && + dd of=".git/objects/pack/pack-${pack1}.pack" seek=$(($offs_101 + 1)) \ + if=".git/objects/pack/pack-${pack1}.idx" \ + skip=$((8 + 256 * 4 + $nr_099 * 20)) \ + bs=1 count=20 conv=notrunc && + git cat-file blob $sha1_101 > file_101_foo2' test_expect_success \ '[index v2] 3) corrupted delta happily returned wrong data' \ - '! cmp blob_3 blob_4' + 'test -f file_101_foo2 && ! cmp file_101 file_101_foo2' test_expect_success \ '[index v2] 4) confirm that the pack is actually corrupted' \ @@ -160,16 +197,19 @@ test_expect_success \ test_expect_success \ '[index v2] 5) pack-objects refuses to reuse corrupted data' \ - 'test_must_fail git pack-objects test-5 <obj-list' + 'test_must_fail git pack-objects test-5 <obj-list && + test_must_fail git pack-objects --no-reuse-object test-6 <obj-list' test_expect_success \ '[index v2] 6) verify-pack detects CRC mismatch' \ 'rm -f .git/objects/pack/* && git index-pack --index-version=2 --stdin < "test-1-${pack1}.pack" && git verify-pack ".git/objects/pack/pack-${pack1}.pack" && + obj=`git hash-object file_001` && + nr=`index_obj_nr ".git/objects/pack/pack-${pack1}.idx" $obj` && chmod +w ".git/objects/pack/pack-${pack1}.idx" && dd if=/dev/zero of=".git/objects/pack/pack-${pack1}.idx" conv=notrunc \ - bs=1 count=4 seek=$((8 + 256 * 4 + `wc -l <obj-list` * 20 + 0)) && + bs=1 count=4 seek=$((8 + 256 * 4 + `wc -l <obj-list` * 20 + $nr * 4)) && ( while read obj do git cat-file -p $obj >/dev/null || exit 1 done <obj-list ) && diff --git a/t/t5303-pack-corruption-resilience.sh b/t/t5303-pack-corruption-resilience.sh index 31b20b21d2..d4e30fc43c 100755 --- a/t/t5303-pack-corruption-resilience.sh +++ b/t/t5303-pack-corruption-resilience.sh @@ -41,11 +41,17 @@ create_new_pack() { git verify-pack -v ${pack}.pack } +do_repack() { + pack=`printf "$blob_1\n$blob_2\n$blob_3\n" | + git pack-objects $@ .git/objects/pack/pack` && + pack=".git/objects/pack/pack-${pack}" +} + do_corrupt_object() { ofs=`git show-index < ${pack}.idx | grep $1 | cut -f1 -d" "` && ofs=$(($ofs + $2)) && chmod +w ${pack}.pack && - dd if=/dev/zero of=${pack}.pack count=1 bs=1 conv=notrunc seek=$ofs && + dd of=${pack}.pack count=1 bs=1 conv=notrunc seek=$ofs && test_must_fail git verify-pack ${pack}.pack } @@ -60,7 +66,7 @@ test_expect_success \ test_expect_success \ 'create corruption in header of first object' \ - 'do_corrupt_object $blob_1 0 && + 'do_corrupt_object $blob_1 0 < /dev/zero && test_must_fail git cat-file blob $blob_1 > /dev/null && test_must_fail git cat-file blob $blob_2 > /dev/null && test_must_fail git cat-file blob $blob_3 > /dev/null' @@ -119,7 +125,7 @@ test_expect_success \ 'create corruption in header of first delta' \ 'create_new_pack && git prune-packed && - do_corrupt_object $blob_2 0 && + do_corrupt_object $blob_2 0 < /dev/zero && git cat-file blob $blob_1 > /dev/null && test_must_fail git cat-file blob $blob_2 > /dev/null && test_must_fail git cat-file blob $blob_3 > /dev/null' @@ -134,6 +140,15 @@ test_expect_success \ git cat-file blob $blob_3 > /dev/null' test_expect_success \ + '... and then a repack "clears" the corruption' \ + 'do_repack && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null' + +test_expect_success \ 'create corruption in data of first delta' \ 'create_new_pack && git prune-packed && @@ -153,10 +168,19 @@ test_expect_success \ git cat-file blob $blob_3 > /dev/null' test_expect_success \ + '... and then a repack "clears" the corruption' \ + 'do_repack && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null' + +test_expect_success \ 'corruption in delta base reference of first delta (OBJ_REF_DELTA)' \ 'create_new_pack && git prune-packed && - do_corrupt_object $blob_2 2 && + do_corrupt_object $blob_2 2 < /dev/zero && git cat-file blob $blob_1 > /dev/null && test_must_fail git cat-file blob $blob_2 > /dev/null && test_must_fail git cat-file blob $blob_3 > /dev/null' @@ -171,17 +195,75 @@ test_expect_success \ git cat-file blob $blob_3 > /dev/null' test_expect_success \ - 'corruption in delta base reference of first delta (OBJ_OFS_DELTA)' \ + '... and then a repack "clears" the corruption' \ + 'do_repack && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null' + +test_expect_success \ + 'corruption #0 in delta base reference of first delta (OBJ_OFS_DELTA)' \ 'create_new_pack --delta-base-offset && git prune-packed && - do_corrupt_object $blob_2 2 && + do_corrupt_object $blob_2 2 < /dev/zero && git cat-file blob $blob_1 > /dev/null && test_must_fail git cat-file blob $blob_2 > /dev/null && test_must_fail git cat-file blob $blob_3 > /dev/null' test_expect_success \ - '... and a redundant pack allows for full recovery too' \ + '... but having a loose copy allows for full recovery' \ 'mv ${pack}.idx tmp && + git hash-object -t blob -w file_2 && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null' + +test_expect_success \ + '... and then a repack "clears" the corruption' \ + 'do_repack --delta-base-offset && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null' + +test_expect_success \ + 'corruption #1 in delta base reference of first delta (OBJ_OFS_DELTA)' \ + 'create_new_pack --delta-base-offset && + git prune-packed && + printf "\001" | do_corrupt_object $blob_2 2 && + git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null' + +test_expect_success \ + '... but having a loose copy allows for full recovery' \ + 'mv ${pack}.idx tmp && + git hash-object -t blob -w file_2 && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null' + +test_expect_success \ + '... and then a repack "clears" the corruption' \ + 'do_repack --delta-base-offset && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null' + +test_expect_success \ + '... and a redundant pack allows for full recovery too' \ + 'do_corrupt_object $blob_2 2 < /dev/zero && + git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null && + mv ${pack}.idx tmp && git hash-object -t blob -w file_1 && git hash-object -t blob -w file_2 && printf "$blob_1\n$blob_2\n" | git pack-objects .git/objects/pack/pack && diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh index 771c0a06a4..55ed7c7935 100755 --- a/t/t5304-prune.sh +++ b/t/t5304-prune.sh @@ -112,4 +112,42 @@ test_expect_success 'prune: do not prune heads listed as an argument' ' ' +test_expect_success 'gc --no-prune' ' + + before=$(git count-objects | sed "s/ .*//") && + BLOB=$(echo aleph_0 | git hash-object -w --stdin) && + BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") && + test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && + test -f $BLOB_FILE && + test-chmtime =-$((86400*5001)) $BLOB_FILE && + git config gc.pruneExpire 2.days.ago && + git gc --no-prune && + test 1 = $(git count-objects | sed "s/ .*//") && + test -f $BLOB_FILE + +' + +test_expect_success 'gc respects gc.pruneExpire' ' + + git config gc.pruneExpire 5002.days.ago && + git gc && + test -f $BLOB_FILE && + git config gc.pruneExpire 5000.days.ago && + git gc && + test ! -f $BLOB_FILE + +' + +test_expect_success 'gc --prune=<date>' ' + + BLOB=$(echo aleph_0 | git hash-object -w --stdin) && + BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") && + test-chmtime =-$((86400*5001)) $BLOB_FILE && + git gc --prune=5002.days.ago && + test -f $BLOB_FILE && + git gc --prune=5000.days.ago && + test ! -f $BLOB_FILE + +' + test_done diff --git a/t/t5307-pack-missing-commit.sh b/t/t5307-pack-missing-commit.sh new file mode 100755 index 0000000000..ae52a1882d --- /dev/null +++ b/t/t5307-pack-missing-commit.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +test_description='pack should notice missing commit objects' + +. ./test-lib.sh + +test_expect_success setup ' + for i in 1 2 3 4 5 + do + echo "$i" >"file$i" && + git add "file$i" && + test_tick && + git commit -m "$i" && + git tag "tag$i" + done && + obj=$(git rev-parse --verify tag3) && + fanout=$(expr "$obj" : "\(..\)") && + remainder=$(expr "$obj" : "..\(.*\)") && + rm -f ".git/objects/$fanout/$remainder" +' + +test_expect_success 'check corruption' ' + test_must_fail git fsck +' + +test_expect_success 'rev-list notices corruption (1)' ' + test_must_fail git rev-list HEAD +' + +test_expect_success 'rev-list notices corruption (2)' ' + test_must_fail git rev-list --objects HEAD +' + +test_expect_success 'pack-objects notices corruption' ' + echo HEAD | + test_must_fail git pack-objects --revs pack +' + +test_done diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index 544771d8fa..f2d5581b12 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -32,9 +32,7 @@ test_expect_success setup ' done && git update-ref HEAD "$commit" && git clone ./. victim && - cd victim && - git log && - cd .. && + ( cd victim && git log ) && git update-ref HEAD "$zero" && parent=$zero && i=0 && @@ -59,77 +57,84 @@ test_expect_success 'pack the source repository' ' ' test_expect_success 'pack the destination repository' ' + ( cd victim && git repack -a -d && - git prune && - cd .. + git prune + ) ' -test_expect_success \ - 'pushing rewound head should not barf but require --force' ' - # should not fail but refuse to update. - if git send-pack ./victim/.git/ master - then - # now it should fail with Pasky patch - echo >&2 Gaah, it should have failed. - false - else - echo >&2 Thanks, it correctly failed. - true - fi && - if cmp victim/.git/refs/heads/master .git/refs/heads/master - then - # should have been left as it was! - false - else - true - fi && +test_expect_success 'refuse pushing rewound head without --force' ' + pushed_head=$(git rev-parse --verify master) && + victim_orig=$(cd victim && git rev-parse --verify master) && + test_must_fail git send-pack ./victim master && + victim_head=$(cd victim && git rev-parse --verify master) && + test "$victim_head" = "$victim_orig" && # this should update - git send-pack --force ./victim/.git/ master && - cmp victim/.git/refs/heads/master .git/refs/heads/master + git send-pack --force ./victim master && + victim_head=$(cd victim && git rev-parse --verify master) && + test "$victim_head" = "$pushed_head" ' test_expect_success \ 'push can be used to delete a ref' ' - cd victim && - git branch extra master && - cd .. && - test -f victim/.git/refs/heads/extra && - git send-pack ./victim/.git/ :extra master && - ! test -f victim/.git/refs/heads/extra + ( cd victim && git branch extra master ) && + git send-pack ./victim :extra master && + ( cd victim && + test_must_fail git rev-parse --verify extra ) ' -unset GIT_CONFIG GIT_CONFIG_LOCAL -HOME=`pwd`/no-such-directory -export HOME ;# this way we force the victim/.git/config to be used. +test_expect_success 'refuse deleting push with denyDeletes' ' + ( + cd victim && + ( git branch -D extra || : ) && + git config receive.denyDeletes true && + git branch extra master + ) && + test_must_fail git send-pack ./victim :extra master +' -test_expect_success \ - 'pushing with --force should be denied with denyNonFastforwards' ' - cd victim && - git config receive.denyNonFastforwards true && - cd .. && - git update-ref refs/heads/master master^ || return 1 - git send-pack --force ./victim/.git/ master && return 1 - ! test_cmp .git/refs/heads/master victim/.git/refs/heads/master +test_expect_success 'denyNonFastforwards trumps --force' ' + ( + cd victim && + ( git branch -D extra || : ) && + git config receive.denyNonFastforwards true + ) && + victim_orig=$(cd victim && git rev-parse --verify master) && + test_must_fail git send-pack --force ./victim master^:master && + victim_head=$(cd victim && git rev-parse --verify master) && + test "$victim_orig" = "$victim_head" ' -test_expect_success \ - 'pushing does not include non-head refs' ' - mkdir parent && cd parent && - git init && touch file && git add file && git commit -m add && - cd .. && - git clone parent child && cd child && git push --all && - cd ../parent && - git branch -a >branches && ! grep origin/master branches +test_expect_success 'push --all excludes remote tracking hierarchy' ' + mkdir parent && + ( + cd parent && + git init && : >file && git add file && git commit -m add + ) && + git clone parent child && + ( + cd child && git push --all + ) && + ( + cd parent && + test -z "$(git for-each-ref refs/remotes/origin)" + ) ' rewound_push_setup() { rm -rf parent child && - mkdir parent && cd parent && - git init && echo one >file && git add file && git commit -m one && - echo two >file && git commit -a -m two && - cd .. && - git clone parent child && cd child && git reset --hard HEAD^ + mkdir parent && + ( + cd parent && + git init && + echo one >file && git add file && git commit -m one && + echo two >file && git commit -a -m two + ) && + git clone parent child && + ( + cd child && git reset --hard HEAD^ + ) } rewound_push_succeeded() { @@ -145,30 +150,57 @@ rewound_push_failed() { fi } -test_expect_success \ - 'pushing explicit refspecs respects forcing' ' +test_expect_success 'pushing explicit refspecs respects forcing' ' rewound_push_setup && - if git send-pack ../parent/.git refs/heads/master:refs/heads/master - then - false - else - true - fi && rewound_push_failed && - git send-pack ../parent/.git +refs/heads/master:refs/heads/master && - rewound_push_succeeded + parent_orig=$(cd parent && git rev-parse --verify master) && + ( + cd child && + test_must_fail git send-pack ../parent \ + refs/heads/master:refs/heads/master + ) && + parent_head=$(cd parent && git rev-parse --verify master) && + test "$parent_orig" = "$parent_head" && + ( + cd child && + git send-pack ../parent \ + +refs/heads/master:refs/heads/master + ) && + parent_head=$(cd parent && git rev-parse --verify master) && + child_head=$(cd parent && git rev-parse --verify master) && + test "$parent_head" = "$child_head" ' -test_expect_success \ - 'pushing wildcard refspecs respects forcing' ' +test_expect_success 'pushing wildcard refspecs respects forcing' ' rewound_push_setup && - if git send-pack ../parent/.git refs/heads/*:refs/heads/* - then - false - else - true - fi && rewound_push_failed && - git send-pack ../parent/.git +refs/heads/*:refs/heads/* && - rewound_push_succeeded + parent_orig=$(cd parent && git rev-parse --verify master) && + ( + cd child && + test_must_fail git send-pack ../parent \ + "refs/heads/*:refs/heads/*" + ) && + parent_head=$(cd parent && git rev-parse --verify master) && + test "$parent_orig" = "$parent_head" && + ( + cd child && + git send-pack ../parent \ + "+refs/heads/*:refs/heads/*" + ) && + parent_head=$(cd parent && git rev-parse --verify master) && + child_head=$(cd parent && git rev-parse --verify master) && + test "$parent_head" = "$child_head" +' + +test_expect_success 'warn pushing to delete current branch' ' + rewound_push_setup && + ( + cd child && + git send-pack ../parent :refs/heads/master 2>errs + ) && + grep "warning: to refuse deleting" child/errs && + ( + cd parent && + test_must_fail git rev-parse --verify master + ) ' test_done diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 448ec71565..c450f33f33 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -137,7 +137,7 @@ test_expect_success "clone shallow object count" \ "test \"in-pack: 18\" = \"$(grep in-pack count.shallow)\"" count_output () { - sed -e '/^in-pack:/d' -e '/^packs:/d' -e '/: 0$/d' "$1" + sed -e '/^in-pack:/d' -e '/^packs:/d' -e '/^size-pack:/d' -e '/: 0$/d' "$1" } test_expect_success "clone shallow object count (part 2)" ' diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 0103e1a180..eb637184a0 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -28,7 +28,7 @@ tokens_match () { } check_remote_track () { - actual=$(git remote show "$1" | sed -n -e '$p') && + actual=$(git remote show "$1" | sed -e '1,/Tracked/d') && shift && tokens_match "$*" "$actual" } @@ -107,6 +107,32 @@ test_expect_success 'remove remote' ' ) ' +test_expect_success 'remove remote protects non-remote branches' ' +( + cd test && + (cat >expect1 <<EOF +Note: A non-remote branch was not removed; to delete it, use: + git branch -d master +EOF + cat >expect2 <<EOF +Note: Non-remote branches were not removed; to delete them, use: + git branch -d foobranch + git branch -d master +EOF +) && + git tag footag + git config --add remote.oops.fetch "+refs/*:refs/*" && + git remote rm oops 2>actual1 && + git branch foobranch && + git config --add remote.oops.fetch "+refs/*:refs/*" && + git remote rm oops 2>actual2 && + git branch -d foobranch && + git tag -d footag && + test_cmp expect1 actual1 && + test_cmp expect2 actual2 +) +' + cat > test/expect << EOF * remote origin URL: $(pwd)/one @@ -115,9 +141,11 @@ cat > test/expect << EOF New remote branch (next fetch will store in remotes/origin) master Tracked remote branches - side master + side + master Local branches pushed with 'git push' - master:upstream +refs/tags/lastbackup + master:upstream + +refs/tags/lastbackup EOF test_expect_success 'show' ' @@ -144,9 +172,11 @@ cat > test/expect << EOF Remote branch merged with 'git pull' while on branch master master Tracked remote branches - master side + master + side Local branches pushed with 'git push' - master:upstream +refs/tags/lastbackup + master:upstream + +refs/tags/lastbackup EOF test_expect_success 'show -n' ' @@ -324,4 +354,79 @@ test_expect_success 'reject adding remote with an invalid name' ' ' +# The first three test if the tracking branches are properly renamed, +# the last two ones check if the config is updated. + +test_expect_success 'rename a remote' ' + + git clone one four && + (cd four && + git remote rename origin upstream && + rmdir .git/refs/remotes/origin && + test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" && + test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" && + test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" && + test "$(git config branch.master.remote)" = "upstream") + +' + +cat > remotes_origin << EOF +URL: $(pwd)/one +Push: refs/heads/master:refs/heads/upstream +Pull: refs/heads/master:refs/heads/origin +EOF + +test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' ' + git clone one five && + origin_url=$(pwd)/one && + (cd five && + git remote rm origin && + mkdir -p .git/remotes && + cat ../remotes_origin > .git/remotes/origin && + git remote rename origin origin && + ! test -f .git/remotes/origin && + test "$(git config remote.origin.url)" = "$origin_url" && + test "$(git config remote.origin.push)" = "refs/heads/master:refs/heads/upstream" && + test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin") +' + +test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' ' + git clone one six && + origin_url=$(pwd)/one && + (cd six && + git remote rm origin && + echo "$origin_url" > .git/branches/origin && + git remote rename origin origin && + ! test -f .git/branches/origin && + test "$(git config remote.origin.url)" = "$origin_url" && + test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin") +' + +test_expect_success 'remote prune to cause a dangling symref' ' + git clone one seven && + ( + cd one && + git checkout side2 && + git branch -D master + ) && + ( + cd seven && + git remote prune origin + ) 2>err && + grep "has become dangling" err && + + : And the dangling symref will not cause other annoying errors + ( + cd seven && + git branch -a + ) 2>err && + ! grep "points nowhere" err + ( + cd seven && + test_must_fail git branch nomore origin + ) 2>err && + grep "dangling symref" err +' + test_done + diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 52094e78dc..bee3424fed 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -191,38 +191,39 @@ test_expect_success 'bundle should be able to create a full history' ' ' -test "$TEST_RSYNC" && { +! rsync --help > /dev/null 2> /dev/null && +say 'Skipping rsync tests because rsync was not found' || { test_expect_success 'fetch via rsync' ' git pack-refs && mkdir rsynced && - cd rsynced && - git init && - git fetch rsync://127.0.0.1$(pwd)/../.git master:refs/heads/master && - git gc --prune && - test $(git rev-parse master) = $(cd .. && git rev-parse master) && - git fsck --full + (cd rsynced && + git init --bare && + git fetch "rsync:$(pwd)/../.git" master:refs/heads/master && + git gc --prune && + test $(git rev-parse master) = $(cd .. && git rev-parse master) && + git fsck --full) ' test_expect_success 'push via rsync' ' - mkdir ../rsynced2 && - (cd ../rsynced2 && + mkdir rsynced2 && + (cd rsynced2 && git init) && - git push rsync://127.0.0.1$(pwd)/../rsynced2/.git master && - cd ../rsynced2 && - git gc --prune && - test $(git rev-parse master) = $(cd .. && git rev-parse master) && - git fsck --full + (cd rsynced && + git push "rsync:$(pwd)/../rsynced2/.git" master) && + (cd rsynced2 && + git gc --prune && + test $(git rev-parse master) = $(cd .. && git rev-parse master) && + git fsck --full) ' test_expect_success 'push via rsync' ' - cd .. && mkdir rsynced3 && (cd rsynced3 && git init) && - git push --all rsync://127.0.0.1$(pwd)/rsynced3/.git && - cd rsynced3 && - test $(git rev-parse master) = $(cd .. && git rev-parse master) && - git fsck --full + git push --all "rsync:$(pwd)/rsynced3/.git" && + (cd rsynced3 && + test $(git rev-parse master) = $(cd .. && git rev-parse master) && + git fsck --full) ' } @@ -303,6 +304,26 @@ test_expect_success 'pushing nonexistent branch by mistake should not segv' ' ' +test_expect_success 'auto tag following fetches minimum' ' + + cd "$D" && + git clone .git follow && + git checkout HEAD^0 && + ( + for i in 1 2 3 4 5 6 7 + do + echo $i >>file && + git commit -m $i -a && + git tag -a -m $i excess-$i || exit 1 + done + ) && + git checkout master && + ( + cd follow && + git fetch + ) +' + test_expect_success 'refuse to fetch into the current branch' ' test_must_fail git fetch . side:master diff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh index 8becbc3f38..1f4608d8ba 100755 --- a/t/t5515-fetch-merge-logic.sh +++ b/t/t5515-fetch-merge-logic.sh @@ -131,9 +131,9 @@ do test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'` cnt=`expr $test_count + 1` pfx=`printf "%04d" $cnt` - expect_f="../../t5515/fetch.$test" + expect_f="$TEST_DIRECTORY/t5515/fetch.$test" actual_f="$pfx-fetch.$test" - expect_r="../../t5515/refs.$test" + expect_r="$TEST_DIRECTORY/t5515/refs.$test" actual_r="$pfx-refs.$test" test_expect_success "$cmd" ' diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index f9e878022a..89649e7a9b 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -39,6 +39,11 @@ mk_test () { ) } +mk_child() { + rm -rf "$1" && + git clone testrepo "$1" +} + check_push_result () { ( cd testrepo && @@ -425,13 +430,10 @@ test_expect_success 'push with dry-run' ' test_expect_success 'push updates local refs' ' - rm -rf parent child && - mkdir parent && - (cd parent && git init && - echo one >foo && git add foo && git commit -m one) && - git clone parent child && + mk_test heads/master && + mk_child child && (cd child && - echo two >foo && git commit -a -m two && + git pull .. master && git push && test $(git rev-parse master) = $(git rev-parse remotes/origin/master)) @@ -439,15 +441,10 @@ test_expect_success 'push updates local refs' ' test_expect_success 'push updates up-to-date local refs' ' - rm -rf parent child && - mkdir parent && - (cd parent && git init && - echo one >foo && git add foo && git commit -m one) && - git clone parent child1 && - git clone parent child2 && - (cd child1 && - echo two >foo && git commit -a -m two && - git push) && + mk_test heads/master && + mk_child child1 && + mk_child child2 && + (cd child1 && git pull .. master && git push) && (cd child2 && git pull ../child1 master && git push && @@ -457,11 +454,8 @@ test_expect_success 'push updates up-to-date local refs' ' test_expect_success 'push preserves up-to-date packed refs' ' - rm -rf parent child && - mkdir parent && - (cd parent && git init && - echo one >foo && git add foo && git commit -m one) && - git clone parent child && + mk_test heads/master && + mk_child child && (cd child && git push && ! test -f .git/refs/remotes/origin/master) @@ -470,15 +464,13 @@ test_expect_success 'push preserves up-to-date packed refs' ' test_expect_success 'push does not update local refs on failure' ' - rm -rf parent child && - mkdir parent && - (cd parent && git init && - echo one >foo && git add foo && git commit -m one && - echo exit 1 >.git/hooks/pre-receive && - chmod +x .git/hooks/pre-receive) && - git clone parent child && + mk_test heads/master && + mk_child child && + mkdir testrepo/.git/hooks && + echo exit 1 >testrepo/.git/hooks/pre-receive && + chmod +x testrepo/.git/hooks/pre-receive && (cd child && - echo two >foo && git commit -a -m two && + git pull .. master test_must_fail git push && test $(git rev-parse master) != \ $(git rev-parse remotes/origin/master)) @@ -487,13 +479,50 @@ test_expect_success 'push does not update local refs on failure' ' test_expect_success 'allow deleting an invalid remote ref' ' - pwd && + mk_test heads/master && rm -f testrepo/.git/objects/??/* && git push testrepo :refs/heads/master && (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master) ' +test_expect_success 'warn on push to HEAD of non-bare repository' ' + mk_test heads/master + (cd testrepo && + git checkout master && + git config receive.denyCurrentBranch warn) && + git push testrepo master 2>stderr && + grep "warning: updating the current branch" stderr +' + +test_expect_success 'deny push to HEAD of non-bare repository' ' + mk_test heads/master + (cd testrepo && + git checkout master && + git config receive.denyCurrentBranch true) && + test_must_fail git push testrepo master +' + +test_expect_success 'allow push to HEAD of bare repository (bare)' ' + mk_test heads/master + (cd testrepo && + git checkout master && + git config receive.denyCurrentBranch true && + git config core.bare true) && + git push testrepo master 2>stderr && + ! grep "warning: updating the current branch" stderr +' + +test_expect_success 'allow push to HEAD of non-bare repository (config)' ' + mk_test heads/master + (cd testrepo && + git checkout master && + git config receive.denyCurrentBranch false + ) && + git push testrepo master 2>stderr && + ! grep "warning: updating the current branch" stderr +' + test_expect_success 'fetch with branches' ' mk_empty && git branch second $the_first_commit && diff --git a/t/t5519-push-alternates.sh b/t/t5519-push-alternates.sh new file mode 100755 index 0000000000..96be5236a2 --- /dev/null +++ b/t/t5519-push-alternates.sh @@ -0,0 +1,143 @@ +#!/bin/sh + +test_description='push to a repository that borrows from elsewhere' + +. ./test-lib.sh + +test_expect_success setup ' + mkdir alice-pub && + ( + cd alice-pub && + GIT_DIR=. git init + ) && + mkdir alice-work && + ( + cd alice-work && + git init && + >file && + git add . && + git commit -m initial && + git push ../alice-pub master + ) && + + # Project Bob is a fork of project Alice + mkdir bob-pub && + ( + cd bob-pub && + GIT_DIR=. git init && + mkdir -p objects/info && + echo ../../alice-pub/objects >objects/info/alternates + ) && + git clone alice-pub bob-work && + ( + cd bob-work && + git push ../bob-pub master + ) +' + +test_expect_success 'alice works and pushes' ' + ( + cd alice-work && + echo more >file && + git commit -a -m second && + git push ../alice-pub + ) +' + +test_expect_success 'bob fetches from alice, works and pushes' ' + ( + # Bob acquires what Alice did in his work tree first. + # Even though these objects are not directly in + # the public repository of Bob, this push does not + # need to send the commit Bob received from Alice + # to his public repository, as all the object Alice + # has at her public repository are available to it + # via its alternates. + cd bob-work && + git pull ../alice-pub master && + echo more bob >file && + git commit -a -m third && + git push ../bob-pub + ) && + + # Check that the second commit by Alice is not sent + # to ../bob-pub + ( + cd bob-pub && + second=$(git rev-parse HEAD^) && + rm -f objects/info/alternates && + test_must_fail git cat-file -t $second && + echo ../../alice-pub/objects >objects/info/alternates + ) +' + +test_expect_success 'clean-up in case the previous failed' ' + ( + cd bob-pub && + echo ../../alice-pub/objects >objects/info/alternates + ) +' + +test_expect_success 'alice works and pushes again' ' + ( + # Alice does not care what Bob does. She does not + # even have to be aware of his existence. She just + # keeps working and pushing + cd alice-work && + echo more alice >file && + git commit -a -m fourth && + git push ../alice-pub + ) +' + +test_expect_success 'bob works and pushes' ' + ( + # This time Bob does not pull from Alice, and + # the master branch at her public repository points + # at a commit Bob does not know about. This should + # not prevent the push by Bob from succeeding. + cd bob-work && + echo yet more bob >file && + git commit -a -m fifth && + git push ../bob-pub + ) +' + +test_expect_success 'alice works and pushes yet again' ' + ( + # Alice does not care what Bob does. She does not + # even have to be aware of his existence. She just + # keeps working and pushing + cd alice-work && + echo more and more alice >file && + git commit -a -m sixth.1 && + echo more and more alice >>file && + git commit -a -m sixth.2 && + echo more and more alice >>file && + git commit -a -m sixth.3 && + git push ../alice-pub + ) +' + +test_expect_success 'bob works and pushes again' ' + ( + cd alice-pub && + git cat-file commit master >../bob-work/commit + ) + ( + # This time Bob does not pull from Alice, and + # the master branch at her public repository points + # at a commit Bob does not fully know about, but + # he happens to have the commit object (but not the + # necessary tree) in his repository from Alice. + # This should not prevent the push by Bob from + # succeeding. + cd bob-work && + git hash-object -t commit -w commit && + echo even more bob >file && + git commit -a -m seventh && + git push ../bob-pub + ) +' + +test_done diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh new file mode 100755 index 0000000000..83e2e8ab80 --- /dev/null +++ b/t/t5521-pull-options.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +test_description='pull options' + +. ./test-lib.sh + +D=`pwd` + +test_expect_success 'setup' ' + mkdir parent && + (cd parent && git init && + echo one >file && git add file && + git commit -m one) +' + +cd "$D" + +test_expect_success 'git pull -q' ' + mkdir clonedq && + cd clonedq && + git pull -q "$D/parent" >out 2>err && + test ! -s out +' + +cd "$D" + +test_expect_success 'git pull' ' + mkdir cloned && + cd cloned && + git pull "$D/parent" >out 2>err && + test -s out +' +cd "$D" + +test_expect_success 'git pull -v' ' + mkdir clonedv && + cd clonedv && + git pull -v "$D/parent" >out 2>err && + test -s out +' + +cd "$D" + +test_expect_success 'git pull -v -q' ' + mkdir clonedvq && + cd clonedvq && + git pull -v -q "$D/parent" >out 2>err && + test ! -s out +' + +cd "$D" + +test_expect_success 'git pull -q -v' ' + mkdir clonedqv && + cd clonedqv && + git pull -q -v "$D/parent" >out 2>err && + test -s out +' + +test_done diff --git a/t/t5521-pull-symlink.sh b/t/t5521-pull-symlink.sh new file mode 100755 index 0000000000..5672b51e2e --- /dev/null +++ b/t/t5521-pull-symlink.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +test_description='pulling from symlinked subdir' + +. ./test-lib.sh + +# The scenario we are building: +# +# trash\ directory/ +# clone-repo/ +# subdir/ +# bar +# subdir-link -> clone-repo/subdir/ +# +# The working directory is subdir-link. + +mkdir subdir +echo file >subdir/file +git add subdir/file +git commit -q -m file +git clone -q . clone-repo +ln -s clone-repo/subdir/ subdir-link + + +# Demonstrate that things work if we just avoid the symlink +# +test_expect_success 'pulling from real subdir' ' + ( + echo real >subdir/file && + git commit -m real subdir/file && + cd clone-repo/subdir/ && + git pull && + test real = $(cat file) + ) +' + +# From subdir-link, pulling should work as it does from +# clone-repo/subdir/. +# +# Instead, the error pull gave was: +# +# fatal: 'origin': unable to chdir or not a git archive +# fatal: The remote end hung up unexpectedly +# +# because git would find the .git/config for the "trash directory" +# repo, not for the clone-repo repo. The "trash directory" repo +# had no entry for origin. Git found the wrong .git because +# git rev-parse --show-cdup printed a path relative to +# clone-repo/subdir/, not subdir-link/. Git rev-parse --show-cdup +# used the correct .git, but when the git pull shell script did +# "cd `git rev-parse --show-cdup`", it ended up in the wrong +# directory. A POSIX shell's "cd" works a little differently +# than chdir() in C; "cd -P" is much closer to chdir(). +# +test_expect_success 'pulling from symlinked subdir' ' + ( + echo link >subdir/file && + git commit -m link subdir/file && + cd subdir-link/ && + git pull && + test link = $(cat file) + ) +' + +# Prove that the remote end really is a repo, and other commands +# work fine in this context. It's just that "git pull" breaks. +# +test_expect_success 'pushing from symlinked subdir' ' + ( + cd subdir-link/ && + echo push >file && + git commit -m push ./file && + git push + ) && + test push = $(git show HEAD:subdir/file) +' + +test_done diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh index b0d242e3ed..10e5fd0d5a 100755 --- a/t/t5540-http-push.sh +++ b/t/t5540-http-push.sh @@ -19,7 +19,7 @@ then exit fi -. ../lib-httpd.sh +. "$TEST_DIRECTORY"/lib-httpd.sh if ! start_httpd >&3 2>&4 then @@ -51,17 +51,29 @@ test_expect_success 'clone remote repository' ' git clone $HTTPD_URL/test_repo.git test_repo_clone ' -test_expect_failure 'push to remote repository' ' +test_expect_failure 'push to remote repository with packed refs' ' cd "$ROOT_PATH"/test_repo_clone && : >path2 && git add path2 && test_tick && git commit -m path2 && + HEAD=$(git rev-parse --verify HEAD) && git push && - [ -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/refs/heads/master" ] + (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && + test $HEAD = $(git rev-parse --verify HEAD)) ' -test_expect_failure 'create and delete remote branch' ' +test_expect_success ' push to remote repository with unpacked refs' ' + (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && + rm packed-refs && + git update-ref refs/heads/master \ + 0c973ae9bd51902a28466f3850b543fa66a6aaf4) && + git push && + (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && + test $HEAD = $(git rev-parse --verify HEAD)) +' + +test_expect_success 'create and delete remote branch' ' cd "$ROOT_PATH"/test_repo_clone && git checkout -b dev && : >path3 && @@ -76,6 +88,24 @@ test_expect_failure 'create and delete remote branch' ' test_must_fail git show-ref --verify refs/remotes/origin/dev ' +test_expect_success 'MKCOL sends directory names with trailing slashes' ' + + ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log + +' + +x1="[0-9a-f]" +x2="$x1$x1" +x5="$x1$x1$x1$x1$x1" +x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1" +x40="$x38$x2" + +test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' ' + sed -e "s/PUT /OP /" -e "s/MOVE /OP /" "$HTTPD_ROOT_PATH"/access.log | + grep -e "\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9] " + +' + stop_httpd test_done diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index 78a3fa639c..44793f2eee 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -125,4 +125,38 @@ test_expect_success 'clone to destination with extra trailing /' ' ' +test_expect_success 'clone to an existing empty directory' ' + mkdir target-3 && + git clone src target-3 && + T=$( cd target-3 && git rev-parse HEAD ) && + S=$( cd src && git rev-parse HEAD ) && + test "$T" = "$S" +' + +test_expect_success 'clone to an existing non-empty directory' ' + mkdir target-4 && + >target-4/Fakefile && + test_must_fail git clone src target-4 +' + +test_expect_success 'clone to an existing path' ' + >target-5 && + test_must_fail git clone src target-5 +' + +test_expect_success 'clone a void' ' + mkdir src-0 && + ( + cd src-0 && git init + ) && + git clone src-0 target-6 && + ( + cd src-0 && test_commit A + ) && + git clone src-0 target-7 && + # There is no reason to insist they are bit-for-bit + # identical, but this test should suffice for now. + test_cmp target-6/.git/config target-7/.git/config +' + test_done diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh index 8dfaaa456e..3559d17964 100755 --- a/t/t5701-clone-local.sh +++ b/t/t5701-clone-local.sh @@ -11,8 +11,8 @@ test_expect_success 'preparing origin repository' ' git clone --bare . x && test "$(GIT_CONFIG=a.git/config git config --bool core.bare)" = true && test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true - git bundle create b1.bundle --all HEAD && - git bundle create b2.bundle --all && + git bundle create b1.bundle --all && + git bundle create b2.bundle master && mkdir dir && cp b1.bundle dir/b3 cp b1.bundle b4 @@ -116,4 +116,20 @@ test_expect_success 'bundle clone with nonexistent HEAD' ' test ! -e .git/refs/heads/master ' +test_expect_success 'clone empty repository' ' + cd "$D" && + mkdir empty && + (cd empty && git init) && + git clone empty empty-clone && + test_tick && + (cd empty-clone + echo "content" >> foo && + git add foo && + git commit -m "Initial commit" && + git push origin master && + expected=$(git rev-parse master) && + actual=$(git --git-dir=../empty/.git rev-parse master) && + test $actual = $expected) +' + test_done diff --git a/t/t5702-clone-options.sh b/t/t5702-clone-options.sh index 328e4d9a33..27825f5f31 100755 --- a/t/t5702-clone-options.sh +++ b/t/t5702-clone-options.sh @@ -19,4 +19,17 @@ test_expect_success 'clone -o' ' ' +test_expect_success 'redirected clone' ' + + git clone "file://$(pwd)/parent" clone-redirected >out 2>err && + test ! -s err + +' +test_expect_success 'redirected clone -v' ' + + git clone -v "file://$(pwd)/parent" clone-redirected-v >out 2>err && + test -s err + +' + test_done diff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh new file mode 100755 index 0000000000..a8f4419e61 --- /dev/null +++ b/t/t5704-bundle.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +test_description='some bundle related tests' +. ./test-lib.sh + +test_expect_success 'setup' ' + + : > file && + git add file && + test_tick && + git commit -m initial && + test_tick && + git tag -m tag tag && + : > file2 && + git add file2 && + : > file3 && + test_tick && + git commit -m second && + git add file3 && + test_tick && + git commit -m third + +' + +test_expect_success 'tags can be excluded by rev-list options' ' + + git bundle create bundle --all --since=7.Apr.2005.15:16:00.-0700 && + git ls-remote bundle > output && + ! grep tag output + +' + +test_done diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh index 8f5de097ec..b4e8fbaa5e 100755 --- a/t/t6002-rev-list-bisect.sh +++ b/t/t6002-rev-list-bisect.sh @@ -5,7 +5,7 @@ test_description='Tests git rev-list --bisect functionality' . ./test-lib.sh -. ../t6000lib.sh # t6xxx specific functions +. "$TEST_DIRECTORY"/t6000lib.sh # t6xxx specific functions # usage: test_bisection max-diff bisect-option head ^prune... # diff --git a/t/t6003-rev-list-topo-order.sh b/t/t6003-rev-list-topo-order.sh index 5daa0be8cc..2c73f2da7b 100755 --- a/t/t6003-rev-list-topo-order.sh +++ b/t/t6003-rev-list-topo-order.sh @@ -6,7 +6,7 @@ test_description='Tests git rev-list --topo-order functionality' . ./test-lib.sh -. ../t6000lib.sh # t6xxx specific functions +. "$TEST_DIRECTORY"/t6000lib.sh # t6xxx specific functions list_duplicates() { diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index 86bf7e14ba..59d1f6283b 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -14,7 +14,7 @@ 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 rev-list --pretty=format:'$2' master >output.$1 && test_cmp expect.$1 output.$1 " } @@ -101,6 +101,13 @@ commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 [31mfoo[32mbar[34mbaz[mxyzzy EOF +test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF' +commit 131a310eb913d107dd3c09a65d1651175898735d +[1;31;43mfoo[m +commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 +[1;31;43mfoo[m +EOF + cat >commit-msg <<'EOF' Test printing of complex bodies diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh index b6e57b2426..04e4b7c5c2 100755 --- a/t/t6010-merge-base.sh +++ b/t/t6010-merge-base.sh @@ -108,4 +108,52 @@ test_expect_success 'compute merge-base (all)' \ 'MB=$(git merge-base --all PL PR) && expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/C2"' +# Another set to demonstrate base between one commit and a merge +# in the documentation. + +test_expect_success 'merge-base for octopus-step (setup)' ' + test_tick && git commit --allow-empty -m root && git tag MMR && + test_tick && git commit --allow-empty -m 1 && git tag MM1 && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m A && git tag MMA && + git checkout MM1 && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m B && git tag MMB && + git checkout MMR && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m C && git tag MMC +' + +test_expect_success 'merge-base A B C' ' + MB=$(git merge-base --all MMA MMB MMC) && + MM1=$(git rev-parse --verify MM1) && + test "$MM1" = "$MB" +' + +test_expect_success 'criss-cross merge-base for octopus-step (setup)' ' + git reset --hard MMR && + test_tick && git commit --allow-empty -m 1 && git tag CC1 && + git reset --hard E && + test_tick && git commit --allow-empty -m 2 && git tag CC2 && + test_tick && git merge -s ours CC1 && + test_tick && git commit --allow-empty -m o && + test_tick && git commit --allow-empty -m B && git tag CCB && + git reset --hard CC1 && + test_tick && git merge -s ours CC2 && + test_tick && git commit --allow-empty -m A && git tag CCA +' + +test_expect_success 'merge-base B A^^ A^^2' ' + MB0=$(git merge-base --all CCB CCA^^ CCA^^2 | sort) && + MB1=$(git rev-parse CC1 CC2 | sort) && + test "$MB0" = "$MB1" +' + test_done diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh new file mode 100755 index 0000000000..510bb9679f --- /dev/null +++ b/t/t6012-rev-list-simplify.sh @@ -0,0 +1,93 @@ +#!/bin/sh + +test_description='merge simplification' + +. ./test-lib.sh + +note () { + git tag "$1" +} + +_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" + +unnote () { + git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\)) |\1 |g" +} + +test_expect_success setup ' + echo "Hi there" >file && + git add file && + test_tick && git commit -m "Initial file" && + note A && + + git branch other-branch && + + echo "Hello" >file && + git add file && + test_tick && git commit -m "Modified file" && + note B && + + git checkout other-branch && + + echo "Hello" >file && + git add file && + test_tick && git commit -m "Modified the file identically" && + note C && + + echo "This is a stupid example" >another-file && + git add another-file && + test_tick && git commit -m "Add another file" && + note D && + + test_tick && git merge -m "merge" master && + note E && + + echo "Yet another" >elif && + git add elif && + test_tick && git commit -m "Irrelevant change" && + note F && + + git checkout master && + echo "Yet another" >elif && + git add elif && + test_tick && git commit -m "Another irrelevant change" && + note G && + + test_tick && git merge -m "merge" other-branch && + note H && + + echo "Final change" >file && + test_tick && git commit -a -m "Final change" && + note I +' + +FMT='tformat:%P %H | %s' + +check_result () { + for c in $1 + do + echo "$c" + done >expect && + shift && + param="$*" && + test_expect_success "log $param" ' + git log --pretty="$FMT" --parents $param | + unnote >actual && + sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual && + test_cmp expect check || { + cat actual + false + } + ' +} + +check_result 'I H G F E D C B A' --full-history +check_result 'I H E C B A' --full-history -- file +check_result 'I H E C B A' --full-history --topo-order -- file +check_result 'I H E C B A' --full-history --date-order -- file +check_result 'I E C B A' --simplify-merges -- file +check_result 'I B A' -- file +check_result 'I B A' --topo-order -- file + +test_done diff --git a/t/t6013-rev-list-reverse-parents.sh b/t/t6013-rev-list-reverse-parents.sh new file mode 100755 index 0000000000..59fc2f06e0 --- /dev/null +++ b/t/t6013-rev-list-reverse-parents.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +test_description='--reverse combines with --parents' + +. ./test-lib.sh + + +commit () { + test_tick && + echo $1 > foo && + git add foo && + git commit -m "$1" +} + +test_expect_success 'set up --reverse example' ' + commit one && + git tag root && + commit two && + git checkout -b side HEAD^ && + commit three && + git checkout master && + git merge -s ours side && + commit five + ' + +test_expect_success '--reverse --parents --full-history combines correctly' ' + git rev-list --parents --full-history master -- foo | + perl -e "print reverse <>" > expected && + git rev-list --reverse --parents --full-history master -- foo \ + > actual && + test_cmp actual expected + ' + +test_expect_success '--boundary does too' ' + git rev-list --boundary --parents --full-history master ^root -- foo | + perl -e "print reverse <>" > expected && + git rev-list --boundary --reverse --parents --full-history \ + master ^root -- foo > actual && + test_cmp actual expected + ' + +test_done diff --git a/t/t6014-rev-list-all.sh b/t/t6014-rev-list-all.sh new file mode 100755 index 0000000000..991ab4a65b --- /dev/null +++ b/t/t6014-rev-list-all.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +test_description='--all includes detached HEADs' + +. ./test-lib.sh + + +commit () { + test_tick && + echo $1 > foo && + git add foo && + git commit -m "$1" +} + +test_expect_success 'setup' ' + + commit one && + commit two && + git checkout HEAD^ && + commit detached + +' + +test_expect_success 'rev-list --all lists detached HEAD' ' + + test 3 = $(git rev-list --all | wc -l) + +' + +test_expect_success 'repack does not lose detached HEAD' ' + + git gc && + git prune --expire=now && + git show HEAD + +' + +test_done diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index f674c48cab..f8942bc890 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -136,7 +136,7 @@ test_expect_success "expected conflict markers" "test_cmp expect out" test_expect_success 'binary files cannot be merged' ' test_must_fail git merge-file -p \ - orig.txt ../test4012.png new1.txt 2> merge.err && + orig.txt "$TEST_DIRECTORY"/test4012.png new1.txt 2> merge.err && grep "Cannot merge binary files" merge.err ' @@ -150,8 +150,8 @@ test_expect_success 'MERGE_ZEALOUS simplifies non-conflicts' ' ' -sed -e 's/deerit./&\n\n\n\n/' -e "s/locavit,/locavit;/" < new6.txt > new8.txt -sed -e 's/deerit./&\n\n\n\n/' -e "s/locavit,/locavit --/" < new7.txt > new9.txt +sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit;/"< new6.txt | tr '%' '\012' > new8.txt +sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit --/" < new7.txt | tr '%' '\012' > new9.txt test_expect_success 'ZEALOUS_ALNUM' ' @@ -161,4 +161,48 @@ test_expect_success 'ZEALOUS_ALNUM' ' ' +cat >expect <<\EOF +Dominus regit me, +<<<<<<< new8.txt +et nihil mihi deerit; + + + + +In loco pascuae ibi me collocavit; +super aquam refectionis educavit me. +||||||| +et nihil mihi deerit. +In loco pascuae ibi me collocavit, +super aquam refectionis educavit me; +======= +et nihil mihi deerit, + + + + +In loco pascuae ibi me collocavit -- +super aquam refectionis educavit me, +>>>>>>> new9.txt +animam meam convertit, +deduxit me super semitas jusitiae, +propter nomen suum. +Nam et si ambulavero in medio umbrae mortis, +non timebo mala, quoniam TU mecum es: +virga tua et baculus tuus ipsa me consolata sunt. +EOF + +test_expect_success '"diff3 -m" style output (1)' ' + test_must_fail git merge-file -p --diff3 \ + new8.txt new5.txt new9.txt >actual && + test_cmp expect actual +' + +test_expect_success '"diff3 -m" style output (2)' ' + git config merge.conflictstyle diff3 && + test_must_fail git merge-file -p \ + new8.txt new5.txt new9.txt >actual && + test_cmp expect actual +' + test_done diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh index 802d0d06eb..129fa3000c 100755 --- a/t/t6024-recursive-merge.sh +++ b/t/t6024-recursive-merge.sh @@ -97,4 +97,27 @@ test_expect_success 'refuse to merge binary files' ' merge.err ' +test_expect_success 'mark rename/delete as unmerged' ' + + git reset --hard && + git checkout -b delete && + git rm a1 && + test_tick && + git commit -m delete && + git checkout -b rename HEAD^ && + git mv a1 a2 + test_tick && + git commit -m rename && + test_must_fail git merge delete && + test 1 = $(git ls-files --unmerged | wc -l) && + git rev-parse --verify :2:a2 && + test_must_fail git rev-parse --verify :3:a2 && + git checkout -f delete && + test_must_fail git merge rename && + test 1 = $(git ls-files --unmerged | wc -l) && + test_must_fail git rev-parse --verify :2:a2 && + git rev-parse --verify :3:a2 + +' + test_done diff --git a/t/t6025-merge-symlinks.sh b/t/t6025-merge-symlinks.sh index 53892a555c..433c4de08f 100755 --- a/t/t6025-merge-symlinks.sh +++ b/t/t6025-merge-symlinks.sh @@ -18,11 +18,11 @@ git add file && git commit -m initial && git branch b-symlink && git branch b-file && -l=$(echo -n file | git hash-object -t blob -w --stdin) && +l=$(printf file | git hash-object -t blob -w --stdin) && 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) && +l=$(printf file-different | git hash-object -t blob -w --stdin) && echo "120000 $l symlink" | git update-index --index-info && git commit -m b-symlink && git checkout b-file && diff --git a/t/t6026-merge-attr.sh b/t/t6026-merge-attr.sh index 4b423e937d..1ba0a25223 100755 --- a/t/t6026-merge-attr.sh +++ b/t/t6026-merge-attr.sh @@ -142,4 +142,26 @@ test_expect_success 'custom merge backend' ' rm -f $o $a $b ' +test_expect_success 'up-to-date merge without common ancestor' ' + test_create_repo repo1 && + test_create_repo repo2 && + test_tick && + ( + cd repo1 && + >a && + git add a && + git commit -m initial + ) && + test_tick && + ( + cd repo2 && + git commit --allow-empty -m initial + ) && + test_tick && + ( + cd repo1 && + git pull ../repo2 master + ) +' + test_done diff --git a/t/t6027-merge-binary.sh b/t/t6027-merge-binary.sh index 92ca1f0f8c..b519626ca0 100755 --- a/t/t6027-merge-binary.sh +++ b/t/t6027-merge-binary.sh @@ -6,7 +6,7 @@ test_description='ask merge-recursive to merge binary files' test_expect_success setup ' - cat ../test4012.png >m && + cat "$TEST_DIRECTORY"/test4012.png >m && git add m && git ls-files -s | sed -e "s/ 0 / 1 /" >E1 && test_tick && diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 36c9a6965f..052a6c90f5 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -224,6 +224,31 @@ test_expect_success 'bisect skip: cannot tell between 2 commits' ' fi ' +# $HASH1 is good, $HASH4 is both skipped and bad, we skip $HASH3 +# and $HASH2 is good, +# so we should not be able to tell the first bad commit +# among $HASH3 and $HASH4 +test_expect_success 'bisect skip: with commit both bad and skipped' ' + git bisect start && + git bisect skip && + git bisect bad && + git bisect good $HASH1 && + git bisect skip && + if git bisect good > my_bisect_log.txt + then + echo Oops, should have failed. + false + else + test $? -eq 2 && + grep "first bad commit could be any of" my_bisect_log.txt && + ! grep $HASH1 my_bisect_log.txt && + ! grep $HASH2 my_bisect_log.txt && + grep $HASH3 my_bisect_log.txt && + grep $HASH4 my_bisect_log.txt && + git bisect reset + fi +' + # We want to automatically find the commit that # introduced "Another" into hello. test_expect_success \ @@ -313,8 +338,25 @@ test_expect_success 'bisect run & skip: find first bad' ' grep "$HASH6 is first bad commit" my_bisect_log.txt ' -test_expect_success 'bisect starting with a detached HEAD' ' +test_expect_success 'bisect skip only one range' ' + git bisect reset && + git bisect start $HASH7 $HASH1 && + git bisect skip $HASH1..$HASH5 && + test "$HASH6" = "$(git rev-parse --verify HEAD)" && + test_must_fail git bisect bad > my_bisect_log.txt && + grep "first bad commit could be any of" my_bisect_log.txt +' + +test_expect_success 'bisect skip many ranges' ' + git bisect start $HASH7 $HASH1 && + test "$HASH4" = "$(git rev-parse --verify HEAD)" && + git bisect skip $HASH2 $HASH2.. ..$HASH5 && + test "$HASH6" = "$(git rev-parse --verify HEAD)" && + test_must_fail git bisect bad > my_bisect_log.txt && + grep "first bad commit could be any of" my_bisect_log.txt +' +test_expect_success 'bisect starting with a detached HEAD' ' git bisect reset && git checkout master^ && HEAD=$(git rev-parse --verify HEAD) && @@ -350,6 +392,120 @@ test_expect_success 'bisect does not create a "bisect" branch' ' git branch -D bisect ' +# This creates a "side" branch to test "siblings" cases. +# +# H1-H2-H3-H4-H5-H6-H7 <--other +# \ +# S5-S6-S7 <--side +# +test_expect_success 'side branch creation' ' + git bisect reset && + git checkout -b side $HASH4 && + add_line_into_file "5(side): first line on a side branch" hello2 && + SIDE_HASH5=$(git rev-parse --verify HEAD) && + add_line_into_file "6(side): second line on a side branch" hello2 && + SIDE_HASH6=$(git rev-parse --verify HEAD) && + add_line_into_file "7(side): third line on a side branch" hello2 && + SIDE_HASH7=$(git rev-parse --verify HEAD) +' + +test_expect_success 'good merge base when good and bad are siblings' ' + git bisect start "$HASH7" "$SIDE_HASH7" > my_bisect_log.txt && + grep "merge base must be tested" my_bisect_log.txt && + grep $HASH4 my_bisect_log.txt && + git bisect good > my_bisect_log.txt && + test_must_fail grep "merge base must be tested" my_bisect_log.txt && + grep $HASH6 my_bisect_log.txt && + git bisect reset +' +test_expect_success 'skipped merge base when good and bad are siblings' ' + git bisect start "$SIDE_HASH7" "$HASH7" > my_bisect_log.txt && + grep "merge base must be tested" my_bisect_log.txt && + grep $HASH4 my_bisect_log.txt && + git bisect skip > my_bisect_log.txt 2>&1 && + grep "Warning" my_bisect_log.txt && + grep $SIDE_HASH6 my_bisect_log.txt && + git bisect reset +' + +test_expect_success 'bad merge base when good and bad are siblings' ' + git bisect start "$HASH7" HEAD > my_bisect_log.txt && + grep "merge base must be tested" my_bisect_log.txt && + grep $HASH4 my_bisect_log.txt && + test_must_fail git bisect bad > my_bisect_log.txt 2>&1 && + grep "merge base $HASH4 is bad" my_bisect_log.txt && + grep "fixed between $HASH4 and \[$SIDE_HASH7\]" my_bisect_log.txt && + git bisect reset +' + +# This creates a few more commits (A and B) to test "siblings" cases +# when a good and a bad rev have many merge bases. +# +# We should have the following: +# +# H1-H2-H3-H4-H5-H6-H7 +# \ \ \ +# S5-A \ +# \ \ +# S6-S7----B +# +# And there A and B have 2 merge bases (S5 and H5) that should be +# reported by "git merge-base --all A B". +# +test_expect_success 'many merge bases creation' ' + git checkout "$SIDE_HASH5" && + git merge -m "merge HASH5 and SIDE_HASH5" "$HASH5" && + A_HASH=$(git rev-parse --verify HEAD) && + git checkout side && + git merge -m "merge HASH7 and SIDE_HASH7" "$HASH7" && + B_HASH=$(git rev-parse --verify HEAD) && + git merge-base --all "$A_HASH" "$B_HASH" > merge_bases.txt && + test $(wc -l < merge_bases.txt) = "2" && + grep "$HASH5" merge_bases.txt && + grep "$SIDE_HASH5" merge_bases.txt +' + +test_expect_success 'good merge bases when good and bad are siblings' ' + git bisect start "$B_HASH" "$A_HASH" > my_bisect_log.txt && + grep "merge base must be tested" my_bisect_log.txt && + git bisect good > my_bisect_log2.txt && + grep "merge base must be tested" my_bisect_log2.txt && + { + { + grep "$SIDE_HASH5" my_bisect_log.txt && + grep "$HASH5" my_bisect_log2.txt + } || { + grep "$SIDE_HASH5" my_bisect_log2.txt && + grep "$HASH5" my_bisect_log.txt + } + } && + git bisect reset +' + +check_trace() { + grep "$1" "$GIT_TRACE" | grep "\^$2" | grep "$3" >/dev/null +} + +test_expect_success 'optimized merge base checks' ' + GIT_TRACE="$(pwd)/trace.log" && + export GIT_TRACE && + git bisect start "$HASH7" "$SIDE_HASH7" > my_bisect_log.txt && + grep "merge base must be tested" my_bisect_log.txt && + grep "$HASH4" my_bisect_log.txt && + check_trace "rev-list" "$HASH7" "$SIDE_HASH7" && + git bisect good > my_bisect_log2.txt && + test -f ".git/BISECT_ANCESTORS_OK" && + test "$HASH6" = $(git rev-parse --verify HEAD) && + : > "$GIT_TRACE" && + git bisect bad > my_bisect_log3.txt && + test_must_fail check_trace "rev-list" "$HASH6" "$SIDE_HASH7" && + git bisect good "$A_HASH" > my_bisect_log4.txt && + grep "merge base must be tested" my_bisect_log4.txt && + test_must_fail test -f ".git/BISECT_ANCESTORS_OK" && + check_trace "rev-list" "$HASH6" "$A_HASH" && + unset GIT_TRACE +' + # # test_done diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh index aac212e936..ba9060190d 100755 --- a/t/t6040-tracking-info.sh +++ b/t/t6040-tracking-info.sh @@ -53,7 +53,7 @@ test_expect_success 'checkout' ' ( cd test && git checkout b1 ) >actual && - grep -e "have 1 and 1 different" actual + grep "have 1 and 1 different" actual ' test_expect_success 'status' ' @@ -63,7 +63,7 @@ test_expect_success 'status' ' # reports nothing to commit test_must_fail git status ) >actual && - grep -e "have 1 and 1 different" actual + grep "have 1 and 1 different" actual ' diff --git a/t/t6101-rev-parse-parents.sh b/t/t6101-rev-parse-parents.sh index 919552a2fc..f105fab98e 100755 --- a/t/t6101-rev-parse-parents.sh +++ b/t/t6101-rev-parse-parents.sh @@ -6,7 +6,7 @@ test_description='Test git rev-parse with different parent options' . ./test-lib.sh -. ../t6000lib.sh # t6xxx specific functions +. "$TEST_DIRECTORY"/t6000lib.sh # t6xxx specific functions date >path0 git update-index --add path0 diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index 16cc635813..8c7e081c53 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -91,15 +91,21 @@ check_describe D-* HEAD^^ check_describe A-* HEAD^^2 check_describe B HEAD^^2^ -check_describe A-* --tags HEAD -check_describe A-* --tags HEAD^ -check_describe D-* --tags HEAD^^ -check_describe A-* --tags HEAD^^2 +check_describe c-* --tags HEAD +check_describe c-* --tags HEAD^ +check_describe e-* --tags HEAD^^ +check_describe c-* --tags HEAD^^2 check_describe B --tags HEAD^^2^ check_describe B-0-* --long HEAD^^2^ check_describe A-3-* --long HEAD^^2 +: >err.expect +check_describe A --all A^0 +test_expect_success 'no warning was displayed for A' ' + test_cmp err.expect err.actual +' + test_expect_success 'rename tag A to Q locally' ' mv .git/refs/tags/A .git/refs/tags/Q ' diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index bc74349416..8f5a06f7dd 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -83,13 +83,13 @@ test_expect_success 'merge-msg test #1' ' ' cat >expected <<EOF -Merge branch 'left' of ../$test +Merge branch 'left' of $TEST_DIRECTORY/$test EOF test_expect_success 'merge-msg test #2' ' git checkout master && - git fetch ../"$test" left && + git fetch "$TEST_DIRECTORY/$test" left && git fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index 26995b3cdd..8bfae44a83 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -262,6 +262,50 @@ for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do " done +cat >expected <<\EOF +master +testtag +EOF + +test_expect_success 'Check short refname format' ' + (git for-each-ref --format="%(refname:short)" refs/heads && + git for-each-ref --format="%(refname:short)" refs/tags) >actual && + test_cmp expected actual +' + +test_expect_success 'Check for invalid refname format' ' + test_must_fail git for-each-ref --format="%(refname:INVALID)" +' + +cat >expected <<\EOF +heads/master +master +EOF + +test_expect_success 'Check ambiguous head and tag refs' ' + git checkout -b newtag && + echo "Using $datestamp" > one && + git add one && + git commit -m "Branch" && + setdate_and_increment && + git tag -m "Tagging at $datestamp" master && + git for-each-ref --format "%(refname:short)" refs/heads/master refs/tags/master >actual && + test_cmp expected actual +' + +cat >expected <<\EOF +heads/ambiguous +ambiguous +EOF + +test_expect_success 'Check ambiguous head and tag refs II' ' + git checkout master && + git tag ambiguous testtag^0 && + git branch ambiguous testtag^0 && + git for-each-ref --format "%(refname:short)" refs/heads/ambiguous refs/tags/ambiguous >actual && + test_cmp expected actual +' + test_expect_success 'an unusual tag with an incomplete line' ' git tag -m "bogo" bogo && diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index 66bb1264ff..8fb3a56838 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -6,7 +6,7 @@ test_description='git mv in subdirs' test_expect_success \ 'prepare reference tree' \ 'mkdir path0 path1 && - cp ../../COPYING path0/COPYING && + cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && git add path0/COPYING && git commit -m add -a' @@ -39,8 +39,41 @@ test_expect_success \ grep "^R100..*path1/COPYING..*path0/COPYING"' test_expect_success \ + 'checking -k on non-existing file' \ + 'git mv -k idontexist path0' + +test_expect_success \ + 'checking -k on untracked file' \ + 'touch untracked1 && + git mv -k untracked1 path0 && + test -f untracked1 && + test ! -f path0/untracked1' + +test_expect_success \ + 'checking -k on multiple untracked files' \ + 'touch untracked2 && + git mv -k untracked1 untracked2 path0 && + test -f untracked1 && + test -f untracked2 && + test ! -f path0/untracked1 && + test ! -f path0/untracked2' + +test_expect_success \ + 'checking -f on untracked file with existing target' \ + 'touch path0/untracked1 && + git mv -f untracked1 path0 + test ! -f .git/index.lock && + test -f untracked1 && + test -f path0/untracked1' + +# clean up the mess in case bad things happen +rm -f idontexist untracked1 untracked2 \ + path0/idontexist path0/untracked1 path0/untracked2 \ + .git/index.lock + +test_expect_success \ 'adding another file' \ - 'cp ../../README path0/README && + 'cp "$TEST_DIRECTORY"/../README path0/README && git add path0/README && git commit -m add2 -a' diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index 5e359cb561..c4938544d4 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -109,7 +109,7 @@ do ' test_expect_success "grep -c $L (no /dev/null)" ' - ! git grep -c test $H | grep -q /dev/null + ! git grep -c test $H | grep /dev/null ' done @@ -161,7 +161,14 @@ test_expect_success 'log grep (6)' ' git log --author=-0700 --pretty=tformat:%s >actual && >expect && test_cmp expect actual +' +test_expect_success 'grep with CE_VALID file' ' + git update-index --assume-unchanged t/t && + rm t/t && + test "$(git grep --no-ext-grep t)" = "t/t:test" && + git update-index --no-assume-unchanged t/t && + git checkout t/t ' test_done diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 182aea4267..329c851685 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -39,13 +39,31 @@ test_expect_success 'result is really identical' ' ' test_expect_success 'rewrite bare repository identically' ' - (git config core.bare true && cd .git && git filter-branch branch) + (git config core.bare true && cd .git && + git filter-branch branch > filter-output 2>&1 && + ! fgrep fatal filter-output) ' git config core.bare false test_expect_success 'result is really identical' ' test $H = $(git rev-parse HEAD) ' +TRASHDIR=$(pwd) +test_expect_success 'correct GIT_DIR while using -d' ' + mkdir drepo && + ( cd drepo && + git init && + test_commit drepo && + git filter-branch -d "$TRASHDIR/dfoo" \ + --index-filter "cp \"$TRASHDIR\"/dfoo/backup-refs \"$TRASHDIR\"" \ + ) && + grep drepo "$TRASHDIR/backup-refs" +' + +test_expect_success 'Fail if commit filter fails' ' + test_must_fail git filter-branch -f --commit-filter "exit 1" HEAD +' + test_expect_success 'rewrite, renaming a specific file' ' git filter-branch -f --tree-filter "mv d doh || :" HEAD ' @@ -96,13 +114,17 @@ test_expect_success 'filter subdirectory only' ' test_tick && git commit -m "again not subdir" && git branch sub && - git filter-branch -f --subdirectory-filter subdir refs/heads/sub + git branch sub-earlier HEAD~2 && + git filter-branch -f --subdirectory-filter subdir \ + refs/heads/sub refs/heads/sub-earlier ' test_expect_success 'subdirectory filter result looks okay' ' test 2 = $(git rev-list sub | wc -l) && git show sub:new && - test_must_fail git show sub:subdir + test_must_fail git show sub:subdir && + git show sub-earlier:new && + test_must_fail git show sub-earlier:subdir ' test_expect_success 'more setup' ' @@ -250,4 +272,20 @@ test_expect_success 'Tag name filtering strips gpg signature' ' test_cmp expect actual ' +test_expect_success 'Tag name filtering allows slashes in tag names' ' + git tag -m tag-with-slash X/1 && + git cat-file tag X/1 | sed -e s,X/1,X/2, > expect && + git filter-branch -f --tag-name-filter "echo X/2" && + git cat-file tag X/2 > actual && + test_cmp expect actual +' + +test_expect_success 'Prune empty commits' ' + git rev-list HEAD > expect && + make_commit to_remove && + git filter-branch -f --index-filter "git update-index --remove to_remove" --prune-empty HEAD && + git rev-list HEAD > actual && + test_cmp expect actual +' + test_done diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index c616deb0d0..69501e2711 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -625,7 +625,7 @@ esac # Name and email: C O Mitter <committer@example.com> # No password given, to enable non-interactive operation. -cp -R ../t7004 ./gpghome +cp -R "$TEST_DIRECTORY"/t7004 ./gpghome chmod 0700 gpghome GNUPGHOME="$(pwd)/gpghome" export GNUPGHOME @@ -1090,6 +1090,121 @@ test_expect_success 'filename for the message is relative to cwd' ' git cat-file tag tag-from-subdir-2 | grep "in sub directory" ' +# create a few more commits to test --contains + +hash1=$(git rev-parse HEAD) + +test_expect_success 'creating second commit and tag' ' + echo foo-2.0 >foo && + git add foo && + git commit -m second + git tag v2.0 +' + +hash2=$(git rev-parse HEAD) + +test_expect_success 'creating third commit without tag' ' + echo foo-dev >foo && + git add foo && + git commit -m third +' + +hash3=$(git rev-parse HEAD) + +# simple linear checks of --continue + +cat > expected <<EOF +v0.2.1 +v1.0 +v1.0.1 +v1.1.3 +v2.0 +EOF + +test_expect_success 'checking that first commit is in all tags (hash)' " + git tag -l --contains $hash1 v* >actual + test_cmp expected actual +" + +# other ways of specifying the commit +test_expect_success 'checking that first commit is in all tags (tag)' " + git tag -l --contains v1.0 v* >actual + test_cmp expected actual +" + +test_expect_success 'checking that first commit is in all tags (relative)' " + git tag -l --contains HEAD~2 v* >actual + test_cmp expected actual +" + +cat > expected <<EOF +v2.0 +EOF + +test_expect_success 'checking that second commit only has one tag' " + git tag -l --contains $hash2 v* >actual + test_cmp expected actual +" + + +cat > expected <<EOF +EOF + +test_expect_success 'checking that third commit has no tags' " + git tag -l --contains $hash3 v* >actual + test_cmp expected actual +" + +# how about a simple merge? + +test_expect_success 'creating simple branch' ' + git branch stable v2.0 && + git checkout stable && + echo foo-3.0 > foo && + git commit foo -m fourth + git tag v3.0 +' + +hash4=$(git rev-parse HEAD) + +cat > expected <<EOF +v3.0 +EOF + +test_expect_success 'checking that branch head only has one tag' " + git tag -l --contains $hash4 v* >actual + test_cmp expected actual +" + +test_expect_success 'merging original branch into this branch' ' + git merge --strategy=ours master && + git tag v4.0 +' + +cat > expected <<EOF +v4.0 +EOF + +test_expect_success 'checking that original branch head has one tag now' " + git tag -l --contains $hash3 v* >actual + test_cmp expected actual +" + +cat > expected <<EOF +v0.2.1 +v1.0 +v1.0.1 +v1.1.3 +v2.0 +v3.0 +v4.0 +EOF + +test_expect_success 'checking that initial commit is in all tags' " + git tag -l --contains $hash1 v* >actual + test_cmp expected actual +" + # mixing modes and options: test_expect_success 'mixing incompatibles modes and options is forbidden' ' diff --git a/t/t7101-reset.sh b/t/t7101-reset.sh index c4ef19e402..96e163f084 100755 --- a/t/t7101-reset.sh +++ b/t/t7101-reset.sh @@ -9,7 +9,7 @@ test_description='git reset should cull empty subdirs' test_expect_success \ 'creating initial files' \ 'mkdir path0 && - cp ../../COPYING path0/COPYING && + cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && git add path0/COPYING && git commit -m add -a' @@ -17,10 +17,10 @@ test_expect_success \ 'creating second files' \ 'mkdir path1 && mkdir path1/path2 && - cp ../../COPYING path1/path2/COPYING && - cp ../../COPYING path1/COPYING && - cp ../../COPYING COPYING && - cp ../../COPYING path0/COPYING-TOO && + cp "$TEST_DIRECTORY"/../COPYING path1/path2/COPYING && + cp "$TEST_DIRECTORY"/../COPYING path1/COPYING && + cp "$TEST_DIRECTORY"/../COPYING COPYING && + cp "$TEST_DIRECTORY"/../COPYING path0/COPYING-TOO && git add path1/path2/COPYING && git add path1/COPYING && git add COPYING && diff --git a/t/t7201-co.sh b/t/t7201-co.sh index c9abed6a2b..bdb808af1a 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -171,7 +171,7 @@ test_expect_success 'checkout to detach HEAD' ' git checkout -f renamer && git clean -f && git checkout renamer^ 2>messages && (cat >messages.expect <<EOF -Note: moving to "renamer^" which isn'"'"'t a local branch +Note: moving to '\''renamer^'\'' which isn'\''t a local branch If you want to create a new branch from this checkout, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new_branch_name> @@ -351,7 +351,39 @@ test_expect_success 'detach a symbolic link HEAD' ' test "z$(git rev-parse --verify refs/heads/master)" = "z$here" ' -test_expect_success 'checkout an unmerged path should fail' ' +test_expect_success \ + 'checkout with --track fakes a sensible -b <name>' ' + git update-ref refs/remotes/origin/koala/bear renamer && + git update-ref refs/new/koala/bear renamer && + + git checkout --track origin/koala/bear && + test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && + test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" && + + git checkout master && git branch -D koala/bear && + + git checkout --track refs/remotes/origin/koala/bear && + test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && + test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" && + + git checkout master && git branch -D koala/bear && + + git checkout --track remotes/origin/koala/bear && + test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && + test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" && + + git checkout master && git branch -D koala/bear && + + git checkout --track refs/new/koala/bear && + test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && + test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" +' + +test_expect_success \ + 'checkout with --track, but without -b, fails with too short tracked name' ' + test_must_fail git checkout --track renamer' + +setup_conflicting_index () { rm -f .git/index && O=$(echo original | git hash-object -w --stdin) && A=$(echo ourside | git hash-object -w --stdin) && @@ -362,7 +394,11 @@ test_expect_success 'checkout an unmerged path should fail' ' echo "100644 $A 2 file" && echo "100644 $B 3 file" && echo "100644 $A 0 filf" - ) | git update-index --index-info && + ) | git update-index --index-info +} + +test_expect_success 'checkout an unmerged path should fail' ' + setup_conflicting_index && echo "none of the above" >sample && cat sample >fild && cat sample >file && @@ -373,6 +409,121 @@ test_expect_success 'checkout an unmerged path should fail' ' test_cmp sample file ' +test_expect_success 'checkout with an unmerged path can be ignored' ' + setup_conflicting_index && + echo "none of the above" >sample && + echo ourside >expect && + cat sample >fild && + cat sample >file && + cat sample >filf && + git checkout -f fild file filf && + test_cmp expect fild && + test_cmp expect filf && + test_cmp sample file +' + +test_expect_success 'checkout unmerged stage' ' + setup_conflicting_index && + echo "none of the above" >sample && + echo ourside >expect && + cat sample >fild && + cat sample >file && + cat sample >filf && + git checkout --ours . && + test_cmp expect fild && + test_cmp expect filf && + test_cmp expect file && + git checkout --theirs file && + test ztheirside = "z$(cat file)" +' + +test_expect_success 'checkout with --merge' ' + setup_conflicting_index && + echo "none of the above" >sample && + echo ourside >expect && + cat sample >fild && + cat sample >file && + cat sample >filf && + git checkout -m -- fild file filf && + ( + echo "<<<<<<< ours" + echo ourside + echo "=======" + echo theirside + echo ">>>>>>> theirs" + ) >merged && + test_cmp expect fild && + test_cmp expect filf && + test_cmp merged file +' + +test_expect_success 'checkout with --merge, in diff3 -m style' ' + git config merge.conflictstyle diff3 && + setup_conflicting_index && + echo "none of the above" >sample && + echo ourside >expect && + cat sample >fild && + cat sample >file && + cat sample >filf && + git checkout -m -- fild file filf && + ( + echo "<<<<<<< ours" + echo ourside + echo "|||||||" + echo original + echo "=======" + echo theirside + echo ">>>>>>> theirs" + ) >merged && + test_cmp expect fild && + test_cmp expect filf && + test_cmp merged file +' + +test_expect_success 'checkout --conflict=merge, overriding config' ' + git config merge.conflictstyle diff3 && + setup_conflicting_index && + echo "none of the above" >sample && + echo ourside >expect && + cat sample >fild && + cat sample >file && + cat sample >filf && + git checkout --conflict=merge -- fild file filf && + ( + echo "<<<<<<< ours" + echo ourside + echo "=======" + echo theirside + echo ">>>>>>> theirs" + ) >merged && + test_cmp expect fild && + test_cmp expect filf && + test_cmp merged file +' + +test_expect_success 'checkout --conflict=diff3' ' + git config --unset merge.conflictstyle + setup_conflicting_index && + echo "none of the above" >sample && + echo ourside >expect && + cat sample >fild && + cat sample >file && + cat sample >filf && + git checkout --conflict=diff3 -- fild file filf && + ( + echo "<<<<<<< ours" + echo ourside + echo "|||||||" + echo original + echo "=======" + echo theirside + echo ">>>>>>> theirs" + ) >merged && + test_cmp expect fild && + test_cmp expect filf && + test_cmp merged file +' + test_expect_success 'failing checkout -b should not break working tree' ' git reset --hard master && git symbolic-ref HEAD refs/heads/master && diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index be73f7b60a..af690ec6c1 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -47,6 +47,55 @@ test_expect_success 'Prepare submodule testing' ' GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git ' +test_expect_success 'Prepare submodule add testing' ' + submodurl=$(pwd) + ( + mkdir addtest && + cd addtest && + git init + ) +' + +test_expect_success 'submodule add' ' + ( + cd addtest && + git submodule add "$submodurl" submod && + git submodule init + ) +' + +test_expect_success 'submodule add with ./ in path' ' + ( + cd addtest && + git submodule add "$submodurl" ././dotsubmod/./frotz/./ && + git submodule init + ) +' + +test_expect_success 'submodule add with // in path' ' + ( + cd addtest && + git submodule add "$submodurl" slashslashsubmod///frotz// && + git submodule init + ) +' + +test_expect_success 'submodule add with /.. in path' ' + ( + cd addtest && + git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. && + git submodule init + ) +' + +test_expect_success 'submodule add with ./, /.. and // in path' ' + ( + cd addtest && + git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. && + git submodule init + ) +' + test_expect_success 'status should fail for unmapped paths' ' if git submodule status then @@ -209,4 +258,42 @@ test_expect_success 'update --init' ' ' +test_expect_success 'do not add files from a submodule' ' + + git reset --hard && + test_must_fail git add init/a + +' + +test_expect_success 'gracefully add submodule with a trailing slash' ' + + git reset --hard && + git commit -m "commit subproject" init && + (cd init && + echo b > a) && + git add init/ && + git diff --exit-code --cached init && + commit=$(cd init && + git commit -m update a >/dev/null && + git rev-parse HEAD) && + git add init/ && + test_must_fail git diff --exit-code --cached init && + test $commit = $(git ls-files --stage | + sed -n "s/^160000 \([^ ]*\).*/\1/p") + +' + +test_expect_success 'ls-files gracefully handles trailing slash' ' + + test "init" = "$(git ls-files init/)" + +' + +test_expect_success 'submodule <invalid-path> warns' ' + + git submodule no-such-submodule 2> output.err && + grep "^error: .*no-such-submodule" output.err + +' + test_done diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh new file mode 100755 index 0000000000..7538756487 --- /dev/null +++ b/t/t7403-submodule-sync.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# +# Copyright (c) 2008 David Aguilar +# + +test_description='git submodule sync + +These tests exercise the "git submodule sync" subcommand. +' + +. ./test-lib.sh + +test_expect_success setup ' + echo file > file && + git add file && + test_tick && + git commit -m upstream + git clone . super && + git clone super submodule && + (cd super && + git submodule add ../submodule submodule && + test_tick && + git commit -m "submodule" + ) && + git clone super super-clone && + (cd super-clone && git submodule update --init) +' + +test_expect_success 'change submodule' ' + (cd submodule && + echo second line >> file && + test_tick && + git commit -a -m "change submodule" + ) +' + +test_expect_success 'change submodule url' ' + (cd super && + cd submodule && + git checkout master && + git pull + ) && + mv submodule moved-submodule && + (cd super && + git config -f .gitmodules submodule.submodule.url ../moved-submodule + test_tick && + git commit -a -m moved-submodule + ) +' + +test_expect_success '"git submodule sync" should update submodule URLs' ' + (cd super-clone && + git pull && + git submodule sync + ) && + test -d "$(git config -f super-clone/submodule/.git/config \ + remote.origin.url)" && + (cd super-clone/submodule && + git checkout master && + git pull + ) +' + +test_done diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh index 0fe745ea0d..5998baf27b 100755 --- a/t/t7500-commit.sh +++ b/t/t7500-commit.sh @@ -46,15 +46,24 @@ test_expect_success 'unedited template with comments should not commit' ' ' test_expect_success 'a Signed-off-by line by itself should not commit' ' - ! GIT_EDITOR=../t7500/add-signed-off git commit --template "$TEMPLATE" + ( + test_set_editor "$TEST_DIRECTORY"/t7500/add-signed-off && + test_must_fail 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_set_editor "$TEST_DIRECTORY"/t7500/add-comments && + test_must_fail git commit --template "$TEMPLATE" + ) ' test_expect_success 'adding real content to a template should commit' ' - GIT_EDITOR=../t7500/add-content git commit --template "$TEMPLATE" && + ( + test_set_editor "$TEST_DIRECTORY"/t7500/add-content && + git commit --template "$TEMPLATE" + ) && commit_msg_is "template linecommit message" ' @@ -62,7 +71,10 @@ 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" && + ( + test_set_editor "$TEST_DIRECTORY"/t7500/add-content && + git commit -t "$TEMPLATE" + ) && commit_msg_is "short templatecommit message" ' @@ -71,7 +83,10 @@ test_expect_success 'config-specified template should commit' ' git config commit.template "$TEMPLATE" && echo "more content" >> foo && git add foo && - GIT_EDITOR=../t7500/add-content git commit && + ( + test_set_editor "$TEST_DIRECTORY"/t7500/add-content && + git commit + ) && git config --unset commit.template && commit_msg_is "new templatecommit message" ' @@ -79,7 +94,7 @@ test_expect_success 'config-specified template should commit' ' 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" \ + GIT_EDITOR="$TEST_DIRECTORY"/t7500/add-content git commit --template "$TEMPLATE" \ -m "command line msg" && commit_msg_is "command line msg" ' @@ -88,8 +103,10 @@ 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 - && + ( + test_set_editor "$TEST_DIRECTORY"/t7500/add-content && + git commit --template "$TEMPLATE" --file - + ) && commit_msg_is "standard input msg" ' @@ -132,10 +149,9 @@ EOF test_expect_success '--signoff' ' echo "yet another content *narf*" >> foo && - echo "zort" | - GIT_EDITOR=../t7500/add-content git commit -s -F - foo && + echo "zort" | git commit -s -F - foo && git cat-file commit HEAD | sed "1,/^$/d" > output && - diff expect output + test_cmp expect output ' test_expect_success 'commit message from file (1)' ' diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 63bfc6d8b3..b4e2b4db84 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -127,6 +127,26 @@ test_expect_success \ "showing committed revisions" \ "git rev-list HEAD >current" +cat >editor <<\EOF +#!/bin/sh +sed -e "s/good/bad/g" < "$1" > "$1-" +mv "$1-" "$1" +EOF +chmod 755 editor + +cat >msg <<EOF +A good commit message. +EOF + +test_expect_success \ + 'editor not invoked if -F is given' ' + echo "moo" >file && + VISUAL=./editor git commit -a -F msg && + git show -s --pretty=format:"%s" | grep -q good && + echo "quack" >file && + echo "Another good message." | VISUAL=./editor git commit -a -F - && + git show -s --pretty=format:"%s" | grep -q good + ' # We could just check the head sha1, but checking each commit makes it # easier to isolate bugs. diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh index 3eb9faedcf..ad42c78d7c 100755 --- a/t/t7502-commit.sh +++ b/t/t7502-commit.sh @@ -89,6 +89,14 @@ test_expect_success 'verbose' ' ' +test_expect_success 'verbose respects diff config' ' + + git config color.diff always && + git status -v >actual && + grep "\[1mdiff --git" actual && + git config --unset color.diff +' + test_expect_success 'cleanup commit messages (verbatim,-t)' ' echo >>negative && diff --git a/t/t7502-status.sh b/t/t7502-status.sh index 187a13e64f..93f875f500 100755 --- a/t/t7502-status.sh +++ b/t/t7502-status.sh @@ -46,6 +46,7 @@ cat > expect << \EOF # # Changed but not updated: # (use "git add <file>..." to update what will be committed) +# (use "git checkout -- <file>..." to discard changes in working directory) # # modified: dir1/modified # @@ -76,6 +77,7 @@ cat >expect <<EOF # # Changed but not updated: # (use "git add <file>..." to update what will be committed) +# (use "git checkout -- <file>..." to discard changes in working directory) # # modified: dir1/modified # @@ -104,6 +106,7 @@ cat >expect <<EOF # # Changed but not updated: # (use "git add <file>..." to update what will be committed) +# (use "git checkout -- <file>..." to discard changes in working directory) # # modified: dir1/modified # @@ -138,6 +141,7 @@ cat >expect <<EOF # # Changed but not updated: # (use "git add <file>..." to update what will be committed) +# (use "git checkout -- <file>..." to discard changes in working directory) # # modified: dir1/modified # @@ -174,6 +178,7 @@ cat > expect << \EOF # # Changed but not updated: # (use "git add <file>..." to update what will be committed) +# (use "git checkout -- <file>..." to discard changes in working directory) # # modified: modified # @@ -204,6 +209,7 @@ cat > expect << \EOF # # Changed but not updated: # (use "git add <file>..." to update what will be committed) +# (use "git checkout -- <file>..." to discard changes in working directory) # # modified: dir1/modified # @@ -267,6 +273,7 @@ cat >expect <<EOF # # Changed but not updated: # (use "git add <file>..." to update what will be committed) +# (use "git checkout -- <file>..." to discard changes in working directory) # # modified: dir1/modified # @@ -303,6 +310,7 @@ cat >expect <<EOF # # Changed but not updated: # (use "git add <file>..." to update what will be committed) +# (use "git checkout -- <file>..." to discard changes in working directory) # # modified: dir1/modified # @@ -332,6 +340,7 @@ cat >expect <<EOF # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) +# (use "git checkout -- <file>..." to discard changes in working directory) # # modified: dir1/modified # @@ -363,6 +372,7 @@ cat >expect <<EOF # # Changed but not updated: # (use "git add <file>..." to update what will be committed) +# (use "git checkout -- <file>..." to discard changes in working directory) # # modified: dir1/modified # diff --git a/t/t7507-commit-verbose.sh b/t/t7507-commit-verbose.sh index 519adba80b..da5bd3b5a5 100755 --- a/t/t7507-commit-verbose.sh +++ b/t/t7507-commit-verbose.sh @@ -22,7 +22,7 @@ test_expect_success 'setup' ' git commit -F message ' -test_expect_failure 'initial commit shows verbose diff' ' +test_expect_success 'initial commit shows verbose diff' ' git commit --amend -v ' diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 5abce3119b..e5b210bc96 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -230,6 +230,10 @@ test_expect_success 'test option parsing' ' test_must_fail git merge ' +test_expect_success 'reject non-strategy with a git-merge-foo name' ' + test_must_fail git merge -s index c1 +' + test_expect_success 'merge c0 with c1' ' git reset --hard c0 && git merge c1 && @@ -507,6 +511,13 @@ test_expect_success 'in-index merge' ' test_debug 'gitk --all' +test_expect_success 'refresh the index before merging' ' + git reset --hard c1 && + sleep 1 && + touch file && + git merge c3 +' + cat >expected <<EOF Merge branch 'c5' (early part) EOF @@ -533,4 +544,20 @@ test_expect_success 'merge early part of c2' ' test_debug 'gitk --all' +test_expect_success 'merge --no-ff --no-commit && commit' ' + git reset --hard c0 && + git merge --no-ff --no-commit c1 && + EDITOR=: git commit && + verify_parents $c0 $c1 +' + +test_debug 'gitk --all' + +test_expect_success 'amending no-ff merge commit' ' + EDITOR=: git commit --amend && + verify_parents $c0 $c1 +' + +test_debug 'gitk --all' + test_done diff --git a/t/t7603-merge-reduce-heads.sh b/t/t7603-merge-reduce-heads.sh index b47b7b9757..7e17eb490d 100755 --- a/t/t7603-merge-reduce-heads.sh +++ b/t/t7603-merge-reduce-heads.sh @@ -60,4 +60,57 @@ test_expect_success 'merge c1 with c2, c3, c4, c5' ' test -f c5.c ' +test_expect_success 'setup' ' + for i in A B C D E + do + echo $i > $i.c && + git add $i.c && + git commit -m $i && + git tag $i + done && + git reset --hard A && + for i in F G H I + do + echo $i > $i.c && + git add $i.c && + git commit -m $i && + git tag $i + done +' + +test_expect_success 'merge E and I' ' + git reset --hard A && + git merge E I +' + +test_expect_success 'verify merge result' ' + test $(git rev-parse HEAD^1) = $(git rev-parse E) && + test $(git rev-parse HEAD^2) = $(git rev-parse I) +' + +test_expect_success 'add conflicts' ' + git reset --hard E && + echo foo > file.c && + git add file.c && + git commit -m E2 && + git tag E2 && + git reset --hard I && + echo bar >file.c && + git add file.c && + git commit -m I2 && + git tag I2 +' + +test_expect_success 'merge E2 and I2, causing a conflict and resolve it' ' + git reset --hard A && + test_must_fail git merge E2 I2 && + echo baz > file.c && + git add file.c && + git commit -m "resolve conflict" +' + +test_expect_success 'verify merge result' ' + test $(git rev-parse HEAD^1) = $(git rev-parse E2) && + test $(git rev-parse HEAD^2) = $(git rev-parse I2) +' test_done diff --git a/t/t7606-merge-custom.sh b/t/t7606-merge-custom.sh new file mode 100755 index 0000000000..52a451dd57 --- /dev/null +++ b/t/t7606-merge-custom.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +test_description='git merge + +Testing a custom strategy.' + +. ./test-lib.sh + +cat >git-merge-theirs <<EOF +#!$SHELL_PATH +eval git read-tree --reset -u \\\$\$# +EOF +chmod +x git-merge-theirs +PATH=.:$PATH +export PATH + +test_expect_success 'setup' ' + echo c0 >c0.c && + git add c0.c && + git commit -m c0 && + git tag c0 && + echo c1 >c1.c && + git add c1.c && + git commit -m c1 && + git tag c1 && + git reset --hard c0 && + echo c1c1 >c1.c && + echo c2 >c2.c && + git add c1.c c2.c && + git commit -m c2 && + git tag c2 +' + +test_expect_success 'merge c2 with a custom strategy' ' + git reset --hard c1 && + git merge -s theirs c2 && + test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" && + test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" && + test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" && + test "$(git rev-parse c2^{tree})" = "$(git rev-parse HEAD^{tree})" && + git diff --exit-code && + git diff --exit-code c2 HEAD && + git diff --exit-code c2 && + test -f c0.c && + grep c1c1 c1.c && + test -f c2.c +' + +test_done diff --git a/t/t7607-merge-overwrite.sh b/t/t7607-merge-overwrite.sh new file mode 100755 index 0000000000..49f4e1599a --- /dev/null +++ b/t/t7607-merge-overwrite.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +test_description='git-merge + +Do not overwrite changes.' + +. ./test-lib.sh + +test_expect_success 'setup' ' + echo c0 > c0.c && + git add c0.c && + git commit -m c0 && + git tag c0 && + echo c1 > c1.c && + git add c1.c && + git commit -m c1 && + git tag c1 && + git reset --hard c0 && + echo c2 > c2.c && + git add c2.c && + git commit -m c2 && + git tag c2 && + git reset --hard c1 && + echo "c1 a" > c1.c && + git add c1.c && + git commit -m "c1 a" && + git tag c1a && + echo "VERY IMPORTANT CHANGES" > important +' + +test_expect_success 'will not overwrite untracked file' ' + git reset --hard c1 && + cat important > c2.c && + ! git merge c2 && + test_cmp important c2.c +' + +test_expect_success 'will not overwrite new file' ' + git reset --hard c1 && + cat important > c2.c && + git add c2.c && + ! git merge c2 && + test_cmp important c2.c +' + +test_expect_success 'will not overwrite staged changes' ' + git reset --hard c1 && + cat important > c2.c && + git add c2.c && + rm c2.c && + ! git merge c2 && + git checkout c2.c && + test_cmp important c2.c +' + +test_expect_success 'will not overwrite removed file' ' + git reset --hard c1 && + git rm c1.c && + git commit -m "rm c1.c" && + cat important > c1.c && + ! git merge c1a && + test_cmp important c1.c +' + +test_expect_success 'will not overwrite re-added file' ' + git reset --hard c1 && + git rm c1.c && + git commit -m "rm c1.c" && + cat important > c1.c && + git add c1.c && + ! git merge c1a && + test_cmp important c1.c +' + +test_expect_success 'will not overwrite removed file with staged changes' ' + git reset --hard c1 && + git rm c1.c && + git commit -m "rm c1.c" && + cat important > c1.c && + git add c1.c && + rm c1.c && + ! git merge c1a && + git checkout c1.c && + test_cmp important c1.c +' + +test_done diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index 09fa5f115c..e768c3eb2d 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -9,38 +9,81 @@ Testing basic merge tool invocation' . ./test-lib.sh +# All the mergetool test work by checking out a temporary branch based +# off 'branch1' and then merging in master and checking the results of +# running mergetool + test_expect_success 'setup' ' echo master >file1 && - git add file1 && + mkdir subdir && + echo master sub >subdir/file3 && + git add file1 subdir/file3 && git commit -m "added file1" && + git checkout -b branch1 master && echo branch1 change >file1 && echo branch1 newfile >file2 && - git add file1 file2 && + echo branch1 sub >subdir/file3 && + git add file1 file2 subdir/file3 && git commit -m "branch1 changes" && - git checkout -b branch2 master && - echo branch2 change >file1 && - echo branch2 newfile >file2 && - git add file1 file2 && - git commit -m "branch2 changes" && + git checkout master && echo master updated >file1 && echo master new >file2 && - git add file1 file2 && - git commit -m "master updates" -' + echo master new sub >subdir/file3 && + git add file1 file2 subdir/file3 && + git commit -m "master updates" && -test_expect_success 'custom mergetool' ' git config merge.tool mytool && git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && - git config mergetool.mytool.trustExitCode true && - git checkout branch1 && + git config mergetool.mytool.trustExitCode true +' + +test_expect_success 'custom mergetool' ' + git checkout -b test1 branch1 && test_must_fail git merge master >/dev/null 2>&1 && - ( yes "" | git mergetool file1>/dev/null 2>&1 ) && - ( yes "" | git mergetool file2>/dev/null 2>&1 ) && + ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && + ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && test "$(cat file1)" = "master updated" && test "$(cat file2)" = "master new" && - git commit -m "branch1 resolved with mergetool" + test "$(cat subdir/file3)" = "master new sub" && + git commit -m "branch1 resolved with mergetool" ' +test_expect_success 'mergetool crlf' ' + git config core.autocrlf true && + git checkout -b test2 branch1 + test_must_fail git merge master >/dev/null 2>&1 && + ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && + ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && + ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && + test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" && + test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" && + test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" && + git commit -m "branch1 resolved with mergetool - autocrlf" && + git config core.autocrlf false && + git reset --hard +' + +test_expect_success 'mergetool in subdir' ' + git checkout -b test3 branch1 + cd subdir && ( + test_must_fail git merge master >/dev/null 2>&1 && + ( yes "" | git mergetool file3 >/dev/null 2>&1 ) && + test "$(cat file3)" = "master new sub" ) +' + +# We can't merge files from parent directories when running mergetool +# from a subdir. Is this a bug? +# +#test_expect_failure 'mergetool in subdir' ' +# cd subdir && ( +# ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && +# ( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) && +# test "$(cat ../file1)" = "master updated" && +# test "$(cat ../file2)" = "master new" && +# git commit -m "branch1 resolved with mergetool - subdir" ) +#' + test_done diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 9ce546e3b2..6b29bff782 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -69,6 +69,25 @@ test_expect_success 'packed obs in alt ODB are repacked even when local repo is done ' +test_expect_failure 'packed obs in alt ODB are repacked when local repo has packs' ' + rm -f .git/objects/pack/* && + echo new_content >> file1 && + git add file1 && + git commit -m more_content && + git repack && + git repack -a -d && + myidx=$(ls -1 .git/objects/pack/*.idx) && + test -f "$myidx" && + for p in alt_objects/pack/*.idx; do + git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" + done | while read sha1 rest; do + if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then + echo "Missing object in local pack: $sha1" + return 1 + fi + done +' + test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' # swap the .keep so the commit object is in the pack with .keep for p in alt_objects/pack/*.pack diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh index 9813f113a2..5babdf26e6 100755 --- a/t/t7701-repack-unpack-unreachable.sh +++ b/t/t7701-repack-unpack-unreachable.sh @@ -29,7 +29,7 @@ test_expect_success '-A with -d option leaves unreachable objects unpacked' ' git repack -A -d -l && # verify objects are packed in repository test 3 = $(git verify-pack -v -- .git/objects/pack/*.idx | - grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " | + egrep "^($fsha1|$csha1|$tsha1) " | sort | uniq | wc -l) && git show $fsha1 && git show $csha1 && @@ -41,7 +41,7 @@ test_expect_success '-A with -d option leaves unreachable objects unpacked' ' git repack -A -d -l && # verify objects are retained unpacked test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | - grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " | + egrep "^($fsha1|$csha1|$tsha1) " | sort | uniq | wc -l) && git show $fsha1 && git show $csha1 && @@ -50,12 +50,10 @@ test_expect_success '-A with -d option leaves unreachable objects unpacked' ' compare_mtimes () { - perl -e 'my $reference = shift; - foreach my $file (@ARGV) { - exit(1) unless(-f $file && -M $file == -M $reference); - } - exit(0); - ' -- "$@" + read tref rest && + while read t rest; do + test "$tref" = "$t" || break + done } test_expect_success '-A without -d option leaves unreachable objects packed' ' @@ -87,7 +85,9 @@ test_expect_success 'unpacked objects receive timestamp of pack file' ' tmppack=".git/objects/pack/tmp_pack" && ln "$packfile" "$tmppack" && git repack -A -l -d && - compare_mtimes "$tmppack" "$fsha1path" "$csha1path" "$tsha1path" + test-chmtime -v +0 "$tmppack" "$fsha1path" "$csha1path" "$tsha1path" \ + > mtimes && + compare_mtimes < mtimes ' test_done diff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh index eabec2e06e..45cb60ea4b 100755 --- a/t/t8001-annotate.sh +++ b/t/t8001-annotate.sh @@ -4,7 +4,7 @@ test_description='git annotate' . ./test-lib.sh PROG='git annotate' -. ../annotate-tests.sh +. "$TEST_DIRECTORY"/annotate-tests.sh test_expect_success \ 'Annotating an old revision works' \ diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh index 92ece30fa9..597cf0486f 100755 --- a/t/t8002-blame.sh +++ b/t/t8002-blame.sh @@ -4,6 +4,6 @@ test_description='git blame' . ./test-lib.sh PROG='git blame -c' -. ../annotate-tests.sh +. "$TEST_DIRECTORY"/annotate-tests.sh test_done diff --git a/t/t8005-blame-i18n.sh b/t/t8005-blame-i18n.sh new file mode 100755 index 0000000000..4470a92bb2 --- /dev/null +++ b/t/t8005-blame-i18n.sh @@ -0,0 +1,92 @@ +#!/bin/sh + +test_description='git blame encoding conversion' +. ./test-lib.sh + +. "$TEST_DIRECTORY"/t8005/utf8.txt +. "$TEST_DIRECTORY"/t8005/cp1251.txt +. "$TEST_DIRECTORY"/t8005/sjis.txt + +test_expect_success 'setup the repository' ' + # Create the file + echo "UTF-8 LINE" > file && + git add file && + git commit --author "$UTF8_NAME <utf8@localhost>" -m "$UTF8_MSG" && + + echo "CP1251 LINE" >> file && + git add file && + git config i18n.commitencoding cp1251 && + git commit --author "$CP1251_NAME <cp1251@localhost>" -m "$CP1251_MSG" && + + echo "SJIS LINE" >> file && + git add file && + git config i18n.commitencoding shift-jis && + git commit --author "$SJIS_NAME <sjis@localhost>" -m "$SJIS_MSG" +' + +cat >expected <<EOF +author $SJIS_NAME +summary $SJIS_MSG +author $SJIS_NAME +summary $SJIS_MSG +author $SJIS_NAME +summary $SJIS_MSG +EOF + +test_expect_success \ + 'blame respects i18n.commitencoding' ' + git blame --incremental file | \ + grep "^\(author\|summary\) " > actual && + test_cmp actual expected +' + +cat >expected <<EOF +author $CP1251_NAME +summary $CP1251_MSG +author $CP1251_NAME +summary $CP1251_MSG +author $CP1251_NAME +summary $CP1251_MSG +EOF + +test_expect_success \ + 'blame respects i18n.logoutputencoding' ' + git config i18n.logoutputencoding cp1251 && + git blame --incremental file | \ + grep "^\(author\|summary\) " > actual && + test_cmp actual expected +' + +cat >expected <<EOF +author $UTF8_NAME +summary $UTF8_MSG +author $UTF8_NAME +summary $UTF8_MSG +author $UTF8_NAME +summary $UTF8_MSG +EOF + +test_expect_success \ + 'blame respects --encoding=utf-8' ' + git blame --incremental --encoding=utf-8 file | \ + grep "^\(author\|summary\) " > actual && + test_cmp actual expected +' + +cat >expected <<EOF +author $SJIS_NAME +summary $SJIS_MSG +author $CP1251_NAME +summary $CP1251_MSG +author $UTF8_NAME +summary $UTF8_MSG +EOF + +test_expect_success \ + 'blame respects --encoding=none' ' + git blame --incremental --encoding=none file | \ + grep "^\(author\|summary\) " > actual && + test_cmp actual expected +' + +test_done diff --git a/t/t8005/cp1251.txt b/t/t8005/cp1251.txt new file mode 100644 index 0000000000..ce41e98b81 --- /dev/null +++ b/t/t8005/cp1251.txt @@ -0,0 +1,2 @@ +CP1251_NAME=" " +CP1251_MSG=" " diff --git a/t/t8005/sjis.txt b/t/t8005/sjis.txt new file mode 100644 index 0000000000..2ccfbad207 --- /dev/null +++ b/t/t8005/sjis.txt @@ -0,0 +1,2 @@ +SJIS_NAME="Irp~ Pury Rytr" +SJIS_MSG="Suru qu~yu" diff --git a/t/t8005/utf8.txt b/t/t8005/utf8.txt new file mode 100644 index 0000000000..f46cfc56d8 --- /dev/null +++ b/t/t8005/utf8.txt @@ -0,0 +1,2 @@ +UTF8_NAME="Иван Петрович Сидоров" +UTF8_MSG="Тестовое сообщение" diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index d098a01ba3..d7634187aa 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -32,16 +32,18 @@ clean_fake_sendmail() { } test_expect_success 'Extract patches' ' - patches=`git format-patch -n HEAD^1` + patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1` ' test_expect_success 'Send patches' ' - git send-email --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors + git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors ' cat >expected <<\EOF !nobody@example.com! !author@example.com! +!one@example.com! +!two@example.com! EOF test_expect_success \ 'Verify commandline' \ @@ -50,13 +52,15 @@ test_expect_success \ cat >expected-show-all-headers <<\EOF 0001-Second.patch (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' +(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<bcc@example.com> +RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<bcc@example.com> From: Example <from@example.com> To: to@example.com -Cc: cc@example.com, A <author@example.com> +Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -70,6 +74,7 @@ EOF test_expect_success 'Show all headers' ' git send-email \ --dry-run \ + --suppress-cc=sob \ --from="Example <from@example.com>" \ --to=to@example.com \ --cc=cc@example.com \ @@ -104,12 +109,34 @@ test_expect_success 'no patch was sent' ' ! test -e commandline1 ' +test_expect_success 'Author From: in message body' ' + clean_fake_sendmail && + git send-email \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && + sed "1,/^$/d" < msgtxt1 > msgbody1 + grep "From: A <author@example.com>" msgbody1 +' + +test_expect_success 'Author From: not in message body' ' + clean_fake_sendmail && + git send-email \ + --from="A <author@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + $patches && + sed "1,/^$/d" < msgtxt1 > msgbody1 + ! grep "From: A <author@example.com>" msgbody1 +' + test_expect_success 'allow long lines with --no-validate' ' git send-email \ --from="Example <nobody@example.com>" \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ - --no-validate \ + --novalidate \ $patches longline.patch \ 2>errors ' @@ -167,16 +194,18 @@ test_expect_success 'second message is patch' ' grep "Subject:.*Second" msgtxt2 ' -cat >expected-show-all-headers <<\EOF +cat >expected-suppress-sob <<\EOF 0001-Second.patch (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' +(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com> +RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com> From: Example <from@example.com> To: to@example.com -Cc: cc@example.com, A <author@example.com> +Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -185,10 +214,10 @@ X-Mailer: X-MAILER-STRING Result: OK EOF -test_expect_success 'sendemail.cc set' ' - git config sendemail.cc cc@example.com && +test_suppression () { git send-email \ --dry-run \ + --suppress-cc=$1 \ --from="Example <from@example.com>" \ --to=to@example.com \ --smtp-server relay.example.com \ @@ -196,20 +225,27 @@ test_expect_success 'sendemail.cc set' ' sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ - >actual-show-all-headers && - test_cmp expected-show-all-headers actual-show-all-headers + >actual-suppress-$1 && + test_cmp expected-suppress-$1 actual-suppress-$1 +} + +test_expect_success 'sendemail.cc set' ' + git config sendemail.cc cc@example.com && + test_suppression sob ' -cat >expected-show-all-headers <<\EOF +cat >expected-suppress-sob <<\EOF 0001-Second.patch (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' +(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' Dry-OK. Log says: Server: relay.example.com MAIL FROM:<from@example.com> -RCPT TO:<to@example.com>,<author@example.com> +RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com> From: Example <from@example.com> To: to@example.com -Cc: A <author@example.com> +Cc: A <author@example.com>, One <one@example.com>, two@example.com Subject: [PATCH 1/1] Second. Date: DATE-STRING Message-Id: MESSAGE-ID-STRING @@ -220,17 +256,123 @@ EOF test_expect_success 'sendemail.cc unset' ' git config --unset sendemail.cc && - git send-email \ - --dry-run \ - --from="Example <from@example.com>" \ - --to=to@example.com \ - --smtp-server relay.example.com \ - $patches | - sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ - -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ - -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ - >actual-show-all-headers && - test_cmp expected-show-all-headers actual-show-all-headers + test_suppression sob +' + +cat >expected-suppress-all <<\EOF +0001-Second.patch +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM:<from@example.com> +RCPT TO:<to@example.com> +From: Example <from@example.com> +To: to@example.com +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=all' ' + test_suppression all +' + +cat >expected-suppress-body <<\EOF +0001-Second.patch +(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' +(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM:<from@example.com> +RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com> +From: Example <from@example.com> +To: to@example.com +Cc: A <author@example.com>, One <one@example.com>, two@example.com +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=body' ' + test_suppression body +' + +cat >expected-suppress-sob <<\EOF +0001-Second.patch +(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' +(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM:<from@example.com> +RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com> +From: Example <from@example.com> +To: to@example.com +Cc: A <author@example.com>, One <one@example.com>, two@example.com +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=sob' ' + test_suppression sob +' + +cat >expected-suppress-bodycc <<\EOF +0001-Second.patch +(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' +(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' +(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' +(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM:<from@example.com> +RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com> +From: Example <from@example.com> +To: to@example.com +Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com> +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=bodycc' ' + test_suppression bodycc +' + +cat >expected-suppress-cc <<\EOF +0001-Second.patch +(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' +(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM:<from@example.com> +RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com> +From: Example <from@example.com> +To: to@example.com +Cc: A <author@example.com>, C O Mitter <committer@example.com> +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success '--suppress-cc=cc' ' + test_suppression cc ' test_expect_success '--compose adds MIME for utf8 body' ' @@ -292,4 +434,36 @@ test_expect_success '--compose adds MIME for utf8 subject' ' grep "^Subject: =?utf-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 ' +test_expect_success 'detects ambiguous reference/file conflict' ' + echo master > master && + git add master && + git commit -m"add master" && + test_must_fail git send-email --dry-run master 2>errors && + grep disambiguate errors +' + +test_expect_success 'feed two files' ' + rm -fr outdir && + git format-patch -2 -o outdir && + GIT_SEND_EMAIL_NOTTY=1 git send-email \ + --dry-run \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + outdir/000?-*.patch 2>errors >out && + grep "^Subject: " out >subjects && + test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && + test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master" +' + +test_expect_success 'in-reply-to but no threading' ' + git send-email \ + --dry-run \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --in-reply-to="<in-reply-id@example.com>" \ + --no-thread \ + $patches | + grep "In-Reply-To: <in-reply-id@example.com>" +' + test_done diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 843a5013b9..bb921af56a 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Eric Wong # -test_description='git-svn basic tests' +test_description='git svn basic tests' GIT_SVN_LC_ALL=${LC_ALL:-$LANG} case "$GIT_SVN_LC_ALL" in @@ -17,10 +17,10 @@ esac . ./lib-git-svn.sh -say 'define NO_SVN_TESTS to skip git-svn tests' +say 'define NO_SVN_TESTS to skip git svn tests' test_expect_success \ - 'initialize git-svn' ' + 'initialize git svn' ' mkdir import && cd import && echo foo > foo && @@ -31,26 +31,26 @@ test_expect_success \ echo "zzz" > bar/zzz && echo "#!/bin/sh" > exec.sh && chmod +x exec.sh && - svn import -m "import for git-svn" . "$svnrepo" >/dev/null && + svn import -m "import for git svn" . "$svnrepo" >/dev/null && cd .. && rm -rf import && - git-svn init "$svnrepo"' + git svn init "$svnrepo"' test_expect_success \ 'import an SVN revision into git' \ - 'git-svn fetch' + 'git svn fetch' test_expect_success "checkout from svn" 'svn co "$svnrepo" "$SVN_TREE"' name='try a deep --rmdir with a commit' test_expect_success "$name" ' - git checkout -f -b mybranch remotes/git-svn && + git checkout -f -b mybranch ${remotes_git_svn} && mv dir/a/b/c/d/e/file dir/file && cp dir/file file && git update-index --add --remove dir/a/b/c/d/e/file dir/file file && git commit -m "$name" && - git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch && + git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch && svn up "$SVN_TREE" && test -d "$SVN_TREE"/dir && test ! -d "$SVN_TREE"/dir/a' @@ -63,61 +63,61 @@ test_expect_success "$name" " git update-index --remove dir/file && git update-index --add dir/file/file && git commit -m '$name' && - test_must_fail git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch" || true + test_must_fail git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch" || true name='detect node change from directory to file #1' test_expect_success "$name" ' rm -rf dir "$GIT_DIR"/index && - git checkout -f -b mybranch2 remotes/git-svn && + git checkout -f -b mybranch2 ${remotes_git_svn} && mv bar/zzz zzz && rm -rf bar && mv zzz bar && git update-index --remove -- bar/zzz && git update-index --add -- bar && git commit -m "$name" && - test_must_fail git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch2' || true + test_must_fail git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch2' || true name='detect node change from file to directory #2' test_expect_success "$name" ' rm -f "$GIT_DIR"/index && - git checkout -f -b mybranch3 remotes/git-svn && + git checkout -f -b mybranch3 ${remotes_git_svn} && rm bar/zzz && git update-index --remove bar/zzz && mkdir bar/zzz && echo yyy > bar/zzz/yyy && git update-index --add bar/zzz/yyy && git commit -m "$name" && - test_must_fail git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch3' || true + test_must_fail git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch3' || true name='detect node change from directory to file #2' test_expect_success "$name" ' rm -f "$GIT_DIR"/index && - git checkout -f -b mybranch4 remotes/git-svn && + git checkout -f -b mybranch4 ${remotes_git_svn} && rm -rf dir && git update-index --remove -- dir/file && touch dir && echo asdf > dir && git update-index --add -- dir && git commit -m "$name" && - test_must_fail git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch4' || true + test_must_fail git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch4' || true name='remove executable bit from a file' test_expect_success "$name" ' rm -f "$GIT_DIR"/index && - git checkout -f -b mybranch5 remotes/git-svn && + git checkout -f -b mybranch5 ${remotes_git_svn} && chmod -x exec.sh && git update-index exec.sh && git commit -m "$name" && - git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch5 && + git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch5 && svn up "$SVN_TREE" && test ! -x "$SVN_TREE"/exec.sh' @@ -127,8 +127,8 @@ test_expect_success "$name" ' chmod +x exec.sh && git update-index exec.sh && git commit -m "$name" && - git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch5 && + git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch5 && svn up "$SVN_TREE" && test -x "$SVN_TREE"/exec.sh' @@ -139,8 +139,8 @@ test_expect_success "$name" ' ln -s bar/zzz exec.sh && git update-index exec.sh && git commit -m "$name" && - git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch5 && + git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch5 && svn up "$SVN_TREE" && test -L "$SVN_TREE"/exec.sh' @@ -151,8 +151,8 @@ test_expect_success "$name" ' ln -s bar/zzz exec-2.sh && git update-index --add bar/zzz exec-2.sh && git commit -m "$name" && - git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch5 && + git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch5 && svn up "$SVN_TREE" && test -x "$SVN_TREE"/bar/zzz && test -L "$SVN_TREE"/exec-2.sh' @@ -164,8 +164,8 @@ test_expect_success "$name" ' cp help exec-2.sh && git update-index exec-2.sh && git commit -m "$name" && - git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch5 && + git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch5 && svn up "$SVN_TREE" && test -f "$SVN_TREE"/exec-2.sh && test ! -L "$SVN_TREE"/exec-2.sh && @@ -180,7 +180,7 @@ then echo '# hello' >> exec-2.sh && git update-index exec-2.sh && git commit -m 'éï∏' && - git-svn set-tree HEAD" + git svn set-tree HEAD" unset LC_ALL else say "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)" @@ -190,8 +190,8 @@ name='test fetch functionality (svn => git) with alternate GIT_SVN_ID' 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 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 && test_cmp a b' @@ -215,45 +215,45 @@ test_expect_success "$name" "test_cmp a expected" test_expect_success 'exit if remote refs are ambigious' " git config --add svn-remote.svn.fetch \ - bar:refs/remotes/git-svn && - test_must_fail git-svn migrate + bar:refs/${remotes_git_svn} && + test_must_fail git svn migrate " test_expect_success '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 \ - "^bar:refs/remotes/git-svn$" && - test_must_fail git-svn init "${svnrepo}2/bar" + "^bar:refs/${remotes_git_svn}$" && + test_must_fail git svn init "${svnrepo}2/bar" ' test_expect_success \ 'init allows us to connect to another directory in the same repo' ' - git-svn init --minimize-url -i bar "$svnrepo/bar" && + git svn init --minimize-url -i bar "$svnrepo/bar" && git config --get svn-remote.svn.fetch \ "^bar:refs/remotes/bar$" && git config --get svn-remote.svn.fetch \ - "^:refs/remotes/git-svn$" + "^:refs/${remotes_git_svn}$" ' test_expect_success 'able to dcommit to a subdirectory' " - git-svn fetch -i bar && + git svn fetch -i bar && git checkout -b my-bar refs/remotes/bar && echo abc > d && git update-index --add d && git commit -m '/bar/d should be in the log' && - git-svn dcommit -i bar && + git svn dcommit -i bar && test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" && mkdir newdir && echo new > newdir/dir && git update-index --add newdir/dir && git commit -m 'add a new directory' && - git-svn dcommit -i bar && + git svn dcommit -i bar && test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" && echo foo >> newdir/dir && git update-index newdir/dir && git commit -m 'modify a file in new directory' && - git-svn dcommit -i bar && + git svn dcommit -i bar && test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" " @@ -261,8 +261,17 @@ test_expect_success 'able to set-tree to a subdirectory' " echo cba > d && git update-index d && git commit -m 'update /bar/d' && - git-svn set-tree -i bar HEAD && + git svn set-tree -i bar HEAD && test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" " +test_expect_success 'git-svn works in a bare repository' ' + mkdir bare-repo && + ( cd bare-repo && + git init --bare && + GIT_DIR=. git svn init "$svnrepo" && + git svn fetch ) && + rm -rf bare-repo + ' + test_done diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh index f420796c31..1e31d6ea72 100755 --- a/t/t9101-git-svn-props.sh +++ b/t/t9101-git-svn-props.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Eric Wong # -test_description='git-svn property tests' +test_description='git svn property tests' . ./lib-git-svn.sh mkdir import @@ -26,29 +26,29 @@ cd import EOF printf "Hello\r\nWorld\r\n" > crlf - a_crlf=`git-hash-object -w crlf` + a_crlf=`git hash-object -w crlf` printf "Hello\rWorld\r" > cr - a_cr=`git-hash-object -w cr` + a_cr=`git hash-object -w cr` printf "Hello\nWorld\n" > lf - a_lf=`git-hash-object -w lf` + a_lf=`git hash-object -w lf` printf "Hello\r\nWorld" > ne_crlf - a_ne_crlf=`git-hash-object -w ne_crlf` + a_ne_crlf=`git hash-object -w ne_crlf` printf "Hello\nWorld" > ne_lf - a_ne_lf=`git-hash-object -w ne_lf` + a_ne_lf=`git hash-object -w ne_lf` printf "Hello\rWorld" > ne_cr - a_ne_cr=`git-hash-object -w ne_cr` + a_ne_cr=`git hash-object -w ne_cr` touch empty - a_empty=`git-hash-object -w empty` + a_empty=`git hash-object -w empty` printf "\n" > empty_lf - a_empty_lf=`git-hash-object -w empty_lf` + a_empty_lf=`git hash-object -w empty_lf` printf "\r" > empty_cr - a_empty_cr=`git-hash-object -w empty_cr` + a_empty_cr=`git hash-object -w empty_cr` printf "\r\n" > empty_crlf - a_empty_crlf=`git-hash-object -w empty_crlf` + a_empty_crlf=`git hash-object -w empty_crlf` - svn import --no-auto-props -m 'import for git-svn' . "$svnrepo" >/dev/null + svn import --no-auto-props -m 'import for git svn' . "$svnrepo" >/dev/null cd .. rm -rf import @@ -66,16 +66,16 @@ test_expect_success 'setup some commits to svn' \ svn commit -m "Propset Id" && cd ..' -test_expect_success 'initialize git-svn' 'git-svn init "$svnrepo"' -test_expect_success 'fetch revisions from svn' 'git-svn fetch' +test_expect_success 'initialize git svn' 'git svn init "$svnrepo"' +test_expect_success 'fetch revisions from svn' 'git svn fetch' name='test svn:keywords ignoring' test_expect_success "$name" \ - 'git checkout -b mybranch remotes/git-svn && + 'git checkout -b mybranch ${remotes_git_svn} && echo Hi again >> kw.c && git commit -a -m "test keywords ignoring" && - git-svn set-tree remotes/git-svn..mybranch && - git pull . remotes/git-svn' + git svn set-tree ${remotes_git_svn}..mybranch && + git pull . ${remotes_git_svn}' expect='/* $Id$ */' got="`sed -ne 2p kw.c`" @@ -90,8 +90,8 @@ test_expect_success "propset CR on crlf files" \ cd ..' test_expect_success 'fetch and pull latest from svn and checkout a new wc' \ - 'git-svn fetch && - git pull . remotes/git-svn && + 'git svn fetch && + git pull . ${remotes_git_svn} && svn co "$svnrepo" new_wc' for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf @@ -103,8 +103,8 @@ done cd test_wc printf '$Id$\rHello\rWorld\r' > cr printf '$Id$\rHello\rWorld' > ne_cr - a_cr=`printf '$Id$\r\nHello\r\nWorld\r\n' | git-hash-object --stdin` - a_ne_cr=`printf '$Id$\r\nHello\r\nWorld' | git-hash-object --stdin` + a_cr=`printf '$Id$\r\nHello\r\nWorld\r\n' | git hash-object --stdin` + a_ne_cr=`printf '$Id$\r\nHello\r\nWorld' | git hash-object --stdin` test_expect_success 'Set CRLF on cr files' \ 'svn propset svn:eol-style CRLF cr && svn propset svn:eol-style CRLF ne_cr && @@ -113,10 +113,10 @@ cd test_wc svn commit -m "propset CRLF on cr files"' cd .. test_expect_success 'fetch and pull latest from svn' \ - 'git-svn fetch && git pull . remotes/git-svn' + 'git svn fetch && git pull . ${remotes_git_svn}' -b_cr="`git-hash-object cr`" -b_ne_cr="`git-hash-object ne_cr`" +b_cr="`git hash-object cr`" +b_ne_cr="`git hash-object ne_cr`" test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'" test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'" @@ -145,7 +145,7 @@ test_expect_success 'test show-ignore' " svn propset -R svn:ignore 'no-such-file*' . svn commit -m 'propset svn:ignore' cd .. && - git-svn show-ignore > show-ignore.got && + git svn show-ignore > show-ignore.got && cmp show-ignore.expect show-ignore.got " @@ -161,8 +161,8 @@ cat >create-ignore-index.expect <<\EOF EOF test_expect_success 'test create-ignore' " - git-svn fetch && git pull . remotes/git-svn && - git-svn create-ignore && + git svn fetch && git pull . ${remotes_git_svn} && + git svn create-ignore && cmp ./.gitignore create-ignore.expect && cmp ./deeply/.gitignore create-ignore.expect && cmp ./deeply/nested/.gitignore create-ignore.expect && @@ -182,15 +182,15 @@ EOF # pattern, it can pass even though the propget did not execute on the # right directory. test_expect_success 'test propget' " - git-svn propget svn:ignore . | cmp - prop.expect && + git svn propget svn:ignore . | cmp - prop.expect && cd deeply && - git-svn propget svn:ignore . | cmp - ../prop.expect && - git-svn propget svn:entry:committed-rev nested/directory/.keep \ + git svn propget svn:ignore . | cmp - ../prop.expect && + git svn propget svn:entry:committed-rev nested/directory/.keep \ | cmp - ../prop2.expect && - git-svn propget svn:ignore .. | cmp - ../prop.expect && - git-svn propget svn:ignore nested/ | cmp - ../prop.expect && - git-svn propget svn:ignore ./nested | cmp - ../prop.expect && - git-svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect + git svn propget svn:ignore .. | cmp - ../prop.expect && + git svn propget svn:ignore nested/ | cmp - ../prop.expect && + git svn propget svn:ignore ./nested | cmp - ../prop.expect && + git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect " cat >prop.expect <<\EOF @@ -210,8 +210,8 @@ Properties on 'nested/directory/.keep': EOF test_expect_success 'test proplist' " - git-svn proplist . | cmp - prop.expect && - git-svn proplist nested/directory/.keep | cmp - prop2.expect + git svn proplist . | cmp - prop.expect && + git svn proplist nested/directory/.keep | cmp - prop2.expect " test_done diff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh index 0e7ce34b9b..e223218015 100755 --- a/t/t9102-git-svn-deep-rmdir.sh +++ b/t/t9102-git-svn-deep-rmdir.sh @@ -1,5 +1,5 @@ #!/bin/sh -test_description='git-svn rmdir' +test_description='git svn rmdir' . ./lib-git-svn.sh test_expect_success 'initialize repo' ' @@ -9,20 +9,20 @@ test_expect_success 'initialize repo' ' mkdir -p deeply/nested/directory/number/2 && echo foo > deeply/nested/directory/number/1/file && echo foo > deeply/nested/directory/number/2/another && - svn import -m "import for git-svn" . "$svnrepo" && + svn import -m "import for git svn" . "$svnrepo" && cd .. ' -test_expect_success 'mirror via git-svn' ' - git-svn init "$svnrepo" && - git-svn fetch && - git checkout -f -b test-rmdir remotes/git-svn +test_expect_success 'mirror via git svn' ' + git svn init "$svnrepo" && + git svn fetch && + git checkout -f -b test-rmdir ${remotes_git_svn} ' test_expect_success 'Try a commit on rmdir' ' git rm -f deeply/nested/directory/number/2/another && git commit -a -m "remove another" && - git-svn set-tree --rmdir HEAD && + git svn set-tree --rmdir HEAD && svn ls -R "$svnrepo" | grep ^deeply/nested/directory/number/1 ' diff --git a/t/t9103-git-svn-tracked-directory-removed.sh b/t/t9103-git-svn-tracked-directory-removed.sh index 9ffd8458ef..963dd95e4a 100755 --- a/t/t9103-git-svn-tracked-directory-removed.sh +++ b/t/t9103-git-svn-tracked-directory-removed.sh @@ -3,7 +3,7 @@ # Copyright (c) 2007 Eric Wong # -test_description='git-svn tracking removed top-level path' +test_description='git svn tracking removed top-level path' . ./lib-git-svn.sh test_expect_success 'make history for tracking' ' diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index d80ea64e49..ab9fa32220 100755 --- a/t/t9104-git-svn-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Eric Wong # -test_description='git-svn fetching' +test_description='git svn fetching' . ./lib-git-svn.sh test_expect_success 'initialize repo' ' @@ -27,8 +27,8 @@ 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 && + 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 |\ @@ -43,7 +43,7 @@ test_expect_success 'init and fetch from one svn-remote' ' trunk:refs/remotes/svn/trunk && git config --add svn-remote.svn.fetch \ thunk:refs/remotes/svn/thunk && - git-svn fetch -i 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 |\ @@ -57,8 +57,8 @@ test_expect_success 'follow deleted parent' ' -r2 "$svnrepo"/trunk "$svnrepo"/junk) && git config --add svn-remote.svn.fetch \ junk:refs/remotes/svn/junk && - git-svn fetch -i svn/thunk && - git-svn fetch -i svn/junk && + git svn fetch -i svn/thunk && + git svn fetch -i svn/junk && test -z "`git diff svn/junk svn/trunk`" && test "`git merge-base svn/junk svn/trunk`" \ = "`git rev-parse svn/trunk`" @@ -69,9 +69,9 @@ test_expect_success 'follow larger parent' ' echo hi > import/trunk/thunk/bump/thud/file && svn import -m "import a larger parent" import "$svnrepo"/larger-parent && svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger && - git-svn init --minimize-url -i larger \ + git svn init --minimize-url -i larger \ "$svnrepo"/another-larger/trunk/thunk/bump/thud && - git-svn fetch -i larger && + git svn fetch -i larger && git rev-parse --verify refs/remotes/larger && git rev-parse --verify \ refs/remotes/larger-parent/trunk/thunk/bump/thud && @@ -92,15 +92,15 @@ test_expect_success 'follow higher-level parent' ' cd .. svn mkdir -m "new glob at top level" "$svnrepo"/glob && svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob && - git-svn init --minimize-url -i blob "$svnrepo"/glob/blob && - git-svn fetch -i blob + git svn init --minimize-url -i blob "$svnrepo"/glob/blob && + git svn fetch -i blob ' test_expect_success 'follow deleted directory' ' svn mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye && svn rm -m "remove glob" "$svnrepo"/glob && - git-svn init --minimize-url -i glob "$svnrepo"/glob && - git-svn fetch -i glob && + git svn init --minimize-url -i glob "$svnrepo"/glob && + git svn fetch -i glob && test "`git cat-file blob refs/remotes/glob:blob/bye`" = hi && test "`git ls-tree refs/remotes/glob | wc -l `" -eq 1 ' @@ -129,9 +129,9 @@ test_expect_success 'follow-parent avoids deleting relevant info' ' poke native/t/c.t && svn commit -m "reorg test" && cd .. && - git-svn init --minimize-url -i r9270-t \ + git svn init --minimize-url -i r9270-t \ "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t && - git-svn fetch -i r9270-t && + git svn fetch -i r9270-t && test `git rev-list r9270-t | wc -l` -eq 2 && test "`git ls-tree --name-only r9270-t~1`" = \ "`git ls-tree --name-only r9270-t`" @@ -139,9 +139,9 @@ test_expect_success 'follow-parent avoids deleting relevant info' ' test_expect_success "track initial change if it was only made to parent" ' svn cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk && - git-svn init --minimize-url -i r9270-d \ + git svn init --minimize-url -i r9270-d \ "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t && - git-svn fetch -i r9270-d && + git svn fetch -i r9270-d && test `git rev-list r9270-d | wc -l` -eq 3 && test "`git ls-tree --name-only r9270-t`" = \ "`git ls-tree --name-only r9270-d`" && @@ -193,19 +193,19 @@ test_expect_success "follow-parent is atomic" ' test_expect_success "track multi-parent paths" ' svn cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob && - git-svn multi-fetch && + git svn multi-fetch && test `git cat-file commit refs/remotes/glob | \ grep "^parent " | wc -l` -eq 2 ' test_expect_success "multi-fetch continues to work" " - git-svn multi-fetch + git svn multi-fetch " test_expect_success "multi-fetch works off a 'clean' repository" ' rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" && mkdir "$GIT_DIR/svn" && - git-svn multi-fetch + git svn multi-fetch ' test_debug 'gitk --all &' diff --git a/t/t9105-git-svn-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh index 63230367bb..ba99abb6d9 100755 --- a/t/t9105-git-svn-commit-diff.sh +++ b/t/t9105-git-svn-commit-diff.sh @@ -1,7 +1,7 @@ #!/bin/sh # # Copyright (c) 2006 Eric Wong -test_description='git-svn commit-diff' +test_description='git svn commit-diff' . ./lib-git-svn.sh test_expect_success 'initialize repo' ' @@ -26,16 +26,16 @@ prev=`git rev-parse --verify HEAD^1` test_expect_success 'test the commit-diff command' ' test -n "$prev" && test -n "$head" && - git-svn commit-diff -r1 "$prev" "$head" "$svnrepo" && + git svn commit-diff -r1 "$prev" "$head" "$svnrepo" && svn co "$svnrepo" wc && cmp readme wc/readme ' -test_expect_success 'commit-diff to a sub-directory (with git-svn config)' ' +test_expect_success 'commit-diff to a sub-directory (with git svn config)' ' svn import -m "sub-directory" import "$svnrepo"/subdir && - git-svn init --minimize-url "$svnrepo"/subdir && - git-svn fetch && - git-svn commit-diff -r3 "$prev" "$head" && + git svn init --minimize-url "$svnrepo"/subdir && + git svn fetch && + git svn commit-diff -r3 "$prev" "$head" && svn cat "$svnrepo"/subdir/readme > readme.2 && cmp readme readme.2 ' diff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh index 83896e9687..6eb0fd85c8 100755 --- a/t/t9106-git-svn-commit-diff-clobber.sh +++ b/t/t9106-git-svn-commit-diff-clobber.sh @@ -1,7 +1,7 @@ #!/bin/sh # # Copyright (c) 2006 Eric Wong -test_description='git-svn commit-diff clobber' +test_description='git svn commit-diff clobber' . ./lib-git-svn.sh test_expect_success 'initialize repo' ' @@ -27,7 +27,7 @@ test_expect_success 'commit change from svn side' ' test_expect_success 'commit conflicting change from git' ' echo second line from git >> file && git commit -a -m "second line from git" && - test_must_fail git-svn commit-diff -r1 HEAD~1 HEAD "$svnrepo" + test_must_fail git svn commit-diff -r1 HEAD~1 HEAD "$svnrepo" ' test_expect_success 'commit complementing change from git' ' @@ -36,13 +36,13 @@ test_expect_success 'commit complementing change from git' ' git commit -a -m "second line from svn" && echo third line from git >> file && git commit -a -m "third line from git" && - git-svn commit-diff -r2 HEAD~1 HEAD "$svnrepo" + git svn commit-diff -r2 HEAD~1 HEAD "$svnrepo" ' test_expect_success 'dcommit fails to commit because of conflict' ' - git-svn init "$svnrepo" && - git-svn fetch && - git reset --hard refs/remotes/git-svn && + git svn init "$svnrepo" && + git svn fetch && + git reset --hard refs/${remotes_git_svn} && svn co "$svnrepo" t.svn && cd t.svn && echo fourth line from svn >> file && @@ -52,18 +52,18 @@ test_expect_success 'dcommit fails to commit because of conflict' ' rm -rf t.svn && echo "fourth line from git" >> file && git commit -a -m "fourth line from git" && - test_must_fail git-svn dcommit + test_must_fail git svn dcommit ' test_expect_success 'dcommit does the svn equivalent of an index merge' " - git reset --hard refs/remotes/git-svn && + git reset --hard refs/${remotes_git_svn} && echo 'index merge' > file2 && git update-index --add file2 && git commit -a -m 'index merge' && echo 'more changes' >> file2 && git update-index file2 && git commit -a -m 'more changes' && - git-svn dcommit + git svn dcommit " test_expect_success 'commit another change from svn side' ' @@ -76,8 +76,8 @@ test_expect_success 'commit another change from svn side' ' rm -rf t.svn ' -test_expect_success 'multiple dcommit from git-svn will not clobber svn' " - git reset --hard refs/remotes/git-svn && +test_expect_success 'multiple dcommit from git svn will not clobber svn' " + git reset --hard refs/${remotes_git_svn} && echo new file >> new-file && git update-index --add new-file && git commit -a -m 'new file' && diff --git a/t/t9106-git-svn-dcommit-clobber-series.sh b/t/t9106-git-svn-dcommit-clobber-series.sh index bc37db9d62..fd185011b7 100755 --- a/t/t9106-git-svn-dcommit-clobber-series.sh +++ b/t/t9106-git-svn-dcommit-clobber-series.sh @@ -1,7 +1,7 @@ #!/bin/sh # # Copyright (c) 2007 Eric Wong -test_description='git-svn dcommit clobber series' +test_description='git svn dcommit clobber series' . ./lib-git-svn.sh test_expect_success 'initialize repo' ' diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh index d9b553ad55..acad16a6f0 100755 --- a/t/t9107-git-svn-migrate.sh +++ b/t/t9107-git-svn-migrate.sh @@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) 2006 Eric Wong -test_description='git-svn metadata migrations from previous versions' +test_description='git svn metadata migrations from previous versions' . ./lib-git-svn.sh test_expect_success 'setup old-looking metadata' ' @@ -14,34 +14,34 @@ test_expect_success 'setup old-looking metadata' ' done && \ svn import -m test . "$svnrepo" cd .. && - git-svn init "$svnrepo" && - git-svn fetch && + git svn init "$svnrepo" && + git svn fetch && 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` test_expect_success 'git-svn-HEAD is a real HEAD' "test -n '$head'" -test_expect_success 'initialize old-style (v0) git-svn layout' ' +test_expect_success 'initialize old-style (v0) git svn layout' ' mkdir -p "$GIT_DIR"/git-svn/info "$GIT_DIR"/svn/info && echo "$svnrepo" > "$GIT_DIR"/git-svn/info/url && 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 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 && test "$(git config --get svn-remote.svn.url)" = "$svnrepo" && test `git config --get svn-remote.svn.fetch` = \ - ":refs/remotes/git-svn" + ":refs/${remotes_git_svn}" ' test_expect_success 'initialize a multi-repository repo' ' - git-svn init "$svnrepo" -T trunk -t tags -b branches && + git svn init "$svnrepo" -T trunk -t tags -b branches && 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 \ @@ -61,7 +61,7 @@ test_expect_success 'initialize a multi-repository repo' ' # refs should all be different, but the trees should all be the same: test_expect_success 'multi-fetch works on partial urls + paths' " - git-svn multi-fetch && + git svn multi-fetch && for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do git rev-parse --verify refs/remotes/\$i^0 >> refs.out || exit 1; done && @@ -85,7 +85,7 @@ test_expect_success 'migrate --minimize on old inited layout' ' ( mkdir -p "$GIT_DIR"/svn/$ref/info/ && echo "$svnrepo"$path > "$GIT_DIR"/svn/$ref/info/url ) || exit 1; done && - git-svn migrate --minimize && + 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 && grep "^trunk:refs/remotes/trunk$" fetch.out && @@ -94,11 +94,11 @@ test_expect_success 'migrate --minimize on old inited layout' ' grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out && grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out && grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out - grep "^:refs/remotes/git-svn" fetch.out + grep "^:refs/${remotes_git_svn}" fetch.out ' test_expect_success ".rev_db auto-converted to .rev_map.UUID" ' - git-svn fetch -i trunk && + git svn fetch -i trunk && test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" && expect="$(ls "$GIT_DIR"/svn/trunk/.rev_map.*)" && test -n "$expect" && @@ -106,7 +106,7 @@ test_expect_success ".rev_db auto-converted to .rev_map.UUID" ' convert_to_rev_db "$expect" "$rev_db" && rm -f "$expect" && test -f "$rev_db" && - git-svn fetch -i trunk && + git svn fetch -i trunk && test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" && test ! -e "$GIT_DIR"/svn/trunk/.rev_db && test -f "$expect" diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh index 8b792a1370..d8582b1aa5 100755 --- a/t/t9108-git-svn-glob.sh +++ b/t/t9108-git-svn-glob.sh @@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) 2007 Eric Wong -test_description='git-svn globbing refspecs' +test_description='git svn globbing refspecs' . ./lib-git-svn.sh cat > expect.end <<EOF @@ -46,7 +46,7 @@ test_expect_success 'test refspec globbing' ' "branches/*/src/a:refs/remotes/branches/*" && git config --add svn-remote.svn.tags\ "tags/*/src/a:refs/remotes/tags/*" && - git-svn multi-fetch && + git svn multi-fetch && git log --pretty=oneline refs/remotes/tags/end | \ sed -e "s/^.\{41\}//" > output.end && test_cmp expect.end output.end && @@ -74,7 +74,7 @@ test_expect_success 'test left-hand-side only globbing' ' poke tags/end/src/b/readme && svn commit -m "try to try" ) && - git-svn fetch two && + git svn fetch two && test `git rev-list refs/remotes/two/tags/end | wc -l` -eq 6 && test `git rev-list refs/remotes/two/branches/start | wc -l` -eq 3 && test `git rev-parse refs/remotes/two/branches/start~2` = \ @@ -104,7 +104,7 @@ test_expect_success 'test disallow multi-globs' ' poke tags/end/src/b/readme && svn commit -m "try to try" ) && - test_must_fail git-svn fetch three 2> stderr.three && + test_must_fail git svn fetch three 2> stderr.three && test_cmp expect.three stderr.three ' diff --git a/t/t9108-git-svn-multi-glob.sh b/t/t9108-git-svn-multi-glob.sh index 3583721652..8f79c3f251 100755 --- a/t/t9108-git-svn-multi-glob.sh +++ b/t/t9108-git-svn-multi-glob.sh @@ -1,6 +1,6 @@ #!/bin/sh # Copyright (c) 2007 Eric Wong -test_description='git-svn globbing refspecs' +test_description='git svn globbing refspecs' . ./lib-git-svn.sh cat > expect.end <<EOF @@ -46,7 +46,7 @@ test_expect_success 'test refspec globbing' ' "branches/*/*/src/a:refs/remotes/branches/*/*" && git config --add svn-remote.svn.tags\ "tags/*/src/a:refs/remotes/tags/*" && - git-svn multi-fetch && + git svn multi-fetch && git log --pretty=oneline refs/remotes/tags/end | \ sed -e "s/^.\{41\}//" > output.end && test_cmp expect.end output.end && @@ -74,7 +74,7 @@ test_expect_success 'test left-hand-side only globbing' ' poke tags/end/src/b/readme && svn commit -m "try to try" ) && - git-svn fetch two && + git svn fetch two && test `git rev-list refs/remotes/two/tags/end | wc -l` -eq 6 && test `git rev-list refs/remotes/two/branches/v1/start | wc -l` -eq 3 && test `git rev-parse refs/remotes/two/branches/v1/start~2` = \ @@ -123,7 +123,7 @@ test_expect_success 'test another branch' ' "branches/*/*:refs/remotes/four/branches/*/*" && git config --add svn-remote.four.tags \ "tags/*:refs/remotes/four/tags/*" && - git-svn fetch four && + git svn fetch four && test `git rev-list refs/remotes/four/tags/next | wc -l` -eq 5 && test `git rev-list refs/remotes/four/branches/v2/start | wc -l` -eq 3 && test `git rev-parse refs/remotes/four/branches/v2/start~2` = \ @@ -153,7 +153,7 @@ test_expect_success 'test disallow multiple globs' ' poke tags/end/src/b/readme && svn commit -m "try to try" ) && - test_must_fail git-svn fetch three 2> stderr.three && + test_must_fail git svn fetch three 2> stderr.three && test_cmp expect.three stderr.three ' diff --git a/t/t9110-git-svn-use-svm-props.sh b/t/t9110-git-svn-use-svm-props.sh index 04d2a65c08..a06e4c5b8e 100755 --- a/t/t9110-git-svn-use-svm-props.sh +++ b/t/t9110-git-svn-use-svm-props.sh @@ -3,18 +3,18 @@ # Copyright (c) 2007 Eric Wong # -test_description='git-svn useSvmProps test' +test_description='git svn useSvmProps test' . ./lib-git-svn.sh test_expect_success 'load svm repo' ' - svnadmin load -q "$rawsvnrepo" < ../t9110/svm.dump && - git-svn init --minimize-url -R arr -i bar "$svnrepo"/mirror/arr && - git-svn init --minimize-url -R argh -i dir "$svnrepo"/mirror/argh && - git-svn init --minimize-url -R argh -i e \ + svnadmin load -q "$rawsvnrepo" < "$TEST_DIRECTORY"/t9110/svm.dump && + git svn init --minimize-url -R arr -i bar "$svnrepo"/mirror/arr && + 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-svn fetch --all + git svn fetch --all ' uuid=161ce429-a9dd-4828-af4a-52023f968c89 @@ -22,40 +22,40 @@ 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 | \ - grep '^git-svn-id: $bar_url@12 $uuid$' && + grep '^${git_svn_id}: $bar_url@12 $uuid$' && git cat-file commit refs/remotes/bar~1 | \ - grep '^git-svn-id: $bar_url@11 $uuid$' && + grep '^${git_svn_id}: $bar_url@11 $uuid$' && git cat-file commit refs/remotes/bar~2 | \ - grep '^git-svn-id: $bar_url@10 $uuid$' && + grep '^${git_svn_id}: $bar_url@10 $uuid$' && git cat-file commit refs/remotes/bar~3 | \ - grep '^git-svn-id: $bar_url@9 $uuid$' && + grep '^${git_svn_id}: $bar_url@9 $uuid$' && git cat-file commit refs/remotes/bar~4 | \ - grep '^git-svn-id: $bar_url@6 $uuid$' && + grep '^${git_svn_id}: $bar_url@6 $uuid$' && git cat-file commit refs/remotes/bar~5 | \ - grep '^git-svn-id: $bar_url@1 $uuid$' + 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 | \ - grep '^git-svn-id: $e_url@1 $uuid$' + 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 | \ - grep '^git-svn-id: $dir_url@2 $uuid$' && + grep '^${git_svn_id}: $dir_url@2 $uuid$' && git cat-file commit refs/remotes/dir~1 | \ - grep '^git-svn-id: $dir_url@1 $uuid$' + grep '^${git_svn_id}: $dir_url@1 $uuid$' " test_expect_success 'find commit based on SVN revision number' " - git-svn find-rev r12 | + git svn find-rev r12 | grep `git rev-parse HEAD` " test_expect_success 'empty rebase' " - git-svn rebase + git svn rebase " test_done diff --git a/t/t9111-git-svn-use-svnsync-props.sh b/t/t9111-git-svn-use-svnsync-props.sh index a8d74dcd3a..bd081c2ec3 100755 --- a/t/t9111-git-svn-use-svnsync-props.sh +++ b/t/t9111-git-svn-use-svnsync-props.sh @@ -3,17 +3,17 @@ # Copyright (c) 2007 Eric Wong # -test_description='git-svn useSvnsyncProps test' +test_description='git svn useSvnsyncProps test' . ./lib-git-svn.sh test_expect_success 'load svnsync repo' ' - svnadmin load -q "$rawsvnrepo" < ../t9111/svnsync.dump && - 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 && + svnadmin load -q "$rawsvnrepo" < "$TEST_DIRECTORY"/t9111/svnsync.dump && + 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-svn fetch --all + git svn fetch --all ' uuid=161ce429-a9dd-4828-af4a-52023f968c89 @@ -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 | \ - grep '^git-svn-id: $bar_url@12 $uuid$' && + grep '^${git_svn_id}: $bar_url@12 $uuid$' && git cat-file commit refs/remotes/bar~1 | \ - grep '^git-svn-id: $bar_url@11 $uuid$' && + grep '^${git_svn_id}: $bar_url@11 $uuid$' && git cat-file commit refs/remotes/bar~2 | \ - grep '^git-svn-id: $bar_url@10 $uuid$' && + grep '^${git_svn_id}: $bar_url@10 $uuid$' && git cat-file commit refs/remotes/bar~3 | \ - grep '^git-svn-id: $bar_url@9 $uuid$' && + grep '^${git_svn_id}: $bar_url@9 $uuid$' && git cat-file commit refs/remotes/bar~4 | \ - grep '^git-svn-id: $bar_url@6 $uuid$' && + grep '^${git_svn_id}: $bar_url@6 $uuid$' && git cat-file commit refs/remotes/bar~5 | \ - grep '^git-svn-id: $bar_url@1 $uuid$' + 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 | \ - grep '^git-svn-id: $e_url@1 $uuid$' + 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 | \ - grep '^git-svn-id: $dir_url@2 $uuid$' && + grep '^${git_svn_id}: $dir_url@2 $uuid$' && git cat-file commit refs/remotes/dir~1 | \ - grep '^git-svn-id: $dir_url@1 $uuid$' + grep '^${git_svn_id}: $dir_url@1 $uuid$' " test_done diff --git a/t/t9112-git-svn-md5less-file.sh b/t/t9112-git-svn-md5less-file.sh index d470a920e4..a61d6716d2 100755 --- a/t/t9112-git-svn-md5less-file.sh +++ b/t/t9112-git-svn-md5less-file.sh @@ -42,6 +42,6 @@ EOF test_expect_success 'load svn dumpfile' 'svnadmin load "$rawsvnrepo" < dumpfile.svn' -test_expect_success 'initialize git-svn' 'git-svn init "$svnrepo"' -test_expect_success 'fetch revisions from svn' 'git-svn fetch' +test_expect_success 'initialize git svn' 'git svn init "$svnrepo"' +test_expect_success 'fetch revisions from svn' 'git svn fetch' test_done diff --git a/t/t9113-git-svn-dcommit-new-file.sh b/t/t9113-git-svn-dcommit-new-file.sh index c2b24a439d..e9b6128b3f 100755 --- a/t/t9113-git-svn-dcommit-new-file.sh +++ b/t/t9113-git-svn-dcommit-new-file.sh @@ -8,7 +8,7 @@ # daemon running on a users system if the test fails. # Not all git users will need to interact with SVN. -test_description='git-svn dcommit new files over svn:// test' +test_description='git svn dcommit new files over svn:// test' . ./lib-git-svn.sh diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh index 61d7781616..17b2855c4f 100755 --- a/t/t9114-git-svn-dcommit-merge.sh +++ b/t/t9114-git-svn-dcommit-merge.sh @@ -3,7 +3,7 @@ # Copyright (c) 2007 Eric Wong # Based on a script by Joakim Tjernlund <joakim.tjernlund@transmode.se> -test_description='git-svn dcommit handles merges' +test_description='git svn dcommit handles merges' . ./lib-git-svn.sh diff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh index f0fbd3aff7..9be7aefaee 100755 --- a/t/t9115-git-svn-dcommit-funky-renames.sh +++ b/t/t9115-git-svn-dcommit-funky-renames.sh @@ -3,12 +3,12 @@ # Copyright (c) 2007 Eric Wong -test_description='git-svn dcommit can commit renames of files with ugly names' +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 && + svnadmin load -q "$rawsvnrepo" < "$TEST_DIRECTORY"/t9115/funky-names.dump && start_httpd gtk+ ' @@ -75,7 +75,7 @@ test_expect_success 'make a commit to test rebase' ' git svn dcommit ' -test_expect_success 'git-svn rebase works inside a fresh-cloned repository' ' +test_expect_success 'git svn rebase works inside a fresh-cloned repository' ' cd test-rebase && git svn rebase && test -e test-rebase-main && diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh index 4b2cc878f6..fd6d1d2046 100755 --- a/t/t9116-git-svn-log.sh +++ b/t/t9116-git-svn-log.sh @@ -3,7 +3,7 @@ # Copyright (c) 2007 Eric Wong # -test_description='git-svn log tests' +test_description='git svn log tests' . ./lib-git-svn.sh test_expect_success 'setup repository and import' ' @@ -16,8 +16,8 @@ test_expect_success 'setup repository and import' ' done && \ svn import -m test . "$svnrepo" cd .. && - git-svn init "$svnrepo" -T trunk -b branches -t tags && - git-svn fetch && + git svn init "$svnrepo" -T trunk -b branches -t tags && + git svn fetch && git reset --hard trunk && echo bye >> README && git commit -a -m bye && diff --git a/t/t9117-git-svn-init-clone.sh b/t/t9117-git-svn-init-clone.sh index 7a689bb1cd..dde46cd92f 100755 --- a/t/t9117-git-svn-init-clone.sh +++ b/t/t9117-git-svn-init-clone.sh @@ -3,7 +3,7 @@ # Copyright (c) 2007 Eric Wong # -test_description='git-svn init/clone tests' +test_description='git svn init/clone tests' . ./lib-git-svn.sh diff --git a/t/t9118-git-svn-funky-branch-names.sh b/t/t9118-git-svn-funky-branch-names.sh index 43ceb75d59..7a7c128687 100755 --- a/t/t9118-git-svn-funky-branch-names.sh +++ b/t/t9118-git-svn-funky-branch-names.sh @@ -3,7 +3,7 @@ # Copyright (c) 2007 Eric Wong # -test_description='git-svn funky branch names' +test_description='git svn funky branch names' . ./lib-git-svn.sh # Abo-Uebernahme (Bug #994) diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh index 5fd36a1483..27dd7c273a 100755 --- a/t/t9119-git-svn-info.sh +++ b/t/t9119-git-svn-info.sh @@ -2,16 +2,14 @@ # # Copyright (c) 2007 David D. Kilzer -test_description='git-svn info' +test_description='git svn info' . ./lib-git-svn.sh -set -e - # Tested with: svn, version 1.4.4 (r25188) -v=`svn --version | sed -n -e 's/^svn, version \(1\.4\.[0-9]\).*$/\1/p'` +v=`svn --version | sed -n -e 's/^svn, version \(1\.[0-9]*\.[0-9]*\).*$/\1/p'` case $v in -1.4.*) +1.[45].*) ;; *) say "skipping svn-info test (SVN version: $v not supported)" @@ -36,6 +34,8 @@ ptouch() { ' "`svn info $2 | grep '^Text Last Updated:'`" "$1" } +quoted_svnrepo="$(echo $svnrepo | sed 's/ /%20/')" + test_expect_success 'setup repository and import' ' mkdir info && cd info && @@ -47,80 +47,92 @@ test_expect_success 'setup repository and import' ' ln -s directory symlink-directory && svn import -m "initial" . "$svnrepo" && cd .. && + svn co "$svnrepo" svnwc && + cd svnwc && + echo foo > foo && + svn add foo && + svn commit -m "change outside directory" && + svn update && + cd .. && mkdir gitwc && cd gitwc && - git-svn init "$svnrepo" && - git-svn fetch && + git svn init "$svnrepo" && + git svn fetch && cd .. && - svn co "$svnrepo" svnwc && - ptouch svnwc/file gitwc/file && - ptouch svnwc/directory gitwc/directory && - ptouch svnwc/symlink-file gitwc/symlink-file && - ptouch svnwc/symlink-directory gitwc/symlink-directory + ptouch gitwc/file svnwc/file && + ptouch gitwc/directory svnwc/directory && + ptouch gitwc/symlink-file svnwc/symlink-file && + ptouch gitwc/symlink-directory svnwc/symlink-directory ' test_expect_success 'info' " (cd svnwc; svn info) > expected.info && - (cd gitwc; git-svn info) > actual.info && - git-diff expected.info actual.info + (cd gitwc; git svn info) > actual.info && + test_cmp expected.info actual.info " test_expect_success 'info --url' ' - test "$(cd gitwc; git-svn info --url)" = "$svnrepo" + test "$(cd gitwc; git svn info --url)" = "$quoted_svnrepo" ' test_expect_success 'info .' " (cd svnwc; svn info .) > expected.info-dot && - (cd gitwc; git-svn info .) > actual.info-dot && - git-diff expected.info-dot actual.info-dot + (cd gitwc; git svn info .) > actual.info-dot && + test_cmp expected.info-dot actual.info-dot " test_expect_success 'info --url .' ' - test "$(cd gitwc; git-svn info --url .)" = "$svnrepo" + test "$(cd gitwc; git svn info --url .)" = "$quoted_svnrepo" ' test_expect_success 'info file' " (cd svnwc; svn info file) > expected.info-file && - (cd gitwc; git-svn info file) > actual.info-file && - git-diff expected.info-file actual.info-file + (cd gitwc; git svn info file) > actual.info-file && + test_cmp expected.info-file actual.info-file " test_expect_success 'info --url file' ' - test "$(cd gitwc; git-svn info --url file)" = "$svnrepo/file" + test "$(cd gitwc; git svn info --url file)" = "$quoted_svnrepo/file" ' test_expect_success 'info directory' " (cd svnwc; svn info directory) > expected.info-directory && - (cd gitwc; git-svn info directory) > actual.info-directory && - git-diff expected.info-directory actual.info-directory + (cd gitwc; git svn info directory) > actual.info-directory && + test_cmp expected.info-directory actual.info-directory + " + +test_expect_success 'info inside directory' " + (cd svnwc/directory; svn info) > expected.info-inside-directory && + (cd gitwc/directory; git svn info) > actual.info-inside-directory && + test_cmp expected.info-inside-directory actual.info-inside-directory " test_expect_success 'info --url directory' ' - test "$(cd gitwc; git-svn info --url directory)" = "$svnrepo/directory" + test "$(cd gitwc; git svn info --url directory)" = "$quoted_svnrepo/directory" ' test_expect_success 'info symlink-file' " (cd svnwc; svn info symlink-file) > expected.info-symlink-file && - (cd gitwc; git-svn info symlink-file) > actual.info-symlink-file && - git-diff expected.info-symlink-file actual.info-symlink-file + (cd gitwc; git svn info symlink-file) > actual.info-symlink-file && + test_cmp expected.info-symlink-file actual.info-symlink-file " test_expect_success 'info --url symlink-file' ' - test "$(cd gitwc; git-svn info --url symlink-file)" \ - = "$svnrepo/symlink-file" + test "$(cd gitwc; git svn info --url symlink-file)" \ + = "$quoted_svnrepo/symlink-file" ' test_expect_success 'info symlink-directory' " (cd svnwc; svn info symlink-directory) \ > expected.info-symlink-directory && - (cd gitwc; git-svn info symlink-directory) \ + (cd gitwc; git svn info symlink-directory) \ > actual.info-symlink-directory && - git-diff expected.info-symlink-directory actual.info-symlink-directory + test_cmp expected.info-symlink-directory actual.info-symlink-directory " test_expect_success 'info --url symlink-directory' ' - test "$(cd gitwc; git-svn info --url symlink-directory)" \ - = "$svnrepo/symlink-directory" + test "$(cd gitwc; git svn info --url symlink-directory)" \ + = "$quoted_svnrepo/symlink-directory" ' test_expect_success 'info added-file' " @@ -134,13 +146,13 @@ test_expect_success 'info added-file' " svn add added-file > /dev/null && cd .. && (cd svnwc; svn info added-file) > expected.info-added-file && - (cd gitwc; git-svn info added-file) > actual.info-added-file && - git-diff expected.info-added-file actual.info-added-file + (cd gitwc; git svn info added-file) > actual.info-added-file && + test_cmp expected.info-added-file actual.info-added-file " test_expect_success 'info --url added-file' ' - test "$(cd gitwc; git-svn info --url added-file)" \ - = "$svnrepo/added-file" + test "$(cd gitwc; git svn info --url added-file)" \ + = "$quoted_svnrepo/added-file" ' test_expect_success 'info added-directory' " @@ -155,14 +167,14 @@ test_expect_success 'info added-directory' " cd .. && (cd svnwc; svn info added-directory) \ > expected.info-added-directory && - (cd gitwc; git-svn info added-directory) \ + (cd gitwc; git svn info added-directory) \ > actual.info-added-directory && - git-diff expected.info-added-directory actual.info-added-directory + test_cmp expected.info-added-directory actual.info-added-directory " test_expect_success 'info --url added-directory' ' - test "$(cd gitwc; git-svn info --url added-directory)" \ - = "$svnrepo/added-directory" + test "$(cd gitwc; git svn info --url added-directory)" \ + = "$quoted_svnrepo/added-directory" ' test_expect_success 'info added-symlink-file' " @@ -177,15 +189,15 @@ test_expect_success 'info added-symlink-file' " ptouch gitwc/added-symlink-file svnwc/added-symlink-file && (cd svnwc; svn info added-symlink-file) \ > expected.info-added-symlink-file && - (cd gitwc; git-svn info added-symlink-file) \ + (cd gitwc; git svn info added-symlink-file) \ > actual.info-added-symlink-file && - git-diff expected.info-added-symlink-file \ + test_cmp expected.info-added-symlink-file \ actual.info-added-symlink-file " test_expect_success 'info --url added-symlink-file' ' - test "$(cd gitwc; git-svn info --url added-symlink-file)" \ - = "$svnrepo/added-symlink-file" + test "$(cd gitwc; git svn info --url added-symlink-file)" \ + = "$quoted_svnrepo/added-symlink-file" ' test_expect_success 'info added-symlink-directory' " @@ -200,15 +212,15 @@ test_expect_success 'info added-symlink-directory' " ptouch gitwc/added-symlink-directory svnwc/added-symlink-directory && (cd svnwc; svn info added-symlink-directory) \ > expected.info-added-symlink-directory && - (cd gitwc; git-svn info added-symlink-directory) \ + (cd gitwc; git svn info added-symlink-directory) \ > actual.info-added-symlink-directory && - git-diff expected.info-added-symlink-directory \ + test_cmp expected.info-added-symlink-directory \ actual.info-added-symlink-directory " test_expect_success 'info --url added-symlink-directory' ' - test "$(cd gitwc; git-svn info --url added-symlink-directory)" \ - = "$svnrepo/added-symlink-directory" + test "$(cd gitwc; git svn info --url added-symlink-directory)" \ + = "$quoted_svnrepo/added-symlink-directory" ' # The next few tests replace the "Text Last Updated" value with a @@ -226,15 +238,15 @@ test_expect_success 'info deleted-file' " (cd svnwc; svn info file) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > expected.info-deleted-file && - (cd gitwc; git-svn info file) | + (cd gitwc; git svn info file) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > actual.info-deleted-file && - git-diff expected.info-deleted-file actual.info-deleted-file + test_cmp expected.info-deleted-file actual.info-deleted-file " test_expect_success 'info --url file (deleted)' ' - test "$(cd gitwc; git-svn info --url file)" \ - = "$svnrepo/file" + test "$(cd gitwc; git svn info --url file)" \ + = "$quoted_svnrepo/file" ' test_expect_success 'info deleted-directory' " @@ -247,15 +259,15 @@ test_expect_success 'info deleted-directory' " (cd svnwc; svn info directory) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > expected.info-deleted-directory && - (cd gitwc; git-svn info directory) | + (cd gitwc; git svn info directory) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > actual.info-deleted-directory && - git-diff expected.info-deleted-directory actual.info-deleted-directory + test_cmp expected.info-deleted-directory actual.info-deleted-directory " test_expect_success 'info --url directory (deleted)' ' - test "$(cd gitwc; git-svn info --url directory)" \ - = "$svnrepo/directory" + test "$(cd gitwc; git svn info --url directory)" \ + = "$quoted_svnrepo/directory" ' test_expect_success 'info deleted-symlink-file' " @@ -268,16 +280,16 @@ test_expect_success 'info deleted-symlink-file' " (cd svnwc; svn info symlink-file) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > expected.info-deleted-symlink-file && - (cd gitwc; git-svn info symlink-file) | + (cd gitwc; git svn info symlink-file) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > actual.info-deleted-symlink-file && - git-diff expected.info-deleted-symlink-file \ + test_cmp expected.info-deleted-symlink-file \ actual.info-deleted-symlink-file " test_expect_success 'info --url symlink-file (deleted)' ' - test "$(cd gitwc; git-svn info --url symlink-file)" \ - = "$svnrepo/symlink-file" + test "$(cd gitwc; git svn info --url symlink-file)" \ + = "$quoted_svnrepo/symlink-file" ' test_expect_success 'info deleted-symlink-directory' " @@ -290,16 +302,16 @@ test_expect_success 'info deleted-symlink-directory' " (cd svnwc; svn info symlink-directory) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > expected.info-deleted-symlink-directory && - (cd gitwc; git-svn info symlink-directory) | + (cd gitwc; git svn info symlink-directory) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > actual.info-deleted-symlink-directory && - git-diff expected.info-deleted-symlink-directory \ + test_cmp expected.info-deleted-symlink-directory \ actual.info-deleted-symlink-directory " test_expect_success 'info --url symlink-directory (deleted)' ' - test "$(cd gitwc; git-svn info --url symlink-directory)" \ - = "$svnrepo/symlink-directory" + test "$(cd gitwc; git svn info --url symlink-directory)" \ + = "$quoted_svnrepo/symlink-directory" ' # NOTE: git does not have the concept of replaced objects, @@ -307,82 +319,59 @@ test_expect_success 'info --url symlink-directory (deleted)' ' test_expect_success 'info unknown-file' " echo two > gitwc/unknown-file && - cp gitwc/unknown-file svnwc/unknown-file && - ptouch gitwc/unknown-file svnwc/unknown-file && - (cd svnwc; svn info unknown-file) 2> expected.info-unknown-file && - (cd gitwc; git-svn info unknown-file) 2> actual.info-unknown-file && - git-diff expected.info-unknown-file actual.info-unknown-file + (cd gitwc; test_must_fail git svn info unknown-file) \ + 2> actual.info-unknown-file && + grep unknown-file actual.info-unknown-file " test_expect_success 'info --url unknown-file' ' - test -z "$(cd gitwc; git-svn info --url unknown-file \ - 2> ../actual.info--url-unknown-file)" && - git-diff expected.info-unknown-file actual.info--url-unknown-file + echo two > gitwc/unknown-file && + (cd gitwc; test_must_fail git svn info --url unknown-file) \ + 2> actual.info-url-unknown-file && + grep unknown-file actual.info-url-unknown-file ' test_expect_success 'info unknown-directory' " mkdir gitwc/unknown-directory svnwc/unknown-directory && - ptouch gitwc/unknown-directory svnwc/unknown-directory && - touch gitwc/unknown-directory/.placeholder && - (cd svnwc; svn info unknown-directory) \ - 2> expected.info-unknown-directory && - (cd gitwc; git-svn info unknown-directory) \ - 2> actual.info-unknown-directory && - git-diff expected.info-unknown-directory actual.info-unknown-directory + (cd gitwc; test_must_fail git svn info unknown-directory) \ + 2> actual.info-unknown-directory && + grep unknown-directory actual.info-unknown-directory " test_expect_success 'info --url unknown-directory' ' - test -z "$(cd gitwc; git-svn info --url unknown-directory \ - 2> ../actual.info--url-unknown-directory)" && - git-diff expected.info-unknown-directory \ - actual.info--url-unknown-directory + (cd gitwc; test_must_fail git svn info --url unknown-directory) \ + 2> actual.info-url-unknown-directory && + grep unknown-directory actual.info-url-unknown-directory ' test_expect_success 'info unknown-symlink-file' " cd gitwc && ln -s unknown-file unknown-symlink-file && cd .. && - cd svnwc && - ln -s unknown-file unknown-symlink-file && - cd .. && - ptouch gitwc/unknown-symlink-file svnwc/unknown-symlink-file && - (cd svnwc; svn info unknown-symlink-file) \ - 2> expected.info-unknown-symlink-file && - (cd gitwc; git-svn info unknown-symlink-file) \ - 2> actual.info-unknown-symlink-file && - git-diff expected.info-unknown-symlink-file \ - actual.info-unknown-symlink-file + (cd gitwc; test_must_fail git svn info unknown-symlink-file) \ + 2> actual.info-unknown-symlink-file && + grep unknown-symlink-file actual.info-unknown-symlink-file " test_expect_success 'info --url unknown-symlink-file' ' - test -z "$(cd gitwc; git-svn info --url unknown-symlink-file \ - 2> ../actual.info--url-unknown-symlink-file)" && - git-diff expected.info-unknown-symlink-file \ - actual.info--url-unknown-symlink-file + (cd gitwc; test_must_fail git svn info --url unknown-symlink-file) \ + 2> actual.info-url-unknown-symlink-file && + grep unknown-symlink-file actual.info-url-unknown-symlink-file ' test_expect_success 'info unknown-symlink-directory' " cd gitwc && ln -s unknown-directory unknown-symlink-directory && cd .. && - cd svnwc && - ln -s unknown-directory unknown-symlink-directory && - cd .. && - ptouch gitwc/unknown-symlink-directory \ - svnwc/unknown-symlink-directory && - (cd svnwc; svn info unknown-symlink-directory) \ - 2> expected.info-unknown-symlink-directory && - (cd gitwc; git-svn info unknown-symlink-directory) \ - 2> actual.info-unknown-symlink-directory && - git-diff expected.info-unknown-symlink-directory \ - actual.info-unknown-symlink-directory + (cd gitwc; test_must_fail git svn info unknown-symlink-directory) \ + 2> actual.info-unknown-symlink-directory && + grep unknown-symlink-directory actual.info-unknown-symlink-directory " test_expect_success 'info --url unknown-symlink-directory' ' - test -z "$(cd gitwc; git-svn info --url unknown-symlink-directory \ - 2> ../actual.info--url-unknown-symlink-directory)" && - git-diff expected.info-unknown-symlink-directory \ - actual.info--url-unknown-symlink-directory + (cd gitwc; test_must_fail git svn info --url unknown-symlink-directory) \ + 2> actual.info-url-unknown-symlink-directory && + grep unknown-symlink-directory actual.info-url-unknown-symlink-directory ' test_done diff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh index 5979e133b9..ef2c0523cd 100755 --- a/t/t9120-git-svn-clone-with-percent-escapes.sh +++ b/t/t9120-git-svn-clone-with-percent-escapes.sh @@ -3,7 +3,7 @@ # Copyright (c) 2008 Kevin Ballard # -test_description='git-svn clone with percent escapes' +test_description='git svn clone with percent escapes' . ./lib-git-svn.sh test_expect_success 'setup svnrepo' ' @@ -21,7 +21,7 @@ else test_expect_success 'test clone with percent escapes' ' git svn clone "$svnrepo/pr%20ject" clone && cd clone && - git rev-parse refs/remotes/git-svn && + git rev-parse refs/${remotes_git_svn} && cd .. ' fi diff --git a/t/t9121-git-svn-fetch-renamed-dir.sh b/t/t9121-git-svn-fetch-renamed-dir.sh index 99230b0810..000cad37c6 100755 --- a/t/t9121-git-svn-fetch-renamed-dir.sh +++ b/t/t9121-git-svn-fetch-renamed-dir.sh @@ -3,12 +3,12 @@ # Copyright (c) 2008 Santhosh Kumar Mani -test_description='git-svn can fetch renamed directories' +test_description='git svn can fetch renamed directories' . ./lib-git-svn.sh test_expect_success 'load repository with renamed directory' ' - svnadmin load -q "$rawsvnrepo" < ../t9121/renamed-dir.dump + svnadmin load -q "$rawsvnrepo" < "$TEST_DIRECTORY"/t9121/renamed-dir.dump ' test_expect_success 'init and fetch repository' ' diff --git a/t/t9122-git-svn-author.sh b/t/t9122-git-svn-author.sh index 1190576a65..1b1cf47281 100755 --- a/t/t9122-git-svn-author.sh +++ b/t/t9122-git-svn-author.sh @@ -13,7 +13,7 @@ test_expect_success 'setup svn repository' ' ) ' -test_expect_success 'interact with it via git-svn' ' +test_expect_success 'interact with it via git svn' ' mkdir work.git && ( cd work.git && diff --git a/t/t9123-git-svn-rebuild-with-rewriteroot.sh b/t/t9123-git-svn-rebuild-with-rewriteroot.sh index c18878fad1..cf0415274c 100755 --- a/t/t9123-git-svn-rebuild-with-rewriteroot.sh +++ b/t/t9123-git-svn-rebuild-with-rewriteroot.sh @@ -3,21 +3,21 @@ # Copyright (c) 2008 Jan Krüger # -test_description='git-svn respects rewriteRoot during rebuild' +test_description='git svn respects rewriteRoot during rebuild' . ./lib-git-svn.sh mkdir import cd import touch foo - svn import -m 'import for git-svn' . "$svnrepo" >/dev/null + svn import -m 'import for git svn' . "$svnrepo" >/dev/null cd .. rm -rf import test_expect_success 'init, fetch and checkout repository' ' git svn init --rewrite-root=http://invalid.invalid/ "$svnrepo" && git svn fetch - git checkout -b mybranch remotes/git-svn + git checkout -b mybranch ${remotes_git_svn} ' test_expect_success 'remove rev_map' ' diff --git a/t/t9124-git-svn-dcommit-auto-props.sh b/t/t9124-git-svn-dcommit-auto-props.sh index 8223c5909e..263dbf5fc2 100755 --- a/t/t9124-git-svn-dcommit-auto-props.sh +++ b/t/t9124-git-svn-dcommit-auto-props.sh @@ -2,7 +2,7 @@ # # Copyright (c) 2008 Brad King -test_description='git-svn dcommit honors auto-props' +test_description='git svn dcommit honors auto-props' . ./lib-git-svn.sh @@ -16,26 +16,24 @@ enable-auto-props=$1 EOF } -test_expect_success 'initialize git-svn' ' +test_expect_success 'initialize git svn' ' mkdir import && ( cd import && echo foo >foo && - svn import -m "import for git-svn" . "$svnrepo" + svn import -m "import for git svn" . "$svnrepo" ) && rm -rf import && - git-svn init "$svnrepo" - git-svn fetch + git svn init "$svnrepo" + git svn fetch ' test_expect_success 'enable auto-props config' ' - cd "$gittestrepo" && mkdir user && generate_auto_props yes >user/config ' test_expect_success 'add files matching auto-props' ' - cd "$gittestrepo" && echo "#!$SHELL_PATH" >exec1.sh && chmod +x exec1.sh && echo "hello" >hello.txt && @@ -46,12 +44,10 @@ test_expect_success 'add files matching auto-props' ' ' test_expect_success 'disable auto-props config' ' - cd "$gittestrepo" && generate_auto_props no >user/config ' test_expect_success 'add files matching disabled auto-props' ' - cd "$gittestrepo" && echo "#$SHELL_PATH" >exec2.sh && chmod +x exec2.sh && echo "world" >world.txt && @@ -62,6 +58,7 @@ test_expect_success 'add files matching disabled auto-props' ' ' test_expect_success 'check resulting svn repository' ' +( mkdir work && cd work && svn co "$svnrepo" && @@ -81,6 +78,24 @@ test_expect_success 'check resulting svn repository' ' test "x$(svn propget svn:mime-type world.txt)" = "x" && test "x$(svn propget svn:eol-style world.txt)" = "x" && test "x$(svn propget svn:mime-type zot)" = "x" +) +' + +test_expect_success 'check renamed file' ' + test -d user && + generate_auto_props yes > user/config && + git mv foo foo.sh && + git commit -m "foo => foo.sh" && + git svn dcommit --config-dir=user && + ( + cd work/svnrepo && + svn up && + test ! -e foo && + test -e foo.sh && + test "x$(svn propget svn:mime-type foo.sh)" = \ + "xapplication/x-shellscript" && + test "x$(svn propget svn:eol-style foo.sh)" = "xLF" + ) ' test_done diff --git a/t/t9125-git-svn-multi-glob-branch-names.sh b/t/t9125-git-svn-multi-glob-branch-names.sh index 6b62b52f54..475c751c1c 100755 --- a/t/t9125-git-svn-multi-glob-branch-names.sh +++ b/t/t9125-git-svn-multi-glob-branch-names.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copyright (c) 2008 Marcus Griep -test_description='git-svn multi-glob branch names' +test_description='git svn multi-glob branch names' . ./lib-git-svn.sh test_expect_success 'setup svnrepo' ' diff --git a/t/t9127-git-svn-partial-rebuild.sh b/t/t9127-git-svn-partial-rebuild.sh new file mode 100755 index 0000000000..87696a92dc --- /dev/null +++ b/t/t9127-git-svn-partial-rebuild.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Copyright (c) 2008 Deskin Miller +# + +test_description='git svn partial-rebuild tests' +. ./lib-git-svn.sh + +test_expect_success 'initialize svnrepo' ' + mkdir import && + ( + cd import && + mkdir trunk branches tags && + cd trunk && + echo foo > foo && + cd .. && + svn import -m "import for git-svn" . "$svnrepo" >/dev/null && + svn copy "$svnrepo"/trunk "$svnrepo"/branches/a \ + -m "created branch a" && + cd .. && + rm -rf import && + svn co "$svnrepo"/trunk trunk && + cd trunk && + echo bar >> foo && + svn ci -m "updated trunk" && + cd .. && + svn co "$svnrepo"/branches/a a && + cd a && + echo baz >> a && + svn add a && + svn ci -m "updated a" && + cd .. && + git svn init --stdlayout "$svnrepo" + ) +' + +test_expect_success 'import an early SVN revision into git' ' + git svn fetch -r1:2 +' + +test_expect_success 'make full git mirror of SVN' ' + mkdir mirror && + ( + cd mirror && + git init && + git svn init --stdlayout "$svnrepo" && + git svn fetch && + cd .. + ) +' + +test_expect_success 'fetch from git mirror and partial-rebuild' ' + git config --add remote.origin.url "file://$PWD/mirror/.git" && + git config --add remote.origin.fetch refs/remotes/*:refs/remotes/* && + git fetch origin && + git svn fetch +' + +test_done diff --git a/t/t9128-git-svn-cmd-branch.sh b/t/t9128-git-svn-cmd-branch.sh new file mode 100755 index 0000000000..252daa7e1a --- /dev/null +++ b/t/t9128-git-svn-cmd-branch.sh @@ -0,0 +1,78 @@ +#!/bin/sh +# +# Copyright (c) 2008 Deskin Miller +# + +test_description='git svn partial-rebuild tests' +. ./lib-git-svn.sh + +test_expect_success 'initialize svnrepo' ' + mkdir import && + ( + cd import && + mkdir trunk branches tags && + cd trunk && + echo foo > foo && + cd .. && + svn import -m "import for git-svn" . "$svnrepo" >/dev/null && + cd .. && + rm -rf import && + svn co "$svnrepo"/trunk trunk && + cd trunk && + echo bar >> foo && + svn ci -m "updated trunk" && + cd .. && + rm -rf trunk + ) +' + +test_expect_success 'import into git' ' + git svn init --stdlayout "$svnrepo" && + git svn fetch && + git checkout remotes/trunk +' + +test_expect_success 'git svn branch tests' ' + git svn branch a && + base=$(git rev-parse HEAD:) && + test $base = $(git rev-parse remotes/a:) && + git svn branch -m "created branch b blah" b && + test $base = $(git rev-parse remotes/b:) && + test_must_fail git branch -m "no branchname" && + git svn branch -n c && + test_must_fail git rev-parse remotes/c && + test_must_fail git svn branch a && + git svn branch -t tag1 && + test $base = $(git rev-parse remotes/tags/tag1:) && + git svn branch --tag tag2 && + test $base = $(git rev-parse remotes/tags/tag2:) && + git svn tag tag3 && + test $base = $(git rev-parse remotes/tags/tag3:) && + git svn tag -m "created tag4 foo" tag4 && + test $base = $(git rev-parse remotes/tags/tag4:) && + test_must_fail git svn tag -m "no tagname" && + git svn tag -n tag5 && + test_must_fail git rev-parse remotes/tags/tag5 && + test_must_fail git svn tag tag1 +' + +test_expect_success 'branch uses correct svn-remote' ' + (svn co "$svnrepo" svn && + cd svn && + mkdir mirror && + svn add mirror && + svn copy trunk mirror/ && + svn copy tags mirror/ && + svn copy branches mirror/ && + svn ci -m "made mirror" ) && + rm -rf svn && + git svn init -s -R mirror --prefix=mirror/ "$svnrepo"/mirror && + git svn fetch -R mirror && + git checkout mirror/trunk && + base=$(git rev-parse HEAD:) && + git svn branch -m "branch in mirror" d && + test $base = $(git rev-parse remotes/mirror/d:) && + test_must_fail git rev-parse remotes/d +' + +test_done diff --git a/t/t9129-git-svn-i18n-commitencoding.sh b/t/t9129-git-svn-i18n-commitencoding.sh new file mode 100755 index 0000000000..9c7b1ad18b --- /dev/null +++ b/t/t9129-git-svn-i18n-commitencoding.sh @@ -0,0 +1,93 @@ +#!/bin/sh +# +# Copyright (c) 2008 Eric Wong + +test_description='git svn honors i18n.commitEncoding in config' + +. ./lib-git-svn.sh + +compare_git_head_with () { + nr=`wc -l < "$1"` + a=7 + b=$(($a + $nr - 1)) + git cat-file commit HEAD | sed -ne "$a,${b}p" >current && + test_cmp current "$1" +} + +compare_svn_head_with () { + # extract just the log message and strip out committer info. + # don't use --limit here since svn 1.1.x doesn't have it, + LC_ALL=en_US.UTF-8 svn log `git svn info --url` | perl -w -e ' + use bytes; + $/ = ("-"x72) . "\n"; + my @x = <STDIN>; + @x = split(/\n/, $x[1]); + splice(@x, 0, 2); + $x[-1] = ""; + print join("\n", @x); + ' > current && + test_cmp current "$1" +} + +for H in ISO-8859-1 EUCJP ISO-2022-JP +do + test_expect_success "$H setup" ' + mkdir $H && + svn import -m "$H test" $H "$svnrepo"/$H && + git svn clone "$svnrepo"/$H $H + ' +done + +for H in ISO-8859-1 EUCJP ISO-2022-JP +do + test_expect_success "$H commit on git side" ' + ( + cd $H && + git config i18n.commitencoding $H && + git checkout -b t refs/remotes/git-svn && + echo $H >F && + git add F && + git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt && + E=$(git cat-file commit HEAD | sed -ne "s/^encoding //p") && + test "z$E" = "z$H" + compare_git_head_with "$TEST_DIRECTORY"/t3900/$H.txt + ) + ' +done + +for H in ISO-8859-1 EUCJP ISO-2022-JP +do + test_expect_success "$H dcommit to svn" ' + ( + cd $H && + git svn dcommit && + git cat-file commit HEAD | grep git-svn-id: && + E=$(git cat-file commit HEAD | sed -ne "s/^encoding //p") && + test "z$E" = "z$H" && + compare_git_head_with "$TEST_DIRECTORY"/t3900/$H.txt + ) + ' +done + +if locale -a |grep -q en_US.utf8; then + test_expect_success 'ISO-8859-1 should match UTF-8 in svn' ' + ( + cd ISO-8859-1 && + compare_svn_head_with "$TEST_DIRECTORY"/t3900/1-UTF-8.txt + ) + ' + + for H in EUCJP ISO-2022-JP + do + test_expect_success '$H should match UTF-8 in svn' ' + ( + cd $H && + compare_svn_head_with "$TEST_DIRECTORY"/t3900/2-UTF-8.txt + ) + ' + done +else + say "UTF-8 locale not available, test skipped" +fi + +test_done diff --git a/t/t9130-git-svn-authors-file.sh b/t/t9130-git-svn-authors-file.sh new file mode 100755 index 0000000000..b8fb277562 --- /dev/null +++ b/t/t9130-git-svn-authors-file.sh @@ -0,0 +1,94 @@ +#!/bin/sh +# +# Copyright (c) 2008 Eric Wong +# + +test_description='git svn authors file tests' + +. ./lib-git-svn.sh + +cat > svn-authors <<EOF +aa = AAAAAAA AAAAAAA <aa@example.com> +bb = BBBBBBB BBBBBBB <bb@example.com> +EOF + +test_expect_success 'setup svnrepo' ' + for i in aa bb cc dd + do + svn mkdir -m $i --username $i "$svnrepo"/$i + done + ' + +test_expect_success 'start import with incomplete authors file' ' + ! git svn clone --authors-file=svn-authors "$svnrepo" x + ' + +test_expect_success 'imported 2 revisions successfully' ' + ( + cd x + test "`git rev-list refs/remotes/git-svn | wc -l`" -eq 2 && + git rev-list -1 --pretty=raw refs/remotes/git-svn | \ + grep "^author BBBBBBB BBBBBBB <bb@example\.com> " && + git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ + grep "^author AAAAAAA AAAAAAA <aa@example\.com> " + ) + ' + +cat >> svn-authors <<EOF +cc = CCCCCCC CCCCCCC <cc@example.com> +dd = DDDDDDD DDDDDDD <dd@example.com> +EOF + +test_expect_success 'continues to import once authors have been added' ' + ( + cd x + git svn fetch --authors-file=../svn-authors && + test "`git rev-list refs/remotes/git-svn | wc -l`" -eq 4 && + git rev-list -1 --pretty=raw refs/remotes/git-svn | \ + grep "^author DDDDDDD DDDDDDD <dd@example\.com> " && + git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ + grep "^author CCCCCCC CCCCCCC <cc@example\.com> " + ) + ' + +test_expect_success 'authors-file against globs' ' + svn mkdir -m globs --username aa \ + "$svnrepo"/aa/trunk "$svnrepo"/aa/branches "$svnrepo"/aa/tags && + git svn clone --authors-file=svn-authors -s "$svnrepo"/aa aa-work && + for i in bb ee cc + do + branch="aa/branches/$i" + svn mkdir -m "$branch" --username $i "$svnrepo/$branch" + done + ' + +test_expect_success 'fetch fails on ee' ' + ( cd aa-work && ! git svn fetch --authors-file=../svn-authors ) + ' + +tmp_config_get () { + GIT_CONFIG=.git/svn/.metadata git config --get "$1" +} + +test_expect_success 'failure happened without negative side effects' ' + ( + cd aa-work && + test 6 -eq "`tmp_config_get svn-remote.svn.branches-maxRev`" && + test 6 -eq "`tmp_config_get svn-remote.svn.tags-maxRev`" + ) + ' + +cat >> svn-authors <<EOF +ee = EEEEEEE EEEEEEE <ee@example.com> +EOF + +test_expect_success 'fetch continues after authors-file is fixed' ' + ( + cd aa-work && + git svn fetch --authors-file=../svn-authors && + test 8 -eq "`tmp_config_get svn-remote.svn.branches-maxRev`" && + test 8 -eq "`tmp_config_get svn-remote.svn.tags-maxRev`" + ) + ' + +test_done diff --git a/t/t9131-git-svn-empty-symlink.sh b/t/t9131-git-svn-empty-symlink.sh new file mode 100755 index 0000000000..8f35e294aa --- /dev/null +++ b/t/t9131-git-svn-empty-symlink.sh @@ -0,0 +1,110 @@ +#!/bin/sh + +test_description='test that git handles an svn repository with empty symlinks' + +. ./lib-git-svn.sh +test_expect_success 'load svn dumpfile' ' + svnadmin load "$rawsvnrepo" <<EOF +SVN-fs-dump-format-version: 2 + +UUID: 60780f9a-7df5-43b4-83ab-60e2c0673ef7 + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2008-11-26T07:17:27.590577Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 111 +Content-length: 111 + +K 7 +svn:log +V 4 +test +K 10 +svn:author +V 12 +normalperson +K 8 +svn:date +V 27 +2008-11-26T07:18:03.511836Z +PROPS-END + +Node-path: bar +Node-kind: file +Node-action: add +Prop-content-length: 33 +Text-content-length: 0 +Text-content-md5: d41d8cd98f00b204e9800998ecf8427e +Content-length: 33 + +K 11 +svn:special +V 1 +* +PROPS-END + +Revision-number: 2 +Prop-content-length: 121 +Content-length: 121 + +K 7 +svn:log +V 13 +bar => doink + +K 10 +svn:author +V 12 +normalperson +K 8 +svn:date +V 27 +2008-11-27T03:55:31.601672Z +PROPS-END + +Node-path: bar +Node-kind: file +Node-action: change +Text-content-length: 10 +Text-content-md5: 92ca4fe7a9721f877f765c252dcd66c9 +Content-length: 10 + +link doink + +EOF +' + +test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" x' +test_expect_success 'enable broken symlink workaround' \ + '(cd x && git config svn.brokenSymlinkWorkaround true)' +test_expect_success '"bar" is an empty file' 'test -f x/bar && ! test -s x/bar' +test_expect_success 'get "bar" => symlink fix from svn' \ + '(cd x && git svn rebase)' +test_expect_success '"bar" becomes a symlink' 'test -L x/bar' + + +test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" y' +test_expect_success 'disable broken symlink workaround' \ + '(cd y && git config svn.brokenSymlinkWorkaround false)' +test_expect_success '"bar" is an empty file' 'test -f y/bar && ! test -s y/bar' +test_expect_success 'get "bar" => symlink fix from svn' \ + '(cd y && git svn rebase)' +test_expect_success '"bar" does not become a symlink' '! test -L y/bar' + +# svn.brokenSymlinkWorkaround is unset +test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" z' +test_expect_success '"bar" is an empty file' 'test -f z/bar && ! test -s z/bar' +test_expect_success 'get "bar" => symlink fix from svn' \ + '(cd z && git svn rebase)' +test_expect_success '"bar" does not become a symlink' '! test -L z/bar' + + +test_done diff --git a/t/t9132-git-svn-broken-symlink.sh b/t/t9132-git-svn-broken-symlink.sh new file mode 100755 index 0000000000..b8de59e493 --- /dev/null +++ b/t/t9132-git-svn-broken-symlink.sh @@ -0,0 +1,102 @@ +#!/bin/sh + +test_description='test that git handles an svn repository with empty symlinks' + +. ./lib-git-svn.sh +test_expect_success 'load svn dumpfile' ' + svnadmin load "$rawsvnrepo" <<EOF +SVN-fs-dump-format-version: 2 + +UUID: 60780f9a-7df5-43b4-83ab-60e2c0673ef7 + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2008-11-26T07:17:27.590577Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 111 +Content-length: 111 + +K 7 +svn:log +V 4 +test +K 10 +svn:author +V 12 +normalperson +K 8 +svn:date +V 27 +2008-11-26T07:18:03.511836Z +PROPS-END + +Node-path: bar +Node-kind: file +Node-action: add +Prop-content-length: 33 +Text-content-length: 4 +Text-content-md5: 912ec803b2ce49e4a541068d495ab570 +Content-length: 37 + +K 11 +svn:special +V 1 +* +PROPS-END +asdf + +Revision-number: 2 +Prop-content-length: 121 +Content-length: 121 + +K 7 +svn:log +V 13 +bar => doink + +K 10 +svn:author +V 12 +normalperson +K 8 +svn:date +V 27 +2008-11-27T03:55:31.601672Z +PROPS-END + +Node-path: bar +Node-kind: file +Node-action: change +Text-content-length: 10 +Text-content-md5: 92ca4fe7a9721f877f765c252dcd66c9 +Content-length: 10 + +link doink + +EOF +' + +test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" x' + +test_expect_success '"bar" is a symlink that points to "asdf"' ' + test -L x/bar && + (cd x && test xasdf = x"`git cat-file blob HEAD:bar`") +' + +test_expect_success 'get "bar" => symlink fix from svn' ' + (cd x && git svn rebase) +' + +test_expect_success '"bar" remains a proper symlink' ' + test -L x/bar && + (cd x && test xdoink = x"`git cat-file blob HEAD:bar`") +' + +test_done diff --git a/t/t9133-git-svn-nested-git-repo.sh b/t/t9133-git-svn-nested-git-repo.sh new file mode 100755 index 0000000000..893f57ef73 --- /dev/null +++ b/t/t9133-git-svn-nested-git-repo.sh @@ -0,0 +1,101 @@ +#!/bin/sh +# +# Copyright (c) 2009 Eric Wong +# + +test_description='git svn property tests' +. ./lib-git-svn.sh + +test_expect_success 'setup repo with a git repo inside it' ' + svn co "$svnrepo" s && + ( + cd s && + git init && + test -f .git/HEAD && + > .git/a && + echo a > a && + svn add .git a && + svn commit -m "create a nested git repo" && + svn up && + echo hi >> .git/a && + svn commit -m "modify .git/a" && + svn up + ) +' + +test_expect_success 'clone an SVN repo containing a git repo' ' + git svn clone "$svnrepo" g && + echo a > expect && + test_cmp expect g/a +' + +test_expect_success 'SVN-side change outside of .git' ' + ( + cd s && + echo b >> a && + svn commit -m "SVN-side change outside of .git" && + svn up && + svn log -v | fgrep "SVN-side change outside of .git" + ) +' + +test_expect_success 'update git svn-cloned repo' ' + ( + cd g && + git svn rebase && + echo a > expect && + echo b >> expect && + test_cmp a expect && + rm expect + ) +' + +test_expect_success 'SVN-side change inside of .git' ' + ( + cd s && + git add a && + git commit -m "add a inside an SVN repo" && + git log && + svn add --force .git && + svn commit -m "SVN-side change inside of .git" && + svn up && + svn log -v | fgrep "SVN-side change inside of .git" + ) +' + +test_expect_success 'update git svn-cloned repo' ' + ( + cd g && + git svn rebase && + echo a > expect && + echo b >> expect && + test_cmp a expect && + rm expect + ) +' + +test_expect_success 'SVN-side change in and out of .git' ' + ( + cd s && + echo c >> a && + git add a && + git commit -m "add a inside an SVN repo" && + svn commit -m "SVN-side change in and out of .git" && + svn up && + svn log -v | fgrep "SVN-side change in and out of .git" + ) +' + +test_expect_success 'update git svn-cloned repo again' ' + ( + cd g && + git svn rebase && + echo a > expect && + echo b >> expect && + echo c >> expect && + test_cmp a expect && + rm expect + ) +' + +test_done diff --git a/t/t9134-git-svn-ignore-paths.sh b/t/t9134-git-svn-ignore-paths.sh new file mode 100755 index 0000000000..c4b5b8bcf7 --- /dev/null +++ b/t/t9134-git-svn-ignore-paths.sh @@ -0,0 +1,98 @@ +#!/bin/sh +# +# Copyright (c) 2009 Vitaly Shukela +# Copyright (c) 2009 Eric Wong +# + +test_description='git svn property tests' +. ./lib-git-svn.sh + +test_expect_success 'setup test repository' ' + svn co "$svnrepo" s && + ( + cd s && + mkdir qqq www && + echo test_qqq > qqq/test_qqq.txt && + echo test_www > www/test_www.txt && + svn add qqq && + svn add www && + svn commit -m "create some files" && + svn up && + echo hi >> www/test_www.txt && + svn commit -m "modify www/test_www.txt" && + svn up + ) +' + +test_expect_success 'clone an SVN repository with ignored www directory' ' + git svn clone --ignore-paths="^www" "$svnrepo" g && + echo test_qqq > expect && + for i in g/*/*.txt; do cat $i >> expect2; done && + test_cmp expect expect2 +' + +test_expect_success 'SVN-side change outside of www' ' + ( + cd s && + echo b >> qqq/test_qqq.txt && + svn commit -m "SVN-side change outside of www" && + svn up && + svn log -v | fgrep "SVN-side change outside of www" + ) +' + +test_expect_success 'update git svn-cloned repo' ' + ( + cd g && + git svn rebase --ignore-paths="^www" && + printf "test_qqq\nb\n" > expect && + for i in */*.txt; do cat $i >> expect2; done && + test_cmp expect2 expect && + rm expect expect2 + ) +' + +test_expect_success 'SVN-side change inside of ignored www' ' + ( + cd s && + echo zaq >> www/test_www.txt + svn commit -m "SVN-side change inside of www/test_www.txt" && + svn up && + svn log -v | fgrep "SVN-side change inside of www/test_www.txt" + ) +' + +test_expect_success 'update git svn-cloned repo' ' + ( + cd g && + git svn rebase --ignore-paths="^www" && + printf "test_qqq\nb\n" > expect && + for i in */*.txt; do cat $i >> expect2; done && + test_cmp expect2 expect && + rm expect expect2 + ) +' + +test_expect_success 'SVN-side change in and out of ignored www' ' + ( + cd s && + echo cvf >> www/test_www.txt + echo ygg >> qqq/test_qqq.txt + svn commit -m "SVN-side change in and out of ignored www" && + svn up && + svn log -v | fgrep "SVN-side change in and out of ignored www" + ) +' + +test_expect_success 'update git svn-cloned repo again' ' + ( + cd g && + git svn rebase --ignore-paths="^www" && + printf "test_qqq\nb\nygg\n" > expect && + for i in */*.txt; do cat $i >> expect2; done && + test_cmp expect2 expect && + rm expect expect2 + ) +' + +test_done diff --git a/t/t9135-git-svn-moved-branch-empty-file.sh b/t/t9135-git-svn-moved-branch-empty-file.sh new file mode 100755 index 0000000000..03705fa4ce --- /dev/null +++ b/t/t9135-git-svn-moved-branch-empty-file.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +test_description='test moved svn branch with missing empty files' + +. ./lib-git-svn.sh +test_expect_success 'load svn dumpfile' ' + svnadmin load "$rawsvnrepo" < "${TEST_DIRECTORY}/t9135/svn.dump" + ' + +test_expect_success 'clone using git svn' 'git svn clone -s "$svnrepo" x' + +test_expect_success 'test that b1 exists and is empty' ' + (cd x && test -f b1 && ! test -s b1) + ' + +test_done diff --git a/t/t9135/svn.dump b/t/t9135/svn.dump new file mode 100644 index 0000000000..b51c0ccceb --- /dev/null +++ b/t/t9135/svn.dump @@ -0,0 +1,192 @@ +SVN-fs-dump-format-version: 2 + +UUID: 1f80e919-e9e3-4d80-a3ae-d9f21095e27b + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2009-02-10T19:23:16.424027Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 123 +Content-length: 123 + +K 7 +svn:log +V 20 +init standard layout +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-10T19:23:17.195072Z +PROPS-END + +Node-path: branches +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: trunk +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Revision-number: 2 +Prop-content-length: 121 +Content-length: 121 + +K 7 +svn:log +V 18 +branch-b off trunk +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-10T19:23:19.160095Z +PROPS-END + +Node-path: branches/branch-b +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 1 +Node-copyfrom-path: trunk +Prop-content-length: 34 +Content-length: 34 + +K 13 +svn:mergeinfo +V 0 + +PROPS-END + + +Revision-number: 3 +Prop-content-length: 120 +Content-length: 120 + +K 7 +svn:log +V 17 +add empty file b1 +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-10T19:23:20.194568Z +PROPS-END + +Node-path: branches/branch-b/b1 +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 0 +Text-content-md5: d41d8cd98f00b204e9800998ecf8427e +Content-length: 10 + +PROPS-END + + +Revision-number: 4 +Prop-content-length: 110 +Content-length: 110 + +K 7 +svn:log +V 8 +branch-c +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-10T19:23:21.169100Z +PROPS-END + +Node-path: branches/branch-c +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 3 +Node-copyfrom-path: trunk + + +Revision-number: 5 +Prop-content-length: 126 +Content-length: 126 + +K 7 +svn:log +V 23 +oops, wrong branchpoint +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-10T19:23:21.253557Z +PROPS-END + +Node-path: branches/branch-c +Node-action: delete + + +Revision-number: 6 +Prop-content-length: 127 +Content-length: 127 + +K 7 +svn:log +V 24 +branch-c off of branch-b +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-10T19:23:21.314659Z +PROPS-END + +Node-path: branches/branch-c +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 5 +Node-copyfrom-path: branches/branch-b +Prop-content-length: 34 +Content-length: 34 + +K 13 +svn:mergeinfo +V 0 + +PROPS-END + + diff --git a/t/t9136-git-svn-recreated-branch-empty-file.sh b/t/t9136-git-svn-recreated-branch-empty-file.sh new file mode 100755 index 0000000000..733d16e0b2 --- /dev/null +++ b/t/t9136-git-svn-recreated-branch-empty-file.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +test_description='test recreated svn branch with empty files' + +. ./lib-git-svn.sh +test_expect_success 'load svn dumpfile' ' + svnadmin load "$rawsvnrepo" < "${TEST_DIRECTORY}/t9136/svn.dump" + ' + +test_expect_success 'clone using git svn' 'git svn clone -s "$svnrepo" x' + +test_done diff --git a/t/t9136/svn.dump b/t/t9136/svn.dump new file mode 100644 index 0000000000..6b1ce0b2e8 --- /dev/null +++ b/t/t9136/svn.dump @@ -0,0 +1,192 @@ +SVN-fs-dump-format-version: 2 + +UUID: eecae021-8f16-48da-969d-79beb8ae6ea5 + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2009-02-22T00:50:56.292890Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 106 +Content-length: 106 + +K 7 +svn:log +V 4 +init +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-22T00:50:57.192384Z +PROPS-END + +Node-path: branches +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: tags +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: trunk +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: trunk/file +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 0 +Text-content-md5: d41d8cd98f00b204e9800998ecf8427e +Content-length: 10 + +PROPS-END + + +Revision-number: 2 +Prop-content-length: 105 +Content-length: 105 + +K 7 +svn:log +V 3 +1.0 +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-22T00:50:58.124724Z +PROPS-END + +Node-path: tags/1.0 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 1 +Node-copyfrom-path: trunk + + +Revision-number: 3 +Prop-content-length: 111 +Content-length: 111 + +K 7 +svn:log +V 9 +1.0.1-bad +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-22T00:50:58.151727Z +PROPS-END + +Node-path: tags/1.0.1 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 2 +Node-copyfrom-path: tags/1.0 + + +Revision-number: 4 +Prop-content-length: 111 +Content-length: 111 + +K 7 +svn:log +V 9 +Wrong tag +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-22T00:50:58.167427Z +PROPS-END + +Node-path: tags/1.0.1 +Node-action: delete + + +Revision-number: 5 +Prop-content-length: 113 +Content-length: 113 + +K 7 +svn:log +V 10 +1.0-branch +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-22T00:50:58.184498Z +PROPS-END + +Node-path: branches/1.0 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 4 +Node-copyfrom-path: tags/1.0 + + +Revision-number: 6 +Prop-content-length: 113 +Content-length: 113 + +K 7 +svn:log +V 10 +1.0.1-good +K 10 +svn:author +V 8 +john.doe +K 8 +svn:date +V 27 +2009-02-22T00:50:58.200695Z +PROPS-END + +Node-path: tags/1.0.1 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 5 +Node-copyfrom-path: branches/1.0 + + diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh index 3e32e84e6c..245a7c3662 100755 --- a/t/t9200-git-cvsexportcommit.sh +++ b/t/t9200-git-cvsexportcommit.sh @@ -9,7 +9,7 @@ test_description='Test export of commits to CVS' cvs >/dev/null 2>&1 if test $? -ne 1 then - test_expect_success 'skipping git-cvsexportcommit tests, cvs not found' : + test_expect_success 'skipping git cvsexportcommit tests, cvs not found' : test_done exit fi @@ -45,8 +45,8 @@ test_expect_success \ 'mkdir A B C D E F && echo hello1 >A/newfile1.txt && echo hello2 >B/newfile2.txt && - cp ../test9200a.png C/newfile3.png && - cp ../test9200a.png D/newfile4.png && + cp "$TEST_DIRECTORY"/test9200a.png C/newfile3.png && + cp "$TEST_DIRECTORY"/test9200a.png D/newfile4.png && git add A/newfile1.txt && git add B/newfile2.txt && git add C/newfile3.png && @@ -71,8 +71,8 @@ test_expect_success \ rm -f B/newfile2.txt && rm -f C/newfile3.png && echo Hello5 >E/newfile5.txt && - cp ../test9200b.png D/newfile4.png && - cp ../test9200a.png F/newfile6.png && + cp "$TEST_DIRECTORY"/test9200b.png D/newfile4.png && + cp "$TEST_DIRECTORY"/test9200a.png F/newfile6.png && git add E/newfile5.txt && git add F/newfile6.png && git commit -a -m "Test: Remove, add and update" && @@ -91,7 +91,7 @@ test_expect_success \ diff F/newfile6.png ../F/newfile6.png )' -# Should fail (but only on the git-cvsexportcommit stage) +# Should fail (but only on the git cvsexportcommit stage) test_expect_success \ 'Fail to change binary more than one generation old' \ 'cat F/newfile6.png >>D/newfile4.png && @@ -160,24 +160,24 @@ test_expect_success \ 'mkdir "G g" && echo ok then >"G g/with spaces.txt" && git add "G g/with spaces.txt" && \ - cp ../test9200a.png "G g/with spaces.png" && \ + cp "$TEST_DIRECTORY"/test9200a.png "G g/with spaces.png" && \ git add "G g/with spaces.png" && git commit -a -m "With spaces" && id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && - git-cvsexportcommit -c $id && + git cvsexportcommit -c $id && check_entries "G g" "with spaces.png/1.1/-kb|with spaces.txt/1.1/" )' test_expect_success \ 'Update file with spaces in file name' \ 'echo Ok then >>"G g/with spaces.txt" && - cat ../test9200a.png >>"G g/with spaces.png" && \ + cat "$TEST_DIRECTORY"/test9200a.png >>"G g/with spaces.png" && \ git add "G g/with spaces.png" && git commit -a -m "Update with spaces" && id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && - git-cvsexportcommit -c $id + git cvsexportcommit -c $id check_entries "G g" "with spaces.png/1.2/-kb|with spaces.txt/1.2/" )' @@ -197,12 +197,12 @@ test_expect_success \ 'mkdir -p Å/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/å/ä/ö && echo Foo >Å/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.txt && git add Å/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.txt && - cp ../test9200a.png Å/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 && + cp "$TEST_DIRECTORY"/test9200a.png Å/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 && git add Å/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 && git commit -a -m "Går det så går det" && \ id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && - git-cvsexportcommit -v -c $id && + git cvsexportcommit -v -c $id && 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/" @@ -222,7 +222,7 @@ test_expect_success \ git commit -a -m "Update two" && id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && - test_must_fail git-cvsexportcommit -c $id + test_must_fail git cvsexportcommit -c $id )' case "$(git config --bool core.filemode)" in @@ -239,7 +239,7 @@ test_expect_success \ git add G/off && git commit -a -m "Execute test" && (cd "$CVSWORK" && - git-cvsexportcommit -c HEAD + git cvsexportcommit -c HEAD test -x G/on && ! test -x G/off )' diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 8b79de5b63..821be7ce8d 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -3,9 +3,9 @@ # Copyright (c) 2007 Shawn Pearce # -test_description='test git-fast-import utility' +test_description='test git fast-import utility' . ./test-lib.sh -. ../diff-lib.sh ;# test-lib chdir's into trash +. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash file2_data='file2 second line of EOF' @@ -65,7 +65,7 @@ EOF INPUT_END test_expect_success \ 'A: create pack from stdin' \ - 'git-fast-import --export-marks=marks.out <input && + 'git fast-import --export-marks=marks.out <input && git whatchanged master' test_expect_success \ 'A: verify pack' \ @@ -131,7 +131,7 @@ test_expect_success \ test_expect_success \ 'A: verify marks import' \ - 'git-fast-import \ + 'git fast-import \ --import-marks=marks.out \ --export-marks=marks.new \ </dev/null && @@ -151,7 +151,7 @@ M 755 :2 copy-of-file2 INPUT_END test_expect_success \ 'A: verify marks import does not crash' \ - 'git-fast-import --import-marks=marks.out <input && + 'git fast-import --import-marks=marks.out <input && git whatchanged verify--import-marks' test_expect_success \ 'A: verify pack' \ @@ -184,7 +184,7 @@ M 755 0000000000000000000000000000000000000001 zero1 INPUT_END test_expect_success 'B: fail on invalid blob sha1' ' - test_must_fail git-fast-import <input + test_must_fail git fast-import <input ' rm -f .git/objects/pack_* .git/objects/index_* @@ -199,7 +199,7 @@ from refs/heads/master INPUT_END test_expect_success 'B: fail on invalid branch name ".badbranchname"' ' - test_must_fail git-fast-import <input + test_must_fail git fast-import <input ' rm -f .git/objects/pack_* .git/objects/index_* @@ -214,7 +214,7 @@ from refs/heads/master INPUT_END test_expect_success 'B: fail on invalid branch name "bad[branch]name"' ' - test_must_fail git-fast-import <input + test_must_fail git fast-import <input ' rm -f .git/objects/pack_* .git/objects/index_* @@ -230,7 +230,7 @@ from refs/heads/master INPUT_END test_expect_success \ 'B: accept branch name "TEMP_TAG"' \ - 'git-fast-import <input && + 'git fast-import <input && test -f .git/TEMP_TAG && test `git rev-parse master` = `git rev-parse TEMP_TAG^`' rm -f .git/TEMP_TAG @@ -239,7 +239,7 @@ rm -f .git/TEMP_TAG ### series C ### -newf=`echo hi newf | git-hash-object -w --stdin` +newf=`echo hi newf | git hash-object -w --stdin` oldf=`git rev-parse --verify master:file2` test_tick cat >input <<INPUT_END @@ -257,7 +257,7 @@ D file3 INPUT_END test_expect_success \ 'C: incremental import create pack from stdin' \ - 'git-fast-import <input && + 'git fast-import <input && git whatchanged branch' test_expect_success \ 'C: verify pack' \ @@ -315,7 +315,7 @@ EOF INPUT_END test_expect_success \ 'D: inline data in commit' \ - 'git-fast-import <input && + 'git fast-import <input && git whatchanged branch' test_expect_success \ 'D: verify pack' \ @@ -358,11 +358,11 @@ from refs/heads/branch^0 INPUT_END test_expect_success 'E: rfc2822 date, --date-format=raw' ' - test_must_fail git-fast-import --date-format=raw <input + test_must_fail git fast-import --date-format=raw <input ' test_expect_success \ 'E: rfc2822 date, --date-format=rfc2822' \ - 'git-fast-import --date-format=rfc2822 <input' + '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' @@ -399,7 +399,7 @@ from refs/heads/branch INPUT_END test_expect_success \ 'F: non-fast-forward update skips' \ - 'if git-fast-import <input + 'if git fast-import <input then echo BAD gfi did not fail return 1 @@ -449,7 +449,7 @@ from refs/heads/branch~1 INPUT_END test_expect_success \ 'G: non-fast-forward update forced' \ - 'git-fast-import --force <input' + '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' @@ -485,7 +485,7 @@ EOF INPUT_END test_expect_success \ 'H: deletall, add 1' \ - 'git-fast-import <input && + 'git fast-import <input && git whatchanged H' test_expect_success \ 'H: verify pack' \ @@ -525,7 +525,7 @@ from refs/heads/branch INPUT_END test_expect_success \ 'I: export-pack-edges' \ - 'git-fast-import --export-pack-edges=edges.list <input' + 'git fast-import --export-pack-edges=edges.list <input' cat >expect <<EOF .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary` @@ -559,7 +559,7 @@ COMMIT INPUT_END test_expect_success \ 'J: reset existing branch creates empty commit' \ - 'git-fast-import <input' + 'git fast-import <input' test_expect_success \ 'J: branch has 1 commit, empty tree' \ 'test 1 = `git rev-list J | wc -l` && @@ -589,7 +589,7 @@ from refs/heads/branch^1 INPUT_END test_expect_success \ 'K: reinit branch with from' \ - 'git-fast-import <input' + 'git fast-import <input' test_expect_success \ 'K: verify K^1 = branch^1' \ 'test `git rev-parse --verify branch^1` \ @@ -641,7 +641,7 @@ EXPECT_END test_expect_success \ 'L: verify internal tree sorting' \ - 'git-fast-import <input && + 'git fast-import <input && git diff-tree --abbrev --raw L^ L >output && test_cmp expect output' @@ -667,7 +667,7 @@ cat >expect <<EOF EOF test_expect_success \ 'M: rename file in same subdirectory' \ - 'git-fast-import <input && + 'git fast-import <input && git diff-tree -M -r M1^ M1 >actual && compare_diff_raw expect actual' @@ -688,7 +688,7 @@ cat >expect <<EOF EOF test_expect_success \ 'M: rename file to new subdirectory' \ - 'git-fast-import <input && + 'git fast-import <input && git diff-tree -M -r M2^ M2 >actual && compare_diff_raw expect actual' @@ -709,7 +709,7 @@ cat >expect <<EOF EOF test_expect_success \ 'M: rename subdirectory to new subdirectory' \ - 'git-fast-import <input && + 'git fast-import <input && git diff-tree -M -r M3^ M3 >actual && compare_diff_raw expect actual' @@ -735,7 +735,7 @@ cat >expect <<EOF EOF test_expect_success \ 'N: copy file in same subdirectory' \ - 'git-fast-import <input && + 'git fast-import <input && git diff-tree -C --find-copies-harder -r N1^ N1 >actual && compare_diff_raw expect actual' @@ -769,7 +769,7 @@ cat >expect <<EOF EOF test_expect_success \ 'N: copy then modify subdirectory' \ - 'git-fast-import <input && + 'git fast-import <input && git diff-tree -C --find-copies-harder -r N2^^ N2 >actual && compare_diff_raw expect actual' @@ -793,8 +793,8 @@ INPUT_END test_expect_success \ 'N: copy dirty subdirectory' \ - 'git-fast-import <input && - test `git-rev-parse N2^{tree}` = `git-rev-parse N3^{tree}`' + 'git fast-import <input && + test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`' ### ### series O @@ -833,8 +833,8 @@ INPUT_END test_expect_success \ 'O: comments are all skipped' \ - 'git-fast-import <input && - test `git-rev-parse N3` = `git-rev-parse O1`' + 'git fast-import <input && + test `git rev-parse N3` = `git rev-parse O1`' cat >input <<INPUT_END commit refs/heads/O2 @@ -854,8 +854,8 @@ INPUT_END test_expect_success \ 'O: blank lines not necessary after data commands' \ - 'git-fast-import <input && - test `git-rev-parse N3` = `git-rev-parse O2`' + 'git fast-import <input && + test `git rev-parse N3` = `git rev-parse O2`' test_expect_success \ 'O: repack before next test' \ @@ -899,7 +899,7 @@ commits INPUT_END test_expect_success \ 'O: blank lines not necessary after other commands' \ - 'git-fast-import <input && + 'git fast-import <input && test 8 = `find .git/objects/pack -type f | wc -l` && test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` && git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual && @@ -932,7 +932,7 @@ progress I'm done! INPUT_END test_expect_success \ 'O: progress outputs as requested by input' \ - 'git-fast-import <input >actual && + 'git fast-import <input >actual && grep "progress " <input >expect && test_cmp expect actual' @@ -997,7 +997,7 @@ INPUT_END test_expect_success \ 'P: supermodule & submodule mix' \ - 'git-fast-import <input && + 'git fast-import <input && git checkout subuse1 && rm -rf sub && mkdir sub && cd sub && git init && @@ -1007,8 +1007,8 @@ test_expect_success \ git submodule init && git submodule update' -SUBLAST=$(git-rev-parse --verify sub) -SUBPREV=$(git-rev-parse --verify sub^) +SUBLAST=$(git rev-parse --verify sub) +SUBPREV=$(git rev-parse --verify sub^) cat >input <<INPUT_END blob @@ -1042,8 +1042,8 @@ test_expect_success \ 'P: verbatim SHA gitlinks' \ 'git branch -D sub && git gc && git prune && - git-fast-import <input && - test $(git-rev-parse --verify subuse2) = $(git-rev-parse --verify subuse1)' + git fast-import <input && + test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)' test_tick cat >input <<INPUT_END @@ -1063,7 +1063,7 @@ DATA INPUT_END test_expect_success 'P: fail on inline gitlink' ' - test_must_fail git-fast-import <input' + test_must_fail git fast-import <input' test_tick cat >input <<INPUT_END @@ -1086,6 +1086,6 @@ M 160000 :1 sub INPUT_END test_expect_success 'P: fail on blob mark in gitlink' ' - test_must_fail git-fast-import <input' + test_must_fail git fast-import <input' test_done diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh index 3a6509a1c8..86c376088c 100755 --- a/t/t9301-fast-export.sh +++ b/t/t9301-fast-export.sh @@ -3,7 +3,7 @@ # Copyright (c) 2007 Johannes E. Schindelin # -test_description='git-fast-export' +test_description='git fast-export' . ./test-lib.sh test_expect_success 'setup' ' @@ -67,7 +67,7 @@ test_expect_success '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_DIRECTORY"/t3901-8859-1.txt && test_tick && echo rosten >file && git commit -s -m den file && @@ -185,8 +185,8 @@ test_expect_success 'submodule fast-export | fast-import' ' ' -export GIT_AUTHOR_NAME='A U Thor' -export GIT_COMMITTER_NAME='C O Mitter' +GIT_AUTHOR_NAME='A U Thor'; export GIT_AUTHOR_NAME +GIT_COMMITTER_NAME='C O Mitter'; export GIT_COMMITTER_NAME test_expect_success 'setup copies' ' diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index c1850d2923..6a37f71d11 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -424,7 +424,7 @@ cd "$WORKDIR" test_expect_success 'cvs update (-p)' ' touch really-empty && echo Line 1 > no-lf && - echo -n Line 2 >> no-lf && + printf "Line 2" >> no-lf && git add really-empty no-lf && git commit -q -m "Update -p test" && git push gitcvs.git >/dev/null && diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh index d8f278ffee..6ed10d0933 100755 --- a/t/t9500-gitweb-standalone-no-errors.sh +++ b/t/t9500-gitweb-standalone-no-errors.sh @@ -25,9 +25,9 @@ our \$site_name = "[localhost]"; our \$site_header = ""; our \$site_footer = ""; our \$home_text = "indextext.html"; -our @stylesheets = ("file:///$safe_pwd/../../gitweb/gitweb.css"); -our \$logo = "file:///$safe_pwd/../../gitweb/git-logo.png"; -our \$favicon = "file:///$safe_pwd/../../gitweb/git-favicon.png"; +our @stylesheets = ("file:///$TEST_DIRECTORY/../gitweb/gitweb.css"); +our \$logo = "file:///$TEST_DIRECTORY/../gitweb/git-logo.png"; +our \$favicon = "file:///$TEST_DIRECTORY/../gitweb/git-favicon.png"; our \$projects_list = ""; our \$export_ok = ""; our \$strict_export = ""; @@ -43,9 +43,11 @@ gitweb_run () { GATEWAY_INTERFACE="CGI/1.1" HTTP_ACCEPT="*/*" REQUEST_METHOD="GET" + SCRIPT_NAME="$TEST_DIRECTORY/../gitweb/gitweb.perl" QUERY_STRING=""$1"" PATH_INFO=""$2"" - export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD QUERY_STRING PATH_INFO + export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD \ + SCRIPT_NAME QUERY_STRING PATH_INFO GITWEB_CONFIG=$(pwd)/gitweb_config.perl export GITWEB_CONFIG @@ -54,9 +56,9 @@ gitweb_run () { # 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" \ + perl -- "$SCRIPT_NAME" \ >/dev/null 2>gitweb.log && - if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi + if grep "^[[]" gitweb.log >/dev/null 2>&1; then false; else true; fi # gitweb.log is left for debugging } @@ -574,20 +576,20 @@ test_debug 'cat gitweb.log' test_expect_success \ 'encode(commit): utf8' \ - '. ../t3901-utf8.txt && + '. "$TEST_DIRECTORY"/t3901-utf8.txt && echo "UTF-8" >> file && git add file && - git commit -F ../t3900/1-UTF-8.txt && + git commit -F "$TEST_DIRECTORY"/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 && + '. "$TEST_DIRECTORY"/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 commit -F "$TEST_DIRECTORY"/t3900/ISO-8859-1.txt && git config --unset i18n.commitencoding && gitweb_run "p=.git;a=commit"' test_debug 'cat gitweb.log' @@ -660,6 +662,11 @@ cat >>gitweb_config.perl <<EOF EOF test_expect_success \ + 'config override: tree view, features not overridden in repo config' \ + 'gitweb_run "p=.git;a=tree"' +test_debug 'cat gitweb.log' + +test_expect_success \ 'config override: tree view, features disabled in repo config' \ 'git config gitweb.blame no && git config gitweb.snapshot none && @@ -667,10 +674,31 @@ test_expect_success \ test_debug 'cat gitweb.log' test_expect_success \ - 'config override: tree view, features enabled in repo config' \ + 'config override: tree view, features enabled in repo config (1)' \ 'git config gitweb.blame yes && git config gitweb.snapshot "zip,tgz, tbz2" && gitweb_run "p=.git;a=tree"' test_debug 'cat gitweb.log' +cat >.git/config <<\EOF +# testing noval and alternate separator +[gitweb] + blame + snapshot = zip tgz +EOF +test_expect_success \ + 'config override: tree view, features enabled in repo config (2)' \ + 'gitweb_run "p=.git;a=tree"' +test_debug 'cat gitweb.log' + +# ---------------------------------------------------------------------- +# non-ASCII in README.html + +test_expect_success \ + 'README.html with non-ASCII characters (utf-8)' \ + 'echo "<b>UTF-8 example:</b><br />" > .git/README.html && + cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >> .git/README.html && + gitweb_run "p=.git;a=summary"' +test_debug 'cat gitweb.log' + test_done diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh index 0d7786a8c7..d2379e7f62 100755 --- a/t/t9600-cvsimport.sh +++ b/t/t9600-cvsimport.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-cvsimport basic tests' +test_description='git cvsimport basic tests' . ./test-lib.sh CVSROOT=$(pwd)/cvsroot diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh index 9706ee5773..b81d5dfc34 100755 --- a/t/t9700-perl-git.sh +++ b/t/t9700-perl-git.sh @@ -27,18 +27,18 @@ test_expect_success \ echo "changed file 1" > file1 && git commit -a -m "second commit" && - git-config --add color.test.slot1 green && - git-config --add test.string value && - git-config --add test.dupstring value1 && - git-config --add test.dupstring value2 && - git-config --add test.booltrue true && - git-config --add test.boolfalse no && - git-config --add test.boolother other && - git-config --add test.int 2k + git config --add color.test.slot1 green && + git config --add test.string value && + git config --add test.dupstring value1 && + git config --add test.dupstring value2 && + git config --add test.booltrue true && + git config --add test.boolfalse no && + git config --add test.boolother other && + git config --add test.int 2k ' test_external_without_stderr \ 'Perl API' \ - perl ../t9700/test.pl + perl "$TEST_DIRECTORY"/t9700/test.pl test_done diff --git a/t/t9700/test.pl b/t/t9700/test.pl index 504f95a47d..697daf3ffd 100755 --- a/t/t9700/test.pl +++ b/t/t9700/test.pl @@ -13,10 +13,7 @@ use File::Basename; BEGIN { use_ok('Git') } # set up -our $repo_dir = "trash directory"; our $abs_repo_dir = Cwd->cwd; -die "this must be run by calling the t/t97* shell script(s)\n" - if basename(Cwd->cwd) ne $repo_dir; ok(our $r = Git->repository(Directory => "."), "open repository"); # config diff --git a/t/test-lib.sh b/t/test-lib.sh index 689ac2f4b4..59d82d25e9 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -82,7 +82,7 @@ do -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate) immediate=t; shift ;; -l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests) - export GIT_TEST_LONG=t; shift ;; + GIT_TEST_LONG=t; export GIT_TEST_LONG; shift ;; -h|--h|--he|--hel|--help) help=t; shift ;; -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) @@ -127,7 +127,7 @@ fi error () { say_color error "error: $*" - trap - exit + trap - EXIT exit 1 } @@ -163,7 +163,7 @@ die () { exit 1 } -trap 'die' exit +trap 'die' EXIT # The semantics of the editor variables are that of invoking # sh -c "$EDITOR \"$@\"" files ... @@ -193,6 +193,31 @@ test_tick () { export GIT_COMMITTER_DATE GIT_AUTHOR_DATE } +# Call test_commit with the arguments "<message> [<file> [<contents>]]" +# +# This will commit a file with the given contents and the given commit +# message. It will also add a tag with <message> as name. +# +# Both <file> and <contents> default to <message>. + +test_commit () { + file=${2:-"$1.t"} + echo "${3-$1}" > "$file" && + git add "$file" && + test_tick && + git commit -m "$1" && + git tag "$1" +} + +# Call test_merge with the arguments "<message> <commit>", where <commit> +# can be a tag pointing to the commit-to-merge. + +test_merge () { + test_tick && + git merge -m "$1" "$2" && + git tag "$1" +} + # You are not expected to call test_ok_ and test_failure_ directly, use # the text_expect_* functions instead. @@ -208,7 +233,7 @@ test_failure_ () { say_color error "FAIL $test_count: $1" shift echo "$@" | sed -e 's/^/ /' - test "$immediate" = "" || { trap - exit; exit 1; } + test "$immediate" = "" || { trap - EXIT; exit 1; } } test_known_broken_ok_ () { @@ -407,7 +432,7 @@ test_create_repo () { error "bug in the test script: not 1 parameter to test-create-repo" owd=`pwd` repo="$1" - mkdir "$repo" + mkdir -p "$repo" cd "$repo" || error "Cannot setup test environment" "$GIT_EXEC_PATH/git" init "--template=$GIT_EXEC_PATH/templates/blt/" >&3 2>&4 || error "cannot run git init -- have you built things yet?" @@ -416,7 +441,7 @@ test_create_repo () { } test_done () { - trap - exit + trap - EXIT test_results_dir="$TEST_DIRECTORY/test-results" mkdir -p "$test_results_dir" test_results_path="$test_results_dir/${0%-*}-$$" @@ -441,15 +466,12 @@ test_done () { fi case "$test_failure" in 0) - # We could: - # cd .. && rm -fr 'trash directory' - # but that means we forbid any tests that use their own - # subdirectory from calling test_done without coming back - # to where they started from. - # The Makefile provided will clean this test area so - # we will leave things as they are. - say_color pass "passed all $msg" + + test -d "$remove_trash" && + cd "$(dirname "$remove_trash")" && + rm -rf "$(basename "$remove_trash")" + exit 0 ;; *) @@ -466,7 +488,6 @@ PATH=$TEST_DIRECTORY/..:$PATH GIT_EXEC_PATH=$(pwd)/.. GIT_TEMPLATE_DIR=$(pwd)/../templates/blt unset GIT_CONFIG -unset GIT_CONFIG_LOCAL GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_NOGLOBAL=1 export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL @@ -486,9 +507,10 @@ fi . ../GIT-BUILD-OPTIONS # Test repository -test="trash directory" +test="trash directory.$(basename "$0" .sh)" +test ! -z "$debug" || remove_trash="$TEST_DIRECTORY/$test" rm -fr "$test" || { - trap - exit + trap - EXIT echo >&5 "FATAL: Cannot prepare test area" exit 1 } |