Skip to content

Commit 5347a50

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 740a8fc commit 5347a50

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

git-filter-branch.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ OPTIONS_SPEC=
108108
. git-sh-setup
109109

110110
if [ "$(is_bare_repository)" = false ]; then
111-
git diff-files --ignore-submodules --quiet &&
112-
git diff-index --cached --quiet HEAD -- ||
113-
die "Cannot rewrite branch(es) with a dirty working directory."
111+
require_clean_work_tree 'rewrite branches'
114112
fi
115113

116114
tempdir=.git-rewrite

0 commit comments

Comments
 (0)