From: Jeff King <peff@peff.net>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: Junio C Hamano <gitster@pobox.com>,
James Blackburn <jamesblackburn@gmail.com>,
git@vger.kernel.org
Subject: Re: Cannot rewrite branch(es) with a dirty working directory
Date: Thu, 1 Sep 2011 17:53:07 -0400 [thread overview]
Message-ID: <20110901215306.GD16308@sigill.intra.peff.net> (raw)
In-Reply-To: <20110901215003.GC16308@sigill.intra.peff.net>
On Thu, Sep 01, 2011 at 05:50:03PM -0400, Jeff King wrote:
> > No idea. It comes after a "git reset --hard", so it's supposed to be
> > clean.
>
> I wonder if there are racily clean entries[1] in the index, and
> diff-index reports them as potential changes.
>
> At any rate, filter-branch should probably be refreshing the index
> before checking for dirtiness, which would give the correct answer
> either way.
Actually, we've already factored this logic out, so let's use it.
-- >8 --
Subject: filter-branch: use require_clean_work_tree
Filter-branch already requires that we have a clean work
tree before starting. However, it failed to refresh the
index before checking, which means it could be wrong in the
case of stat-dirtiness.
Instead of simply adding a call to refresh the index, let's
switch to using the require_clean_work_tree function
provided by git-sh-setup. It does exactly what we want, and
with fewer lines of code and more specific output messages.
Signed-off-by: Jeff King <peff@peff.net>
---
git-filter-branch.sh | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 804a7f4..add2c02 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -108,9 +108,7 @@ OPTIONS_SPEC=
. git-sh-setup
if [ "$(is_bare_repository)" = false ]; then
- git diff-files --ignore-submodules --quiet &&
- git diff-index --cached --quiet HEAD -- ||
- die "Cannot rewrite branch(es) with a dirty working directory."
+ require_clean_work_tree 'rewrite branches'
fi
tempdir=.git-rewrite
--
1.7.6.10.g62f04
next prev parent reply other threads:[~2011-09-01 21:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-01 15:52 Cannot rewrite branch(es) with a dirty working directory James Blackburn
2011-09-01 17:14 ` Matthieu Moy
2011-09-01 21:50 ` Jeff King
2011-09-01 21:53 ` Jeff King [this message]
2011-09-02 5:52 ` Matthieu Moy
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=20110901215306.GD16308@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jamesblackburn@gmail.com \
/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).