Re: [PATCH v2 07/14] create_autostash(): remove unneeded parameter

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

 



"Phillip Wood via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>
>
> The default_reflog parameter of create_autostash() is passed to
> reset_head(). However as creating a stash does not involve updating
> any refs the parameter is not used by reset_head(). Removing the
> parameter from create_autostash() simplifies the callers.

It does make the callers of create_autostash() easier to reason
about, but ...

> @@ -4132,7 +4131,7 @@ void create_autostash(struct repository *r, const char *path,
>  		write_file(path, "%s", oid_to_hex(&oid));
>  		printf(_("Created autostash: %s\n"), buf.buf);
>  		if (reset_head(r, NULL, NULL, RESET_HEAD_HARD, NULL, NULL,
> -			       default_reflog_action) < 0)
> +			       "") < 0)

... makes the reader wonder what the empty string is doing here.
The fact that reset_head() does not care about the last parameter
when not given oid or switch_to_branch parameters feels like too
much implementation detail to expect the callers to know about.

Unless it is documented in reset.[ch] before the beginning of the
"int reset_head(...)" definition/declaration, that is.

>  			die(_("could not reset --hard"));
>  
>  		if (discard_index(r->index) < 0 ||
> diff --git a/sequencer.h b/sequencer.h
> index 05a7d2ba6b3..da64473636b 100644
> --- a/sequencer.h
> +++ b/sequencer.h
> @@ -197,8 +197,7 @@ void commit_post_rewrite(struct repository *r,
>  			 const struct commit *current_head,
>  			 const struct object_id *new_head);
>  
> -void create_autostash(struct repository *r, const char *path,
> -		      const char *default_reflog_action);
> +void create_autostash(struct repository *r, const char *path);
>  int save_autostash(const char *path);
>  int apply_autostash(const char *path);
>  int apply_autostash_oid(const char *stash_oid);



[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]

  Powered by Linux