Re: Suggestion: git status --untracked

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

 



On Mon, Feb 11, 2008 at 10:46:25AM +0100, Rafael Garcia-Suarez wrote:

> I find myself wanting sometimes to filter out the output of
> git-status, to feed it to another command (for example, git-add, or
> rm, or cat >> .gitignore). However it's not currently very easy to
> parse in a one-liner.

Here's a one-liner:

  git status | sed -ne '/^# Untracked/,${s/#\t//p}'

Unfortunately it is both specific to GNU sed as well as horribly
unreadable.

> I'm suggesting to add options to control this behaviour. My suggestion
> would be (for a start) to add an option --untracked that will list all
> untracked files on stdout, without a leading "#\t", and without
> listing the added / modified / removed files.

The problem you are running into is that "git status" has a specific
purpose: generating the commit message template. Fortunately, it is
built on top of plumbing that is much easier to parse:

  git ls-files -o --exclude-standard

should produce the results you want. It even has a '-z' option to do
things safely in the face of filenames with newlines, and can limit
itself to partial paths.

-Peff
-
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]

  Powered by Linux