# git and gitweb inconsistencies

4 messages from 2005-10-23 to 2005-10-23. Participants: Chris Shoemaker, Sven Verdoolaege.
Thread: https://gitlist.dev/t/2192

## Chris Shoemaker, 2005-10-23 00:14

Subject: git and gitweb inconsistencies
Message-ID: <20051023001412.GA22679@pe.Belkin>
URL: https://gitlist.dev/e/20051023001412.GA22679%40pe.Belkin

```
I've been experimenting with git and gitweb, but I've reached deadend.
Maybe someone can help?


Short Version:

In sub git_get_type in gitweb.cgi, this line:
  open my $fd, "-|", "$gitbin/git-cat-file -t $hash" or return;

results in:
error: unable to find e71b869f3333ad10a492251e099ed9176248a420
fatal: git-cat-file e71b869f3333ad10a492251e099ed9176248a420: bad file

BUT, from the shell:
$ git-cat-file -t e71b869f3333ad10a492251e099ed9176248a420
commit


Longer explanation:

Initially I created the git repository using git-cvsimport as
described in the cvs-migration document.  I also installed gitweb.cgi
and everything seemed to be fine.  In particular the refs/heads/* files
referred to the tips of current branches in cvs.  I was quite pleased.

A few days later, I ran git-cvsimport again, with -i.  This imported
just the recent changes, but the view from gitweb didn't change.  :(

At first, I thought that the git-cvsimport hadn't worked.  But,
git-whatchanged clearly showed the new changes.  (I later learned that
git-rev-list also returned the tip-of-branch commits.)  After reading
gitweb.cgi, I realized that the refs/heads/* files had not been
changed, so they still referred to the tip-of-branch for the initial
import.  (I expected the refs/heads/* to point to the last commit on
each branch.  Was that wrong?)

Anyway, I tried to make a new head that actually pointed to what I
expected: 

$ echo `git-rev-list tip --max-count=1` > refs/heads/mytest
$ git-cat-file -t `cat refs/heads/mytest`
commit

No problem.  But, this same task doesn't seem to work from gitweb.cgi:

$ ./gitweb.cgi http://localhost/cgi-bin/gitweb.cgi?p=test\;a=heads > /dev/null
error: unable to find e71b869f3333ad10a492251e099ed9176248a420
fatal: git-cat-file e71b869f3333ad10a492251e099ed9176248a420: bad file

How can this be?  Have I messed something up, or am I just totally confused?

-chris

ps. please cc, not subscribed.

```

## Sven Verdoolaege, 2005-10-23 11:59

Subject: Re: git and gitweb inconsistencies
Message-ID: <20051023115939.GG8383MdfPADPa@greensroom.kotnet.org>
URL: https://gitlist.dev/e/20051023115939.GG8383MdfPADPa%40greensroom.kotnet.org
In-Reply-To: <20051023001412.GA22679@pe.Belkin>

```
On Sat, Oct 22, 2005 at 08:14:12PM -0400, Chris Shoemaker wrote:
> A few days later, I ran git-cvsimport again, with -i.  This imported
> just the recent changes, but the view from gitweb didn't change.  :(

Are you sure you didn't just create a new import *inside* the old import ?
Do you have, say, both an 'objects' and a '.git/objects' directory ?

> $ echo `git-rev-list tip --max-count=1` > refs/heads/mytest
> $ git-cat-file -t `cat refs/heads/mytest`

That should be

git-update-ref refs/heads/mytest tip
(the new head will appear in .git/refs/heads/mytest, 
unless you've set GIT_DIR)
git-cat-file -t mytest


skimo

```

## Chris Shoemaker, 2005-10-23 17:30

Subject: Re: git and gitweb inconsistencies
Message-ID: <20051023173055.GA3019@pe.Belkin>
URL: https://gitlist.dev/e/20051023173055.GA3019%40pe.Belkin
In-Reply-To: <20051023115939.GG8383MdfPADPa@greensroom.kotnet.org>

```
On Sun, Oct 23, 2005 at 01:59:39PM +0200, Sven Verdoolaege wrote:
> On Sat, Oct 22, 2005 at 08:14:12PM -0400, Chris Shoemaker wrote:
> > A few days later, I ran git-cvsimport again, with -i.  This imported
> > just the recent changes, but the view from gitweb didn't change.  :(
> 
> Are you sure you didn't just create a new import *inside* the old import ?
> Do you have, say, both an 'objects' and a '.git/objects' directory ?

OH!  You, sir, DO have a crystal ball.  :) 

I foolishly assumed that the second time I ran git-cvsimport, with -C
/pub/scm/project/ it would be able to detect that I was using the
stand-alone GIT-DIR.  But, it obviously didn't.  I guess the solution
is use specify GIT_DIR everytime I run git-cvstimport.

So, it seems that git-web.cgi detects and prefers the stand-alone
directory structure, because I specify it in the projects_list file,
while git-cat-file, and git-update-ref default to using .git.

> 
> > $ echo `git-rev-list tip --max-count=1` > refs/heads/mytest
> > $ git-cat-file -t `cat refs/heads/mytest`
> 
> That should be
> 
> git-update-ref refs/heads/mytest tip
> (the new head will appear in .git/refs/heads/mytest, 
> unless you've set GIT_DIR)
> git-cat-file -t mytest

Ah, and if I'd used that command, I would have realized something was
wrong when mytest *didn't* appear in refs/heads, but rather
.git/refs/heads.

Thanks for thinking creatively about how I could have messed it up!

-chris

> 
> 
> skimo

```

## Sven Verdoolaege, 2005-10-23 18:28

Subject: Re: git and gitweb inconsistencies
Message-ID: <20051023182800.GH8383MdfPADPa@greensroom.kotnet.org>
URL: https://gitlist.dev/e/20051023182800.GH8383MdfPADPa%40greensroom.kotnet.org
In-Reply-To: <20051023173055.GA3019@pe.Belkin>

```
On Sun, Oct 23, 2005 at 01:30:55PM -0400, Chris Shoemaker wrote:
> I foolishly assumed that the second time I ran git-cvsimport, with -C
> /pub/scm/project/ it would be able to detect that I was using the
> stand-alone GIT-DIR.  But, it obviously didn't.  I guess the solution
> is use specify GIT_DIR everytime I run git-cvstimport.

Since many of the core git tools try to detect the actual git dir,
it might not be a bad idea for cvsimport to do this as well.
It probably also shouldn't create a new git repository if the -i
option has been specified.

> So, it seems that git-web.cgi detects and prefers the stand-alone
> directory structure, because I specify it in the projects_list file,
> while git-cat-file, and git-update-ref default to using .git.

gitweb just sets GIT_DIR and then the core git tools won't guess.

skimo

```
