Re: Cannot rewrite branch(es) with a dirty working directory
- From
Jeff King <peff@peff.net>
- Date
- Sep 1, 2011, 21:53 UTC
- Message-ID
- <20110901215306.GD16308@sigill.intra.peff.net>
- In-Reply-To
- <20110901215003.GC16308@sigill.intra.peff.net>
On Thu, Sep 01, 2011 at 05:50:03PM -0400, Jeff King wrote:
Show 9 quoted lines
> > 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