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