Skip to content

Commit c2120e5

Browse files
dschoJunio C Hamano
authored andcommitted
git-gc: run pack-refs by default unless the repo is bare
The config variable gc.packrefs is tristate now: "true", "false" and "notbare", where "notbare" is the default. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 85b1f98 commit c2120e5

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

Documentation/config.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,17 @@ format.headers::
321321
Additional email headers to include in a patch to be submitted
322322
by mail. See gitlink:git-format-patch[1].
323323

324+
gc.packrefs::
325+
`git gc` does not run `git pack-refs` in a bare repository by
326+
default so that older dumb-transport clients can still fetch
327+
from the repository. Setting this to `true` lets `git
328+
gc` to run `git pack-refs`. Setting this to `false` tells
329+
`git gc` never to run `git pack-refs`. The default setting is
330+
`notbare`. Enable it only when you know you do not have to
331+
support such clients. The default setting will change to `true`
332+
at some stage, and setting this to `false` will continue to
333+
prevent `git pack-refs` from being run from `git gc`.
334+
324335
gc.reflogexpire::
325336
`git reflog expire` removes reflog entries older than
326337
this time; defaults to 90 days.

Documentation/git-gc.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ The optional configuration variable 'gc.rerereunresolved' indicates
6262
how long records of conflicted merge you have not resolved are
6363
kept. This defaults to 15 days.
6464

65+
The optional configuration variable 'gc.packrefs' determines if
66+
`git gc` runs `git-pack-refs`. Without the configuration, `git-pack-refs`
67+
is not run in bare repositories by default, to allow older dumb-transport
68+
clients fetch from the repository, but this will change in the future.
6569

6670
See Also
6771
--------

git-gc.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ do
2222
shift
2323
done
2424

25+
case "$(git config --get gc.packrefs)" in
26+
notbare|"")
27+
test $(is_bare_repository) = true || pack_refs=true;;
28+
*)
29+
pack_refs=$(git config --bool --get gc.packrefs)
30+
esac
31+
32+
test "true" != "$pack_refs" ||
2533
git-pack-refs --prune &&
2634
git-reflog expire --all &&
2735
git-repack -a -d -l &&

0 commit comments

Comments
 (0)