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

Re: RFE: support change-id generation natively

From
Nasser Grainawi <nasser@codeaurora.org>
Date
Oct 24, 2013, 04:11 UTC
Message-ID
<8D1AF6D7-F7AA-4E64-B6B3-3C8C931312C3@codeaurora.org>
In-Reply-To
<CACsJy8CuEvdTu+P-P-kYC0dKQKnjh5sRoevd_hsbqF0796i0xw@mail.gmail.com>
On Oct 23, 2013, at 8:07 PM, Duy Nguyen wrote:
Show 26 quoted lines
> On Wed, Oct 23, 2013 at 11:00 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Duy Nguyen <pclouds@gmail.com> writes:
>> 
>>> On Wed, Oct 23, 2013 at 2:50 AM, Junio C Hamano <gitster@pobox.com> wrote:
>>>> It would be just the matter of updating commit_tree_extended() in
>>>> commit.c to:
>>>> 
>>>> - detect the need to add a new Change-Id: trailer;
>>>> 
>>>> - call hash_sha1_file() on the commit object buffer (assuming that
>>>>   a commit object that you can actually "git cat-file commit" using
>>>>   the change Id does not have to exist anywhere for Gerrit to
>>>>   work---otherwise you would need to call write_sha1_file()
>>>>   instead) before adding Change-Id: trailer;
>>>> 
>>>> - add Change-Id: trailer to the buffer; and then finally
>>>> 
>>>> - let the existing write_sha1_file() to write it out.
>>> 
>>> I'm not objecting special support for Gerrit, but if the change is
>>> just commit_tree_extended() why don't we just ship the commit hook in
>>> a new "Gerrit" template?
>> 
>> It is not clear to me how you envision to make it work.
> 
> I don't have the source code.
Now you do: https://gerrit.googlesource.com/gerrit/+/master/gerrit-server/src/main/resources/com/google/gerrit/server/tools/root/hooks/commit-msg
Show 32 quoted lines
> But the commit-msg hook document [1]
> describes roughly what you wrote below, except the tree part. And I
> suppose the hook has been working fine so far. Reading back the
> original post, James ruled out always-active hooks in general and
> wanted the control per command line. Perhaps we should add
> --no-hooks[=<name>,<name>] to "git commit"? Or maybe it's still
> inconvenient and --change-id is best.
> 
> [1] http://gerrit-documentation.googlecode.com/svn/Documentation/2.0/cmd-hook-commit-msg.html
> 
>> Naïvely thinking, an obvious place to do this kind of thing may be
>> the "commit-msg" hook, where the hook reads what the user prepared,
>> finds that there is no existing "Change-Id:" trailer, and decides to
>> add one.
>> 
>> But what value would it add on that line as the Id?
>> 
>> It wants to use the name of the commit object that would result if
>> it were to return without further editing the given message, but we
>> do not give such a commit object name to the hook, so the hook needs
>> to duplicate the logic to come up with one.  It may be doable (after
>> all, builtin/commit.c is open source), but we do not give the hook
>> the commit object header (i.e. it does not know what the tree,
>> parent(s), author, committer lines would say, nor it does not know
>> if we are going to add an encoding line), so the hook needs to guess
>> what we will put there, too.
> -- 
> Duy
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

Previous: Duy NguyenNext: Duy Nguyen
Message 16 of 24 in “RFE: support change-id generation natively”
  1. james.moger@gitblit.comOct 21, 2013
  2. Jeremy RosenOct 21, 2013
  3. james.moger@gitblit.comOct 21, 2013
  4. Shawn PearceOct 21, 2013
  5. Ondřej BílkaOct 21, 2013
  6. Shawn PearceOct 21, 2013
  7. Thomas KochOct 21, 2013
  8. james.moger@gitblit.comOct 21, 2013
  9. Martin FickOct 21, 2013
  10. Junio C HamanoOct 22, 2013
  11. Pyeron, Jason J CTR (US)Oct 22, 2013
  12. Junio C HamanoOct 22, 2013
  13. Duy NguyenOct 23, 2013
  14. Junio C HamanoOct 23, 2013
  15. Duy NguyenOct 24, 2013
  16. Nasser GrainawiOct 24, 2013
  17. Duy NguyenOct 24, 2013
  18. Johannes SixtOct 24, 2013
  19. james.moger@gitblit.comOct 24, 2013
  20. Thomas KochOct 24, 2013
  21. Duy NguyenOct 24, 2013
  22. Junio C HamanoOct 24, 2013
  23. Johannes SixtOct 25, 2013
  24. Shawn PearceOct 21, 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.