git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Rafael Garcia-Suarez <rgarciasuarez@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Suggestion: git status --untracked
Date: Mon, 11 Feb 2008 05:23:59 -0500	[thread overview]
Message-ID: <20080211102359.GA5916@coredump.intra.peff.net> (raw)
In-Reply-To: <b77c1dce0802110146o708e26a7lef56683f6b823365@mail.gmail.com>

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

  parent reply	other threads:[~2008-02-11 10:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-11  9:46 Suggestion: git status --untracked Rafael Garcia-Suarez
2008-02-11 10:13 ` Matthieu Moy
2008-02-11 10:54   ` Rafael Garcia-Suarez
2008-02-11 10:23 ` Jeff King [this message]
2008-02-11 10:56 ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080211102359.GA5916@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=rgarciasuarez@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).