git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tor Arne Vestbø" <tor.arne.vestbo@nokia.com>
To: git@vger.kernel.org
Cc: trast@student.ethz.ch, "Tor Arne Vestbø" <tor.arne.vestbo@nokia.com>
Subject: [PATCH] require_work_tree: Look for top-level instead of is-inside-work-tree
Date: Wed, 28 Jul 2010 18:47:04 +0200	[thread overview]
Message-ID: <1280335624-90132-1-git-send-email-tor.arne.vestbo@nokia.com> (raw)

The documentation describes require_work_tree as guarding against
bare repositories, and that's also the way it's used from porcelain
such as git-rebase. When implemented using --is-inside-work-tree
the samantics change, causing git-rebase to fail if run from outside
GIT_WORK_TREE, even if GIT_WORK_TREE is valid.

Signed-off-by: Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
---
 git-sh-setup.sh     |    2 +-
 t/t1501-worktree.sh |    9 +++++++++
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 6131670..f8e4428 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -141,7 +141,7 @@ cd_to_toplevel () {
 }
 
 require_work_tree () {
-	test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
+	test -n "$(git rev-parse --show-toplevel 2>/dev/null)" ||
 	die "fatal: $0 cannot be used without a working tree."
 }
 
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index bd8b607..45b09e7 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -114,6 +114,15 @@ test_expect_success 'repo finds its work tree from work tree, too' '
 	 test sub/dir/tracked = "$(git ls-files)")
 '
 
+test_expect_success 'require_work_tree finds work tree' '
+	(cd repo.git/work &&
+	. "$(git --exec-path)"/git-sh-setup &&
+	cd .. &&
+	require_work_tree &&
+	cd .. &&
+	require_work_tree)
+'
+
 test_expect_success '_gently() groks relative GIT_DIR & GIT_WORK_TREE' '
 	(cd repo.git/work/sub/dir &&
 	GIT_DIR=../../.. GIT_WORK_TREE=../.. GIT_PAGER= \
-- 
1.7.2.19.g48995

             reply	other threads:[~2010-07-28 16:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-28 16:47 Tor Arne Vestbø [this message]
2010-07-28 23:00 ` [PATCH] require_work_tree: Look for top-level instead of is-inside-work-tree Junio C Hamano
2010-07-30 11:04   ` Tor Arne Vestbø
2010-08-02 14:37 ` Michael J Gruber
2010-08-02 17:46   ` Junio C Hamano
2010-08-03  7:57     ` Michael J Gruber

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=1280335624-90132-1-git-send-email-tor.arne.vestbo@nokia.com \
    --to=tor.arne.vestbo@nokia.com \
    --cc=git@vger.kernel.org \
    --cc=trast@student.ethz.ch \
    /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).