git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 2/4] format-patch: improve head calculation for cover-letter

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 7, 2013, 07:50 UTC
Message-ID
<7vbo9q93u2.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1365318630-11882-3-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
> If we do it after the revision traversal we can be sure that this is
> indeed a commit that will be processed (i.e. not a merge) and it's the
> top most one (thus removing the NEEDSWORK comment).

There may not be a single top-most one anyway (which is what that "randomly pick" comment refers to and punts), so taking the tip after traversal is just as good as doing it before. So this is a good change, but it still is punting.

The "head" is used only to produce the fake "From xxxxx <datestamp>" line to mark the output as format-patch output to /etc/magic, so it does not make sense to do anything fancier, like erroring out with "You specified two or more tips and we cannot pick one".

So it is a good thing to punt.
I like this simplification.  Good job.
Show 25 quoted lines
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  builtin/log.c | 20 ++------------------
>  1 file changed, 2 insertions(+), 18 deletions(-)
>
> diff --git a/builtin/log.c b/builtin/log.c
> index 8f0b2e8..6c78d7f 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -1319,24 +1319,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>  	rev.show_root_diff = 1;
>  
>  	if (cover_letter) {
>  		if (!branch_name)
>  			branch_name = find_branch_name(&rev);
>  	}
> @@ -1372,6 +1354,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>  		list = xrealloc(list, nr * sizeof(list[0]));
>  		list[nr - 1] = commit;
>  	}
> +	if (nr > 0)
> +		head = list[0];
>  	total = nr;
>  	if (!keep_subject && auto_number && total > 1)
>  		numbered = 1;
Previous: Felipe ContrerasNext: Felipe Contreras
Message 8 of 21 in “send-email: couple of improvements”
  1. 0/4 send-email: couple of improvementsFelipe Contreras, Apr 7, 2013
  2. 1/4 send-email: make annotate configurableFelipe Contreras, Apr 7, 2013
  3. Junio C HamanoApr 7, 2013
  4. Felipe ContrerasApr 7, 2013
  5. Junio C HamanoApr 7, 2013
  6. Felipe ContrerasApr 7, 2013
  7. 2/4 format-patch: improve head calculation for cover-letterFelipe Contreras, Apr 7, 2013
  8. Junio C HamanoApr 7, 2013
  9. Felipe ContrerasApr 7, 2013
  10. 3/4 format-patch: refactor branch name calculationFelipe Contreras, Apr 7, 2013
  11. 4/4 format-patch: add format.cover-letter configurationFelipe Contreras, Apr 7, 2013
  12. Junio C HamanoApr 7, 2013
  13. Felipe ContrerasApr 7, 2013
  14. Junio C HamanoApr 7, 2013
  15. Felipe ContrerasApr 7, 2013
  16. Matthieu MoyApr 7, 2013
  17. Felipe ContrerasApr 7, 2013
  18. Matthieu MoyApr 7, 2013
  19. Felipe ContrerasApr 7, 2013
  20. Junio C HamanoApr 7, 2013
  21. Felipe ContrerasApr 7, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.