expire_reflog(): move updateref to flags argument
The policy objects don't care about "--updateref". 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>
This commit is contained in:

committed by
Junio C Hamano

parent
98f31d8589
commit
c4c4fbf86c
@ -21,14 +21,14 @@ static unsigned long default_reflog_expire;
|
|||||||
static unsigned long default_reflog_expire_unreachable;
|
static unsigned long default_reflog_expire_unreachable;
|
||||||
|
|
||||||
enum expire_reflog_flags {
|
enum expire_reflog_flags {
|
||||||
EXPIRE_REFLOGS_DRY_RUN = 1 << 0
|
EXPIRE_REFLOGS_DRY_RUN = 1 << 0,
|
||||||
|
EXPIRE_REFLOGS_UPDATE_REF = 1 << 1
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_reflog_expire_cb {
|
struct cmd_reflog_expire_cb {
|
||||||
struct rev_info revs;
|
struct rev_info revs;
|
||||||
int stalefix;
|
int stalefix;
|
||||||
int rewrite;
|
int rewrite;
|
||||||
int updateref;
|
|
||||||
int verbose;
|
int verbose;
|
||||||
unsigned long expire_total;
|
unsigned long expire_total;
|
||||||
unsigned long expire_unreachable;
|
unsigned long expire_unreachable;
|
||||||
@ -474,7 +474,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
|
|||||||
if (close_lock_file(&reflog_lock)) {
|
if (close_lock_file(&reflog_lock)) {
|
||||||
status |= error("couldn't write %s: %s", log_file,
|
status |= error("couldn't write %s: %s", log_file,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
} else if (cmd->updateref &&
|
} else if ((flags & EXPIRE_REFLOGS_UPDATE_REF) &&
|
||||||
(write_in_full(lock->lock_fd,
|
(write_in_full(lock->lock_fd,
|
||||||
sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
|
sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
|
||||||
write_str_in_full(lock->lock_fd, "\n") != 1 ||
|
write_str_in_full(lock->lock_fd, "\n") != 1 ||
|
||||||
@ -485,7 +485,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
|
|||||||
} else if (commit_lock_file(&reflog_lock)) {
|
} else if (commit_lock_file(&reflog_lock)) {
|
||||||
status |= error("unable to commit reflog '%s' (%s)",
|
status |= error("unable to commit reflog '%s' (%s)",
|
||||||
log_file, strerror(errno));
|
log_file, strerror(errno));
|
||||||
} else if (cmd->updateref && commit_ref(lock)) {
|
} else if ((flags & EXPIRE_REFLOGS_UPDATE_REF) && commit_ref(lock)) {
|
||||||
status |= error("couldn't set %s", lock->ref_name);
|
status |= error("couldn't set %s", lock->ref_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -677,7 +677,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
|
|||||||
else if (!strcmp(arg, "--rewrite"))
|
else if (!strcmp(arg, "--rewrite"))
|
||||||
cb.rewrite = 1;
|
cb.rewrite = 1;
|
||||||
else if (!strcmp(arg, "--updateref"))
|
else if (!strcmp(arg, "--updateref"))
|
||||||
cb.updateref = 1;
|
flags |= EXPIRE_REFLOGS_UPDATE_REF;
|
||||||
else if (!strcmp(arg, "--all"))
|
else if (!strcmp(arg, "--all"))
|
||||||
do_all = 1;
|
do_all = 1;
|
||||||
else if (!strcmp(arg, "--verbose"))
|
else if (!strcmp(arg, "--verbose"))
|
||||||
@ -759,7 +759,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
|
|||||||
else if (!strcmp(arg, "--rewrite"))
|
else if (!strcmp(arg, "--rewrite"))
|
||||||
cb.rewrite = 1;
|
cb.rewrite = 1;
|
||||||
else if (!strcmp(arg, "--updateref"))
|
else if (!strcmp(arg, "--updateref"))
|
||||||
cb.updateref = 1;
|
flags |= EXPIRE_REFLOGS_UPDATE_REF;
|
||||||
else if (!strcmp(arg, "--verbose"))
|
else if (!strcmp(arg, "--verbose"))
|
||||||
cb.verbose = 1;
|
cb.verbose = 1;
|
||||||
else if (!strcmp(arg, "--")) {
|
else if (!strcmp(arg, "--")) {
|
||||||
|
Reference in New Issue
Block a user