All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Tor Arne Vestbø" <tor.arne.vestbo@nokia.com>,
	git@vger.kernel.org, trast@student.ethz.ch
Subject: Re: [PATCH] require_work_tree: Look for top-level instead of is-inside-work-tree
Date: Tue, 03 Aug 2010 09:57:35 +0200	[thread overview]
Message-ID: <4C57CBEF.2070102@drmicha.warpmail.net> (raw)
In-Reply-To: <7v8w4onc0l.fsf@alter.siamese.dyndns.org>

Junio C Hamano venit, vidit, dixit 02.08.2010 19:46:
> Michael J Gruber <git@drmicha.warpmail.net> writes:
> 
>> 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.)
> 
> Doesn't it sound stupid to "cd-to-toplevel" and then "require-work-tree"?

It sounds outright silly, agreed.
Though, unless you know the implementation, "cd_to_toplevel" may succeed
cd'ing to what "rev-parse --show-toplevel" returns without
require_work_tree being happy.

But don't we try to preserve existing behavior unless it's a bug? We
certainly have a mismatch of behavior and documentation here. The
question is whether we want to break anyone who relied on
"require_work_tree" dieing when cwd is not within the work-tree.

> 
> If you can go to the top-level, and once you successfully got there, you
> already _know_ that you have a work tree (and also you already know at
> that point you are in the work tree).  The reason why "require-work-tree"
> has been placed before "cd-to-toplevel" is exactly for that purpose, I
> think.  It is possible that some callers wanted to "require-work-tree" to
> mean "I want you to not just _have_ a work tree, but actually be _in_ it",
> but I somehow doubt it.  It is more like "I am going to ask you to go to
> the top, but let's make sure that you do have a top before doing so", I
> think.

Well, if people relied on current behavior...
I didn't, I don't mind changing this, in fact I'm usually in "changing
mood" and running into the "preserve behavior" wall ;)

In any case, I think "require_work_tree" should really test whether we
can cd into the worktree, i.e. whether a cd_to_toplevel would succeed,
and not just whether "rev-parse --show-toplevel" returns a non-empty string.

> 
> I on the other hand do not think it is wrong to lose the existing calls to
> require-work-tree if you know that you are going to call cd-to-toplevel
> before doing any git operation that needs to have a work-tree, though.
> 
>> 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.
> 
> I agree; I don't think GIT_WORK_TREE was designed to be anything but an
> absolute path to begin with.  If a command chdir's around and exports the
> environment to its hooks and subcommands, it should be prepared to adjust
> it before doing so.

We do have some magic to re-export a relative GIT_DIR as absolute, and
the doc says GIT_WORK_TREE is relative to GIT_DIR. We even have a test
which succeeds by pure chance, as playing around with different layouts
shows. I'll try to come up at least with tests for this when I get to it.

Cheers,
Michael

      reply	other threads:[~2010-08-03  7:57 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
2010-08-02 17:46   ` Junio C Hamano
2010-08-03  7:57     ` Michael J Gruber [this message]

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=4C57CBEF.2070102@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tor.arne.vestbo@nokia.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.