Re: [PATCH v1 2/8] format-patch: confirmation whenever patches exist

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

 



Firmin Martin <firminmartin24@xxxxxxxxx> writes:

> Currently, git-format-patch, along with the option --cover-letter,
> unconditionaly overwrites a cover letter with the same name (if
> present). Although this is a desired behaviour for patches which are
> auto-generated from Git commits log, it might not be the case for a
> cover letter whose the content is meticulously written manually.

True.  But if we require confirmation before overwriting patches,
that would be overall worsening the end-user experience, I am
afraid.  In a 5-patch series with a cover-letter that was formatted,
proofread, corrected with "rebase -i" and then re-formatted, unless
you rephrased the titles of the patches, you'd get prompted once for
the cover letter (which *IS* valuable) and five-times for patches
(which is annoying).

It also is unfortunate that this change does not address another
annoyance after retitling a patch---the stale output from the
previous run is not overwritten with the updated one but is left in
the same directory as the output files from the latest run.

So, while I very much do welcome the motivation, I am not onboard
with this particular design.

> diff --git a/builtin/log.c b/builtin/log.c
> index 6102893fcc..bada3db9eb 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -35,6 +35,7 @@
>  #include "repository.h"
>  #include "commit-reach.h"
>  #include "range-diff.h"
> +#include "prompt.h"
>  
>  #define MAIL_DEFAULT_WRAP 72
>  #define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100
> @@ -959,6 +960,10 @@ static int open_next_file(struct commit *commit, const char *subject,
>  			 struct rev_info *rev, int quiet)
>  {
>  	struct strbuf filename = STRBUF_INIT;
> +	struct strbuf file_exists_prompt = STRBUF_INIT;
> +	const char *yesno;
> +	static int not_prompted = 1;

When the API passes a structure that keeps track of state (like
"struct rev_info *rev", used to hold rev->diffopt.file which is
clearly a state), add a member to it, instead of inventing a
function local static that will hurt reuse of the API you are
touching.  This static variable will make it impossible from a
single process to format two patch series, but if it is made a part
of rev_info, you do not have to introduce such a limitation.



[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