Re: [PATCH] git-status: Show empty directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jun 10, 2012 at 3:15 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Leila Muhtasib <muhtasib@xxxxxxxxx> writes:
>
>> git-status now lists empty directories under the untracked header. Before this
>> modification, git status did not list empty directories. The header changed
>> from 'Untracked files' to instead display 'Untracked files and directories'.
>> A helpful reminder is also added after empty directories indicating they cannot
>> be added/staged if they are empty. git status -u is unchanged, and will still
>> only show untracked files just as before. As a result, no need for
>> documentation change.
>
> Please do not write a thick wall of text like this.  State the
> problem you are trying to solve first, by describing the current
> behaviour you want to highlight, and explain why you think the
> current behaviour is bad.  Then describe how you propose to solve
> that issue in a separate paragraph.
>
> For example:
>
>> git-status now lists empty directories under the untracked header. Before this
>> modification, git status did not list empty directories.
>
> The above is backwards.
>
>        "git status" lists untracked files and directories full of
>        untracked files, but does not list empty directories.  This
>        is bad for such and such reasons.
>
> Then describe your solution (which should be a short two sentence in
> this case, because in the problem description you would have justified
> adding "empty directories" section).
>
>        Show empty directories to the "Untracked" section as well.
>        Because an empty directory by definition does not have
>        anything that the user could add, suggest the user to create
>        a file to be committed and then add it.

Understood, I'll make sure to do that in the future. I appreciate the example.

>
> Having said all that, I personally doubt this is a useful change.  I
> may thought of adding a README file to a relatively new project that
> does not yet have one while in shower but I haven't even created the
> file in the working tree.  And I forget about it once I get to the
> office.  Should the system remind me to create README and then add?
> Your patch would not give me such a reminder once the top-level
> directory is populated (because it is no longer empty).  Even if I
> were planning to add Documentation/README instead, I would get such
> a reminder only if the Documentation directory is empty. Once the
> directory is populated, I wouldn't get "create README and then add".
> Why should an empty directory so special?
>

So there are two separate discussions here:
1) Should empty dirs be tracked

2) Should empty dirs appear under 'untracked' in git status

The question 'why are empty dirs special', is issue no 1, which I'm
also happy to discuss. The rule empty dirs can't be added in git is
unintuitive, as people use git to keep track of things - all things.
So it's not about an empty dir being special, it's about how people
use git to keep track of things. Now why might people want empty dirs
tracked? 1) People often setup dir structure in projects before adding
any code. They often want to save that state for themselves or to
share it with other team members. 2) Taken from link below: "Although
the directories contain no files, just empty directories, they are
used by the test suite, so I need them to exist in the working tree."
3) It's about saving state, all of it, including empty dirs (even if
they are not useful at the time).

This issue is often raised:
https://git.wiki.kernel.org/index.php/GitFaq#Can_I_add_empty_directories.3F
http://stackoverflow.com/questions/115983/how-do-i-add-an-empty-directory-to-a-git-repository/8944077#8944077
http://stackoverflow.com/questions/9072022/why-cant-i-track-these-files-with-git

I'm aware of the workaround to add a README or .gitignore file to the
empty dir so it can be tracked, but why have a workaround if people
want to add empty dirs. If they want an empty one, they want an empty
one without any files in it. And if they don't want an empty one, they
want to put something real in it (maybe a README, maybe something
else). Thus knowing a dir is empty helps with this point, as the user
can do something about it. Leading our discussion to point 2...

Now, let's put discussion no. 1 aside, and tackle the completely
separate question "should empty dirs appear under 'untracked' in git
status"?

Regardless of whether or not git supports tracking empty dirs, I think
we need this feature. There is confusion among people on this topic
(thus q's on the q&a site). So a helpful message of "empty dirs cannot
be tracked" will abate that. You bring up a good point with having
that message be in the form of a suggestion such as "empty dir: adding
a file to the dir will allow you to track it", "empty dir can't be
tracked: did you forget to add a file?", or something of the sorts.

Why would showing a message about empty dirs in the untracked section help:
1) Clarifies git's position on the matter, and provides a helpful reminder.
2) Abates confusion since ppl may think they've already tracked the
dir (by adding and commit it) and thus it is not appearing under the
untracked list.
3) People use git status to see the state of their working directory.
Feedback of a dir being empty, because they mistakenly added it and
forgot to remove it, or forgot to add something to it is helpful.

And since untracked means not currently tracked by git, and empty dirs
currently at any given point are untracked, they should appear in this
list. So even if you're not sold on discussion no1, I think we need
this patch to solve a communication issue, and to serve as a helpful
reminder which is what git status is all about.

Thanks,
Leila
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]