Merge branch 'as/maint-expire' into maint
* as/maint-expire: reflog: honor gc.reflogexpire=never prune: honor --expire=never
This commit is contained in:
commit
030bc0aa8b
@ -18,13 +18,11 @@ static unsigned long expire;
|
|||||||
static int prune_tmp_object(const char *path, const char *filename)
|
static int prune_tmp_object(const char *path, const char *filename)
|
||||||
{
|
{
|
||||||
const char *fullpath = mkpath("%s/%s", path, filename);
|
const char *fullpath = mkpath("%s/%s", path, filename);
|
||||||
if (expire) {
|
struct stat st;
|
||||||
struct stat st;
|
if (lstat(fullpath, &st))
|
||||||
if (lstat(fullpath, &st))
|
return error("Could not stat '%s'", fullpath);
|
||||||
return error("Could not stat '%s'", fullpath);
|
if (st.st_mtime > expire)
|
||||||
if (st.st_mtime > expire)
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
printf("Removing stale temporary file %s\n", fullpath);
|
printf("Removing stale temporary file %s\n", fullpath);
|
||||||
if (!show_only)
|
if (!show_only)
|
||||||
unlink_or_warn(fullpath);
|
unlink_or_warn(fullpath);
|
||||||
@ -34,13 +32,11 @@ static int prune_tmp_object(const char *path, const char *filename)
|
|||||||
static int prune_object(char *path, const char *filename, const unsigned char *sha1)
|
static int prune_object(char *path, const char *filename, const unsigned char *sha1)
|
||||||
{
|
{
|
||||||
const char *fullpath = mkpath("%s/%s", path, filename);
|
const char *fullpath = mkpath("%s/%s", path, filename);
|
||||||
if (expire) {
|
struct stat st;
|
||||||
struct stat st;
|
if (lstat(fullpath, &st))
|
||||||
if (lstat(fullpath, &st))
|
return error("Could not stat '%s'", fullpath);
|
||||||
return error("Could not stat '%s'", fullpath);
|
if (st.st_mtime > expire)
|
||||||
if (st.st_mtime > expire)
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (show_only || verbose) {
|
if (show_only || verbose) {
|
||||||
enum object_type type = sha1_object_info(sha1, NULL);
|
enum object_type type = sha1_object_info(sha1, NULL);
|
||||||
printf("%s %s\n", sha1_to_hex(sha1),
|
printf("%s %s\n", sha1_to_hex(sha1),
|
||||||
@ -139,6 +135,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
|
|||||||
};
|
};
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
|
expire = ULONG_MAX;
|
||||||
save_commit_buffer = 0;
|
save_commit_buffer = 0;
|
||||||
read_replace_refs = 0;
|
read_replace_refs = 0;
|
||||||
init_revisions(&revs, prefix);
|
init_revisions(&revs, prefix);
|
||||||
|
@ -530,16 +530,14 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
|
|||||||
int i, status, do_all;
|
int i, status, do_all;
|
||||||
int explicit_expiry = 0;
|
int explicit_expiry = 0;
|
||||||
|
|
||||||
|
default_reflog_expire_unreachable = now - 30 * 24 * 3600;
|
||||||
|
default_reflog_expire = now - 90 * 24 * 3600;
|
||||||
git_config(reflog_expire_config, NULL);
|
git_config(reflog_expire_config, NULL);
|
||||||
|
|
||||||
save_commit_buffer = 0;
|
save_commit_buffer = 0;
|
||||||
do_all = status = 0;
|
do_all = status = 0;
|
||||||
memset(&cb, 0, sizeof(cb));
|
memset(&cb, 0, sizeof(cb));
|
||||||
|
|
||||||
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_total = default_reflog_expire;
|
||||||
cb.expire_unreachable = default_reflog_expire_unreachable;
|
cb.expire_unreachable = default_reflog_expire_unreachable;
|
||||||
|
|
||||||
|
@ -214,4 +214,45 @@ test_expect_success 'delete' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rewind2' '
|
||||||
|
|
||||||
|
test_tick && git reset --hard HEAD~2 &&
|
||||||
|
loglen=$(wc -l <.git/logs/refs/heads/master) &&
|
||||||
|
test $loglen = 4
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success '--expire=never' '
|
||||||
|
|
||||||
|
git reflog expire --verbose \
|
||||||
|
--expire=never \
|
||||||
|
--expire-unreachable=never \
|
||||||
|
--all &&
|
||||||
|
loglen=$(wc -l <.git/logs/refs/heads/master) &&
|
||||||
|
test $loglen = 4
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'gc.reflogexpire=never' '
|
||||||
|
|
||||||
|
git config gc.reflogexpire never &&
|
||||||
|
git config gc.reflogexpireunreachable never &&
|
||||||
|
git reflog expire --verbose --all &&
|
||||||
|
loglen=$(wc -l <.git/logs/refs/heads/master) &&
|
||||||
|
test $loglen = 4
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'gc.reflogexpire=false' '
|
||||||
|
|
||||||
|
git config gc.reflogexpire false &&
|
||||||
|
git config gc.reflogexpireunreachable false &&
|
||||||
|
git reflog expire --verbose --all &&
|
||||||
|
loglen=$(wc -l <.git/logs/refs/heads/master) &&
|
||||||
|
test $loglen = 4 &&
|
||||||
|
|
||||||
|
git config --unset gc.reflogexpire &&
|
||||||
|
git config --unset gc.reflogexpireunreachable
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
@ -148,6 +148,38 @@ test_expect_success 'gc --prune=<date>' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'gc --prune=never' '
|
||||||
|
|
||||||
|
add_blob &&
|
||||||
|
git gc --prune=never &&
|
||||||
|
test -f $BLOB_FILE &&
|
||||||
|
git gc --prune=now &&
|
||||||
|
test ! -f $BLOB_FILE
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'gc respects gc.pruneExpire=never' '
|
||||||
|
|
||||||
|
git config gc.pruneExpire never &&
|
||||||
|
add_blob &&
|
||||||
|
git gc &&
|
||||||
|
test -f $BLOB_FILE &&
|
||||||
|
git config gc.pruneExpire now &&
|
||||||
|
git gc &&
|
||||||
|
test ! -f $BLOB_FILE
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'prune --expire=never' '
|
||||||
|
|
||||||
|
add_blob &&
|
||||||
|
git prune --expire=never &&
|
||||||
|
test -f $BLOB_FILE &&
|
||||||
|
git prune &&
|
||||||
|
test ! -f $BLOB_FILE
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'gc: prune old objects after local clone' '
|
test_expect_success 'gc: prune old objects after local clone' '
|
||||||
add_blob &&
|
add_blob &&
|
||||||
test-chmtime =-$((2*$week+1)) $BLOB_FILE &&
|
test-chmtime =-$((2*$week+1)) $BLOB_FILE &&
|
||||||
|
Loading…
Reference in New Issue
Block a user