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

Re: [PATCH 2/2] merge-recursive: move make_virtual_commit()'s virtual_id to merge_options

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 4, 2008, 19:03 UTC
Message-ID
<7vy7273f9v.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<f2a1ff8d2fe354265a80534cd7beaaa95c2ffc54.1220463034.git.vmiklos@frugalware.org>
I do not think this one is a good idea.

What does it mean for a two "virtual commits" that are returned from separate calls to make_virtual_commit() to have the same virtual_id?

I do not know offhand if the existing code does something like:
	commit = lookup_commit(commit->object.sha1)
or
	if (hashcmp(commit1->object.sha1, commit2->object.sha1))
        	...

but if there is such a code, I think this change makes the problem "virtual id" has even worse. With the current single function local static "virtual_id", at least during a program's lifetime it is guaranteed that there won't be any two instances of virtual commits created for different purposes that share the same (fake) sha1 value. If you call merge_recursive more than once in your process, using a fresh "struct merge_options" each time, that guarantee is lost with your change.

The only purpose of a "virtual commit", as I understand it, is to allow you to pass a tree resulting from an internal merge to a function that expects you to call with three commit objects to come up with a new tree that is the result of the merge. The code stores a "virtual_id" as a phoney sha1 value in the object, but I do not think the actual value is used for anything but debugging purposes (Alex, Dscho, please correct me as necessary).

Does it hurt if we get rid of virtual_id and always leave the object->sha1 field of virtual commits 0{40} as it is initialized?

I further suspect we _could_ fix the API that requires you to pass three commits to accept three trees instead and get rid of virtual commits altogether, but then we would lose an easy access to the message of commits that are being merged, and we would need to pass these strings as separate parameters (or part of merge_options) --- which might be a good clean-up in a longer run, but I do not think it is absolutely necessary during this round.

Previous: Miklos VajnaNext: Miklos Vajna
Message 13 of 15 in “Move call_depth and index_only to struct merge_options”
  1. 0/2 Move call_depth and index_only to struct merge_optionsMiklos Vajna, Sep 2, 2008
  2. 1/2 merge-recursive: move call_depth to struct merge_optionsMiklos Vajna, Sep 2, 2008
  3. 2/2 merge-recursive: move index_only to struct merge_optionsMiklos Vajna, Sep 2, 2008
  4. Makefile: add merge_recursive.h to LIB_HMiklos Vajna, Sep 2, 2008
  5. Junio C HamanoSep 2, 2008
  6. Makefile: add merge_recursive.h to LIB_HMiklos Vajna, Sep 2, 2008
  7. Junio C HamanoSep 2, 2008
  8. merge-recursive: get rid of the index_only global variableMiklos Vajna, Sep 3, 2008
  9. merge-recursive: move the global obuf to struct merge_optionsMiklos Vajna, Sep 3, 2008
  10. Miklos VajnaSep 3, 2008
  11. 1/2 merge-recursive: move current_{file,directory}_set to struct merge_optionsMiklos Vajna, Sep 3, 2008
  12. 2/2 merge-recursive: move make_virtual_commit()'s virtual_id to merge_optionsMiklos Vajna, Sep 3, 2008
  13. Junio C HamanoSep 4, 2008
  14. merge-recursive: get rid of virtual_idMiklos Vajna, Sep 5, 2008
  15. Junio C HamanoSep 4, 2008

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.