git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Ward <greg@gerg.ca>
To: git@vger.kernel.org
Subject: Inconsistent result from git diff --quiet after untar'ing repo+working dir
Date: Sun, 12 Sep 2010 21:24:22 -0400	[thread overview]
Message-ID: <AANLkTikqrn0MKLFAt2D71fNyFkG1T3ncrrHx-LoSZLAH@mail.gmail.com> (raw)

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/ .

                 reply	other threads:[~2010-09-13  1:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=AANLkTikqrn0MKLFAt2D71fNyFkG1T3ncrrHx-LoSZLAH@mail.gmail.com \
    --to=greg@gerg.ca \
    --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).