git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Jon Seymour <jon.seymour@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	"Jakub Narebski <jnareb@gmail.com> Christian Couder" 
	<chriscool@tuxfamily.org>
Subject: Re: RFC: Should git gc/repack respect .git/refs/replace?
Date: Sat, 23 Jul 2011 02:22:24 -0700 (PDT)	[thread overview]
Message-ID: <m3ipqts671.fsf@localhost.localdomain> (raw)
In-Reply-To: <CAH3AnrqDbebODK-A90msoB9JXUwDHKKtQAQo5VdXZ=k8bxzkYQ@mail.gmail.com>

Jon Seymour <jon.seymour@gmail.com> writes:

> I recently damaged a USB drive containing an archive of a finished project.
> 
> I am able to paper over a week of missing history by using the git
> replace mechanism, so that git rev-list now works as expected.
> 
> When I run git gc or git repack, I get the following:
> 
>    error: Could not read 023a1d5d3977420ba041cb556c0eee17c326aeb6
>    fatal: Failed to traverse parents of commit
> 44d578ea81f7a90989e2ee3c676f50e3aff7071f
> 
> where 0bbded9a764d9f4c8dc27b778f70d044df65f65f is one of the missing
> commits I replaced with:
> 
>    git replace 023a1d5d3977420ba041cb556c0eee17c326aeb6
> 238d237db9137b4eaf96f1d554bf2668729b9b93
> 
> Is this expected behaviour? I had assumed that git repack would
> respect the topology implied by git replace.

This is the expected behavior. 

Replace mechanism is meant to be transferable and safe wrt. repacking.
Therefore repack should not remove commits hidden by replacement
objects, otherwise if you push to repository instance that doesn't
have replace refs, you would get corrupt repository.  

As replace mechanism uses ordinary refs, therefore replaced object are
safe against repacking / pruning and transferrable in the same way as
other refs.


If you want paper over missing history, you need to use GRAFTS, not
replace objects.

> 
> Some other differences:
> 
>     git cat-file commit 023a1d5d3977420ba041cb556c0eee17c326aeb6
> 
> produces the expected output (that is the same as git cat-file commit
> 238d237db9137b4eaf96f1d554bf2668729b9b93), but
> 
>    git cat-file commit -t 023a1d5d3977420ba041cb556c0eee17c326aeb6

Errr... isn't it

     git cat-file -t 023a1d5d3977420ba041cb556c0eee17c326aeb6

> 
> fails with:
> 
>    error: unable to find 023a1d5d3977420ba041cb556c0eee17c326aeb6
>    fatal: git cat-file 023a1d5d3977420ba041cb556c0eee17c326aeb6: bad file

Hmmm... that looks like bug, assuming that you didn't make mistake in
writing command.

BTW. do git-cat-file respect replace object, or is it only git-show
that respect them?
 
> In my view, it seems reasonable that git repack should tolerate repos
> that have replace references in them otherwise you can never recover
> unused space.

Replace are not meant for this.  You can use grafts instead, but they
are not transferable in-band, so forget about sharing repository if
you do surgery on it like that...

-- 
Jakub Narebski

      parent reply	other threads:[~2011-07-23  9:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-23  8:39 RFC: Should git gc/repack respect .git/refs/replace? Jon Seymour
2011-07-23  9:20 ` Andreas Schwab
2011-07-23  9:25   ` Jon Seymour
2011-07-23  9:22 ` Jakub Narebski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3ipqts671.fsf@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=jon.seymour@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).