From: Matthias Lederhofer <matled@gmx.net>
To: Git Mailing List <git@vger.kernel.org>,
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Subject: [PATCH 7/7] test GIT_WORK_TREE
Date: Sun, 3 Jun 2007 16:49:25 +0200 [thread overview]
Message-ID: <20070603144925.GG20061@moooo.ath.cx> (raw)
In-Reply-To: <20070603144401.GA9518@moooo.ath.cx>
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
t/t1501-worktree.sh | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 119 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..d9d9e4a
--- /dev/null
+++ b/t/t1501-worktree.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+test_description='test separate work tree'
+. ./test-lib.sh
+
+test_rev_parse() {
+ name=$1
+ shift
+
+ test_expect_success "$name: is-bare-repository" \
+ "test '$1' = \"\$(git rev-parse --is-bare-repository)\""
+ shift
+ [ $# -eq 0 ] && return
+
+ test_expect_success "$name: is-inside-git-dir" \
+ "test '$1' = \"\$(git rev-parse --is-inside-git-dir)\""
+ shift
+ [ $# -eq 0 ] && return
+
+ test_expect_success "$name: is-inside-work-tree" \
+ "test '$1' = \"\$(git rev-parse --is-inside-work-tree)\""
+ shift
+ [ $# -eq 0 ] && return
+
+ test_expect_success "$name: prefix" \
+ "test '$1' = \"\$(git rev-parse --show-prefix)\""
+ shift
+ [ $# -eq 0 ] && return
+}
+
+mkdir -p work/sub/dir || exit 1
+
+say "fallback work tree (name ending in .git)"
+cd work || exit 1
+export GIT_DIR=../.git
+export GIT_CONFIG=$GIT_DIR/config
+unset GIT_WORK_TREE
+git config core.bare true
+test_rev_parse 'core.bare = true' true false false
+git config --unset core.bare
+test_rev_parse 'core.bare undefined' false false true
+git config core.bare false
+test_rev_parse 'core.bare = false' false false true ''
+cd .. || exit 1
+
+mv .git repo.git || exit 1
+
+say "fallback work tree (name ending in repo.git)"
+cd work || exit 1
+export GIT_DIR=../repo.git
+export GIT_CONFIG=$GIT_DIR/config
+unset GIT_WORK_TREE
+git config core.bare true
+test_rev_parse 'core.bare = true' true false false
+git config --unset core.bare
+test_rev_parse 'core.bare undefined' true false false
+git config core.bare false
+test_rev_parse 'core.bare = false' false false true ''
+cd .. || exit 1
+
+say "core.worktree = relative path"
+export GIT_DIR=repo.git
+export GIT_CONFIG=$GIT_DIR/config
+unset GIT_WORK_TREE
+git config core.worktree ../work
+test_rev_parse 'outside' false false false
+cd work || exit 1
+export GIT_DIR=../repo.git
+export GIT_CONFIG=$GIT_DIR/config
+test_rev_parse 'inside' false false true ''
+cd sub/dir || exit 1
+export GIT_DIR=../../../repo.git
+export GIT_CONFIG=$GIT_DIR/config
+test_rev_parse 'subdirectory' false false true sub/dir/
+cd ../../.. || exit 1
+
+say "core.worktree = absolute path"
+export GIT_DIR=$(pwd)/repo.git
+export GIT_CONFIG=$GIT_DIR/config
+git config core.worktree "$(pwd)/work"
+test_rev_parse 'outside' false false false
+cd work || exit 1
+test_rev_parse 'inside' false false true ''
+cd sub/dir || exit 1
+test_rev_parse 'subdirectory' false false true sub/dir/
+cd ../../.. || exit 1
+
+say "GIT_WORK_TREE=relative path (override core.worktree)"
+export GIT_DIR=$(pwd)/repo.git
+export GIT_CONFIG=$GIT_DIR/config
+git config core.worktree non-existent
+export GIT_WORK_TREE=work
+test_rev_parse 'outside' false false false
+cd work || exit 1
+export GIT_WORK_TREE=.
+test_rev_parse 'inside' false false true ''
+cd sub/dir || exit 1
+export GIT_WORK_TREE=../..
+test_rev_parse 'subdirectory' false false true sub/dir/
+cd ../../.. || exit 1
+
+mv work repo.git/work
+
+say "GIT_WORK_TREE=absolute path, work tree below git dir"
+export GIT_DIR=$(pwd)/repo.git
+export GIT_CONFIG=$GIT_DIR/config
+export GIT_WORK_TREE=$(pwd)/repo.git/work
+test_rev_parse 'outside' false false false
+cd repo.git || exit 1
+test_rev_parse 'in repo.git' false true false
+cd objects || exit 1
+test_rev_parse 'in repo.git/objects' false true false
+cd ../work || exit 1
+test_rev_parse 'in repo.git/work' false false true ''
+cd sub/dir || exit 1
+test_rev_parse 'in repo.git/sub/dir' false false true sub/dir/
+cd ../../../.. || exit 1
+
+test_done
--
1.5.0.3
next prev parent reply other threads:[~2007-06-03 14:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-03 14:44 [RFC] GIT_WORK_TREE Matthias Lederhofer
2007-06-03 14:46 ` [PATCH 1/7] rev-parse: document --is-inside-git-dir Matthias Lederhofer
2007-06-03 14:46 ` [PATCH 2/7] rev-parse: introduce --is-bare-repository Matthias Lederhofer
2007-06-03 14:47 ` [PATCH 3/7] test git rev-parse Matthias Lederhofer
2007-06-06 7:01 ` [PATCH 3/7 (amend)] " Matthias Lederhofer
2007-06-03 14:47 ` [PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree Matthias Lederhofer
2007-06-05 7:52 ` Junio C Hamano
2007-06-05 16:49 ` [PATCH] filter-branch: always export GIT_DIR if it is set Matthias Lederhofer
2007-06-05 17:27 ` Johannes Schindelin
2007-06-05 20:39 ` Junio C Hamano
2007-06-06 7:16 ` [PATCH (amend)] " Matthias Lederhofer
2007-06-06 7:10 ` [PATCH 4/7 (amend)] introduce GIT_WORK_TREE to specify the work tree Matthias Lederhofer
2007-06-03 14:48 ` [RFC] GIT_WORK_TREE Matthias Lederhofer
2007-06-03 14:51 ` Matthias Lederhofer
2007-06-03 14:48 ` [PATCH 6/7] extend rev-parse test for --is-inside-work-tree Matthias Lederhofer
2007-06-06 7:13 ` [PATCH 6/7 (amend)] " Matthias Lederhofer
2007-06-03 14:49 ` Matthias Lederhofer [this message]
2007-06-06 7:14 ` [PATCH 7/7 (amend)] test GIT_WORK_TREE Matthias Lederhofer
2007-06-03 16:02 ` [RFC] GIT_WORK_TREE Sergio
2007-06-03 19:32 ` Matthias Lederhofer
2007-06-03 21:34 ` Sergio
2007-06-06 21:29 ` [PATCH] setup_git_directory: fix segfault if repository is found in cwd Matthias Lederhofer
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=20070603144925.GG20061@moooo.ath.cx \
--to=matled@gmx.net \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/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).