filter-branch: Fix renaming a directory in the tree-filter

Commit d89c1df (filter-branch: don't use xargs -0, 2008-03-12) replaced a
'ls-files | xargs rm' pipeline by 'git clean'. 'git clean' however does
not recurse and remove directories by default.

Now, consider a tree-filter that renames a directory.

  1. For the first commit everything works as expected

  2. Then filter-branch checks out the files for the next commit. This
     leaves the new directory behind because there is no real "branch
     switching" involved that would notice that the directory can be
     removed.

  3. Then filter-branch invokes 'git clean' to remove exactly those
     left-overs. But here it does not remove the directory.

  4. The next tree-filter does not work as expected because there already
     exists a directory with the new name.

Just add -d to 'git clean', so that empty directories are removed.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 files changed
tree: a9390a25e666eba12681ded584df47408ee731c0
  1. arm/
  2. compat/
  3. contrib/
  4. Documentation/
  5. git-gui/
  6. gitk-git/
  7. gitweb/
  8. mozilla-sha1/
  9. perl/
  10. ppc/
  11. t/
  12. templates/
  13. xdiff/
  14. .gitattributes
  15. .gitignore
  16. .mailmap
  17. alias.c
  18. alloc.c
  19. archive-tar.c
  20. archive-zip.c
  21. archive.c
  22. archive.h
  23. attr.c
  24. attr.h
  25. base85.c
  26. blob.c
  27. blob.h
  28. branch.c
  29. branch.h
  30. builtin-add.c
  31. builtin-annotate.c
  32. builtin-apply.c
  33. builtin-archive.c
  34. builtin-blame.c
  35. builtin-branch.c
  36. builtin-bundle.c
  37. builtin-cat-file.c
  38. builtin-check-attr.c
  39. builtin-check-ref-format.c
  40. builtin-checkout-index.c
  41. builtin-checkout.c
  42. builtin-clean.c
  43. builtin-commit-tree.c
  44. builtin-commit.c
  45. builtin-config.c
  46. builtin-count-objects.c
  47. builtin-describe.c
  48. builtin-diff-files.c
  49. builtin-diff-index.c
  50. builtin-diff-tree.c
  51. builtin-diff.c
  52. builtin-fast-export.c
  53. builtin-fetch--tool.c
  54. builtin-fetch-pack.c
  55. builtin-fetch.c
  56. builtin-fmt-merge-msg.c
  57. builtin-for-each-ref.c
  58. builtin-fsck.c
  59. builtin-gc.c
  60. builtin-grep.c
  61. builtin-http-fetch.c
  62. builtin-init-db.c
  63. builtin-log.c
  64. builtin-ls-files.c
  65. builtin-ls-remote.c
  66. builtin-ls-tree.c
  67. builtin-mailinfo.c
  68. builtin-mailsplit.c
  69. builtin-merge-base.c
  70. builtin-merge-file.c
  71. builtin-merge-ours.c
  72. builtin-merge-recursive.c
  73. builtin-mv.c
  74. builtin-name-rev.c
  75. builtin-pack-objects.c
  76. builtin-pack-refs.c
  77. builtin-prune-packed.c
  78. builtin-prune.c
  79. builtin-push.c
  80. builtin-read-tree.c
  81. builtin-reflog.c
  82. builtin-remote.c
  83. builtin-rerere.c
  84. builtin-reset.c
  85. builtin-rev-list.c
  86. builtin-rev-parse.c
  87. builtin-revert.c
  88. builtin-rm.c
  89. builtin-send-pack.c
  90. builtin-shortlog.c
  91. builtin-show-branch.c
  92. builtin-show-ref.c
  93. builtin-stripspace.c
  94. builtin-symbolic-ref.c
  95. builtin-tag.c
  96. builtin-tar-tree.c
  97. builtin-unpack-objects.c
  98. builtin-update-index.c
  99. builtin-update-ref.c
  100. builtin-upload-archive.c
  101. builtin-verify-pack.c
  102. builtin-verify-tag.c
  103. builtin-write-tree.c
  104. builtin.h
  105. bundle.c
  106. bundle.h
  107. cache-tree.c
  108. cache-tree.h
  109. cache.h
  110. check-builtins.sh
  111. check-racy.c
  112. color.c
  113. color.h
  114. combine-diff.c
  115. command-list.txt
  116. commit.c
  117. commit.h
  118. config.c
  119. config.mak.in
  120. configure.ac
  121. connect.c
  122. convert.c
  123. copy.c
  124. COPYING
  125. csum-file.c
  126. csum-file.h
  127. ctype.c
  128. daemon.c
  129. date.c
  130. decorate.c
  131. decorate.h
  132. delta.h
  133. diff-delta.c
  134. diff-lib.c
  135. diff.c
  136. diff.h
  137. diffcore-break.c
  138. diffcore-delta.c
  139. diffcore-order.c
  140. diffcore-pickaxe.c
  141. diffcore-rename.c
  142. diffcore.h
  143. dir.c
  144. dir.h
  145. dump-cache-tree.c
  146. entry.c
  147. environment.c
  148. exec_cmd.c
  149. exec_cmd.h
  150. fast-import.c
  151. fetch-pack.h
  152. fixup-builtins
  153. fsck.c
  154. fsck.h
  155. generate-cmdlist.sh
  156. git-add--interactive.perl
  157. git-am.sh
  158. git-archimport.perl
  159. git-bisect.sh
  160. git-clone.sh
  161. git-compat-util.h
  162. git-cvsexportcommit.perl
  163. git-cvsimport.perl
  164. git-cvsserver.perl
  165. git-filter-branch.sh
  166. git-instaweb.sh
  167. git-lost-found.sh
  168. git-merge-octopus.sh
  169. git-merge-one-file.sh
  170. git-merge-resolve.sh
  171. git-merge-stupid.sh
  172. git-merge.sh
  173. git-mergetool.sh
  174. git-parse-remote.sh
  175. git-pull.sh
  176. git-quiltimport.sh
  177. git-rebase--interactive.sh
  178. git-rebase.sh
  179. git-relink.perl
  180. git-repack.sh
  181. git-request-pull.sh
  182. git-send-email.perl
  183. git-sh-setup.sh
  184. git-stash.sh
  185. git-submodule.sh
  186. git-svn.perl
  187. GIT-VERSION-GEN
  188. git-web--browse.sh
  189. git.c
  190. git.spec.in
  191. grep.c
  192. grep.h
  193. hash-object.c
  194. hash.c
  195. hash.h
  196. help.c
  197. http-push.c
  198. http-walker.c
  199. http.c
  200. http.h
  201. ident.c
  202. imap-send.c
  203. index-pack.c
  204. INSTALL
  205. interpolate.c
  206. interpolate.h
  207. list-objects.c
  208. list-objects.h
  209. ll-merge.c
  210. ll-merge.h
  211. lockfile.c
  212. log-tree.c
  213. log-tree.h
  214. mailmap.c
  215. mailmap.h
  216. Makefile
  217. match-trees.c
  218. merge-file.c
  219. merge-index.c
  220. merge-recursive.h
  221. merge-tree.c
  222. mktag.c
  223. mktree.c
  224. object.c
  225. object.h
  226. pack-check.c
  227. pack-redundant.c
  228. pack-revindex.c
  229. pack-revindex.h
  230. pack-write.c
  231. pack.h
  232. pager.c
  233. parse-options.c
  234. parse-options.h
  235. patch-delta.c
  236. patch-id.c
  237. patch-ids.c
  238. patch-ids.h
  239. path-list.c
  240. path-list.h
  241. path.c
  242. pkt-line.c
  243. pkt-line.h
  244. pretty.c
  245. progress.c
  246. progress.h
  247. quote.c
  248. quote.h
  249. reachable.c
  250. reachable.h
  251. read-cache.c
  252. README
  253. receive-pack.c
  254. reflog-walk.c
  255. reflog-walk.h
  256. refs.c
  257. refs.h
  258. remote.c
  259. remote.h
  260. revision.c
  261. revision.h
  262. run-command.c
  263. run-command.h
  264. send-pack.h
  265. server-info.c
  266. setup.c
  267. sha1_file.c
  268. sha1_name.c
  269. shallow.c
  270. shell.c
  271. shortlog.h
  272. show-index.c
  273. sideband.c
  274. sideband.h
  275. strbuf.c
  276. strbuf.h
  277. symlinks.c
  278. tag.c
  279. tag.h
  280. tar.h
  281. test-absolute-path.c
  282. test-chmtime.c
  283. test-date.c
  284. test-delta.c
  285. test-genrandom.c
  286. test-match-trees.c
  287. test-parse-options.c
  288. test-sha1.c
  289. test-sha1.sh
  290. thread-utils.c
  291. thread-utils.h
  292. trace.c
  293. transport.c
  294. transport.h
  295. tree-diff.c
  296. tree-walk.c
  297. tree-walk.h
  298. tree.c
  299. tree.h
  300. unpack-file.c
  301. unpack-trees.c
  302. unpack-trees.h
  303. update-server-info.c
  304. upload-pack.c
  305. usage.c
  306. utf8.c
  307. utf8.h
  308. var.c
  309. walker.c
  310. walker.h
  311. write_or_die.c
  312. ws.c
  313. wt-status.c
  314. wt-status.h
  315. xdiff-interface.c
  316. xdiff-interface.h