From 4fdf71be1ca3a817851a14f91b75e7d30f885a48 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 14 May 2010 09:31:37 +0000 Subject: tests: use "test_cmp", not "diff", when verifying the result In tests, call test_cmp rather than raw diff where possible (i.e. if the output does not go to a pipe), to allow the use of, say, 'cmp' when the default 'diff -u' is not compatible with a vendor diff. When that is not possible, use $DIFF, as set in GIT-BUILD-OPTIONS. Signed-off-by: Gary V. Vaughan Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t3200-branch.sh') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index e0b760513c..8818d0de68 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -43,7 +43,7 @@ test_expect_success \ git branch -l d/e/f && test -f .git/refs/heads/d/e/f && test -f .git/logs/refs/heads/d/e/f && - diff expect .git/logs/refs/heads/d/e/f' + test_cmp expect .git/logs/refs/heads/d/e/f' test_expect_success \ 'git branch -d d/e/f should delete a branch and a log' \ @@ -222,7 +222,7 @@ test_expect_success \ git checkout -b g/h/i -l master && test -f .git/refs/heads/g/h/i && test -f .git/logs/refs/heads/g/h/i && - diff expect .git/logs/refs/heads/g/h/i' + test_cmp expect .git/logs/refs/heads/g/h/i' test_expect_success 'avoid ambiguous track' ' git config branch.autosetupmerge true && -- cgit v1.2.3 From b2099957752071fec70502c81206364ac986073a Mon Sep 17 00:00:00 2001 From: Erick Mattos Date: Fri, 21 May 2010 21:28:38 -0300 Subject: t3200: test -l with core.logAllRefUpdates options By default reflogs are always created for new local branches by "checkout -b". But by setting core.logAllRefUpdates to false this will not be true anymore. In that case you only create the reflogs when you use -l switch with "checkout -b". Added missing tests to check expected behaviors. Signed-off-by: Erick Mattos Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 't/t3200-branch.sh') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index e0b760513c..9d2c06ea69 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -224,6 +224,30 @@ test_expect_success \ test -f .git/logs/refs/heads/g/h/i && diff expect .git/logs/refs/heads/g/h/i' +test_expect_success 'checkout -b makes reflog by default' ' + git checkout master && + git config --unset core.logAllRefUpdates && + git checkout -b alpha && + test -f .git/logs/refs/heads/alpha && + PAGER= git reflog show alpha +' + +test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' ' + git checkout master && + git config core.logAllRefUpdates false && + git checkout -b beta && + ! test -f .git/logs/refs/heads/beta && + test_must_fail PAGER= git reflog show beta +' + +test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' ' + git checkout master && + git checkout -lb gamma && + git config --unset core.logAllRefUpdates && + test -f .git/logs/refs/heads/gamma && + PAGER= git reflog show gamma +' + test_expect_success 'avoid ambiguous track' ' git config branch.autosetupmerge true && git config remote.ambi1.url lalala && -- cgit v1.2.3 From b1edaf669d483e983f1849ce804baa178387e9a9 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Tue, 20 Jul 2010 16:55:31 -0500 Subject: t/: work around one-shot variable assignment with test_must_fail See e2007832552ccea9befed9003580c494f09e666e Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 't/t3200-branch.sh') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 859b99abf1..bf7747dc33 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -237,7 +237,11 @@ test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates git config core.logAllRefUpdates false && git checkout -b beta && ! test -f .git/logs/refs/heads/beta && - test_must_fail PAGER= git reflog show beta + ( + PAGER= && + export PAGER && + test_must_fail git reflog show beta + ) ' test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' ' -- cgit v1.2.3 From 6e6842e36f8c6c12ae0ddd7db98cd900b25bb8dc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 21 Jul 2010 12:47:48 -0700 Subject: tests: correct "does reflog exist?" tests These two tests weren't about how "git reflog show " exits when there is no reflog, but were about "checkout" and "branch" create or not create reflog when creating a new . Update the tests to check what we are interested in, using "git rev-parse --verify". Also lose tests based on "test -f .git/logs/refs/heads/" from nearby, to avoid exposing this particular implementation detail unnecessarily. Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 't/t3200-branch.sh') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index bf7747dc33..f54a533456 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -228,28 +228,21 @@ test_expect_success 'checkout -b makes reflog by default' ' git checkout master && git config --unset core.logAllRefUpdates && git checkout -b alpha && - test -f .git/logs/refs/heads/alpha && - PAGER= git reflog show alpha + git rev-parse --verify alpha@{0} ' test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' ' git checkout master && git config core.logAllRefUpdates false && git checkout -b beta && - ! test -f .git/logs/refs/heads/beta && - ( - PAGER= && - export PAGER && - test_must_fail git reflog show beta - ) + test_must_fail git rev-parse --verify beta@{0} ' test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' ' git checkout master && git checkout -lb gamma && git config --unset core.logAllRefUpdates && - test -f .git/logs/refs/heads/gamma && - PAGER= git reflog show gamma + git rev-parse --verify gamma@{0} ' test_expect_success 'avoid ambiguous track' ' -- cgit v1.2.3 From 1dacfbcf13693dad508095735a95bc4b12382c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 22 Oct 2010 01:42:58 -0500 Subject: branch -h: show usage even in an invalid repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no need for "git branch -h" to try to access a repository. In the spirit of v1.6.6-rc0~34^2~3 (Let 'git -h' show usage without a git dir, 2009-11-09). This brings git one step closer to passing the following (automatically verifiable) test: Before any repository access (aside from git_config()), a function from the setup_git_directory_* family has been run and thus one step closer to being able to use an automatic repository access checker. [jn: simplified; new commit message, test] Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't/t3200-branch.sh') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index f54a533456..f308235f5d 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -26,6 +26,17 @@ test_expect_success \ ! test -f .git/refs/heads/--help ' +test_expect_success 'branch -h in broken repository' ' + mkdir broken && + ( + cd broken && + git init && + >.git/refs/heads/master && + test_expect_code 129 git branch -h >usage 2>&1 + ) && + grep "[Uu]sage" broken/usage +' + test_expect_success \ 'git branch abc should create a branch' \ 'git branch abc && test -f .git/refs/heads/abc' -- cgit v1.2.3 From 21b5b1e8dc9bed2b518defe29d69ebc27da4b68f Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Thu, 17 Feb 2011 00:12:20 +0100 Subject: branch/checkout --track: Ensure that upstream branch is indeed a branch When creating a new branch using the --track option, we must make sure that we don't try to set an upstream that does not make sense to follow (using 'git pull') or update (using 'git push'). The current code checks against using HEAD as upstream (since tracking a symref doesn't make sense). However, tracking a tag doesn't make sense either. Indeed, tracking _any_ ref that is not a (local or remote) branch doesn't make sense, and should be disallowed. This patch achieves this by checking that the ref we're trying to --track resides within refs/heads/* or refs/remotes/*. This new check replaces the previous check against HEAD. A couple of testcases are also added, verifying that we cannot create branches with tags as upstreams. Finally, some selftests relying on using a non-branch as an upstream have been reworked or removed: - t6040: Reverse the meaning of two tests that depend on the ability to use (lightweight and annotated) tags as upstreams. These two tests were originally added in commits 1be570f and 57ffc5f, and this patch reverts the intention of those two commits. - t7201: Remove part of a test (introduced in 9188ed8) relying on a non-branch as upstream. Signed-off-by: Johan Herland Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't/t3200-branch.sh') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index f54a533456..55af032f2e 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -212,6 +212,11 @@ test_expect_success \ 'branch from non-branch HEAD w/--track causes failure' \ 'test_must_fail git branch --track my10 HEAD^' +test_expect_success \ + 'branch from tag w/--track causes failure' \ + 'git tag foobar && + test_must_fail git branch --track my11 foobar' + # Keep this test last, as it changes the current branch cat >expect < 1117150200 +0000 branch: Created from master @@ -477,6 +482,15 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' ' test "z$(git config branch.myr20.rebase)" = z ' +test_expect_success 'autosetuprebase always on detached HEAD' ' + git config branch.autosetupmerge always && + test_when_finished git checkout master && + git checkout HEAD^0 && + git branch my11 && + test -z "$(git config branch.my11.remote)" && + test -z "$(git config branch.my11.merge)" +' + test_expect_success 'detect misconfigured autosetuprebase (bad value)' ' git config branch.autosetuprebase garbage && test_must_fail git branch -- cgit v1.2.3 From 8af42b0f7773bff2529f6c8990bb3d872b8270d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 22 Feb 2011 23:41:36 +0000 Subject: i18n: git-branch "Deleted branch [...]" message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gettextize the "Deleted %sbranch %s (was %s).\n" messages. test in t3200-branch.sh explicitly checked for this message. Change it to skip under GETTEXT_POISON=YesPlease. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t3200-branch.sh') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index f308235f5d..940d7ae1fe 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -203,7 +203,7 @@ test_expect_success 'test deleting branch deletes branch config' \ test -z "$(git config branch.my7.remote)" && test -z "$(git config branch.my7.merge)"' -test_expect_success 'test deleting branch without config' \ +test_expect_success C_LOCALE_OUTPUT 'test deleting branch without config' \ 'git branch my7 s && sha1=$(git rev-parse my7 | cut -c 1-7) && test "$(git branch -d my7 2>&1)" = "Deleted branch my7 (was $sha1)."' -- cgit v1.2.3 From f2c8c8007c43b75e6a461137364a3ec65108afbc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 12 Apr 2011 16:20:32 -0700 Subject: i18n: use test_i18ngrep in t2020, t2204, t3030, and t3200 Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 't/t3200-branch.sh') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 286a2a6869..0ce95c04e5 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -203,10 +203,12 @@ test_expect_success 'test deleting branch deletes branch config' \ test -z "$(git config branch.my7.remote)" && test -z "$(git config branch.my7.merge)"' -test_expect_success C_LOCALE_OUTPUT 'test deleting branch without config' \ +test_expect_success 'test deleting branch without config' \ 'git branch my7 s && sha1=$(git rev-parse my7 | cut -c 1-7) && - test "$(git branch -d my7 2>&1)" = "Deleted branch my7 (was $sha1)."' + echo "Deleted branch my7 (was $sha1)." >expect && + git branch -d my7 >actual 2>&1 && + test_i18ncmp expect actual' test_expect_success 'test --track without .fetch entries' \ 'git branch --track my8 && -- cgit v1.2.3 From 3749fde561ad495dea74b0d3a13bba571068396d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 23 Apr 2011 22:34:13 -0700 Subject: test: use $_z40 from test-lib There is no need to duplicate the definition of $_z40 and $_x40 that test-lib.sh supplies the test scripts. Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t3200-branch.sh') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index f54a533456..4c4cff1963 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -35,7 +35,7 @@ test_expect_success \ 'git branch a/b/c && test -f .git/refs/heads/a/b/c' cat >expect < 1117150200 +0000 branch: Created from master +$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master EOF test_expect_success \ 'git branch -l d/e/f should create a branch and a log' \ @@ -214,7 +214,7 @@ test_expect_success \ # Keep this test last, as it changes the current branch cat >expect < 1117150200 +0000 branch: Created from master +$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master EOF test_expect_success \ 'git checkout -b g/h/i -l should create a branch and a log' \ -- cgit v1.2.3