Add "--expire <time>" option to 'git prune'

Earlier, 'git prune' would prune all loose unreachable objects.
This could be quite dangerous, as the objects could be used in
an ongoing operation.

This patch adds a mode to expire only loose, unreachable objects
which are older than a certain time.  For example, by

	git prune --expire 14.days

you can prune only those objects which are loose, unreachable
and older than 14 days (and thus probably outdated).

The implementation uses st.st_mtime rather than st.st_ctime,
because it can be tested better, using 'touch -d <time>' (and
omitting the test when the platform does not support that
command line switch).

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