public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha•warpmail.net>
To: "Tor Arne Vestbø" <tor.arne.vestbo@nokia•com>
Cc: git@vger•kernel.org, trast@student•ethz.ch,
	Junio C Hamano <gitster@pobox•com>
Subject: Re: [PATCH] require_work_tree: Look for top-level instead of is-inside-work-tree
Date: Mon, 02 Aug 2010 16:37:51 +0200	[thread overview]
Message-ID: <4C56D83F.3050507@drmicha.warpmail.net> (raw)
In-Reply-To: <1280335624-90132-1-git-send-email-tor.arne.vestbo@nokia.com>

Tor Arne Vestbø venit, vidit, dixit 28.07.2010 18:47:
> 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."
>  }
>  

An alternative which does not change the established behavior of
require_work_tree would be changing the order of require_work_tree and
cd_to_top_level in the callers where possible along the lines of

http://mid.gmane.org/96abf622ca2cf92998ce4ed393ccaa75d95dd9a8.1279112025.git.git@drmicha.warpmail.net

which got lost somehow. (The other callers, as mentioned by Junio, would
need to be changed differently, e.g. by moving cd_to... earlier.)

Another problem I noticed back then (I was away since) was that a
relative GIT_WORK_TREE is left in place after a cd_to_top_level and
messes things up completely - it does not seem to be relative to
GIT_DIR. So, there seems to be more to fix in this area.

Cheers,
Michael

  parent reply	other threads:[~2010-08-02 14:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-28 16:47 [PATCH] require_work_tree: Look for top-level instead of is-inside-work-tree Tor Arne Vestbø
2010-07-28 23:00 ` Junio C Hamano
2010-07-30 11:04   ` Tor Arne Vestbø
2010-08-02 14:37 ` Michael J Gruber [this message]
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=4C56D83F.3050507@drmicha.warpmail.net \
    --to=git@drmicha$(echo .)warpmail.net \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=tor.arne.vestbo@nokia$(echo .)com \
    --cc=trast@student$(echo .)ethz.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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