git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Mike Hommey <mh@glandium.org>
Cc: Duy Nguyen <pclouds@gmail.com>,
	Thorsten von Eicken <tve@rightscale.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: git status doesn't ignore GIT_DIR directory?
Date: Sat, 23 May 2015 10:39:39 -0700	[thread overview]
Message-ID: <xmqqk2vzchwk.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <xmqqwpzzcjq0.fsf@gitster.dls.corp.google.com> (Junio C. Hamano's message of "Sat, 23 May 2015 10:00:23 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> I think both of you are wrong ;-)
>>
>> The thing is, what you are seeing does not have much to do with
>> GIT_DIR.  It is "what Git does when it finds a directory inside the
>> working tree of a project".  And ".git" is the only special thing in
>> that context.
>
> In short, I think Duy's "how about this" means well, but adds
> documentation at a wrong place.
>
> Having said all that, the message I am responding to showed the
> right way to look at, understand, and explain the current behaviour.
> It is a separate issue if the current behaviour is optimal from the
> usability point of view.  It is not entirely implausible to extend
> the special casing rules from "a directory named '.git' only" to "in
> addition, the directory pointed at by GIT_DIR, if exists, is treated
> the same way".

If somebody is interested in pursuing this further in the direction
of changing the behaviour (so that Thorsten's original would work as
expected), one thing to be careful about is the case (1) (case (2)
is more or less straight-forward and obvious).

If you do

    $ GIT_DIR=/path/to/worktree/sub/repo.git
    $ GIT_WORK_TREE=/path/to/worktree
    $ export GIT_DIR GIT_WORK_TREE
    $ cd $GIT_WORK_TREE
    $ git add sub

with the current rule, because sub/repo.git does not trigger the
special casing, we may end up adding everything inside our own
repository, which is clearly crazy.  But if you change the rule to
special case the directory pointed at by $GIT_DIR, then we would
start treating that directory as "ah, there is a Git repository".
But the updated code must not say "hence, sub/ is the top level of
the working tree of that repository, so we add it as a submodule".

It instead should just ignore that repo.git directory, just like a
plain vanilla "git add ."  ignores ".git" at the top-level, and add
other things in sub/ directory, i.e. treating sub/ as just a normal
subdirectory in our working tree.

I am not planning to do this in a near future myself, but I thought
I should caution in case anybody is interested.

Thanks.

      reply	other threads:[~2015-05-23 17:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-23  1:03 git status doesn't ignore GIT_DIR directory? Thorsten von Eicken
2015-05-23  2:03 ` Junio C Hamano
2015-05-23  2:22   ` Duy Nguyen
2015-05-23  4:41     ` Thorsten von Eicken
2015-05-23 11:53       ` Duy Nguyen
2015-05-23  5:39     ` Mike Hommey
2015-05-23 11:42       ` Duy Nguyen
2015-05-23 16:54       ` Junio C Hamano
2015-05-23 17:00         ` Junio C Hamano
2015-05-23 17:39           ` Junio C Hamano [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

  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=xmqqk2vzchwk.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=mh@glandium.org \
    --cc=pclouds@gmail.com \
    --cc=tve@rightscale.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.
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).