From: "Dirk Süsserott" <newsletter@dirk.my1.cc>
To: Git Mailing List <git@vger.kernel.org>
Subject: Best way to check for a "dirty" working tree?
Date: Sat, 11 Jun 2011 16:54:55 +0200 [thread overview]
Message-ID: <4DF381BF.3050301@dirk.my1.cc> (raw)
Hi list,
I have a script which moves data from somewhere to my local repo and
then checks it in, like so:
-----------
mv /tmp/foo.bar .
git commit -am "Updated foo.bar at $timestamp"
-----------
However, before overwriting "foo.bar" in my working directory, I'd like
to check whether my working tree is dirty (at least "foo.bar").
I tried
A) if ! git diff-index --quiet HEAD -- foo.bar; then
dirty=1
fi
and
B) if ! git diff --quiet -- foo.bar; then
dirty=1
fi
Both A) and B) work. But which one is better/faster/more reliable? Or is
there a better solution? For my purpose, I cannot see a difference
between diff and diff-index, except the syntax.
Cheers,
Dirk
next reply other threads:[~2011-06-11 15:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-11 14:54 Dirk Süsserott [this message]
2011-06-12 12:23 ` Best way to check for a "dirty" working tree? Ramkumar Ramachandra
2011-06-13 22:22 ` Jonathan Nieder
2011-06-14 13:28 ` Dirk Süsserott
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=4DF381BF.3050301@dirk.my1.cc \
--to=newsletter@dirk.my1.cc \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.