mirror of
https://github.com/git/git.git
synced 2026-03-14 02:43:25 +01:00
Merge branch 'sp/gc' into next
* sp/gc: everyday: replace a few 'prune' and 'repack' with 'gc' Create 'git gc' to perform common maintenance operations. git-reflog: gc.* configuration and documentation. rerere gc: honor configuration and document it
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -42,6 +42,7 @@ git-fmt-merge-msg
|
||||
git-for-each-ref
|
||||
git-format-patch
|
||||
git-fsck-objects
|
||||
git-gc
|
||||
git-get-tar-commit-id
|
||||
git-grep
|
||||
git-hash-object
|
||||
|
||||
@@ -192,6 +192,25 @@ format.headers::
|
||||
Additional email headers to include in a patch to be submitted
|
||||
by mail. See gitlink:git-format-patch[1].
|
||||
|
||||
gc.reflogexpire::
|
||||
`git reflog expire` removes reflog entries older than
|
||||
this time; defaults to 90 days.
|
||||
|
||||
gc.reflogexpireunreachable::
|
||||
`git reflog expire` removes reflog entries older than
|
||||
this time and are not reachable from the current tip;
|
||||
defaults to 30 days.
|
||||
|
||||
gc.rerereresolved::
|
||||
Records of conflicted merge you resolved earlier are
|
||||
kept for this many days when `git rerere gc` is run.
|
||||
The default is 60 days. See gitlink:git-rerere[1].
|
||||
|
||||
gc.rerereunresolved::
|
||||
Records of conflicted merge you have not resolved are
|
||||
kept for this many days when `git rerere gc` is run.
|
||||
The default is 15 days. See gitlink:git-rerere[1].
|
||||
|
||||
gitcvs.enabled::
|
||||
Whether the cvs pserver interface is enabled for this repository.
|
||||
See gitlink:git-cvsserver[1].
|
||||
|
||||
@@ -34,6 +34,9 @@ Everybody uses these commands to maintain git repositories.
|
||||
|
||||
* gitlink:git-repack[1] to pack loose objects for efficiency.
|
||||
|
||||
* gitlink:git-gc[1] to do common housekeeping tasks such as
|
||||
repack and prune.
|
||||
|
||||
Examples
|
||||
~~~~~~~~
|
||||
|
||||
@@ -41,10 +44,9 @@ Check health and remove cruft.::
|
||||
+
|
||||
------------
|
||||
$ git fsck-objects <1>
|
||||
$ git prune
|
||||
$ git count-objects <2>
|
||||
$ git repack <3>
|
||||
$ git prune <4>
|
||||
$ git gc <4>
|
||||
------------
|
||||
+
|
||||
<1> running without `\--full` is usually cheap and assures the
|
||||
@@ -53,7 +55,8 @@ repository health reasonably well.
|
||||
disk space is wasted by not repacking.
|
||||
<3> without `-a` repacks incrementally. repacking every 4-5MB
|
||||
of loose objects accumulation may be a good rule of thumb.
|
||||
<4> after repack, prune removes the duplicate loose objects.
|
||||
<4> it is easier to use `git gc` than individual housekeeping commands
|
||||
such as `prune` and `repack`. This runs `repack -a -d`.
|
||||
|
||||
Repack a small project into single pack.::
|
||||
+
|
||||
|
||||
64
Documentation/git-gc.txt
Normal file
64
Documentation/git-gc.txt
Normal file
@@ -0,0 +1,64 @@
|
||||
git-gc(1)
|
||||
=========
|
||||
|
||||
NAME
|
||||
----
|
||||
git-gc - Cleanup unnecessary files and optimize the local repository
|
||||
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
'git-gc'
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Runs a number of housekeeping tasks within the current repository,
|
||||
such as compressing file revisions (to reduce disk space and increase
|
||||
performance) and removing unreachable objects which may have been
|
||||
created from prior invocations of gitlink:git-add[1].
|
||||
|
||||
Users are encouraged to run this task on a regular basis within
|
||||
each repository to maintain good disk space utilization and good
|
||||
operating performance.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
The optional configuration variable 'gc.reflogExpire' can be
|
||||
set to indicate how long historical entries within each branch's
|
||||
reflog should remain available in this repository. The setting is
|
||||
expressed as a length of time, for example '90 days' or '3 months'.
|
||||
It defaults to '90 days'.
|
||||
|
||||
The optional configuration variable 'gc.reflogExpireUnreachable'
|
||||
can be set to indicate how long historical reflog entries which
|
||||
are not part of the current branch should remain available in
|
||||
this repository. These types of entries are generally created as
|
||||
a result of using `git commit \--amend` or `git rebase` and are the
|
||||
commits prior to the amend or rebase occuring. Since these changes
|
||||
are not part of the current project most users will want to expire
|
||||
them sooner. This option defaults to '30 days'.
|
||||
|
||||
The optional configuration variable 'gc.rerereresolved' indicates
|
||||
how long records of conflicted merge you resolved earlier are
|
||||
kept. This defaults to 60 days.
|
||||
|
||||
The optional configuration variable 'gc.rerereunresolved' indicates
|
||||
how long records of conflicted merge you have not resolved are
|
||||
kept. This defaults to 15 days.
|
||||
|
||||
|
||||
See Also
|
||||
--------
|
||||
gitlink:git-prune[1]
|
||||
gitlink:git-reflog[1]
|
||||
gitlink:git-repack[1]
|
||||
gitlink:git-rerere[1]
|
||||
|
||||
Author
|
||||
------
|
||||
Written by Shawn O. Pearce <spearce@spearce.org>
|
||||
|
||||
GIT
|
||||
---
|
||||
Part of the gitlink:git[7] suite
|
||||
59
Documentation/git-reflog.txt
Normal file
59
Documentation/git-reflog.txt
Normal file
@@ -0,0 +1,59 @@
|
||||
git-reflog(1)
|
||||
=============
|
||||
|
||||
NAME
|
||||
----
|
||||
git-reflog - Manage reflog information
|
||||
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
[verse]
|
||||
'git-reflog' expire [--dry-run]
|
||||
[--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
Reflog is a mechanism to record when the tip of branches are
|
||||
updated. This command is to manage the information recorded in it.
|
||||
|
||||
The subcommand "expire" is used to prune older reflog entries.
|
||||
Entries older than `expire` time, or entries older than
|
||||
`expire-unreachable` time and are not reachable from the current
|
||||
tip, are removed from the reflog. This is typically not used
|
||||
directly by the end users -- instead, see gitlink:git-gc[1].
|
||||
|
||||
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
|
||||
--expire=<time>::
|
||||
Entries older than this time are pruned. Without the
|
||||
option it is taken from configuration `gc.reflogExpire`,
|
||||
which in turn defaults to 90 days.
|
||||
|
||||
--expire-unreachable=<time>::
|
||||
Entries older than this time and are not reachable from
|
||||
the current tip of the branch are pruned. Without the
|
||||
option it is taken from configuration
|
||||
`gc.reflogExpireUnreachable`, which in turn defaults to
|
||||
30 days.
|
||||
|
||||
--all::
|
||||
Instead of listing <refs> explicitly, prune all refs.
|
||||
|
||||
Author
|
||||
------
|
||||
Written by Junio C Hamano <junkio@cox.net>
|
||||
|
||||
Documentation
|
||||
--------------
|
||||
Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
|
||||
|
||||
GIT
|
||||
---
|
||||
Part of the gitlink:git[7] suite
|
||||
|
||||
@@ -7,7 +7,7 @@ git-rerere - Reuse recorded resolve
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
'git-rerere' [clear|diff|status]
|
||||
'git-rerere' [clear|diff|status|gc]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
@@ -55,7 +55,11 @@ for resolutions.
|
||||
'gc'::
|
||||
|
||||
This command is used to prune records of conflicted merge that
|
||||
occurred long time ago.
|
||||
occurred long time ago. By default, conflicts older than 15
|
||||
days that you have not recorded their resolution, and conflicts
|
||||
older than 60 days, are pruned. These are controlled with
|
||||
`gc.rerereunresolved` and `gc.rerereresolved` configuration
|
||||
variables.
|
||||
|
||||
|
||||
DISCUSSION
|
||||
|
||||
@@ -212,6 +212,9 @@ gitlink:git-cvsexportcommit[1]::
|
||||
gitlink:git-cvsserver[1]::
|
||||
A CVS server emulator for git.
|
||||
|
||||
gitlink:git-gc[1]::
|
||||
Cleanup unnecessary files and optimize the local repository.
|
||||
|
||||
gitlink:git-lost-found[1]::
|
||||
Recover lost refs that luckily have not yet been pruned.
|
||||
|
||||
@@ -224,6 +227,9 @@ gitlink:git-prune[1]::
|
||||
gitlink:git-quiltimport[1]::
|
||||
Applies a quilt patchset onto the current branch.
|
||||
|
||||
gitlink:git-reflog[1]::
|
||||
Manage reflog information.
|
||||
|
||||
gitlink:git-relink[1]::
|
||||
Hardlink common objects in local repositories.
|
||||
|
||||
|
||||
2
Makefile
2
Makefile
@@ -157,7 +157,7 @@ BASIC_LDFLAGS =
|
||||
SCRIPT_SH = \
|
||||
git-bisect.sh git-checkout.sh \
|
||||
git-clean.sh git-clone.sh git-commit.sh \
|
||||
git-fetch.sh \
|
||||
git-fetch.sh git-gc.sh \
|
||||
git-ls-remote.sh \
|
||||
git-merge-one-file.sh git-parse-remote.sh \
|
||||
git-pull.sh git-rebase.sh \
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include "dir.h"
|
||||
#include "tree-walk.h"
|
||||
|
||||
static unsigned long default_reflog_expire;
|
||||
static unsigned long default_reflog_expire_unreachable;
|
||||
|
||||
struct expire_reflog_cb {
|
||||
FILE *newlog;
|
||||
const char *ref;
|
||||
@@ -150,6 +153,17 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
|
||||
return status;
|
||||
}
|
||||
|
||||
static int reflog_expire_config(const char *var, const char *value)
|
||||
{
|
||||
if (!strcmp(var, "gc.reflogexpire"))
|
||||
default_reflog_expire = approxidate(value);
|
||||
else if (!strcmp(var, "gc.reflogexpireunreachable"))
|
||||
default_reflog_expire_unreachable = approxidate(value);
|
||||
else
|
||||
return git_default_config(var, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char reflog_expire_usage[] =
|
||||
"git-reflog expire [--dry-run] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
|
||||
|
||||
@@ -159,11 +173,18 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
|
||||
unsigned long now = time(NULL);
|
||||
int i, status, do_all;
|
||||
|
||||
git_config(reflog_expire_config);
|
||||
|
||||
save_commit_buffer = 0;
|
||||
do_all = status = 0;
|
||||
memset(&cb, 0, sizeof(cb));
|
||||
cb.expire_total = now - 90 * 24 * 3600;
|
||||
cb.expire_unreachable = now - 30 * 24 * 3600;
|
||||
|
||||
if (!default_reflog_expire_unreachable)
|
||||
default_reflog_expire_unreachable = now - 30 * 24 * 3600;
|
||||
if (!default_reflog_expire)
|
||||
default_reflog_expire = now - 90 * 24 * 3600;
|
||||
cb.expire_total = default_reflog_expire;
|
||||
cb.expire_unreachable = default_reflog_expire_unreachable;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
const char *arg = argv[i];
|
||||
|
||||
@@ -362,6 +362,17 @@ tail_optimization:
|
||||
return write_rr(rr, fd);
|
||||
}
|
||||
|
||||
static int git_rerere_config(const char *var, const char *value)
|
||||
{
|
||||
if (!strcmp(var, "gc.rerereresolved"))
|
||||
cutoff_resolve = git_config_int(var, value);
|
||||
else if (!strcmp(var, "gc.rerereunresolved"))
|
||||
cutoff_noresolve = git_config_int(var, value);
|
||||
else
|
||||
return git_default_config(var, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_rerere(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
struct path_list merge_rr = { NULL, 0, 0, 1 };
|
||||
@@ -371,6 +382,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
|
||||
if (stat(git_path("rr-cache"), &st) || !S_ISDIR(st.st_mode))
|
||||
return 0;
|
||||
|
||||
git_config(git_rerere_config);
|
||||
|
||||
merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR"));
|
||||
fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
|
||||
read_rr(&merge_rr);
|
||||
|
||||
15
git-gc.sh
Executable file
15
git-gc.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2006, Shawn O. Pearce
|
||||
#
|
||||
# Cleanup unreachable files and optimize the repository.
|
||||
|
||||
USAGE=''
|
||||
SUBDIRECTORY_OK=Yes
|
||||
. git-sh-setup
|
||||
|
||||
git-pack-refs --prune &&
|
||||
git-reflog expire --all &&
|
||||
git-repack -a -d &&
|
||||
git-prune &&
|
||||
git-rerere gc || exit
|
||||
Reference in New Issue
Block a user