From: Jeff King Date: Thu, 1 Sep 2011 21:53:07 +0000 (-0400) Subject: filter-branch: use require_clean_work_tree X-Git-Tag: v1.7.7.1~16^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5347a50fec066845e5dfa34a53cbec1ea347641d;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/git-filter-branch.sh b/git-filter-branch.sh index 6b5f2251b..f5c4db641 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