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

Re: [QUESTION] about .git/info/grafts file

From
Junio C Hamano <junkio@cox.net>
Date
Jan 20, 2006, 17:59 UTC
Message-ID
<7v4q3ybx0m.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<cda58cb80601200207g7c3495ddx@mail.gmail.com>
Franck <vagabon.xyz@gmail.com> writes:
Show 5 quoted lines
> 2006/1/20, Junio C Hamano <junkio@cox.net>:
>
>>         $ git clone git.git junk
>>         $ cd junk ;# I am not brave enough to risk the real thing ;-)
>>         $ git rev-parse master~4 >.git/refs/info/grafts
Typo: 	's|.git/refs/info/grafts|.git/info/grafts|'

BTW the above exact sequence will not work with my "master" today, since I merged up bunch of things last night. You have to cauterize all the paths that lead to earlier history. For example, if I have this:

   ---o---o---x---o---o---o---o (master)
       \         /
        o---o---o

cauterizing at master~4 ('x') will still leak history via the side branch, if you follow the history from the tip and go backwards. I have to also cauterize the merge commit after that to remove the side branch, or cauterize the leftmost branch point and live with a bit deeper history. The choice depends on how much real history I want to keep in the pruned history.

For example, to pretend the history was like this:
   ---o---o   x---o---o---o---o (master)
       \         
        o---o---o
	$ git rev-parse master~4 >.git/info/grafts ;# 'x'
        $ git rev-parse master~3 master~4 >.git/info/grafts

The second line says master~3 (the one that comes after 'x') has only a single parent, which is master~4, in order to throw the side branch away [*1*].

Back to the original example...
Show 6 quoted lines
>>         $ cd ..
>>         $ mkdir cloned
>>         $ cd cloned
>>         $ git init-db
>>         $ cp ../junk/.git/info/grafts .git/info/
>>         $ git clone-pack ../baz

There are a couple of typos here and that was the reason your experiment did not work. Sorry. The "clone-pack" should have been like this:

        $ git clone-pack ../junk master
        Packing 471 objects
        e7555785f4edcf4988c53305349e3f525216e2cb refs/heads/master
	$ git-rev-parse e7555785f >.git/refs/heads/master
This 'cloned' is the lightweight one.
> does the git protocol is really needed in your example ? or can rsync
> work fine too since "franck.git" repo is cautorized so every objects
> of this repo shouldn't be part of old history, so they should be
> usefull, no ?

rsync may for the initial clone but its use afterwards is frowned upon for other reasons these days.

[Footnote]

*1* There still is an anomaly if you look at "git log" after pruning side branch this way; master~3 commit is still shown as "merge". I think you could call it a bug, but I am not sure it is worth fixing.

Previous: Franck
Message 21 of 21 in “[QUESTION] about .git/info/grafts file”
  1. FranckJan 17, 2006
  2. FranckJan 18, 2006
  3. Junio C HamanoJan 19, 2006
  4. FranckJan 19, 2006
  5. Petr BaudisJan 19, 2006
  6. Linus TorvaldsJan 19, 2006
  7. FranckJan 19, 2006
  8. Linus TorvaldsJan 19, 2006
  9. Junio C HamanoJan 19, 2006
  10. Junio C HamanoJan 19, 2006
  11. FranckJan 20, 2006
  12. Andreas EricssonJan 19, 2006
  13. Petr BaudisJan 19, 2006
  14. FranckJan 19, 2006
  15. Andreas EricssonJan 19, 2006
  16. Petr BaudisJan 19, 2006
  17. Petr BaudisJan 19, 2006
  18. Ryan AndersonJan 20, 2006
  19. Junio C HamanoJan 20, 2006
  20. FranckJan 20, 2006
  21. Junio C HamanoJan 20, 2006

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.