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

Re: fetch and bundle don't work in (semi-)broken repo

From
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date
Oct 20, 2010, 07:41 UTC
Message-ID
<20101020074122.GC28166@pengutronix.de>
In-Reply-To
<alpine.LFD.2.00.1010192154200.2764@xanadu.home>
Hello Nico,
On Tue, Oct 19, 2010 at 11:06:50PM -0400, Nicolas Pitre wrote:
Show 45 quoted lines
> On Tue, 19 Oct 2010, Jonathan Nieder wrote:
> 
> > Nicolas Pitre wrote:
> > 
> > >                                 But ideally you should simply find a 
> > > pack that contains the problematic object in another repository and 
> > > copy it with its index file into the broken repository.
> > 
> > I assume the object is gone for good, but if you have it in another
> > repo that would be interesting, too.
> > 
> > To be clear: I think the important data has been recovered from the
> > broken repo already in the form of patches (right?) so the question
> > at hand is whether it would be possible to teach git to do better at
> > recovering automatically.  Which might depend on the nature of the
> > missing objects.
> 
> Sure.  Given that it is possible to create a patch series, that means 
> that all the important objects are still available.  Therefore Git 
> should be able to produce the pack for the equivalent fetch/bundle as 
> well.
> 
> So the following patch should help.  I hope that Uwe still has a copy of 
> the broken repo to test this patch with.
> 
> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> index f8eba53..691c2f1 100644
> --- a/builtin/pack-objects.c
> +++ b/builtin/pack-objects.c
> @@ -1299,6 +1299,15 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
>  		src->data = read_sha1_file(src_entry->idx.sha1, &type, &sz);
>  		read_unlock();
>  		if (!src->data)
> +			if (src_entry->preferred_base) {
> +				/* 
> +				 * Those objects are not included in the
> +				 * resulting pack.  Be resilient and ignore
> +				 * them, in case the pack could be created
> +				 * nevertheless.
> +				 */
> +				return 0;
> +			}
>  			die("object %s cannot be read",
>  			    sha1_to_hex(src_entry->idx.sha1));
>  		if (sz != src_size)

Doesn't help :-( I added a warning(...) before your return 0, and I don't see it. Probably this means this is not the problematic code path.

The output with your patch applied is:
	user@hostname:~/path/linux-2.6$ ~/gsrc/git/bin-wrappers/git bundle create tra linus/master..sectionmismatches
	Counting objects: 118, done.
	error: unable to find 40aaeb204dc04d3cf15c060133f65538b43b13b0
	Delta compression using up to 8 threads.
	fatal: object 3cf4fa25ab3d078a49e9488effaebf571fa128da cannot be read
	error: pack-objects died
If you want I can provide you the broken repo.

Best regards Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Previous: Nicolas PitreNext: Nicolas Pitre
Message 7 of 12 in “fetch and bundle don't work in (semi-)broken repo”
  1. Uwe Kleine-KönigOct 19, 2010
  2. Jonathan NiederOct 19, 2010
  3. Uwe Kleine-KönigOct 19, 2010
  4. Nicolas PitreOct 19, 2010
  5. Jonathan NiederOct 19, 2010
  6. Nicolas PitreOct 20, 2010
  7. Uwe Kleine-KönigOct 20, 2010
  8. Nicolas PitreOct 20, 2010
  9. Uwe Kleine-KönigOct 20, 2010
  10. format-patch broken [Was: fetch and bundle don't work in (semi-)broken repo]Uwe Kleine-König, Oct 21, 2010
  11. Uwe Kleine-KönigOct 21, 2010
  12. Nicolas PitreOct 22, 2010

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.