filter-branch: skip index read/write when possible

If the user specifies an index filter but not a tree filter,
filter-branch cleverly avoids checking out the tree
entirely. But we don't do the next level of optimization: if
you have no index or tree filter, we do not need to read the
index at all.

This can greatly speed up cases where we are only changing
the commit objects (e.g., cementing a graft into place).
Here are numbers from the newly-added perf test:

  Test                  HEAD^              HEAD
  ---------------------------------------------------------------
  7000.2: noop filter   13.81(4.95+0.83)   5.43(0.42+0.43) -60.7%

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 files changed
tree: 068baef549634129847efcc77f7aa8cf3d20566c
  1. .gitattributes
  2. .gitignore
  3. .mailmap
  4. COPYING
  5. Documentation/
  6. GIT-VERSION-GEN
  7. INSTALL
  8. LGPL-2.1
  9. Makefile
  10. README
  11. abspath.c
  12. aclocal.m4
  13. advice.c
  14. advice.h
  15. alias.c
  16. alloc.c
  17. archive-tar.c
  18. archive-zip.c
  19. archive.c
  20. archive.h
  21. argv-array.c
  22. argv-array.h
  23. attr.c
  24. attr.h
  25. base85.c
  26. bisect.c
  27. bisect.h
  28. blob.c
  29. blob.h
  30. block-sha1/
  31. branch.c
  32. branch.h
  33. builtin.h
  34. builtin/
  35. bulk-checkin.c
  36. bulk-checkin.h
  37. bundle.c
  38. bundle.h
  39. cache-tree.c
  40. cache-tree.h
  41. cache.h
  42. check-builtins.sh
  43. check-racy.c
  44. check_bindir
  45. color.c
  46. color.h
  47. column.c
  48. column.h
  49. combine-diff.c
  50. command-list.txt
  51. commit-slab.h
  52. commit.c
  53. commit.h
  54. compat/
  55. config.c
  56. config.mak.in
  57. config.mak.uname
  58. configure.ac
  59. connect.c
  60. connect.h
  61. connected.c
  62. connected.h
  63. contrib/
  64. convert.c
  65. convert.h
  66. copy.c
  67. credential-cache--daemon.c
  68. credential-cache.c
  69. credential-store.c
  70. credential.c
  71. credential.h
  72. csum-file.c
  73. csum-file.h
  74. ctype.c
  75. daemon.c
  76. date.c
  77. decorate.c
  78. decorate.h
  79. delta.h
  80. diff-delta.c
  81. diff-lib.c
  82. diff-no-index.c
  83. diff.c
  84. diff.h
  85. diffcore-break.c
  86. diffcore-delta.c
  87. diffcore-order.c
  88. diffcore-pickaxe.c
  89. diffcore-rename.c
  90. diffcore.h
  91. dir.c
  92. dir.h
  93. editor.c
  94. entry.c
  95. environment.c
  96. ewah/
  97. exec_cmd.c
  98. exec_cmd.h
  99. fast-import.c
  100. fetch-pack.c
  101. fetch-pack.h
  102. fmt-merge-msg.h
  103. fsck.c
  104. fsck.h
  105. generate-cmdlist.sh
  106. gettext.c
  107. gettext.h
  108. git-add--interactive.perl
  109. git-archimport.perl
  110. git-bisect.sh
  111. git-compat-util.h
  112. git-cvsexportcommit.perl
  113. git-cvsimport.perl
  114. git-cvsserver.perl
  115. git-difftool--helper.sh
  116. git-difftool.perl
  117. git-filter-branch.sh
  118. git-gui/
  119. git-instaweb.sh
  120. git-merge-octopus.sh
  121. git-merge-one-file.sh
  122. git-merge-resolve.sh
  123. git-mergetool--lib.sh
  124. git-mergetool.sh
  125. git-p4.py
  126. git-parse-remote.sh
  127. git-quiltimport.sh
  128. git-rebase--am.sh
  129. git-rebase--interactive.sh
  130. git-rebase--merge.sh
  131. git-rebase.sh
  132. git-relink.perl
  133. git-remote-testgit.sh
  134. git-request-pull.sh
  135. git-send-email.perl
  136. git-sh-i18n.sh
  137. git-sh-setup.sh
  138. git-stash.sh
  139. git-submodule.sh
  140. git-svn.perl
  141. git-web--browse.sh
  142. git.c
  143. git.rc
  144. git.spec.in
  145. gitk-git/
  146. gitweb/
  147. gpg-interface.c
  148. gpg-interface.h
  149. graph.c
  150. graph.h
  151. grep.c
  152. grep.h
  153. hashmap.c
  154. hashmap.h
  155. help.c
  156. help.h
  157. hex.c
  158. http-backend.c
  159. http-fetch.c
  160. http-push.c
  161. http-walker.c
  162. http.c
  163. http.h
  164. ident.c
  165. imap-send.c
  166. khash.h
  167. kwset.c
  168. kwset.h
  169. levenshtein.c
  170. levenshtein.h
  171. line-log.c
  172. line-log.h
  173. line-range.c
  174. line-range.h
  175. list-objects.c
  176. list-objects.h
  177. ll-merge.c
  178. ll-merge.h
  179. lockfile.c
  180. lockfile.h
  181. log-tree.c
  182. log-tree.h
  183. mailinfo.c
  184. mailinfo.h
  185. mailmap.c
  186. mailmap.h
  187. match-trees.c
  188. merge-blobs.c
  189. merge-blobs.h
  190. merge-recursive.c
  191. merge-recursive.h
  192. merge.c
  193. mergesort.c
  194. mergesort.h
  195. mergetools/
  196. name-hash.c
  197. notes-cache.c
  198. notes-cache.h
  199. notes-merge.c
  200. notes-merge.h
  201. notes-utils.c
  202. notes-utils.h
  203. notes.c
  204. notes.h
  205. object.c
  206. object.h
  207. pack-bitmap-write.c
  208. pack-bitmap.c
  209. pack-bitmap.h
  210. pack-check.c
  211. pack-objects.c
  212. pack-objects.h
  213. pack-revindex.c
  214. pack-revindex.h
  215. pack-write.c
  216. pack.h
  217. pager.c
  218. parse-options-cb.c
  219. parse-options.c
  220. parse-options.h
  221. patch-delta.c
  222. patch-ids.c
  223. patch-ids.h
  224. path.c
  225. pathspec.c
  226. pathspec.h
  227. perl/
  228. pkt-line.c
  229. pkt-line.h
  230. po/
  231. ppc/
  232. preload-index.c
  233. pretty.c
  234. prio-queue.c
  235. prio-queue.h
  236. progress.c
  237. progress.h
  238. prompt.c
  239. prompt.h
  240. quote.c
  241. quote.h
  242. reachable.c
  243. reachable.h
  244. read-cache.c
  245. ref-filter.c
  246. ref-filter.h
  247. reflog-walk.c
  248. reflog-walk.h
  249. refs.c
  250. refs.h
  251. remote-curl.c
  252. remote-testsvn.c
  253. remote.c
  254. remote.h
  255. replace_object.c
  256. rerere.c
  257. rerere.h
  258. resolve-undo.c
  259. resolve-undo.h
  260. revision.c
  261. revision.h
  262. run-command.c
  263. run-command.h
  264. send-pack.c
  265. send-pack.h
  266. sequencer.c
  267. sequencer.h
  268. server-info.c
  269. setup.c
  270. sh-i18n--envsubst.c
  271. sha1-array.c
  272. sha1-array.h
  273. sha1-lookup.c
  274. sha1-lookup.h
  275. sha1_file.c
  276. sha1_name.c
  277. shallow.c
  278. shell.c
  279. shortlog.h
  280. show-index.c
  281. sideband.c
  282. sideband.h
  283. sigchain.c
  284. sigchain.h
  285. split-index.c
  286. split-index.h
  287. strbuf.c
  288. strbuf.h
  289. streaming.c
  290. streaming.h
  291. string-list.c
  292. string-list.h
  293. submodule-config.c
  294. submodule-config.h
  295. submodule.c
  296. submodule.h
  297. symlinks.c
  298. t/
  299. tag.c
  300. tag.h
  301. tar.h
  302. tempfile.c
  303. tempfile.h
  304. templates/
  305. test-chmtime.c
  306. test-config.c
  307. test-ctype.c
  308. test-date.c
  309. test-delta.c
  310. test-dump-cache-tree.c
  311. test-dump-split-index.c
  312. test-dump-untracked-cache.c
  313. test-genrandom.c
  314. test-hashmap.c
  315. test-index-version.c
  316. test-line-buffer.c
  317. test-match-trees.c
  318. test-mergesort.c
  319. test-mktemp.c
  320. test-parse-options.c
  321. test-path-utils.c
  322. test-prio-queue.c
  323. test-read-cache.c
  324. test-regex.c
  325. test-revision-walking.c
  326. test-run-command.c
  327. test-scrap-cache-tree.c
  328. test-sha1-array.c
  329. test-sha1.c
  330. test-sha1.sh
  331. test-sigchain.c
  332. test-string-list.c
  333. test-submodule-config.c
  334. test-subprocess.c
  335. test-svn-fe.c
  336. test-urlmatch-normalization.c
  337. test-wildmatch.c
  338. thread-utils.c
  339. thread-utils.h
  340. trace.c
  341. trace.h
  342. trailer.c
  343. trailer.h
  344. transport-helper.c
  345. transport.c
  346. transport.h
  347. tree-diff.c
  348. tree-walk.c
  349. tree-walk.h
  350. tree.c
  351. tree.h
  352. unicode_width.h
  353. unimplemented.sh
  354. unix-socket.c
  355. unix-socket.h
  356. unpack-trees.c
  357. unpack-trees.h
  358. update_unicode.sh
  359. upload-pack.c
  360. url.c
  361. url.h
  362. urlmatch.c
  363. urlmatch.h
  364. usage.c
  365. userdiff.c
  366. userdiff.h
  367. utf8.c
  368. utf8.h
  369. varint.c
  370. varint.h
  371. vcs-svn/
  372. version.c
  373. version.h
  374. versioncmp.c
  375. walker.c
  376. walker.h
  377. wildmatch.c
  378. wildmatch.h
  379. worktree.c
  380. worktree.h
  381. wrap-for-bin.sh
  382. wrapper.c
  383. write_or_die.c
  384. ws.c
  385. wt-status.c
  386. wt-status.h
  387. xdiff-interface.c
  388. xdiff-interface.h
  389. xdiff/
  390. zlib.c