Merge branch 'rs/reflog-expire-single-worktree-fix'
"git reflog expire --single-worktree" has been broken for the past 20 months or so, which has been corrected. * rs/reflog-expire-single-worktree-fix: reflog: fix expire --single-worktree
This commit is contained in:
@ -243,7 +243,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
|
|||||||
{
|
{
|
||||||
struct cmd_reflog_expire_cb cmd = { 0 };
|
struct cmd_reflog_expire_cb cmd = { 0 };
|
||||||
timestamp_t now = time(NULL);
|
timestamp_t now = time(NULL);
|
||||||
int i, status, do_all, all_worktrees = 1;
|
int i, status, do_all, single_worktree = 0;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
reflog_expiry_should_prune_fn *should_prune_fn = should_expire_reflog_ent;
|
reflog_expiry_should_prune_fn *should_prune_fn = should_expire_reflog_ent;
|
||||||
@ -268,7 +268,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
|
|||||||
OPT_BOOL(0, "stale-fix", &cmd.stalefix,
|
OPT_BOOL(0, "stale-fix", &cmd.stalefix,
|
||||||
N_("prune any reflog entries that point to broken commits")),
|
N_("prune any reflog entries that point to broken commits")),
|
||||||
OPT_BOOL(0, "all", &do_all, N_("process the reflogs of all references")),
|
OPT_BOOL(0, "all", &do_all, N_("process the reflogs of all references")),
|
||||||
OPT_BOOL(1, "single-worktree", &all_worktrees,
|
OPT_BOOL(0, "single-worktree", &single_worktree,
|
||||||
N_("limits processing to reflogs from the current worktree only")),
|
N_("limits processing to reflogs from the current worktree only")),
|
||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
@ -318,7 +318,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
worktrees = get_worktrees();
|
worktrees = get_worktrees();
|
||||||
for (p = worktrees; *p; p++) {
|
for (p = worktrees; *p; p++) {
|
||||||
if (!all_worktrees && !(*p)->is_current)
|
if (single_worktree && !(*p)->is_current)
|
||||||
continue;
|
continue;
|
||||||
collected.worktree = *p;
|
collected.worktree = *p;
|
||||||
refs_for_each_reflog(get_worktree_ref_store(*p),
|
refs_for_each_reflog(get_worktree_ref_store(*p),
|
||||||
|
@ -446,6 +446,29 @@ test_expect_success 'expire with multiple worktrees' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'expire one of multiple worktrees' '
|
||||||
|
git init main-wt2 &&
|
||||||
|
(
|
||||||
|
cd main-wt2 &&
|
||||||
|
test_tick &&
|
||||||
|
test_commit foo &&
|
||||||
|
git worktree add link-wt &&
|
||||||
|
test_tick &&
|
||||||
|
test_commit -C link-wt foobar &&
|
||||||
|
test_tick &&
|
||||||
|
test-tool ref-store worktree:link-wt for-each-reflog-ent HEAD \
|
||||||
|
>expect-link-wt &&
|
||||||
|
git reflog expire --verbose --all --expire=$test_tick \
|
||||||
|
--single-worktree &&
|
||||||
|
test-tool ref-store worktree:main for-each-reflog-ent HEAD \
|
||||||
|
>actual-main &&
|
||||||
|
test-tool ref-store worktree:link-wt for-each-reflog-ent HEAD \
|
||||||
|
>actual-link-wt &&
|
||||||
|
test_must_be_empty actual-main &&
|
||||||
|
test_cmp expect-link-wt actual-link-wt
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success REFFILES 'empty reflog' '
|
test_expect_success REFFILES 'empty reflog' '
|
||||||
test_when_finished "rm -rf empty" &&
|
test_when_finished "rm -rf empty" &&
|
||||||
git init empty &&
|
git init empty &&
|
||||||
|
Reference in New Issue
Block a user