Skip to content

Commit 98f31d8

Browse files
mhaggergitster
authored andcommitted
expire_reflog(): move dry_run to flags argument
The policy objects don't care about "--dry-run". So move it to expire_reflog()'s flags parameter. Signed-off-by: Michael Haggerty <[email protected]> Reviewed-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aba56c8 commit 98f31d8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

builtin/reflog.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ static const char reflog_delete_usage[] =
2020
static unsigned long default_reflog_expire;
2121
static unsigned long default_reflog_expire_unreachable;
2222

23+
enum expire_reflog_flags {
24+
EXPIRE_REFLOGS_DRY_RUN = 1 << 0
25+
};
26+
2327
struct cmd_reflog_expire_cb {
2428
struct rev_info revs;
25-
int dry_run;
2629
int stalefix;
2730
int rewrite;
2831
int updateref;
@@ -438,7 +441,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
438441
}
439442

440443
log_file = git_pathdup("logs/%s", refname);
441-
if (!cmd->dry_run) {
444+
if (!(flags & EXPIRE_REFLOGS_DRY_RUN)) {
442445
/*
443446
* Even though holding $GIT_DIR/logs/$reflog.lock has
444447
* no locking implications, we use the lock_file
@@ -467,7 +470,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
467470
for_each_reflog_ent(refname, expire_reflog_ent, &cb);
468471
reflog_expiry_cleanup(&cb);
469472

470-
if (cb.newlog) {
473+
if (!(flags & EXPIRE_REFLOGS_DRY_RUN)) {
471474
if (close_lock_file(&reflog_lock)) {
472475
status |= error("couldn't write %s: %s", log_file,
473476
strerror(errno));
@@ -658,7 +661,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
658661
for (i = 1; i < argc; i++) {
659662
const char *arg = argv[i];
660663
if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
661-
cb.dry_run = 1;
664+
flags |= EXPIRE_REFLOGS_DRY_RUN;
662665
else if (starts_with(arg, "--expire=")) {
663666
if (parse_expiry_date(arg + 9, &cb.expire_total))
664667
die(_("'%s' is not a valid timestamp"), arg);
@@ -752,7 +755,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
752755
for (i = 1; i < argc; i++) {
753756
const char *arg = argv[i];
754757
if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
755-
cb.dry_run = 1;
758+
flags |= EXPIRE_REFLOGS_DRY_RUN;
756759
else if (!strcmp(arg, "--rewrite"))
757760
cb.rewrite = 1;
758761
else if (!strcmp(arg, "--updateref"))

0 commit comments

Comments
 (0)