threads / patch / 19951

patchgit status -q (similar to subversion)

Subject: [PATCH] git status -q (similar to subversion)

## tl;dr

11 messages between Jun 27, 2009 and Jul 1, 2009. Diffs are folded; open one to read it.

replies: 10people: 5as markdown or json

Unknown· Jun 27, 2009, 20:57 UTC · lore

Here is a tiny patch adding -q option to git status. It means -uno (Show no untracked files).

Not sure where to add that in documentation. Maybe in git-commit man just below -u: -q (for git-status only, equals to -uno). Or something like this?

Regards, Borg

Show changes to builtin-commit.c +2 −0
diff --git a/builtin-commit.c b/builtin-commit.c
index 41e222d..e4e0074 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -826,6 +826,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
 		diff_use_color_default = git_use_color_default;
 
 	argc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);
+	if(quiet)
+		show_untracked_files = SHOW_NO_UNTRACKED_FILES;
 
 	index_file = prepare_index(argc, argv, prefix);
 
Jeff King· Jun 28, 2009, 18:52 UTC · re: Unknown · lore

Re: [PATCH] git status -q (similar to subversion)

On Sat, Jun 27, 2009 at 10:57:13PM +0200, Unknown wrote:
Show 7 quoted lines
> Here is a tiny patch adding -q option to git status.
> It means -uno (Show no untracked files).
> 
> Not sure where to add that in documentation.
> Maybe in git-commit man just below -u:
> -q (for git-status only, equals to -uno).
> Or something like this?

I'm not sure if this is a good idea. As you mention, there is already "-uno" to accomplish the same thing. So we are making the interface redundant.

It seems from the subject like you are trying to emulate a similar option in "svn status". But my understanding (and I was never a big subversion user, so I am going off of things said on the git list) is that there are quite a few differences between "svn status" and "git status". Enough that we do not want users to really equate them (a subject which has come up over and over on the list).

In other words, it seems like we are at best simply adding a redundant option, and at worst, confusing people even more about the equivalence between the "status" commands of the two systems.

-Peff
Martin Renold· Jun 28, 2009, 21:01 UTC · re: Jeff King · lore

Re: [PATCH] git status -q (similar to subversion)

On Sun, Jun 28, 2009 at 02:52:18PM -0400, Jeff King wrote:
Show 6 quoted lines
> On Sat, Jun 27, 2009 at 10:57:13PM +0200, Unknown wrote:
> > Here is a tiny patch adding -q option to git status.
> > It means -uno (Show no untracked files).
> 
> It seems from the subject like you are trying to emulate a similar
> option in "svn status".

As a former svn user I also miss -q. I like to keep untracked non-ignored files lying around as a short-term TODO list.

I think the point is not SVN compatibility. The point is that SVN just got the commandline interface right here ;-) because -q easier to discover and remember (many programs have --quiet/-q). And when you use it you will use it several times in a row. For this -uno is already too much to bother typing (assuming you have an alias 'git st').

bye, Martin

Jeff King· Jun 30, 2009, 05:33 UTC · re: Martin Renold · lore

Re: [PATCH] git status -q (similar to subversion)

On Sun, Jun 28, 2009 at 11:01:17PM +0200, Martin Renold wrote:
Show 8 quoted lines
> As a former svn user I also miss -q.  I like to keep untracked non-ignored
> files lying around as a short-term TODO list.
> 
> I think the point is not SVN compatibility.  The point is that SVN just got
> the commandline interface right here ;-) because -q easier to discover and
> remember (many programs have --quiet/-q).  And when you use it you will use
> it several times in a row.  For this -uno is already too much to bother
> typing (assuming you have an alias 'git st').
If it is convenience you want, perhaps you would be even happier with:
  git config status.showUntrackedFiles no

As far as "SVN got it right": that may well be the case, but we have to deal with the fact that "git status" is really a dry-run version of "git commit", which already has a "-q" option, which does something totally different. So I am a little hesitant to endorse its use in "git status" for something unrelated (and I am hesitant to have redundant command line options, as well).

-Peff
Martin Renold· Jun 30, 2009, 15:14 UTC · re: Jeff King · lore

Re: [PATCH] git status -q (similar to subversion)

On Tue, Jun 30, 2009 at 01:33:05AM -0400, Jeff King wrote:
> If it is convenience you want, perhaps you would be even happier with:
>   git config status.showUntrackedFiles no

No, that doesn't help in my usecase. I want to be reminded about the untracked files by default because I intend to clean them up later.

> [...] but we have to deal with the fact that "git status" is really a
> dry-run version of "git commit", which already has a "-q" option

Good point. However I think those commands are similar only from an implementation point of view. As an user I think of them as being quite different. I would not be surprised about different meaning of options - certainly less than about "git commit -a" vs "git add -u".

> So I am a little hesitant to endorse its use in "git status" for something
> unrelated (and I am hesitant to have redundant command line options, as
> well).

Yes I understand that. I'm using a wrapper script for now, but if it was any other one-letter shortcut, I would prefer to learn that instead.

bye, Martin

Jeff King· Jun 30, 2009, 15:33 UTC · re: Martin Renold · lore

Re: [PATCH] git status -q (similar to subversion)

On Tue, Jun 30, 2009 at 05:14:42PM +0200, Martin Renold wrote:
Show 7 quoted lines
> > [...] but we have to deal with the fact that "git status" is really a
> > dry-run version of "git commit", which already has a "-q" option
> 
> Good point. However I think those commands are similar only from an
> implementation point of view.  As an user I think of them as being quite
> different.  I would not be surprised about different meaning of options -
> certainly less than about "git commit -a" vs "git add -u".

The main difference that trips people, I think, is that they expect "git status <file>" to restrict status to a subset of the tree. But it is about "what would happen if I did 'git commit <file>'", which is quite different.

There has been much discussion about an alternate command that would be more like "svn status", and even some partial implementations. But it needs somebody who really cares about the feature to step up and complete it.

-Peff
Paolo Bonzini· Jul 1, 2009, 08:37 UTC · re: Jeff King · lore

Re: [PATCH] git status -q (similar to subversion)

> There has been much discussion about an alternate command that would be
> more like "svn status", and even some partial implementations. But it
> needs somebody who really cares about the feature to step up and
> complete it.
An alias
         changes=diff --name-status -r

already does almost the same function as "svn status -q". If you wanted full svn status with untracked files you could use this:

	changes = "!sh -c 'git status | sed -n 
\"/Untracked/N;//N;1,//d;s/^#/?/p\"; git diff --name-status -r \"$@\"' -"
Paolo
David Aguilar· Jun 28, 2009, 22:44 UTC · re: Unknown · lore

Re: [PATCH] git status -q (similar to subversion)

On Sat, Jun 27, 2009 at 10:57:13PM +0200, Unknown wrote:
Show 10 quoted lines
> Here is a tiny patch adding -q option to git status.
> It means -uno (Show no untracked files).
>
> Not sure where to add that in documentation.
> Maybe in git-commit man just below -u:
> -q (for git-status only, equals to -uno).
> Or something like this?
>
> Regards,
> Borg
Hello

Please take a look at Documentation/SubmittingPatches (all of the documentation lives in Documentation/).

It doesn't seem like this patch was generated with git format-patch. You'll also want to submit your patch using git send-email, as we require inline patches instead of attachments.

You'll need to include a signed-off-by line (which you can do by using `git commit -s`) and it seems like you need to introduce yourself to git:

http://book.git-scm.com/2_setup_and_initialization.html

Sorry, we cannot accept patches from "Unknown" for a number of reasons.

Thanks for your help and we look forward to hearing your response to the rest of the feedback received in this thread.

Show 13 quoted lines
> diff --git a/builtin-commit.c b/builtin-commit.c
> index 41e222d..e4e0074 100644
> --- a/builtin-commit.c
> +++ b/builtin-commit.c
> @@ -826,6 +826,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
>  		diff_use_color_default = git_use_color_default;
>  
>  	argc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);
> +	if(quiet)
> +		show_untracked_files = SHOW_NO_UNTRACKED_FILES;
>  
>  	index_file = prepare_index(argc, argv, prefix);
>  
-- 
	David
Unknown· Jun 29, 2009, 19:39 UTC · re: David Aguilar · lore

Re: [PATCH] git status -q (similar to subversion)

On Sun, 28 Jun 2009, David Aguilar wrote:
> Hello
Hi and thanks for reply.
Show 7 quoted lines
> Please take a look at Documentation/SubmittingPatches
> (all of the documentation lives in Documentation/).
>
> It doesn't seem like this patch was generated with
> git format-patch.  You'll also want to submit your patch using
> git send-email, as we require inline patches instead of
> attachments.

Right. I though such a small patch can be provided as is. Anyway, I will take necessary steps to peform better next time.

The question is, would that patch will be applied anyway? I already received some criticism about not applying it. I can only answer that where svn status and git status differ in many cases, there are also similar in some.

For now, I would rather want to see a discus about it (Pro vs Cons).

Other solution I see is add extra config variable like: status.showUntrackedDefault = (no|normal|all) So when you peform 'git status -u' it will be used.

Looks better to me if we really want to have difference between git status vs svn status.

Regards, Borg

Jeff King· Jun 30, 2009, 05:33 UTC · re: Unknown · lore

Re: [PATCH] git status -q (similar to subversion)

On Mon, Jun 29, 2009 at 09:39:18PM +0200, Unknown wrote:
> Other solution I see is add extra config variable like:
> status.showUntrackedDefault = (no|normal|all)
> So when you peform 'git status -u' it will be used.

It exists, but is called showUntrackedFiles. See "git help config" for details.

-Peff
Unknown· Jun 30, 2009, 16:56 UTC · re: Jeff King · lore

Re: [PATCH] git status -q (similar to subversion)

On Tue, 30 Jun 2009, Jeff King wrote:
> It exists, but is called showUntrackedFiles. See "git help config" for
> details.

Its not what I meant. showUntrackedFiles is used when you do not specify '-u' option. showUnrackedDefault (not so good name, someone have better idea?) would be used if you specify '-u' option without argument. Currently argument 'all' is used.

-- 
Borg

← back to recent threads