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 <mhagger@alum.mit.edu> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Dec 12, 2014 at 09:56 UTC
98f31d8589d5a26b1b3ab4f30ec9cc81aa625872
1 file changed
+8
-5
builtin/reflog.c
+8
-5
@@ -20,9 +20,12 @@ static const char reflog_delete_usage[] =
20
static unsigned long default_reflog_expire;
21
static unsigned long default_reflog_expire_unreachable;
22
23
+enum expire_reflog_flags {
24
+ EXPIRE_REFLOGS_DRY_RUN = 1 << 0
25
+};
26
+
27
struct cmd_reflog_expire_cb {
28
struct rev_info revs;
25
- int dry_run;
29
int stalefix;
30
int rewrite;
31
int updateref;
@@ -438,7 +441,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
441
}
442
443
log_file = git_pathdup("logs/%s", refname);
441
- if (!cmd->dry_run) {
444
+ if (!(flags & EXPIRE_REFLOGS_DRY_RUN)) {
445
/*
446
* Even though holding $GIT_DIR/logs/$reflog.lock has
447
* no locking implications, we use the lock_file
@@ -467,7 +470,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
470
for_each_reflog_ent(refname, expire_reflog_ent, &cb);
471
reflog_expiry_cleanup(&cb);
472
470
- if (cb.newlog) {
473
+ if (!(flags & EXPIRE_REFLOGS_DRY_RUN)) {
474
if (close_lock_file(&reflog_lock)) {
475
status |= error("couldn't write %s: %s", log_file,
476
strerror(errno));
@@ -658,7 +661,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
661
for (i = 1; i < argc; i++) {
662
const char *arg = argv[i];
663
if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
661
- cb.dry_run = 1;
664
+ flags |= EXPIRE_REFLOGS_DRY_RUN;
665
else if (starts_with(arg, "--expire=")) {
666
if (parse_expiry_date(arg + 9, &cb.expire_total))
667
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)
755
for (i = 1; i < argc; i++) {
756
const char *arg = argv[i];
757
if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
755
- cb.dry_run = 1;
758
+ flags |= EXPIRE_REFLOGS_DRY_RUN;
759
else if (!strcmp(arg, "--rewrite"))
760
cb.rewrite = 1;
761
else if (!strcmp(arg, "--updateref"))