From: Matthias Lederhofer <matled@gmx.net>
To: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: [PATCH 4/5] test GIT_WORK_TREE
Date: Sat, 17 Mar 2007 15:44:56 +0100 [thread overview]
Message-ID: <20070317144456.GD26290@moooo.ath.cx> (raw)
In-Reply-To: <20070317143452.GA21140@moooo.ath.cx>
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
t/t1501-worktree.sh | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 91 insertions(+), 0 deletions(-)
create mode 100755 t/t1501-worktree.sh
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
new file mode 100755
index 0000000..bc08994
--- /dev/null
+++ b/t/t1501-worktree.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+test_description='test GIT_WORK_TREE'
+. ./test-lib.sh
+
+export GIT_DIR=$(pwd)/repository
+export GIT_CONFIG="$GIT_DIR/config"
+top=$(pwd) || exit 1
+mv .git "$GIT_DIR" || exit 1
+mkdir -p working/tree || exit 1
+
+# test setup code and precedence of core.worktree, GIT_WORK_TREE and --work-tree
+test_expect_failure 'GIT_WORK_TREE=non-existent' \
+ 'env GIT_WORK_TREE=non-existent git rev-parse'
+test_expect_success 'GIT_WORK_TREE=working/tree' \
+ 'env GIT_WORK_TREE=working/tree git rev-parse'
+test_expect_success 'GIT_WORK_TREE=`pwd`/working/tree' \
+ 'env GIT_WORK_TREE="$(pwd)"/working/tree git rev-parse'
+
+test_expect_success '--work-tree' \
+ 'git --work-tree working/tree rev-parse'
+test_expect_success '--work-tree overrides GIT_WORK_TREE' \
+ 'env GIT_WORK_TREE=non-existent git --work-tree working/tree rev-parse'
+
+test_expect_success 'core.worktree = non-existent' \
+ 'git config core.worktree non-existent'
+test_expect_failure 'core.worktree' \
+ 'git rev-parse'
+test_expect_success 'GIT_WORK_TREE overrides core.worktree' \
+ 'env GIT_WORK_TREE=working/tree git rev-parse'
+test_expect_success '--work-tree overrides core.worktree' \
+ 'git --work-tree working/tree rev-parse'
+
+test_expect_success 'core.worktree = `pwd`/working/tree' \
+ 'git --work-tree . config core.worktree "$(pwd)"/working/tree'
+test_expect_success 'core.worktree' \
+ 'git rev-parse'
+test_expect_success 'core.worktree = ../working/tree' \
+ 'git --work-tree . config core.worktree ../working/tree'
+test_expect_success 'core.worktree' \
+ 'git rev-parse'
+
+# outside of working tree
+test_expect_success 'outside: --is-bare-repository' \
+ 'test "true" = "$(git rev-parse --is-bare-repository)"'
+
+# in toplevel working tree
+cd working/tree || exit 1
+test_expect_success 'inside: --is-bare-repository' \
+ 'test "false" = "$(git rev-parse --is-bare-repository)"'
+test_expect_success 'inside: --is-inside-git-dir' \
+ 'test "false" = "$(git rev-parse --is-inside-git-dir)"'
+test_expect_success 'inside: --show-prefix' \
+ 'test "" = "$(git rev-parse --show-prefix)"'
+test_expect_success 'inside: --show-cdup' \
+ 'test "" = "$(git rev-parse --show-cdup)"'
+
+# in subdirectory
+mkdir -p a/b || exit 1
+cd a/b || exit 1
+test_expect_success 'subdirectory: --is-bare-repository' \
+ 'test "false" = "$(git rev-parse --is-bare-repository)"'
+test_expect_success 'subdirectory: --is-inside-git-dir' \
+ 'test "false" = "$(git rev-parse --is-inside-git-dir)"'
+test_expect_success 'subdirectory: --show-prefix' \
+ 'test "a/b/" = "$(git rev-parse --show-prefix)"'
+test_expect_success 'subdirectory: --show-cdup' \
+ 'test "../../" = "$(git rev-parse --show-cdup)"'
+
+# in repository directory
+cd "$top/repository" || exit 1
+test_expect_success 'repository: --is-bare-repository' \
+ 'test "true" = "$(git rev-parse --is-bare-repository)"'
+test_expect_success 'repository: --is-inside-git-dir' \
+ 'test "true" = "$(git rev-parse --is-inside-git-dir)"'
+cd objects || exit 1
+test_expect_success 'repository/objects: --is-inside-git-dir' \
+ 'test "true" = "$(git rev-parse --is-inside-git-dir)"'
+cd .. || exit 1
+
+# worktree is subdirectory of repository
+mkdir worktree || exit 1
+cd worktree || exit 1
+test_expect_success 'core.worktree = worktree' \
+ 'git config core.worktree worktree'
+test_expect_success 'repository/worktree: --is-bare-repository' \
+ 'test "false" = "$(git rev-parse --is-bare-repository)"'
+test_expect_success 'repository/worktree: --is-inside-git-dir' \
+ 'test "false" = "$(git rev-parse --is-inside-git-dir)"'
+
+test_done
--
1.5.0.4.414.g32da9
next prev parent reply other threads:[~2007-03-17 14:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-17 1:58 [PATCH] git-init: set core.workdir when GIT_WORK_DIR is specified Matthias Lederhofer
2007-03-17 7:29 ` Junio C Hamano
2007-03-17 11:01 ` Matthias Lederhofer
2007-03-17 14:34 ` Matthias Lederhofer
2007-03-17 14:42 ` [PATCH 1/5] rev-parse: --is-bare-repository option Matthias Lederhofer
2007-03-17 14:43 ` [PATCH 2/5] test git-rev-parse Matthias Lederhofer
2007-03-27 22:07 ` [PATCH(amend)] " Matthias Lederhofer
2007-03-17 14:44 ` [PATCH 3/5] introduce GIT_WORK_TREE environment variable Matthias Lederhofer
2007-03-18 19:43 ` Matthias Lederhofer
2007-03-18 20:12 ` Matthias Lederhofer
2007-03-18 20:23 ` Matthias Lederhofer
2007-03-18 20:28 ` Junio C Hamano
2007-03-17 14:44 ` Matthias Lederhofer [this message]
2007-03-17 14:45 ` [PATCH 5/5] git-init: set core.worktree when GIT_WORK_TREE is specified Matthias Lederhofer
2007-03-18 8:47 ` [PATCH] git-init: set core.workdir when GIT_WORK_DIR " Junio C Hamano
2007-03-18 11:18 ` Matthias Lederhofer
2007-03-18 21:18 ` Matthias Lederhofer
[not found] ` <7vk5xensjn.fsf@assigned-by-dhcp.cox.net>
2007-03-19 14:24 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070317144456.GD26290@moooo.ath.cx \
--to=matled@gmx.net \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).