git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH] builtin-log: Add options to --coverletter
Date: Fri, 15 May 2009 15:07:43 -0700	[thread overview]
Message-ID: <1242425263.31337.17.camel@Joe-Laptop.home> (raw)
In-Reply-To: <7vljoyrq4z.fsf@alter.siamese.dyndns.org>

On Fri, 2009-05-15 at 14:51 -0700, Junio C Hamano wrote:
> Joe Perches <joe@perches.com> writes:
> 
> > On Fri, 2009-05-15 at 11:11 -0700, Junio C Hamano wrote:
> >> I think it makes sense to let users affect how the short-log in the cover
> >> letter is generated.  I do not think overloading the --cover-letter option
> >> for doing it is the ideal approach, though.
> >
> > OK.  How about this patch?
> 
> I'd suggest...
> 
> > diff --git a/builtin-log.c b/builtin-log.c
> > index 5eaec5d..49fd42a 100644
> > --- a/builtin-log.c
> > +++ b/builtin-log.c
> > @@ -460,6 +460,11 @@ static void add_header(const char *value)
> >  static int thread = 0;
> >  static int do_signoff = 0;
> >  
> > +static int coverletter_wrap = 1;
> 
> Do not change the default behaviour before people agree it is a good
> feature;

This doesn't change the default behavior.
The default is still wrap enabled.

> 	static int coverletter_wrap;
> 
> > +static int coverletter_wrappos = 72;
> > +static int coverletter_indent1 = 2;
> > +static int coverletter_indent2 = 4;
> > +
> >  static int git_format_config(const char *var, const char *value, void *cb)
> >  {
> >  	if (!strcmp(var, "format.headers")) {
> > @@ -668,10 +673,10 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
> >  	strbuf_release(&sb);
> >  
> >  	shortlog_init(&log);
> > -	log.wrap_lines = 1;
> > -	log.wrap = 72;
> > -	log.in1 = 2;
> > -	log.in2 = 4;
> > +	log.wrap_lines = coverletter_wrap;
> > +	log.wrap = coverletter_wrappos;
> > +	log.in1 = coverletter_indent1;
> > +	log.in2 = coverletter_indent2;
> >  	for (i = 0; i < nr; i++)
> >  		shortlog_add_commit(&log, list[i]);
> >  
> > @@ -868,6 +873,15 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
> >  			fmt_patch_suffix = argv[i] + 9;
> >  		else if (!strcmp(argv[i], "--cover-letter"))
> >  			cover_letter = 1;
> > +		else if (!prefixcmp(argv[i], "--cover-letter-wrap=")) {
> > +			if (sscanf(argv[i] + 20, "%d,%d,%d",
> > +				   &coverletter_wrappos,
> > +				   &coverletter_indent1,
> > +				   &coverletter_indent2) <= 0)
> > +				die("Need options for --cover-letter-wrap=");
> > +			if (coverletter_wrappos == 0)
> > +				coverletter_wrap = 0;
> 
> ... lose this "if ()"; if you are asking for --cover-letter-wrap from the
> command line explicitly, you do want the result to be wrapped.
[]
> In order to prepare yourself for change of default in the future (or
> adding configurable defaults), the command line parser (the sscanf()
> above) needs to understand something like "--cover-letter-linewrap=no", in
> addition to the up-to-three integers it currently takes via sscanf().
> Treating "the resulting line should be wrapped at 0 column" as "please do
> not wrap" may work in practice but I do not think it is a good style.

Prefixing "no-" to git arguments seems widely used.

Perhaps:
  --no-cover-letter-wrap
and
  --cover-letter-wrap=pos[,indent1[,indent2]]

  reply	other threads:[~2009-05-15 22:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-15  0:57 [RFC PATCH] builtin-log: Add options to --coverletter Joe Perches
2009-05-15 18:11 ` Junio C Hamano
2009-05-15 20:19   ` Joe Perches
2009-05-15 21:51     ` Junio C Hamano
2009-05-15 22:07       ` Joe Perches [this message]
2009-05-16  2:30         ` Junio C Hamano
2009-05-16  0:46       ` Joe Perches
2009-05-16  2:32         ` Junio C Hamano
2009-05-16  5:07   ` Jeff King
2009-05-16 17:35 ` James Cloos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1242425263.31337.17.camel@Joe-Laptop.home \
    --to=joe@perches.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).