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

Re: [PATCH] commit: Add -f, --fixes <commit> option to add Fixes: line

From
Christian Couder <christian.couder@gmail.com>
Date
Nov 2, 2013, 12:54 UTC
Message-ID
<CAP8UFD0RvFo9cHm56+_HFOt2NOvqF0i=65irYd_0-TUbKm4WBA@mail.gmail.com>
In-Reply-To
<CALKQrgdo=RP6vgCUML_L_NPsvSbg8Lyjy4HqmWYXk+NmWOjCvw@mail.gmail.com>
On Wed, Oct 30, 2013 at 8:07 PM, Johan Herland <johan@herland.net> wrote:
Show 19 quoted lines
> On Tue, Oct 29, 2013 at 7:23 AM, Christian Couder
> <christian.couder@gmail.com> wrote:
>>
>> I don't agree. Git doesn't need to dictate anything to be able to do
>> these expansions.
>> Git only needs some hints to do these expansions properly and it could
>> just look at the commit template, or the config, to get those hints.
>>
>> For example, if there is a "Acked-by:" line in the commit template,
>> then Git might decide that "ack" means "Acked-by", and then that "-by"
>> means that "Peff" should be related to an author, and then that it is
>> probably "Jeff King <peff@peff.net>".
>
> I don't like putting that much Magic into core Git... Especially not
> into builtin/commit.c. However, if we - as you suggest further below -
> put it into a separate helper, and we make that helper available (and
> usable) from elsewhere (most importantly from hooks where
> people/projects can add their own more specific functionality), then I
> don't have a problem with it.

Ok, great! I started working on "git interpret-trailers" and I will post an RFC patch soon. It will support both configuration as Junio suggested and reading a commit template file as you suggested.

Show 60 quoted lines
>> Ok, let's call the new plumbing command "git interpret-trailers".
>> And let's suppose that "git commit" is passed "-f ack:Peff -f
>> fix:security-bug" (or "--trailer ack=Peff --trailer
>> fix=security-bug").
>>
>> "git commit" would then call something like:
>>
>> git interpret-trailers --file commit_message_template.txt 'ack:Peff'
>> 'fix:security-bug'
>>
>> And this command would output:
>>
>> ------------------
>> <<<upper part of commit_message_template.txt>>>
>>
>> Fixes: 1234beef56 (Commit message summmary)
>> Reported-by:
>> Suggested-by:
>> Improved-by:
>> Acked-by: Jeff King <peff@peff.net>
>> Reviewed-by:
>> Tested-by:
>> Signed-off-by: Myself <myself@example.com>
>> ------------------
>>
>> Because it would have looked at the commit template it is passed and
>> filled in the blanks it could fill using the arguments it is also
>> passed.
>>
>> "git commit" would then put the above lines in the file that it passes
>> to the prepare-commit-msg hook.
>>
>> Then the prepare-commit-msg could just do nothing.
>>
>> After the user has edited the commit message, the commit-msg hook
>> could just call:
>>
>> git interpret-trailers --trim-empty --file commit_message.txt
>>
>> so that what the user changed is interpreted again.
>>
>> For example if the user changed the "Reviewed-by:" line to
>> "Reviewed-by: Johan", then the output would be:
>>
>> ------------------
>> <<<upper part of commit_message.txt>>>
>>
>> Fixes: 1234beef56 (Commit message summmary)
>> Acked-by: Jeff King <peff@peff.net>
>> Reviewed-by: Johan Herland <johan@herland.net>
>> Signed-off-by: Myself <myself@example.com>
>> ------------------
>>
>> And that would be the final commit message in most cases.
>
> This approach looks OK to me, as long as we make sure that this
> functionality is (a) optional, (b) flexible/reusable from hooks, and
> (c) not bound tightly to core Git (and AFAICS, your proposal is just
> that). As I said above, this stuff certainly does not belong in
> builtin/commit.c...
Ok, I think it will be very easy to do all with "git interpret-trailers".

Best regards, Christian.

Previous: Johan HerlandNext: Stefan Beller
Message 17 of 49 in “commit: Add -f, --fixes <commit> option to add Fixes: line”
  1. commit: Add -f, --fixes <commit> option to add Fixes: lineJosh Triplett, Oct 27, 2013
  2. Michael HaggertyOct 27, 2013
  3. Theodore Ts'oOct 27, 2013
  4. Josh TriplettOct 27, 2013
  5. Michel LespinasseOct 27, 2013
  6. Josh TriplettOct 27, 2013
  7. Thomas RastOct 27, 2013
  8. Josh TriplettOct 27, 2013
  9. Johan HerlandOct 27, 2013
  10. Christian CouderOct 27, 2013
  11. Johan HerlandOct 28, 2013
  12. Thomas RastOct 28, 2013
  13. Jeff KingOct 29, 2013
  14. Johan HerlandOct 30, 2013
  15. Christian CouderOct 29, 2013
  16. Johan HerlandOct 30, 2013
  17. Christian CouderNov 2, 2013
  18. Stefan BellerOct 27, 2013
  19. Thomas RastOct 27, 2013
  20. Stefan BellerOct 27, 2013
  21. Stefan BellerOct 31, 2013
  22. Documentation: add a script to generate a (long/short) options overviewStefan Beller, Oct 31, 2013
  23. Stefan BellerOct 31, 2013
  24. brian m. carlsonOct 31, 2013
  25. Junio C HamanoNov 1, 2013
  26. Michael HaggertyOct 28, 2013
  27. Johan HerlandOct 28, 2013
  28. Jeff KingOct 29, 2013
  29. Matthieu MoyOct 29, 2013
  30. Johan HerlandOct 30, 2013
  31. Duy NguyenOct 31, 2013
  32. Junio C HamanoOct 31, 2013
  33. Duy NguyenOct 31, 2013
  34. Johan HerlandNov 1, 2013
  35. Duy NguyenOct 27, 2013
  36. Josh TriplettOct 27, 2013
  37. Jim HillOct 28, 2013
  38. Junio C HamanoOct 28, 2013
  39. Josh TriplettOct 28, 2013
  40. Michael HaggertyOct 28, 2013
  41. Christoph HellwigOct 28, 2013
  42. Benjamin HerrenschmidtOct 28, 2013
  43. Russell King - ARM LinuxOct 28, 2013
  44. Russell King - ARM LinuxOct 28, 2013
  45. Junio C HamanoOct 28, 2013
  46. Christian CouderOct 29, 2013
  47. Junio C HamanoOct 29, 2013
  48. Tony LuckOct 30, 2013
  49. Junio C HamanoOct 30, 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.