diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/t3406-rebase-message.sh | 5 | ||||
-rwxr-xr-x | t/t3505-cherry-pick-empty.sh | 30 | ||||
-rwxr-xr-x | t/t3510-cherry-pick-sequence.sh | 2 | ||||
-rwxr-xr-x | t/t4012-diff-binary.sh | 12 | ||||
-rwxr-xr-x | t/t5701-clone-local.sh | 83 | ||||
-rwxr-xr-x | t/t6200-fmt-merge-msg.sh | 36 | ||||
-rwxr-xr-x | t/t9501-gitweb-standalone-http-status.sh | 21 | ||||
-rwxr-xr-x | t/t9801-git-p4-branch.sh | 110 | ||||
-rwxr-xr-x | t/t9902-completion.sh | 2 |
9 files changed, 218 insertions, 83 deletions
diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index fe5f936988..6898377910 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -62,4 +62,9 @@ test_expect_success 'rebase -n overrides config rebase.stat config' ' ! grep "^ fileX | *1 +$" diffstat.txt ' +test_expect_success 'rebase --onto outputs the invalid ref' ' + test_must_fail git rebase --onto invalid-ref HEAD HEAD 2>err && + grep "invalid-ref" err +' + test_done diff --git a/t/t3505-cherry-pick-empty.sh b/t/t3505-cherry-pick-empty.sh index 92f00cdf84..5a1340cee6 100755 --- a/t/t3505-cherry-pick-empty.sh +++ b/t/t3505-cherry-pick-empty.sh @@ -71,4 +71,34 @@ test_expect_success 'cherry pick with --keep-redundant-commits' ' git cherry-pick --keep-redundant-commits HEAD^ ' +test_expect_success 'cherry-pick a commit that becomes no-op (prep)' ' + git checkout master && + git branch fork && + echo foo >file2 && + git add file2 && + test_tick && + git commit -m "add file2 on master" && + + git checkout fork && + echo foo >file2 && + git add file2 && + test_tick && + git commit -m "add file2 on the side" +' + +test_expect_success 'cherry-pick a no-op without --keep-redundant' ' + git reset --hard && + git checkout fork^0 && + test_must_fail git cherry-pick master +' + +test_expect_success 'cherry-pick a no-op with --keep-redundant' ' + git reset --hard && + git checkout fork^0 && + git cherry-pick --keep-redundant-commits master && + git show -s --format='%s' >actual && + echo "add file2 on master" >expect && + test_cmp expect actual +' + test_done diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index 97f3710700..f4e6450d6a 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -31,7 +31,7 @@ test_cmp_rev () { } test_expect_success setup ' - git config advice.detachedhead false + git config advice.detachedhead false && echo unrelated >unrelated && git add unrelated && test_commit initial foo a && diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh index 8b4e80de96..6cebb3951b 100755 --- a/t/t4012-diff-binary.sh +++ b/t/t4012-diff-binary.sh @@ -36,6 +36,18 @@ test_expect_success '"apply --stat" output for binary file change' ' test_i18ncmp expected current ' +test_expect_success 'diff --shortstat output for binary file change' ' + echo " 4 files changed, 2 insertions(+), 2 deletions(-)" >expected && + git diff --shortstat >current && + test_i18ncmp expected current +' + +test_expect_success 'diff --shortstat output for binary file change only' ' + echo " 1 file changed, 0 insertions(+), 0 deletions(-)" >expected && + git diff --shortstat -- b >current && + test_i18ncmp expected current +' + test_expect_success 'apply --numstat notices binary file change' ' git diff >diff && git apply --numstat <diff >current && diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh index 6972258b27..7ff6e0e16c 100755 --- a/t/t5701-clone-local.sh +++ b/t/t5701-clone-local.sh @@ -3,7 +3,10 @@ test_description='test local clone' . ./test-lib.sh -D=`pwd` +repo_is_hardlinked() { + find "$1/objects" -type f -links 1 >output && + test_line_count = 0 output +} test_expect_success 'preparing origin repository' ' : >file && git add . && git commit -m1 && @@ -19,105 +22,72 @@ test_expect_success 'preparing origin repository' ' ' test_expect_success 'local clone without .git suffix' ' - cd "$D" && git clone -l -s a b && - cd b && + (cd b && test "$(GIT_CONFIG=.git/config git config --bool core.bare)" = false && - git fetch + git fetch) ' test_expect_success 'local clone with .git suffix' ' - cd "$D" && git clone -l -s a.git c && - cd c && - git fetch + (cd c && git fetch) ' test_expect_success 'local clone from x' ' - cd "$D" && git clone -l -s x y && - cd y && - git fetch + (cd y && git fetch) ' test_expect_success 'local clone from x.git that does not exist' ' - cd "$D" && - if git clone -l -s x.git z - then - echo "Oops, should have failed" - false - else - echo happy - fi + test_must_fail git clone -l -s x.git z ' test_expect_success 'With -no-hardlinks, local will make a copy' ' - cd "$D" && git clone --bare --no-hardlinks x w && - cd w && - linked=$(find objects -type f ! -links 1 | wc -l) && - test 0 = $linked + ! repo_is_hardlinked w ' test_expect_success 'Even without -l, local will make a hardlink' ' - cd "$D" && rm -fr w && git clone -l --bare x w && - cd w && - copied=$(find objects -type f -links 1 | wc -l) && - test 0 = $copied + repo_is_hardlinked w ' test_expect_success 'local clone of repo with nonexistent ref in HEAD' ' - cd "$D" && echo "ref: refs/heads/nonexistent" > a.git/HEAD && git clone a d && - cd d && + (cd d && git fetch && - test ! -e .git/refs/remotes/origin/HEAD' + test ! -e .git/refs/remotes/origin/HEAD) +' test_expect_success 'bundle clone without .bundle suffix' ' - cd "$D" && git clone dir/b3 && - cd b3 && - git fetch + (cd b3 && git fetch) ' test_expect_success 'bundle clone with .bundle suffix' ' - cd "$D" && git clone b1.bundle && - cd b1 && - git fetch + (cd b1 && git fetch) ' test_expect_success 'bundle clone from b4' ' - cd "$D" && git clone b4 bdl && - cd bdl && - git fetch + (cd bdl && git fetch) ' test_expect_success 'bundle clone from b4.bundle that does not exist' ' - cd "$D" && - if git clone b4.bundle bb - then - echo "Oops, should have failed" - false - else - echo happy - fi + test_must_fail git clone b4.bundle bb ' test_expect_success 'bundle clone with nonexistent HEAD' ' - cd "$D" && git clone b2.bundle b2 && - cd b2 && + (cd b2 && git fetch && - test ! -e .git/refs/heads/master + test_must_fail git rev-parse --verify refs/heads/master) ' test_expect_success 'clone empty repository' ' - cd "$D" && mkdir empty && (cd empty && git init && @@ -135,7 +105,6 @@ test_expect_success 'clone empty repository' ' ' test_expect_success 'clone empty repository, and then push should not segfault.' ' - cd "$D" && rm -fr empty/ empty-clone/ && mkdir empty && (cd empty && git init) && @@ -145,16 +114,24 @@ test_expect_success 'clone empty repository, and then push should not segfault.' ' test_expect_success 'cloning non-existent directory fails' ' - cd "$D" && rm -rf does-not-exist && test_must_fail git clone does-not-exist ' test_expect_success 'cloning non-git directory fails' ' - cd "$D" && rm -rf not-a-git-repo not-a-git-repo-clone && mkdir not-a-git-repo && test_must_fail git clone not-a-git-repo not-a-git-repo-clone ' +test_expect_success 'cloning file:// does not hardlink' ' + git clone --bare file://"$(pwd)"/a non-local && + ! repo_is_hardlinked non-local +' + +test_expect_success 'cloning a local path with --no-local does not hardlink' ' + git clone --bare --no-local a force-nonlocal && + ! repo_is_hardlinked force-nonlocal +' + test_done diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index 9b50f54cc2..992c2a0467 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -102,8 +102,8 @@ test_expect_success '[merge] summary/log configuration' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} - By Another Author (3) and A U Thor (2) - via Another Committer + # By Another Author (3) and A U Thor (2) + # Via Another Committer * left: Left #5 Left #4 @@ -149,8 +149,8 @@ test_expect_success 'merge.log=3 limits shortlog length' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} - By Another Author (3) and A U Thor (2) - via Another Committer + # By Another Author (3) and A U Thor (2) + # Via Another Committer * left: (5 commits) Left #5 Left #4 @@ -166,8 +166,8 @@ test_expect_success 'merge.log=5 shows all 5 commits' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} - By Another Author (3) and A U Thor (2) - via Another Committer + # By Another Author (3) and A U Thor (2) + # Via Another Committer * left: Left #5 Left #4 @@ -190,8 +190,8 @@ test_expect_success '--log=3 limits shortlog length' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} - By Another Author (3) and A U Thor (2) - via Another Committer + # By Another Author (3) and A U Thor (2) + # Via Another Committer * left: (5 commits) Left #5 Left #4 @@ -207,8 +207,8 @@ test_expect_success '--log=5 shows all 5 commits' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} - By Another Author (3) and A U Thor (2) - via Another Committer + # By Another Author (3) and A U Thor (2) + # Via Another Committer * left: Left #5 Left #4 @@ -238,8 +238,8 @@ test_expect_success 'fmt-merge-msg -m' ' cat >expected.log <<-EOF && Sync with left - By Another Author (3) and A U Thor (2) - via Another Committer + # By Another Author (3) and A U Thor (2) + # Via Another Committer * ${apos}left${apos} of $(pwd): Left #5 Left #4 @@ -271,8 +271,8 @@ test_expect_success 'setup: expected shortlog for two branches' ' cat >expected <<-EOF Merge branches ${apos}left${apos} and ${apos}right${apos} - By Another Author (3) and A U Thor (2) - via Another Committer + # By Another Author (3) and A U Thor (2) + # Via Another Committer * left: Left #5 Left #4 @@ -396,8 +396,8 @@ test_expect_success 'merge-msg two tags' ' Common #2 Common #1 - By Another Author (3) and A U Thor (2) - via Another Committer + # By Another Author (3) and A U Thor (2) + # Via Another Committer * tag ${apos}tag-l5${apos}: Left #5 Left #4 @@ -426,8 +426,8 @@ test_expect_success 'merge-msg tag and branch' ' Common #2 Common #1 - By Another Author (3) and A U Thor (2) - via Another Committer + # By Another Author (3) and A U Thor (2) + # Via Another Committer * left: Left #5 Left #4 diff --git a/t/t9501-gitweb-standalone-http-status.sh b/t/t9501-gitweb-standalone-http-status.sh index fa2f65f6be..ef86948d21 100755 --- a/t/t9501-gitweb-standalone-http-status.sh +++ b/t/t9501-gitweb-standalone-http-status.sh @@ -12,6 +12,13 @@ code and message.' . ./gitweb-lib.sh +# +# Gitweb only provides the functionality tested by the 'modification times' +# tests if it can access a date parser from one of these modules: +# +perl -MHTTP::Date -e 0 >/dev/null 2>&1 && test_set_prereq DATE_PARSER +perl -MTime::ParseDate -e 0 >/dev/null 2>&1 && test_set_prereq DATE_PARSER + # ---------------------------------------------------------------------- # snapshot settings @@ -115,14 +122,14 @@ test_debug 'cat gitweb.output' # ---------------------------------------------------------------------- # modification times (Last-Modified and If-Modified-Since) -test_expect_success 'modification: feed last-modified' ' +test_expect_success DATE_PARSER 'modification: feed last-modified' ' gitweb_run "p=.git;a=atom;h=master" && grep "Status: 200 OK" gitweb.headers && grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.headers ' test_debug 'cat gitweb.headers' -test_expect_success 'modification: feed if-modified-since (modified)' ' +test_expect_success DATE_PARSER 'modification: feed if-modified-since (modified)' ' export HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" && test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && gitweb_run "p=.git;a=atom;h=master" && @@ -130,7 +137,7 @@ test_expect_success 'modification: feed if-modified-since (modified)' ' ' test_debug 'cat gitweb.headers' -test_expect_success 'modification: feed if-modified-since (unmodified)' ' +test_expect_success DATE_PARSER 'modification: feed if-modified-since (unmodified)' ' export HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" && test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && gitweb_run "p=.git;a=atom;h=master" && @@ -138,14 +145,14 @@ test_expect_success 'modification: feed if-modified-since (unmodified)' ' ' test_debug 'cat gitweb.headers' -test_expect_success 'modification: snapshot last-modified' ' +test_expect_success DATE_PARSER 'modification: snapshot last-modified' ' gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && grep "Status: 200 OK" gitweb.headers && grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.headers ' test_debug 'cat gitweb.headers' -test_expect_success 'modification: snapshot if-modified-since (modified)' ' +test_expect_success DATE_PARSER 'modification: snapshot if-modified-since (modified)' ' export HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" && test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && @@ -153,7 +160,7 @@ test_expect_success 'modification: snapshot if-modified-since (modified)' ' ' test_debug 'cat gitweb.headers' -test_expect_success 'modification: snapshot if-modified-since (unmodified)' ' +test_expect_success DATE_PARSER 'modification: snapshot if-modified-since (unmodified)' ' export HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" && test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && @@ -161,7 +168,7 @@ test_expect_success 'modification: snapshot if-modified-since (unmodified)' ' ' test_debug 'cat gitweb.headers' -test_expect_success 'modification: tree snapshot' ' +test_expect_success DATE_PARSER 'modification: tree snapshot' ' ID=`git rev-parse --verify HEAD^{tree}` && export HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" && test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && diff --git a/t/t9801-git-p4-branch.sh b/t/t9801-git-p4-branch.sh index 2859256de3..99fe16b72d 100755 --- a/t/t9801-git-p4-branch.sh +++ b/t/t9801-git-p4-branch.sh @@ -218,7 +218,7 @@ test_expect_success 'git p4 clone simple branches' ' cd branch1 && p4 edit file2 && echo file2_ >>file2 && - p4 submit -d "update file2 in branch3" && + p4 submit -d "update file2 in branch1" && cd "$git" && git reset --hard p4/depot/branch1 && git p4 rebase && @@ -249,8 +249,6 @@ test_expect_success 'git p4 clone simple branches' ' # `- file2 # `- file3 test_expect_success 'git p4 add complex branches' ' - test_when_finished cleanup_git && - test_create_repo "$git" && ( cd "$cli" && changelist=$(p4 changes -m1 //depot/... | cut -d" " -f2) && @@ -306,6 +304,112 @@ test_expect_success 'git p4 clone complex branches' ' ) ' +# Move branch3/file3 to branch4/file3 in a single changelist +test_expect_success 'git p4 submit to two branches in a single changelist' ' + ( + cd "$cli" && + p4 integrate //depot/branch3/file3 //depot/branch4/file3 && + p4 delete //depot/branch3/file3 && + p4 submit -d "Move branch3/file3 to branch4/file3" + ) +' + +# Confirm that changes to two branches done in a single changelist +# are correctly imported by git p4 +test_expect_success 'git p4 sync changes to two branches in the same changelist' ' + test_when_finished cleanup_git && + test_create_repo "$git" && + ( + cd "$git" && + git config git-p4.branchList branch1:branch2 && + git config --add git-p4.branchList branch1:branch3 && + git config --add git-p4.branchList branch1:branch4 && + git config --add git-p4.branchList branch1:branch5 && + git p4 clone --dest=. --detect-branches //depot@all && + git log --all --graph --decorate --stat && + git reset --hard p4/depot/branch1 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_file file3 && + grep update file2 && + git reset --hard p4/depot/branch2 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_missing file3 && + ! grep update file2 && + git reset --hard p4/depot/branch3 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_missing file3 && + grep update file2 && + git reset --hard p4/depot/branch4 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_file file3 && + ! grep update file2 && + git reset --hard p4/depot/branch5 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_file file3 && + ! grep update file2 && + test_path_is_missing .git/git-p4-tmp + ) +' + +# Create a branch by integrating a single file +test_expect_success 'git p4 file subset branch' ' + ( + cd "$cli" && + p4 integrate //depot/branch1/file1 //depot/branch6/file1 && + p4 submit -d "Integrate file1 alone from branch1 to branch6" + ) +' + +# Check if git p4 creates a new branch containing a single file, +# instead of keeping the old files from the original branch +test_expect_failure 'git p4 clone file subset branch' ' + test_when_finished cleanup_git && + test_create_repo "$git" && + ( + cd "$git" && + git config git-p4.branchList branch1:branch2 && + git config --add git-p4.branchList branch1:branch3 && + git config --add git-p4.branchList branch1:branch4 && + git config --add git-p4.branchList branch1:branch5 && + git config --add git-p4.branchList branch1:branch6 && + git p4 clone --dest=. --detect-branches //depot@all && + git log --all --graph --decorate --stat && + git reset --hard p4/depot/branch1 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_file file3 && + grep update file2 && + git reset --hard p4/depot/branch2 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_missing file3 && + ! grep update file2 && + git reset --hard p4/depot/branch3 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_missing file3 && + grep update file2 && + git reset --hard p4/depot/branch4 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_file file3 && + ! grep update file2 && + git reset --hard p4/depot/branch5 && + test_path_is_file file1 && + test_path_is_file file2 && + test_path_is_file file3 && + ! grep update file2 && + git reset --hard p4/depot/branch6 && + test_path_is_file file1 && + test_path_is_missing file2 && + test_path_is_missing file3 + ) +' test_expect_success 'kill p4d' ' kill_p4d ' diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 9a80c60945..256e6a0b3f 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -63,7 +63,7 @@ run_completion () local _cword _words=( $1 ) (( _cword = ${#_words[@]} - 1 )) - __git_wrap_main_git && print_comp + __git_wrap__git_main && print_comp } test_completion () |