Skip to content

Commit eedb9d9

Browse files
committed
Merge branch 'js/filter-branch'
* js/filter-branch: filter-branch: Fix renaming a directory in the tree-filter filter-branch: Test renaming directories in a tree-filter
2 parents cfc4ba3 + 6a589fd commit eedb9d9

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

git-filter-branch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ while read commit parents; do
281281
die "Could not checkout the index"
282282
# files that $commit removed are now still in the working tree;
283283
# remove them, else they would be added again
284-
git clean -q -f -x
284+
git clean -d -q -f -x
285285
eval "$filter_tree" < /dev/null ||
286286
die "tree filter failed: $filter_tree"
287287

t/t7003-filter-branch.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ test_expect_success 'setup' '
1717
make_commit B
1818
git checkout -b branch B
1919
make_commit D
20+
mkdir dir
21+
make_commit dir/D
2022
make_commit E
2123
git checkout master
2224
make_commit C
@@ -41,9 +43,23 @@ test_expect_success 'rewrite, renaming a specific file' '
4143
'
4244

4345
test_expect_success 'test that the file was renamed' '
44-
test d = $(git show HEAD:doh) &&
46+
test d = "$(git show HEAD:doh --)" &&
47+
! test -f d &&
4548
test -f doh &&
46-
test d = $(cat doh)
49+
test d = "$(cat doh)"
50+
'
51+
52+
test_expect_success 'rewrite, renaming a specific directory' '
53+
git-filter-branch -f --tree-filter "mv dir diroh || :" HEAD
54+
'
55+
56+
test_expect_success 'test that the directory was renamed' '
57+
test dir/d = "$(git show HEAD:diroh/d --)" &&
58+
! test -d dir &&
59+
test -d diroh &&
60+
! test -d diroh/dir &&
61+
test -f diroh/d &&
62+
test dir/d = "$(cat diroh/d)"
4763
'
4864

4965
git tag oldD HEAD~4

0 commit comments

Comments
 (0)