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

Re: RFE: support change-id generation natively

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 24, 2013, 20:04 UTC
Message-ID
<xmqqzjpymo4y.fsf@gitster.dls.corp.google.com>
In-Reply-To
<5268B7D6.5050106@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
Show 20 quoted lines
> Am 10/24/2013 7:25, schrieb Duy Nguyen:
>> On Thu, Oct 24, 2013 at 11:11 AM, Nasser Grainawi <nasser@codeaurora.org> wrote:
>>>>> 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
>> 
>> Thanks. So you do have tree sha-1 by running "git write-tree". But at
>> that point I'm not sure if cache-tree is written down to disk yet, so
>> write-tree could be more expensive than necessary (one good point for
>> building --change-id in).
>
> Consider that I make a commit with a change-id. Then I rewrite the commit,
> but keep the change-id. Then I push the rewritten commit to Gerrit. Gerrit
> does not have the objects that the change-id is based on; the change-id is
> just a random number and has no other significance. Right?
>
> Why do you go all the length in computing a change-id instead of just
> pulling 20 bytes from /dev/random?
Very good point.

The quoted script does not necessarily give the right commit object name at least under three scenarios:

 - when we would need to add encoding header, etc.;
 - when we are recording merges (perhaps merges will not get rebased
   in Gerrit workflow and it does not matter what random garbage
   this script added to them).
 - when we record the commit after 1-sec boundary since _gen_ChangeIdInput
   in the script was called.

I wouldn't call the script "buggy", but I tend to agree with you that it is an unnecessarily more complex way to spell "grab 20 random bytes" ;-)

> That said, I don't think that --change-id option that the user must not
> forget to use is any better than a hook that the user must not forget to
> install.
That is why I said this in my first response to this thread:
>> ...  We may even want to
>> introduce commit.changeId boolean configuration variable if we did
>> so.
Previous: Duy NguyenNext: Johannes Sixt
Message 22 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.