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

Re: What's cooking in git.git (Dec 2008, #04; Mon, 29)

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 3, 2009, 10:31 UTC
Message-ID
<7vhc4gadg9.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<200901030640.36426.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 20 quoted lines
> Le mardi 30 décembre 2008, Junio C Hamano a écrit :
>>
>> * cc/bisect-replace (Mon Nov 24 22:20:30 2008 +0100) 9 commits
>>  - bisect: add "--no-replace" option to bisect without using replace
>>    refs
>>  - rev-list: make it possible to disable replacing using "--no-
>>    bisect-replace"
>>  - bisect: use "--bisect-replace" options when checking merge bases
>>  - merge-base: add "--bisect-replace" option to use fixed up revs
>>  - commit: add "bisect_replace_all" prototype to "commit.h"
>>  - rev-list: add "--bisect-replace" to list revisions with fixed up
>>    history
>>  - Documentation: add "git bisect replace" documentation
>>  - bisect: add test cases for "git bisect replace"
>>  - bisect: add "git bisect replace" subcommand
>>
>> I think a mechanism like this should be added to replace grafts, 
>
> The problem with replacing grafts is that a graft can specify many parents 
> for one commit while a ref associates only one object to a name.

Sorry, maybe I misunderstood your implementation. What I thought we discussed during GitTogether was to write out the object name of the replacement object in refs/replace/<sha1>.

When the caller asks read_sha1_file() for an object whose object name is <sha1>, you see if there is refs/replace/<sha1> in the repository, and read the ref to learn the object name of the object that replaces it. And you return that as if it is the original object.

So if your commit cca1704897e7fdb182f68d4c48a437c5d7bc5203 looks like:
    tree 7ccf394b2e80536442703e0013bf0dde86547e08
    parent 3827210b91a7d363ea67bcf0b9c6ee1c91d2f3c5
    author Johannes Schindelin <Johannes.Schindelin@gmx.de> 1230919672 +0100
    committer Junio C Hamano <gitster@pobox.com> 1230931180 -0800
    git wrapper: Make while loop more reader-friendly
    ...

and you would want to lie about its author (or add/subtract different parent lines, or record a fixed-up tree, or whatever), you first prepare a replacement commit object:

    $ R=$(git cat-file commit cca17048 |
      sed -e 's/Johannes /&E /' |
      git hash-object -t commit --stdin -w)
    $ git cat-file commit $R
    tree 7ccf394b2e80536442703e0013bf0dde86547e08
    parent 3827210b91a7d363ea67bcf0b9c6ee1c91d2f3c5
    author Johannes E Schindelin <Johannes.Schindelin@gmx.de> 1230919672 +0100
    committer Junio C Hamano <gitster@pobox.com> 1230931180 -0800
    git wrapper: Make while loop more reader-friendly
    ...
and then tell git to replace the original object with this one:
    $ git update-ref refs/replace/$(git rev-parse cca17048) $R

With such a layout, if your arrange the object reachability traverser (e.g. fsck, pack-objects, bundle and prune) ignore refs/replace mechanism, while everybody else pay attention to it, you will be able to safely transfer the "graft" information via usual clone/fetch/push mechanism, while making things like log, bisect and show just work, pretending as if the commit cca17048 were made by JES and not by JS.

Previous: Christian CouderNext: Christian Couder
Message 6 of 7 in “What's cooking in git.git (Dec 2008, #04; Mon, 29)”
  1. Junio C HamanoDec 30, 2008
  2. Jakub NarebskiDec 30, 2008
  3. Miklos VajnaDec 31, 2008
  4. Junio C HamanoDec 31, 2008
  5. Christian CouderJan 3, 2009
  6. Junio C HamanoJan 3, 2009
  7. Christian CouderJan 4, 2009

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.