Re: How to check repository/working tree status from a script

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

 




On Tue, 19 May 2009, Marc Haber wrote:
> 
> On Tue, May 19, 2009 at 04:34:47PM +0100, Tony Finch wrote:
> > On Tue, 19 May 2009, Marc Haber wrote:
> > > I would like to check in a script whether there (a) are uncommitted
> > > changes (as in "working tree differs from local repository")
> > 
> > # check working tree is not different from the index
> > git diff --quiet
> > # check that the index is not different from the head
> > git diff --quiet --cached
> 
> $ git diff --quiet; echo $?
> 0
> $ git diff --quiet --cached; echo $?
> 0
> $ touch keks
> $ git diff --quiet; echo $?
> 0
> $ git diff --quiet --cached; echo $?
> 0
> $
> 
> Am I missing something?

If "keks" is already something you know about, then 'touch' wouldn't have 
changed it, so diff won't show it.

And if what you want to know about is whether there are _new_ files you 
might want to check, then you need a third check: 'git ls-files'. You 
won't see it in the error code, but you can do

	others=$(git ls-files -o --exclude-standard)

and then check it 'others' is empty or not.

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