* Re: git rm bug
2018-06-06 19:47 ` Thomas Fischer
@ 2018-06-06 19:51 ` Robert P. J. Day
2018-06-06 20:01 ` Todd Zullinger
2018-06-06 22:50 ` Ævar Arnfjörð Bjarmason
2 siblings, 0 replies; 11+ messages in thread
From: Robert P. J. Day @ 2018-06-06 19:51 UTC (permalink / raw)
To: Thomas Fischer; +Cc: git
On Wed, 6 Jun 2018, Thomas Fischer wrote:
> I agree that the entire chain of empty directories should not be
> tracked, as git tracks content, not files.
>
> However, when I run 'rm path/to/some/file', I expect path/to/some/
> to still exist.
why?
> Similarly, when I run 'git rm path/to/some/file', I expect
> path/to/some/ to exist, *albeit untracked*.
again, why?
> I do NOT expect git to *track* empty directories. But I also do NOT
> expect it to remove untracked directories.
why not?
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca/dokuwiki
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: git rm bug
2018-06-06 19:47 ` Thomas Fischer
2018-06-06 19:51 ` Robert P. J. Day
@ 2018-06-06 20:01 ` Todd Zullinger
2018-06-06 20:10 ` Timothy Rice
2018-06-06 20:11 ` Jeff King
2018-06-06 22:50 ` Ævar Arnfjörð Bjarmason
2 siblings, 2 replies; 11+ messages in thread
From: Todd Zullinger @ 2018-06-06 20:01 UTC (permalink / raw)
To: Thomas Fischer; +Cc: Robert P. J. Day, git
Thomas Fischer wrote:
> I agree that the entire chain of empty directories should not be tracked, as git tracks content, not files.
>
> However, when I run 'rm path/to/some/file', I expect path/to/some/ to still exist.
>
> Similarly, when I run 'git rm path/to/some/file', I expect path/to/some/ to exist, *albeit untracked*.
>
> I do NOT expect git to *track* empty directories. But I also do NOT expect it to remove untracked directories.
It looks like this behavior has been in place for many
years, since d9b814cc97 ("Add builtin "git rm" command",
2006-05-19). Interestingly, Linus noted in the commit
message that the removal of leading directories was
different than when git-rm was a shell script. And he
wondered if it might be worth having an option to control
that behavior.
I imagine that most users either want the current behavior
or they rarely run across this and are surprised, given how
long git rm has worked this way.
It does seem like something which could be noted in the git
rm docs. Perhaps you'd care to take a stab at a patch to
add a note to Documentation/git-rm.txt Thomas? Maybe a note
at the end of the DISCUSSION section?
--
Todd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If everything seems to be going well, you have obviously overlooked
something.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: git rm bug
2018-06-06 20:01 ` Todd Zullinger
@ 2018-06-06 20:10 ` Timothy Rice
2018-06-06 20:20 ` Robert P. J. Day
2018-06-06 22:51 ` Ævar Arnfjörð Bjarmason
2018-06-06 20:11 ` Jeff King
1 sibling, 2 replies; 11+ messages in thread
From: Timothy Rice @ 2018-06-06 20:10 UTC (permalink / raw)
To: Todd Zullinger; +Cc: Thomas Fischer, Robert P. J. Day, git
> It does seem like something which could be noted in the git
> rm docs. Perhaps you'd care to take a stab at a patch to
> add a note to Documentation/git-rm.txt Thomas? Maybe a note
> at the end of the DISCUSSION section?
That same documentation could mention a common workaround for when someone
does really want to keep the empty directories:
$ touch ./path/to/empty/dir/.keep
$ git add ./path/to/empty/dir/.keep
$ git commit -m "Keep that empty directory because it is needed for <whatever>"
This would obviate the need for a new flag to switch behaviours.
~ Tim
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: git rm bug
2018-06-06 20:10 ` Timothy Rice
@ 2018-06-06 20:20 ` Robert P. J. Day
2018-06-06 22:51 ` Ævar Arnfjörð Bjarmason
1 sibling, 0 replies; 11+ messages in thread
From: Robert P. J. Day @ 2018-06-06 20:20 UTC (permalink / raw)
To: Timothy Rice; +Cc: Todd Zullinger, Thomas Fischer, git
On Thu, 7 Jun 2018, Timothy Rice wrote:
> > It does seem like something which could be noted in the git
> > rm docs. Perhaps you'd care to take a stab at a patch to
> > add a note to Documentation/git-rm.txt Thomas? Maybe a note
> > at the end of the DISCUSSION section?
>
> That same documentation could mention a common workaround for when
> someone does really want to keep the empty directories:
>
> $ touch ./path/to/empty/dir/.keep
> $ git add ./path/to/empty/dir/.keep
> $ git commit -m "Keep that empty directory because it is needed for <whatever>"
>
> This would obviate the need for a new flag to switch behaviours.
i'm going to be contrarian and obstinate and suggest that the
current behaviour is fine, since there is no compelling rationale for
any *other* behaviour.
invariably, every defense for hanging on to empty directories boils
down to, "i might do something in the future that expects those
directories to exist." well, if that's the case, then create them when
you need them -- nothing you do should ever simply *assume* the
existence of essential directories.
in addition, by "untracking" those directories, you're suggesting
that git quietly do what should normally be done by "git rm --cached".
if i want that behaviour, i would prefer to have to type it myself.
i'm fine with just adding a note to "git rm" making it clear what
happens in this case. i see no value in supporting extra options that
simply encourage bad behaviour.
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca/dokuwiki
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: git rm bug
2018-06-06 20:10 ` Timothy Rice
2018-06-06 20:20 ` Robert P. J. Day
@ 2018-06-06 22:51 ` Ævar Arnfjörð Bjarmason
1 sibling, 0 replies; 11+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-06-06 22:51 UTC (permalink / raw)
To: Timothy Rice; +Cc: Todd Zullinger, Thomas Fischer, Robert P. J. Day, git
On Wed, Jun 06 2018, Timothy Rice wrote:
>> It does seem like something which could be noted in the git
>> rm docs. Perhaps you'd care to take a stab at a patch to
>> add a note to Documentation/git-rm.txt Thomas? Maybe a note
>> at the end of the DISCUSSION section?
>
> That same documentation could mention a common workaround for when someone
> does really want to keep the empty directories:
>
> $ touch ./path/to/empty/dir/.keep
> $ git add ./path/to/empty/dir/.keep
> $ git commit -m "Keep that empty directory because it is needed for <whatever>"
nit: The .gitkeep convention seems to be much more common in the wild
than .keep, and it's probably time we documented that somewhere, even
though it's not a magic .git* file like .gitattributes et al.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: git rm bug
2018-06-06 20:01 ` Todd Zullinger
2018-06-06 20:10 ` Timothy Rice
@ 2018-06-06 20:11 ` Jeff King
1 sibling, 0 replies; 11+ messages in thread
From: Jeff King @ 2018-06-06 20:11 UTC (permalink / raw)
To: Todd Zullinger; +Cc: Thomas Fischer, Robert P. J. Day, git
On Wed, Jun 06, 2018 at 04:01:38PM -0400, Todd Zullinger wrote:
> Thomas Fischer wrote:
> > I agree that the entire chain of empty directories should not be tracked, as git tracks content, not files.
> >
> > However, when I run 'rm path/to/some/file', I expect path/to/some/ to still exist.
> >
> > Similarly, when I run 'git rm path/to/some/file', I expect path/to/some/ to exist, *albeit untracked*.
> >
> > I do NOT expect git to *track* empty directories. But I also do NOT expect it to remove untracked directories.
>
> It looks like this behavior has been in place for many
> years, since d9b814cc97 ("Add builtin "git rm" command",
> 2006-05-19). Interestingly, Linus noted in the commit
> message that the removal of leading directories was
> different than when git-rm was a shell script. And he
> wondered if it might be worth having an option to control
> that behavior.
>
> I imagine that most users either want the current behavior
> or they rarely run across this and are surprised, given how
> long git rm has worked this way.
It's also consistent with other parts of Git that remove files. E.g.,
"git checkout" to a state that does not have the file will remove the
leading directories (if they're empty, of course).
> It does seem like something which could be noted in the git
> rm docs. Perhaps you'd care to take a stab at a patch to
> add a note to Documentation/git-rm.txt Thomas? Maybe a note
> at the end of the DISCUSSION section?
Yeah, agreed.
-Peff
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: git rm bug
2018-06-06 19:47 ` Thomas Fischer
2018-06-06 19:51 ` Robert P. J. Day
2018-06-06 20:01 ` Todd Zullinger
@ 2018-06-06 22:50 ` Ævar Arnfjörð Bjarmason
2 siblings, 0 replies; 11+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-06-06 22:50 UTC (permalink / raw)
To: Thomas Fischer; +Cc: Robert P. J. Day, git
On Wed, Jun 06 2018, Thomas Fischer wrote:
> I agree that the entire chain of empty directories should not be
> tracked, as git tracks content, not files.
>
> However, when I run 'rm path/to/some/file', I expect path/to/some/ to
> still exist.
>
> Similarly, when I run 'git rm path/to/some/file', I expect
> path/to/some/ to exist, *albeit untracked*.
>
> I do NOT expect git to *track* empty directories. But I also do NOT
> expect it to remove untracked directories.
Others have said why, but here's an edge case you probably haven't
thought of:
(
rm -rf /tmp/repo &&
git init /tmp/repo &&
cd /tmp/repo &&
mkdir -p foo/bar/baz &&
git status
)
If you just have empty directories "git status" will report nothing,
although "git clean -dxfn" will show what would be cleaned up.
So if this worked as you're suggesting then someone could 'git rm" some
file, then everything would report that they're on commit XYZ, but if
they re-cloned at that commit they'd get a tree that would look
different.
No git command should behave in such a way as to leave the tree in a
state when moving from commit X->Y that you wouldn't get the same Y if
you re-cloned.
^ permalink raw reply [flat|nested] 11+ messages in thread