* Inconsistent result from git diff --quiet after untar'ing repo+working dir
@ 2010-09-13 1:24 Greg Ward
0 siblings, 0 replies; only message in thread
From: Greg Ward @ 2010-09-13 1:24 UTC (permalink / raw)
To: git
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/ .
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-09-13 1:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-13 1:24 Inconsistent result from git diff --quiet after untar'ing repo+working dir Greg Ward
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).