git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Damien Robert <damien.olivier.robert@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "Philippe Blain" <levraiphilippeblain@gmail.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	git@vger.kernel.org
Subject: Re: GIT_DIR in aliases [Re: Spurious GIT_DIR set when in a worktree [was Re: Nested submodule status bug]
Date: Tue, 3 Mar 2020 23:44:30 +0100	[thread overview]
Message-ID: <20200303224430.c64dmvzr4c72f2tv@doriath> (raw)
In-Reply-To: <20200228190218.GC1408759@coredump.intra.peff.net>

From Jeff King, Fri 28 Feb 2020 at 14:02:18 (-0500) :
> > Furthermore there is a question of consistency. GIT_DIR will not always be set
> > before running a shell alias. Looking at `setup_discovered_git_dir`, it will
> > be set if we are in a bare dir, or core.worktree / WORK_TREE is set, or if
> > we have a gitfile.

> We were discussing the same issue recently with regards to hooks. See:
>   https://lore.kernel.org/git/20200130102933.GE840531@coredump.intra.peff.net/
> and the responses. I think we could do better, but at the cost of
> breaking a relatively obscure git-clone feature.

Yes I found this discussion afterwards. This is related but a bit
different, the problem you discuss is that GIT_WORK_TREE is not always set
even when GIT_DIR is. The problem I have is that GIT_DIR is not always set; it
depends on the phase of the moon (are we in a worktree? ...), which makes
things that forget to unset it half broken and hard to debug.

I would argue that for scripts and hooks we should always set both. This is
easy to do (at least for scripts, I haven't looked at hooks) without
touching at setup_discovered_git_dir, so not affecting git clone.

In fact I would even argue that in setup_discovered_git_dir we should
always set both, and fix the breakages that appear, like the one you
mention for git clone. For instance I wonder if the recent report about
'git gui' setting GIT_DIR is not due to this.

> Note there are other variables you might want to unset, too, if you're
> switching repositories. Doing:
>   unset $(git rev-parse --local-env-vars)
> would cover the full list.

Thanks for the hint; I had forgotten about local-env-vars.

  parent reply	other threads:[~2020-03-03 22:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-14 22:42 Nested submodule checkout Damien Robert
2020-02-17  4:51 ` Philippe Blain
2020-02-18 17:08   ` Damien Robert
2020-02-19  4:19     ` Philippe Blain
2020-02-26 17:23   ` Nested submodule status bug Damien Robert
2020-02-27 10:05     ` Damien Robert
2020-02-27 10:43       ` Spurious GIT_DIR set when in a worktree [was Re: Nested submodule status bug] Damien Robert
2020-02-27 15:50         ` GIT_DIR in aliases [Re: " Damien Robert
2020-02-28 19:02           ` Jeff King
2020-02-28 20:22             ` Junio C Hamano
2020-03-03 22:44             ` Damien Robert [this message]
2020-02-29  1:42           ` Philippe Blain
2020-03-03 21:56             ` Damien Robert

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200303224430.c64dmvzr4c72f2tv@doriath \
    --to=damien.olivier.robert@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=levraiphilippeblain@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).