~kornellapacz/public-inbox

4 2

Re: [gmnigit] object not found during refs page generation

Omar Polo
Details
Message ID
<87y2d5nufk.fsf@omarpolo.com>
DKIM signature
pass
Download raw message
Korneliusz Łapacz <lapacz.kornel@gmail.com> writes:

> Unfortunately I got same error with your repository and I have idea why. If
> I find out I will tell you.

I've got an idea, but I haven't had the time to verify.  That tag is an
annotated one, while the other repos had only lightweight tags.  IIRC
lightweight tags are pointers to commits, while the annotated ones are
full git objects.  Maybe that's the reason?

> I am impressed by your work! I will use gmid server as soon as I migrate
> my debian server to alpine linux (for now I am using gmnisrv). Sorry for
> off topic but do you consider implementing reverse proxy in your server
> (if it is possible with gemini, some servers implement that but as far as
> I know they don't proxy client certificates)

Thanks :)

I don't think is possible to relay the client certificates, since
they're sent as part of the initial TLS handshake; for those you'd
better use CGI or FastCGI.

There is an additional advantage of FastCGI over proxying: less crypto
involved.  You don't have to establish TLS connection between your
server and your backend to serve a request; since Gemini doesn't support
"keepalive" or session resumption, opening a connection is a moderately
heavy operation.

[ gmid only supports CGI as of now, but FastCGI is planned :) ]


Cheers,

Omar Polo

Re: [gmnigit] object not found during refs page generation

Omar Polo
Details
Message ID
<874kfq1p8v.fsf@omarpolo.com>
In-Reply-To
<87y2d5nufk.fsf@omarpolo.com> (view parent)
DKIM signature
pass
Download raw message
Omar Polo <op@omarpolo.com> writes:

> Korneliusz Łapacz <lapacz.kornel@gmail.com> writes:
>
>> Unfortunately I got same error with your repository and I have idea why. If
>> I find out I will tell you.
>
> I've got an idea, but I haven't had the time to verify.  That tag is an
> annotated one, while the other repos had only lightweight tags.  IIRC
> lightweight tags are pointers to commits, while the annotated ones are
> full git objects.  Maybe that's the reason?

I took another look and yes, this is exactly the reason.  While an
lightweight tag is a pointer to a commit (just like a branch), an
annotated one is a full git object which stores author info, the pgp
signature and a pointer to the commit.  So,

> c, err := r.CommitObject(ref.Hash())

will obviously fail for an annotated tags, since its hash is not a
pointer to a commit.

I don't know how I missed it, but this is why.  There is a
repository.TagObject() to resolve an annotated one, I'll send a patch
soon.

Cheers,

Omar Polo

Re: [gmnigit] object not found during refs page generation

Omar Polo
Details
Message ID
<87im46fp6z.fsf@omarpolo.com>
In-Reply-To
<874kfq1p8v.fsf@omarpolo.com> (view parent)
DKIM signature
pass
Download raw message
Omar Polo <op@omarpolo.com> writes:

> Omar Polo <op@omarpolo.com> writes:
>
>> Korneliusz Łapacz <lapacz.kornel@gmail.com> writes:
>>
>>> Unfortunately I got same error with your repository and I have idea why. If
>>> I find out I will tell you.
>>
>> I've got an idea, but I haven't had the time to verify.  That tag is an
>> annotated one, while the other repos had only lightweight tags.  IIRC
>> lightweight tags are pointers to commits, while the annotated ones are
>> full git objects.  Maybe that's the reason?
>
> I took another look and yes, this is exactly the reason.  While an
> lightweight tag is a pointer to a commit (just like a branch), an
> annotated one is a full git object which stores author info, the pgp
> signature and a pointer to the commit.  So,
>
>> c, err := r.CommitObject(ref.Hash())
>
> will obviously fail for an annotated tags, since its hash is not a
> pointer to a commit.
>
> I don't know how I missed it, but this is why.  There is a
> repository.TagObject() to resolve an annotated one, I'll send a patch
> soon.
>
> Cheers,
>
> Omar Polo

Shame on me, I should have followed the go-git documentation more
closely ^_^;

The following should handle both annotated and lightweight tags.


-----------------------------------------------
commit 9603aa27456e9729ceabd469bb2e504055e16497 (master)
from: Omar Polo <op@omarpolo.com>
diff 282b8aef2031c6b45d72e2f09d1d5fc26306d05d ca2b99423d4d3f053f10bfbdd9c9c66c4795158c
blob - 4cf2551fd23b8c090bd39a0003ce67f4ac2ea345
blob + 03e78624e4206c6d7c72021e3dfb1273812532e8
--- commits.go
+++ commits.go
@@ -86,15 +86,30 @@ func createRefsFile(r *git.Repository) {
 	iter, err := r.Tags()
 	check(err)
 	err = iter.ForEach(func(ref *plumbing.Reference) error {
-		c, err := r.CommitObject(ref.Hash())
-		if err != nil {
+		var c *object.Commit
+
+		hash := ref.Hash()
+		obj, err := r.TagObject(hash)
+		switch err {
+		case nil:
+			// an annotated tag
+			if c, err = r.CommitObject(obj.Target); err != nil {
+				return err
+			}
+			hash = obj.Target
+		case plumbing.ErrObjectNotFound:
+			// a lightweight tag
+			if c, err = r.CommitObject(hash); err != nil {
+				return err
+			}
+		default:
 			return err
 		}
 
 		tag := fmt.Sprintf(
 			"=> ../%s/%s.patch %s - %s",
 			commitsSubPath,
-			ref.Hash(),
+			hash,
 			c.Author.When.Format("2006-01-02"),
 			filepath.Base(ref.Name().String()),
 		)

Re: [gmnigit] object not found during refs page generation

Details
Message ID
<CAZLN1Z2GD5K.2DA4UWZT30G9B@thinkpad>
In-Reply-To
<87im46fp6z.fsf@omarpolo.com> (view parent)
DKIM signature
pass
Download raw message
I appreciate your contribution. Could you provide commit message for your
patch? I will push it :)

Thanks in advance,
Korneliusz Łapacz

Re: [gmnigit] object not found during refs page generation

Omar Polo
Details
Message ID
<87k0olv9dj.fsf@omarpolo.com>
In-Reply-To
<CAZLN1Z2GD5K.2DA4UWZT30G9B@thinkpad> (view parent)
DKIM signature
pass
Download raw message
Korneliusz Łapacz <lapacz.kornel@gmail.com> writes:

> I appreciate your contribution. Could you provide commit message for your
> patch? I will push it :)
>
> Thanks in advance,
> Korneliusz Łapacz

Yeah, sorry.  I was playing with got and its output doesn't seem to play
well with git am, apologies.

Here's a proper diff with a commit message :)
Reply to thread Export thread (mbox)