threads / patch / 9627

patch, 2 partsRe: [PATCH 1/2] Add "--only-untracked" flag to status commands.

Subject: Re: [PATCH 1/2] Add "--only-untracked" flag to status commands.

## tl;dr

17 messages between Aug 23, 2007 and Aug 27, 2007. Diffs are folded; open one to read it.

replies: 16people: 7as markdown or json

Alex Riesen· Aug 23, 2007, 20:32 UTC · lore
Väinö Järvelä, Thu, Aug 23, 2007 21:58:31 +0200:
> With this flag, the user can choose to filter untracked files from the
> status output. This can be used to either speed up the status output, as
> the untracked files are not fetched at all, or to just cleanup the
> output without using gitignore.
"git diff -r --name-status; git diff --cached -r --name-status" is not enough?
Väinö Järvelä· Aug 24, 2007, 06:35 UTC · re: Alex Riesen · lore
On Aug 23, 2007, at 23:32, Alex Riesen wrote:
Show 10 quoted lines
> Väinö Järvelä, Thu, Aug 23, 2007 21:58:31 +0200:
>> With this flag, the user can choose to filter untracked files from  
>> the
>> status output. This can be used to either speed up the status  
>> output, as
>> the untracked files are not fetched at all, or to just cleanup the
>> output without using gitignore.
>
> "git diff -r --name-status; git diff --cached -r --name-status" is  
> not enough?

That line will result in duplicate entries, if files are staged, and the output of git-status is neater (but longer) in my opinion.

""" M Makefile M Makefile """ vs. """ # On branch entity_class # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: Makefile # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # # modified: Makefile # # Untracked files were filtered by "--only-tracked" """

Sure you could remove duplicate entries with "sort|uniq", or something, but just running "git status --only-tracked", is cleaner, and more user friendly.

The way I see the flag used is: A user runs "git status", sees that there is too much untracked files and not enough scrollback, so he runs "git status --only-tracked" to filter the results.

-- Väinö

Jakub Narebski· Aug 24, 2007, 07:40 UTC · re: Väinö Järvelä · lore
Väinö Järvelä wrote:
> The way I see the flag used is: A user runs "git status", sees that  
> there is too much untracked files and not enough scrollback, so he  
> runs "git status --only-tracked" to filter the results.
I like it.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Andreas Ericsson· Aug 27, 2007, 13:18 UTC · re: Jakub Narebski · lore
Jakub Narebski wrote:
Show 8 quoted lines
> Väinö Järvelä wrote:
> 
>> The way I see the flag used is: A user runs "git status", sees that  
>> there is too much untracked files and not enough scrollback, so he  
>> runs "git status --only-tracked" to filter the results.
> 
> I like it.
> 

Ack on that. It's happened to me a bunch of times, usually followed by <identical command> | sed '/Untracked/,$d'

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Junio C Hamano· Aug 24, 2007, 07:46 UTC · re: Väinö Järvelä · lore
Väinö Järvelä <v@pp.inet.fi> writes:
> The way I see the flag used is: A user runs "git status", sees that
> there is too much untracked files and not enough scrollback, so he
> runs "git status --only-tracked" to filter the results.
Why?

Just set up .gitignore once then (1) you do not have to worry about them ever again, and (2) you _will_ still be able to notice if you accidentally added more cruft, or more importantly, if you forgot to tell an important file to git.

I think the latter is more important point. If you train a naive user to use --only-tracked to ignore "Untracked" list, you are doing him or her a great disservice. Mistake to forget "git add" a new file before commiting will bound to happen.

Väinö Järvelä· Aug 24, 2007, 09:31 UTC · re: Junio C Hamano · lore
On Aug 24, 2007, at 10:46, Junio C Hamano wrote:
Show 17 quoted lines
> Väinö Järvelä <v@pp.inet.fi> writes:
>
>> The way I see the flag used is: A user runs "git status", sees that
>> there is too much untracked files and not enough scrollback, so he
>> runs "git status --only-tracked" to filter the results.
>
> Why?
>
> Just set up .gitignore once then (1) you do not have to worry
> about them ever again, and (2) you _will_ still be able to
> notice if you accidentally added more cruft, or more
> importantly, if you forgot to tell an important file to git.
>
> I think the latter is more important point.  If you train a
> naive user to use --only-tracked to ignore "Untracked" list, you
> are doing him or her a great disservice.  Mistake to forget "git
> add" a new file before commiting will bound to happen.

I also think that maintaining a proper .gitignore is imporant, and more productive than using --only-tracked instead. But when I have cruft that can't be put in .gitignore, or it would ignore files that are supposed to be shown and tracked, I use --only-tracked.

It's true though, that the user might forget to add a file if he always uses --only-tracked, that's why I added the note in the status that the untracked files were filtered out. The flag is supposed to be a helper for situations where .gitignore wouldn't work, not a way to work always. Maybe if this flag is accepted, the manual should say that in most cases it's better to use .gitignore.

-- Väinö

Johannes Schindelin· Aug 24, 2007, 09:55 UTC · re: Väinö Järvelä · lore
Hi,
On Fri, 24 Aug 2007, V?in? J?rvel wrote:
Show 24 quoted lines
> On Aug 24, 2007, at 10:46, Junio C Hamano wrote:
> 
> > V?in? J?rvel? <v@pp.inet.fi> writes:
> > 
> > > The way I see the flag used is: A user runs "git status", sees that
> > > there is too much untracked files and not enough scrollback, so he
> > > runs "git status --only-tracked" to filter the results.
> > 
> > Why?
> > 
> > Just set up .gitignore once then (1) you do not have to worry
> > about them ever again, and (2) you _will_ still be able to
> > notice if you accidentally added more cruft, or more
> > importantly, if you forgot to tell an important file to git.
> > 
> > I think the latter is more important point.  If you train a
> > naive user to use --only-tracked to ignore "Untracked" list, you
> > are doing him or her a great disservice.  Mistake to forget "git
> > add" a new file before commiting will bound to happen.
> 
> I also think that maintaining a proper .gitignore is imporant, and more
> productive than using --only-tracked instead. But when I have cruft that can't
> be put in .gitignore, or it would ignore files that are supposed to be shown
> and tracked, I use --only-tracked.

Would it not be better to imitate the "-x" and "-X" options of ls-files, then? You could achieve the effect you desire by "git status -x \*" then.

Ciao, Dscho

Väinö Järvelä· Aug 24, 2007, 10:52 UTC · re: Johannes Schindelin · lore
On Aug 24, 2007, at 12:55, Johannes Schindelin wrote:
Show 16 quoted lines
> On Fri, 24 Aug 2007, V?in? J?rvel wrote:
>> I also think that maintaining a proper .gitignore is imporant, and  
>> more
>> productive than using --only-tracked instead. But when I have  
>> cruft that can't
>> be put in .gitignore, or it would ignore files that are supposed  
>> to be shown
>> and tracked, I use --only-tracked.
>
> Would it not be better to imitate the "-x" and "-X" options of ls- 
> files,
> then?  You could achieve the effect you desire by "git status -x  
> \*" then.
>
> Ciao,
> Dscho

I haven't used that option, do I understand correctly, that with that option, you should provide another exclusion file? That would remove the dynamic ability of --only-tracked.

-- Väinö

Johannes Schindelin· Aug 25, 2007, 14:39 UTC · re: Väinö Järvelä · lore
Hi,
On Fri, 24 Aug 2007, V?in? J?rvel wrote:
Show 14 quoted lines
> On Aug 24, 2007, at 12:55, Johannes Schindelin wrote:
> > On Fri, 24 Aug 2007, V?in? J?rvel wrote:
> > > I also think that maintaining a proper .gitignore is imporant, and 
> > > more productive than using --only-tracked instead. But when I have 
> > > cruft that can't be put in .gitignore, or it would ignore files that 
> > > are supposed to be shown and tracked, I use --only-tracked.
> > 
> > Would it not be better to imitate the "-x" and "-X" options of 
> > ls-files, then?  You could achieve the effect you desire by "git 
> > status -x \*" then.
> 
> I haven't used that option, do I understand correctly, that with that 
> option, you should provide another exclusion file? That would remove the 
> dynamic ability of --only-tracked.
-X takes a filename, -x a pattern.

Hth, Dscho

Matthieu Moy· Aug 24, 2007, 11:40 UTC · re: Johannes Schindelin · lore
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Would it not be better to imitate the "-x" and "-X" options of ls-files, 
> then?  You could achieve the effect you desire by "git status -x \*"
> then.

That's equivalent feature-wise, but a bit slower performance-wise (the proposed patch skips file listing totally). But since the use-case for it is not the common case, it probably doesn't matter (and in case, it's possible to hardcode an optimisation if the pattern is "*").

-- 
Matthieu
Jakub Narebski· Aug 24, 2007, 22:47 UTC · re: Junio C Hamano · lore
Junio C Hamano wrote:
> I think the latter is more important point.  If you train a
> naive user to use --only-tracked to ignore "Untracked" list, you
> are doing him or her a great disservice.  Mistake to forget "git
> add" a new file before commiting will bound to happen.

If it won't acquire short version, nor tab completion, mosts users when confronted with such a mothful of option-name wouldn't use it unless necessary, I think...

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Junio C Hamano· Aug 24, 2007, 23:06 UTC · re: Jakub Narebski · lore
Jakub Narebski <jnareb@gmail.com> writes:
Show 10 quoted lines
> Junio C Hamano wrote:
>
>> I think the latter is more important point.  If you train a
>> naive user to use --only-tracked to ignore "Untracked" list, you
>> are doing him or her a great disservice.  Mistake to forget "git
>> add" a new file before commiting will bound to happen.
>
> If it won't acquire short version, nor tab completion, mosts users when
> confronted with such a mothful of option-name wouldn't use it unless
> necessary, I think...

Yeah, but if we accept that --only-tracked patch, I know from the past experience that people would send a "shorter synonym" patch, arguing that the capability is already there.

I really think we should resist temptation to add misfeatures that would encourage bad workflows and new user mistakes.

Väinö Järvelä· Aug 25, 2007, 06:16 UTC · re: Junio C Hamano · lore
On Aug 25, 2007, at 02:06, Junio C Hamano wrote:
Show 20 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
>
>> Junio C Hamano wrote:
>>
>>> I think the latter is more important point.  If you train a
>>> naive user to use --only-tracked to ignore "Untracked" list, you
>>> are doing him or her a great disservice.  Mistake to forget "git
>>> add" a new file before commiting will bound to happen.
>>
>> If it won't acquire short version, nor tab completion, mosts users  
>> when
>> confronted with such a mothful of option-name wouldn't use it unless
>> necessary, I think...
>
> Yeah, but if we accept that --only-tracked patch, I know from
> the past experience that people would send a "shorter synonym"
> patch, arguing that the capability is already there.
>
> I really think we should resist temptation to add misfeatures
> that would encourage bad workflows and new user mistakes.

I really do think that there is a use case for this patch. But this assumes that the testing is done in the source tree, but maybe that in itself can be considered a bad workflow.

An example would be in game development, where I have a directory full of images, and I wish to try out different images in the place of one. I usually create different versions of the images with different names, filling up the image directory under VCS. This usually results in tens of images that will not be tracked (unless they replace the original images), but because of my bad habit of creating the files inside the source tree, which results in a little bit faster workflow for me. With all these untracked files, git- status will obscure the actual contents of the status I wish to see.

I cannot put those files inside .gitignore, as there would have to be some kind of exclusion pattern for them that won't match the tracked files. Sure I could prefix all of my test images with 'test_' or something similiar. Or I could just add '*' to .gitignore, and force adds. The latter seems like a bad habit for me, the other seems to include a lot of manual labor, especially when someone else sends test files for me.

So the end result for me is, that it's easier to use --only-tracked

Fringe case? Maybe. Workflow could be better, sure. But --only- tracked even works for the less technical folk, which might be scared of forcing the changes, or annoyed by having to name the files with a magic prefix.

-- Väinö

Johannes Schindelin· Aug 25, 2007, 14:42 UTC · re: Väinö Järvelä · lore
Hi,
On Sat, 25 Aug 2007, V?in? J?rvel wrote:
> An example would be in game development, where I have a directory full 
> of images, and I wish to try out different images in the place of one. I 
> usually create different versions of the images with different names, 
> filling up the image directory under VCS.

I have a similar use case, funnily enough also with images. I created a tmp/ directory and put the images there, cp'ing or ln -s'ing the current one into the cwd. Then, "/tmp/" is put into .gitignore and all is well.

Especially the fact that I no longer forget to check in the images that I _do_ want to track.

Ciao, Dscho

Alex Riesen· Aug 24, 2007, 22:33 UTC · re: Väinö Järvelä · lore
Väinö Järvelä, Fri, Aug 24, 2007 08:35:13 +0200:
Show 15 quoted lines
> On Aug 23, 2007, at 23:32, Alex Riesen wrote:
> 
> >Väinö Järvelä, Thu, Aug 23, 2007 21:58:31 +0200:
> >>With this flag, the user can choose to filter untracked files from  
> >>the
> >>status output. This can be used to either speed up the status  
> >>output, as
> >>the untracked files are not fetched at all, or to just cleanup the
> >>output without using gitignore.
> >
> >"git diff -r --name-status; git diff --cached -r --name-status" is  
> >not enough?
> 
> That line will result in duplicate entries, if files are staged, and  
> the output of git-status is neater (but longer) in my opinion.

That is because it _is_ two times different: between working directory and the index, and between index and HEAD. git-status _will_ show you the same for the same reason.

Besides, why do you want to hide this "duplication"? It shows how the matters really are.

Besides, it looks like you are using "friendly" where you actually wanted to say "I consider you too dumb to know what happens". Someone may feel offended

Väinö Järvelä· Aug 25, 2007, 05:37 UTC · re: Alex Riesen · lore
On Aug 25, 2007, at 01:33, Alex Riesen wrote:
Show 23 quoted lines
> Väinö Järvelä, Fri, Aug 24, 2007 08:35:13 +0200:
>> On Aug 23, 2007, at 23:32, Alex Riesen wrote:
>>
>>> Väinö Järvelä, Thu, Aug 23, 2007 21:58:31 +0200:
>>>> With this flag, the user can choose to filter untracked files from
>>>> the
>>>> status output. This can be used to either speed up the status
>>>> output, as
>>>> the untracked files are not fetched at all, or to just cleanup the
>>>> output without using gitignore.
>>>
>>> "git diff -r --name-status; git diff --cached -r --name-status" is
>>> not enough?
>>
>> That line will result in duplicate entries, if files are staged, and
>> the output of git-status is neater (but longer) in my opinion.
>
> That is because it _is_ two times different: between working directory
> and the index, and between index and HEAD. git-status _will_ show you
> the same for the same reason.
>
> Besides, why do you want to hide this "duplication"? It shows how the
> matters really are.

git status --only-tracked, does not hide the fact that there are files staged for commit, and modified files relative to the index. The difference is, that it shows them in a clean way. Sure you could make a script like:

echo "Changes to be committed:"; git diff --cached -r --name-status; echo "Changed but not updates:"; git diff -r --name-status

But that is quite long, for a quick look at the state, without any untracked files.

>
> Besides, it looks like you are using "friendly" where you actually
> wanted to say "I consider you too dumb to know what happens". Someone
> may feel offended

I don't see where I consider users dumb, but hey, I'm sorry if I made someone feel offended.

-- Väinö

Junio C Hamano· Aug 25, 2007, 06:10 UTC · re: Väinö Järvelä · lore
Väinö Järvelä <v@pp.inet.fi> writes:
Show 11 quoted lines
> On Aug 25, 2007, at 01:33, Alex Riesen wrote:
>
>>> That line will result in duplicate entries, if files are staged, and
>>> the output of git-status is neater (but longer) in my opinion.
>>
>> That is because it _is_ two times different: between working directory
>> and the index, and between index and HEAD. git-status _will_ show you
>> the same for the same reason.
>>
>> Besides, why do you want to hide this "duplication"? It shows how the
>> matters really are.

The whole argument of "two entries are dups" is showing that you might be repeating past mistake of Cogito where hiding the index from the user would make git somehow more user friendly. It was a laudable attempt, but did not really fly well in practice.

But the --only-tracked has a bigger issue.

Letting the user know about untracked files that should be tracked is really important to avoid mistakes. If the status output is so cluttered for you to want an option like this, it is hard to spot such a file. I do not think disabling the untracked output is a solution to the real problem.

You earlier said that you may not be able to add certain untracked files to .gitignore --- can you elaborate?

I do not think the reason is you are too lazy to do so, nor you are incompetent to understand the ignore pattern. There is something else, which might show that the current ignore facility needs to become easier to use for _your_ use of _your_ repository. I still do not see in the thread what it is yet.

For example, maybe the reason why you do not want to place them in the .gitignore file is because the clutter are your random wip temporary files, whose naming convention is personal to you and does not apply to others. Naturally, you do not want to put such patterns to the tracked .gitignore file, which is for all participants of the project. In such a case, you would want a facility to allow you to specify your personal ignore patterns that is used in addition to the .gitignore file [*1*].

The particular example use case above is covered by an existing facility, but there might be other valid reasons that you cannot express your ignore patterns easily with existing facilities. In which case, we need to know that, so that you and people in similar situation as you are in can express the necessary ignore patterns more easily, in order to reduce the risk of forgetting to add new files.

[Footnote]
*1* Which already exists.  Put them in .git/info/exclude file.

← back to recent threads