Code

filter-branch: use require_clean_work_tree
authorJeff King <peff@peff.net>
Thu, 1 Sep 2011 21:53:07 +0000 (17:53 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Sep 2011 23:58:55 +0000 (16:58 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-filter-branch.sh

index 6b5f2251b6b5f0b9a43e16296c390e991c6fa13a..f5c4db6413bcc6f899bf20dae94eb13a72ed9908 100755 (executable)
@@ -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