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

Re: [PATCH v4 2/3] builtin/commit.c: refactor --trailer logic

From
Patrick Steinhardt <ps@pks.im>
Date
May 2, 2024, 06:27 UTC
Message-ID
<ZjMySkLSUKKEiF_H@tanuki>
In-Reply-To
<8f53a54bbfe9a952ae5e86216681eef2a2e916eb.1714488111.git.gitgitgadget@gmail.com>
On Tue, Apr 30, 2024 at 02:41:50PM +0000, John Passaro via GitGitGadget wrote:
> From: John Passaro <john.a.passaro@gmail.com>
[snip]
Show 10 quoted lines
> diff --git a/trailer.c b/trailer.c
> index c72ae687099..ae0597d919e 100644
> --- a/trailer.c
> +++ b/trailer.c
> @@ -1170,3 +1170,14 @@ void trailer_iterator_release(struct trailer_iterator *iter)
>  	strbuf_release(&iter->val);
>  	strbuf_release(&iter->key);
>  }
> +
> +int amend_file_with_trailers(const char *path, const struct strvec *trailer_args) {
Nit: the opening brace should go on the next line.
Other than that this patch looks good to me.
Patrick
Show 37 quoted lines
> +	struct child_process run_trailer = CHILD_PROCESS_INIT;
> +
> +	run_trailer.git_cmd = 1;
> +	strvec_pushl(&run_trailer.args, "interpret-trailers",
> +		     "--in-place", "--no-divider",
> +		     path, NULL);
> +	strvec_pushv(&run_trailer.args, trailer_args->v);
> +	return run_command(&run_trailer);
> +}
> diff --git a/trailer.h b/trailer.h
> index 9f42aa75994..c364405267a 100644
> --- a/trailer.h
> +++ b/trailer.h
> @@ -4,6 +4,8 @@
>  #include "list.h"
>  #include "strbuf.h"
>  
> +struct strvec;
> +
>  enum trailer_where {
>  	WHERE_DEFAULT,
>  	WHERE_END,
> @@ -158,4 +160,11 @@ int trailer_iterator_advance(struct trailer_iterator *iter);
>   */
>  void trailer_iterator_release(struct trailer_iterator *iter);
>  
> +/*
> + * Augment a file to add trailers to it by running git-interpret-trailers.
> + * This calls run_command() and its return value is the same (i.e. 0 for
> + * success, various non-zero for other errors). See run-command.h.
> + */
> +int amend_file_with_trailers(const char *path, const struct strvec *trailer_args);
> +
>  #endif /* TRAILER_H */
> -- 
> gitgitgadget
> 
Previous: John Passaro via GitGitGadgetNext: John Passaro via GitGitGadget
Message 27 of 37 in “builtin/tag.c: add --trailer arg”
  1. builtin/tag.c: add --trailer argJohn Passaro via GitGitGadget, Apr 29, 2024
  2. Patrick SteinhardtApr 29, 2024
  3. John PassaroApr 29, 2024
  4. John PassaroApr 29, 2024
  5. Junio C HamanoApr 29, 2024
  6. Junio C HamanoApr 29, 2024
  7. John PassaroApr 29, 2024
  8. Junio C HamanoApr 29, 2024
  9. builtin/tag.c: add --trailer argJohn Passaro via GitGitGadget, Apr 29, 2024
  10. 0/3 builtin/tag.c: add --trailer optionJohn Passaro via GitGitGadget, Apr 29, 2024
  11. 1/3 builtin/commit.c: refactor --trailer logicJohn Passaro via GitGitGadget, Apr 29, 2024
  12. Patrick SteinhardtApr 30, 2024
  13. Junio C HamanoApr 30, 2024
  14. 2/3 builtin/tag.c: add --trailer argJohn Passaro via GitGitGadget, Apr 29, 2024
  15. Patrick SteinhardtApr 30, 2024
  16. Junio C HamanoApr 30, 2024
  17. John PassaroApr 30, 2024
  18. Junio C HamanoApr 30, 2024
  19. John PassaroMay 5, 2024
  20. 3/3 po: update git-tag translationsJohn Passaro via GitGitGadget, Apr 29, 2024
  21. Junio C HamanoApr 29, 2024
  22. John PassaroApr 29, 2024
  23. 0/3 builtin/tag.c: add --trailer optionJohn Passaro via GitGitGadget, Apr 30, 2024
  24. 1/3 builtin/commit.c: remove bespoke option callbackJohn Passaro via GitGitGadget, Apr 30, 2024
  25. Patrick SteinhardtMay 2, 2024
  26. 2/3 builtin/commit.c: refactor --trailer logicJohn Passaro via GitGitGadget, Apr 30, 2024
  27. Patrick SteinhardtMay 2, 2024
  28. 3/3 builtin/tag.c: add --trailer optionJohn Passaro via GitGitGadget, Apr 30, 2024
  29. Patrick SteinhardtMay 2, 2024
  30. 0/3 builtin/tag.c: add --trailer optionJohn Passaro via GitGitGadget, May 5, 2024
  31. 1/3 builtin/commit: use ARGV macro to collect trailersJohn Passaro via GitGitGadget, May 5, 2024
  32. John PassaroMay 7, 2024
  33. Junio C HamanoMay 7, 2024
  34. 2/3 builtin/commit: refactor --trailer logicJohn Passaro via GitGitGadget, May 5, 2024
  35. 3/3 builtin/tag: add --trailer optionJohn Passaro via GitGitGadget, May 5, 2024
  36. Patrick SteinhardtMay 6, 2024
  37. Junio C HamanoMay 6, 2024

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.