Re: [PATCH 11/23] expire_reflog(): move dry_run to flags argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 05, 2014 at 12:08:23AM +0100, Michael Haggerty wrote:
> The policy objects don't care about "--dry-run". So move it to
> expire_reflog()'s flags parameter.
> 
> Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx>

Reviewed-by: <sbeller@xxxxxxxxxx>

> ---
>  builtin/reflog.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/builtin/reflog.c b/builtin/reflog.c
> index 319f0d2..a490193 100644
> --- a/builtin/reflog.c
> +++ b/builtin/reflog.c
> @@ -22,7 +22,6 @@ static unsigned long default_reflog_expire_unreachable;
>  
>  struct cmd_reflog_expire_cb {
>  	struct rev_info revs;
> -	int dry_run;
>  	int stalefix;
>  	int rewrite;
>  	int updateref;
> @@ -415,6 +414,10 @@ static void reflog_expiry_cleanup(struct expire_reflog_cb *cb)
>  
>  static struct lock_file reflog_lock;
>  
> +enum expire_reflog_flags {
> +	EXPIRE_REFLOGS_DRY_RUN = 1 << 0
> +};
> +
>  static int expire_reflog(const char *refname, const unsigned char *sha1,
>  			 unsigned int flags, void *cb_data)
>  {
> @@ -439,7 +442,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
>  	}
>  
>  	log_file = git_pathdup("logs/%s", refname);
> -	if (!cmd->dry_run) {
> +	if (!(flags & EXPIRE_REFLOGS_DRY_RUN)) {
>  		if (hold_lock_file_for_update(&reflog_lock, log_file, 0) < 0)
>  			goto failure;
>  		cb.newlog = fdopen_lock_file(&reflog_lock, "w");
> @@ -453,7 +456,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
>  	for_each_reflog_ent(refname, expire_reflog_ent, &cb);
>  	reflog_expiry_cleanup(&cb);
>  
> -	if (cb.newlog) {
> +	if (!(flags & EXPIRE_REFLOGS_DRY_RUN)) {
>  		if (close_lock_file(&reflog_lock)) {
>  			status |= error("Couldn't write %s: %s", log_file,
>  					strerror(errno));
> @@ -644,7 +647,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
>  	for (i = 1; i < argc; i++) {
>  		const char *arg = argv[i];
>  		if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
> -			cb.dry_run = 1;
> +			flags |= EXPIRE_REFLOGS_DRY_RUN;
>  		else if (starts_with(arg, "--expire=")) {
>  			if (parse_expiry_date(arg + 9, &cb.expire_total))
>  				die(_("'%s' is not a valid timestamp"), arg);
> @@ -738,7 +741,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
>  	for (i = 1; i < argc; i++) {
>  		const char *arg = argv[i];
>  		if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
> -			cb.dry_run = 1;
> +			flags |= EXPIRE_REFLOGS_DRY_RUN;
>  		else if (!strcmp(arg, "--rewrite"))
>  			cb.rewrite = 1;
>  		else if (!strcmp(arg, "--updateref"))
> -- 
> 2.1.3
> 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]