git-gc: do not run git-prune by default.
git-prune is not safe when run uncontrolled in parallel while other git operations are creating new objects. To avoid mistakes, do not run git-prune by default from git-gc. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jan 21, 2007 at 23:28 UTC
e3ff4b244726f89620201e3295f097cf00b6b502
2 files changed
+32
-3
Documentation/git-gc.txt
+16
-1
@@ -8,7 +8,7 @@ git-gc - Cleanup unnecessary files and optimize the local repository
8
9
SYNOPSIS
10
--------
11
-'git-gc'
11
+'git-gc' [--prune]
12
13
DESCRIPTION
14
-----------
@@ -21,6 +21,21 @@ Users are encouraged to run this task on a regular basis within
21
each repository to maintain good disk space utilization and good
22
operating performance.
23
24
+OPTIONS
25
+-------
26
+
27
+--prune::
28
+ Usually `git-gc` packs refs, expires old reflog entries,
29
+ packs loose objects,
30
+ and removes old 'rerere' records. Removal
31
+ of unreferenced loose objects is an unsafe operation
32
+ while other git operations are in progress, so it is not
33
+ done by default. Pass this option if you want it, and only
34
+ when you know nobody else is creating new objects in the
35
+ repository at the same time (e.g. never use this option
36
+ in a cron script).
37
+
38
+
39
Configuration
40
-------------
41
git-gc.sh
+16
-2
@@ -4,12 +4,26 @@
4
#
5
# Cleanup unreachable files and optimize the repository.
6
7
-USAGE=''
7
+USAGE='git-gc [--prune]'
8
SUBDIRECTORY_OK=Yes
9
. git-sh-setup
10
11
+no_prune=:
12
+while case $# in 0) break ;; esac
13
+do
14
+ case "$1" in
15
+ --prune)
16
+ no_prune=
17
+ ;;
18
+ --)
19
+ usage
20
+ ;;
21
+ esac
22
+ shift
23
+done
24
+
25
git-pack-refs --prune &&
26
git-reflog expire --all &&
27
git-repack -a -d -l &&
14
-git-prune &&
28
+$no_prune git-prune &&
29
git-rerere gc || exit