git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: git@vger.kernel.org
Subject: Re: git ls-files unreliable?
Date: Fri, 2 Apr 2010 22:54:28 +0200	[thread overview]
Message-ID: <n2p81b0412b1004021354z1ca4f6b4sa4400b484d97b46e@mail.gmail.com> (raw)
In-Reply-To: <20100402180842.GA5798@twister.home>

On Fri, Apr 2, 2010 at 20:08, Gabor Gombas <gombasg@digikabel.hu> wrote:
> Hi,
>
> I want to verify from a script that the working directory is clean. Some
> time ago Linus suggested to use "git diff --quiet --cached" followed by

In your script, you seem to have missed the "diff" part

> "git ls-files --exclude-standard -o -d -m -u". But:
>
> $ git status
> # On branch git_workdir_check
> # Your branch is ahead of 'origin/master' by 1 commit.
> #
> # Changes to be committed:
> #   (use "git reset HEAD <file>..." to unstage)
> #
> #       modified:   ../../../test
> #
> # Changed but not updated:
> #   (use "git add <file>..." to update what will be committed)
> #   (use "git checkout -- <file>..." to discard changes in working
> #   directory)
> #
> #       modified:   ../../../test
> #

Here. Were is your call to "git diff --cached"?

> $ git ls-files --exclude-standard -o -d -m -u
> $ echo $?
> 0

This is correct.

> So there _were_ uncommitted changes, "git status" showed them, but "git
> ls-files" did not.

Because it is not supposed to. The command "git ls-files" just shows
the files not known to git. You have to parse the output. Not that it
is complicated in this particular case: you consider the workdir unclean
on any output.

> Restriction: any solutions must work with git versions as old as 1.5.4.

It probably will, but please check "git diff --cached" exit code.
It may be always 0, in which case you'll have to fallback to
output parsing here too.

      reply	other threads:[~2010-04-02 20:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-02 18:08 git ls-files unreliable? Gabor Gombas
2010-04-02 20:54 ` Alex Riesen [this message]

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=n2p81b0412b1004021354z1ca4f6b4sa4400b484d97b46e@mail.gmail.com \
    --to=raa.lkml@gmail.com \
    --cc=git@vger.kernel.org \
    /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).