Subject: Re: qgit reports errors in the git repository

From: Pavel Roskin <[email-masked]>
Date: Thu, 15 Dec 2005 19:35:49 -0500

On Thu, 2005-12-15 at 20:00 +0100, Marco Costalba wrote:

>  Yes! this is a bug.
> Thanks  for the patch, applied.

Actually, the qgit git repository appear to be broken right now.  First
of all, requests to missing files return code 200 rather that 404.
git-http-fetch crashes trying to parse the returned page as alternates.
I've fixed it.

It's a hack, not a signed patch, please be cautious:

diff --git a/http-fetch.c b/http-fetch.c
index ad59f1c..2767676 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -520,6 +520,8 @@ static void process_alternates_response(
 				}
 			}
 			// skip 'objects' at end
+			okay &= (posn - i > 8);
+			okay &= (strncmp(data + posn - 8, "/objects", 8) == 0);
 			if (okay) {
 				target = xmalloc(serverlen + posn - i - 6);
 				strncpy(target, base, serverlen);
@@ -601,7 +603,7 @@ static void fetch_alternates(char *base)
 	else
 		got_alternates = -1;
 
-	free(data);
+//	free(data);
 	free(url);
 }

The free() was commented out because glibc detects double free and
prints backtrace.  It's Fedora Core 4 on x86_64, all up-to-date.  I
don't see where "data" is freed, maybe it's a bug in glibc.

Even clean fetch of qgit doesn't work:

$ cg-clone http://digilander.libero.it/mcostalba/qgit.git
defaulting to local storage area
Fetching head...
Fetching objects...
progress: 8 objects, 12858 bytes
error: File 8fef66ee82bcbbc26426d21e537478867f648e12 (http://digilander.libero.it/mcostalba/qgit.git/objects/fc/0712e55de18eda32aee44bd7863fee37fc83aa) corrupt

Getting pack list for http://digilander.libero.it/mcostalba/qgit.git/
progress: 11 objects, 76091 bytes
Getting alternates list for http://digilander.libero.it/mcostalba/qgit.git/
error: Unable to find fc0712e55de18eda32aee44bd7863fee37fc83aa under http://digilander.libero.it/mcostalba/qgit.git/

Cannot obtain needed commit fc0712e55de18eda32aee44bd7863fee37fc83aa
while processing commit 5013d718eea0b19a28faebf93eade68127f4b2b4.
Waiting for http://digilander.libero.it/mcostalba/qgit.git/objects/20/35781249a0d6c788e4aef07432c335d9694b9b
progress: 12 objects, 80655 bytes
cg-fetch: objects fetch failed
cg-clone: fetch failed

Anyway, I'm using the latest revision I could get,
9e5ccecbef2a9cb4b75887791b410c0e07d630cc.

> Unfortunatly, regarding the main question on git-cat-file I cannot
> reproduce the bug.

I've made a clean checkout of git using git-fetch:
git-clone git://www.kernel.org/pub/scm/git/git.git

Now qgit complains about 1ed91937e5cd59fdbdfa5f15f6fac132d2b21ce0.

> The problem is that on my box the object
> 23ea3e201cea0deea909569e08e950a9ec2345f7 is
> _never_ fed to git-cat-file because is filtered out ending with "^{}"
> git-ls-remote ./.git |grep 23ea3e201cea0deea909569e08e950a9ec2345f7
> 23ea3e201cea0deea909569e08e950a9ec2345f7        refs/tags/v0.99.9g^{}

Same for me.

> The corresponding tag feeded to git-cat-file is 
> bd67d7d845eb5ae929306dadd3dff41cf04ce004
> 
> I have just made a
> git pull
> git fetch --tags
> 
> from git repository.

OK, "git fetch --tags" made the difference for the old repository!  Now
it also complains about 1ed91937e5cd59fdbdfa5f15f6fac132d2b21ce0.

I was using cogito only on the old repository.  I think cogito doesn't
run "git fetch --tags" or anything equivalent.

> So, please, test with this:
> 
> --- a/src/git_startup.cpp
> +++ b/src/git_startup.cpp
> @@ -111,6 +111,7 @@ bool Git::getRefs() {
>  
>          if (itNext != rLst.constEnd() && (*itNext).right(3) == "^{}")
> {
>              signedTag = true;
> +            dbg(refSha);
>              if (run("git-cat-file tag " + refSha, &runOutput)) {
>                  QString msg(runOutput.section("\n\n", 1));
>                  if (!msg.isEmpty())
> 
> and send me the output. Mine is
[skip]

Both are attached.

-- 
Regards,
Pavel Roskin