Inconsistent result from git diff --quiet after untar'ing repo+working dir

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

 



Hi all --

I'm writing some automated tests that need a tiny git repo [1].  So I
have a shell script create the repo + working dir and tar it up, then
each test case untars the repo and does stuff inside it.  The working
dir deliberately has uncommitted changes and an untracked file.

Some of the test cases involve running "git diff --quiet", and I'm
getting inconsistent results.  Specifically, the first run after
untar'ing the repo+working dir incorrectly reports no changes (exit
status 0).  Subsequent runs correctly report changes (exit status 1).
Morever, if I run "git status" or regular non-quiet "git diff" first,
then "git diff --quiet" correctly reports changes.

Here's my shell script to create the tiny test repo:

"""
#!/bin/sh

# Output is git-repo.tar, which can be unpacked for each test -- that
# way tests can modify the repo and/or working dir without harming
# other tests.

set -ex
rm -rf git-repo
git init git-repo
cd git-repo

# two files tracked by git
echo a > a
echo b > b
git add -A
git commit -m"add a, b"

# uncommitted change to b
echo foo >> b

# some ignored files
echo "*.o" > .git/info/exclude
touch a.o

# an unknown file ("other" in git-speak)
touch junk

cd ..
tar -cf git-repo.tar git-repo
rm -rf git-repo
"""

If you run that in a temp dir, you'll get git-repo.tar.  To reproduce the bug:

  $  tar -xf git-repo.tar
  $ cd git-repo
  $ git diff --quiet && echo "no changes" || echo "changes"
  no changes                    # WRONG
  $ git diff --quiet && echo "no changes" || echo "changes"
  changes                         # CORRECT

Or at least, that's what I'm getting running git 1.7.2.3 on Arch Linux x86_64.

Do I totally misunderstand things, or is there a bug here?

Thanks --

Greg

[1] this is for my vcprompt project, which prints info about the
working dir for hg, git, svn, cvs, and bzr working dirs for use in
your shell prompt: see http://hg.gerg.ca/vcprompt/ .
--
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]