Skip to contentSkip to conversation

cg-admin-rewritehist: fix reappearing files with --filter-tree.

PATCH New Johannes Sixt 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cg-admin-rewritehist: fix reappearing files with --filter-tree.

With --filter-tree a working copy is checked out for each commit. However, if a file is removed by a commit, the file is _not_ removed from the working copy by git-checkout-index. This must be done explicitly, otherwise the file becomes added back again.

---

I'm posting this again, because I haven't received any feedback nor has the patch been applied.

 cg-admin-rewritehist |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

26bb71a2d3d583d9eee10f4e950ff1b7d400e975

cg-admin-rewritehist +4 -1
index 7dd83cf..13ffb5d 100755
@@ -213,10 +213,13 @@ while read commit; do
 
 	if [ "$filter_tree" ]; then
 		git-checkout-index -f -u -a
+		# files that $commit removed are now still in the working tree;
+		# remove them, else they would be added again
+		git-ls-files -z --others | xargs -0 rm -f
 		eval "$filter_tree"
 		git-diff-index -r $commit | cut -f 2- | tr '\n' '\0' | \
 			xargs -0 git-update-index --add --replace --remove
-		git-ls-files --others | tr '\n' '\0' | \
+		git-ls-files -z --others | \
 			xargs -0 git-update-index --add --replace --remove
 	fi
 
Signature · 1 line
1.3.1.gaa6b