From: Jeff King <peff@peff.net>
To: Richard Weinberger <richard@nod.at>
Cc: Philip Oakley <philipoakley@iee.org>,
Junio C Hamano <gitster@pobox.com>,
Jonathan Nieder <jrnieder@gmail.com>,
git@vger.kernel.org
Subject: Re: git ate my home directory :-(
Date: Tue, 26 Mar 2013 13:41:00 -0400 [thread overview]
Message-ID: <20130326174059.GA10383@sigill.intra.peff.net> (raw)
In-Reply-To: <5151D589.2000002@nod.at>
On Tue, Mar 26, 2013 at 06:06:17PM +0100, Richard Weinberger wrote:
> >We could, but that would break the existing behavior for other people
> >(and I assume you mean "when GIT_WORK_TREE is not set at all", as I
> >would think GIT_WORK_TREE=. is explicit enough).
>
> Is there a valid use case to call git-clean with GIT_DIR set but GIT_WORK_TREE
> not (or to ."")?
> It will delete "." ;)
Yes, setting GIT_DIR but not GIT_WORK_TREE has always been a valid way
to work on a repository where you do not want the working tree polluted
with your .git file. It's not a common setup, but people do use it.
E.g., you might keep ~/mail as a git repo, but do not want the presence
of ~/mail/.git to confuse your mail tools. You can keep ~/git/mail.git
as just a repository, and do "cd ~/mail && GIT_DIR=~/git/mail.git git
foo" (or "git --git-dir=~git/mail.git foo").
Later, we introduced GIT_WORK_TREE (and core.worktree), which provided
another way of doing the same thing (instead of the "cd", you could set
GIT_WORK_TREE). For the most part, I'd expect setting core.worktree to
be the simplest for such setups, as once it is set, you can just do "cd
~/git/mail.git git foo", and everything should just work.
We never deprecated the original "GIT_DIR without GIT_WORK_TREE means
'.' is the implicit worktree" behavior, as nobody ever complained, and
it would break existing users of the feature.
We could do so now, as long as we provide an escape hatch (and I think
spelling that hatch as GIT_WORK_TREE=. is probably sane, but I am open
to other suggestions). And in general we try to avoid such breakage
without a deprecation period to give people time to fix their scripts
and workflows.
> But was kinda shocked that git-clean deletes files outside my git tree.
> I'm aware of -d. But in my case it happened within a fully automated script.
> I simply thought GIT_DIR=.. git-clean -f -d does the right thing...
It did do the right thing; just not the one you expected. :)
The problem is not with "clean", which just happens to be a destructive
command, but rather with the notion of what the git tree is when you
provide GIT_DIR. Though clean is an obvious problematic command,
something like "git reset --hard" could also be destructive. I don't
think it makes sense to do any fix that is specific to clean. If there
is a fix to be done, it should be about making the working tree lookup
algorithm more obvious.
-Peff
next prev parent reply other threads:[~2013-03-26 17:41 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-25 21:38 git ate my home directory :-( Richard Weinberger
2013-03-25 21:43 ` Jonathan Nieder
2013-03-25 22:02 ` Junio C Hamano
2013-03-25 22:08 ` Jonathan Nieder
2013-03-25 22:15 ` Junio C Hamano
2013-03-25 22:06 ` Junio C Hamano
2013-03-25 22:09 ` Richard Weinberger
2013-03-25 22:15 ` Jonathan Nieder
2013-03-25 22:20 ` Junio C Hamano
2013-03-25 22:27 ` Richard Weinberger
2013-03-25 22:13 ` Jonathan Nieder
2013-03-25 22:21 ` Brandon Casey
2013-03-26 8:02 ` Philip Oakley
2013-03-26 9:48 ` Duy Nguyen
2013-03-26 15:04 ` Jeff King
2013-03-26 16:32 ` Junio C Hamano
2013-03-27 13:05 ` Duy Nguyen
2013-03-26 21:47 ` Philip Oakley
2013-03-26 13:07 ` Richard Weinberger
2013-03-26 14:56 ` Jeff King
2013-03-26 17:06 ` Richard Weinberger
2013-03-26 17:20 ` demerphq
2013-03-26 17:48 ` Jeff King
2013-03-26 19:08 ` demerphq
2013-03-26 17:41 ` Jeff King [this message]
2013-03-26 18:20 ` Junio C Hamano
2013-03-26 20:08 ` Jeff King
2013-03-26 20:11 ` [DONOTAPPLY PATCH 1/3] environment: set GIT_WORK_TREE when we figure out work tree Jeff King
2013-03-26 20:16 ` Jonathan Nieder
2013-03-26 20:12 ` [DONOTAPPLY PATCH 2/3] setup: warn about implicit worktree with $GIT_DIR Jeff King
2013-03-26 20:21 ` Jonathan Nieder
2013-03-26 20:27 ` Jeff King
2013-03-26 20:35 ` Jonathan Nieder
2013-03-27 8:24 ` Matthieu Moy
2013-03-26 20:13 ` [DONOTAPPLY PATCH 3/3] setup: treat GIT_DIR without GIT_WORK_TREE as a bare repo Jeff King
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=20130326174059.GA10383@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=philipoakley@iee.org \
--cc=richard@nod.at \
/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).