git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC 1/6] tag: read signature
@ 2009-02-22 18:06 Marc-André Lureau
  2009-02-22 18:18 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Marc-André Lureau @ 2009-02-22 18:06 UTC (permalink / raw)
  To: git

Signed-off-by: Marc-Andre Lureau <marcandre.lureau@gmail.com>
---
 tag.c |   11 ++++++++---
 tag.h |    2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/tag.c b/tag.c
index 4470d2b..42e5b22 100644
--- a/tag.c
+++ b/tag.c
@@ -38,9 +38,9 @@ struct tag *lookup_tag(const unsigned char *sha1)

 int parse_tag_buffer(struct tag *item, void *data, unsigned long size)
 {
-	int typelen, taglen;
+	int typelen, taglen, siglen;
 	unsigned char sha1[20];
-	const char *type_line, *tag_line, *sig_line;
+	const char *type_line, *tag_line, *sig_line, *msg_line;
 	char type[20];
 	const char *start = data;

@@ -62,9 +62,12 @@ int parse_tag_buffer(struct tag *item, void *data,
unsigned long size)
 		return -1;

 	sig_line = memchr(tag_line, '\n', size - (tag_line - start));
+	if (!sig_line || memcmp("tagger ", ++sig_line, 7))
+		return -1;
+
+	msg_line = memchr(sig_line, '\n', size - (sig_line - start));
 	if (!sig_line)
 		return -1;
-	sig_line++;

 	typelen = tag_line - type_line - strlen("type \n");
 	if (typelen >= 20)
@@ -73,6 +76,8 @@ int parse_tag_buffer(struct tag *item, void *data,
unsigned long size)
 	type[typelen] = '\0';
 	taglen = sig_line - tag_line - strlen("tag \n");
 	item->tag = xmemdupz(tag_line + 4, taglen);
+	siglen = msg_line - sig_line - strlen("tagger \n");
+	item->signature = xmemdupz(sig_line + 7, siglen);

 	if (!strcmp(type, blob_type)) {
 		item->tagged = &lookup_blob(sha1)->object;
diff --git a/tag.h b/tag.h
index 7a0cb00..bc2cab3 100644
--- a/tag.h
+++ b/tag.h
@@ -9,7 +9,7 @@ struct tag {
 	struct object object;
 	struct object *tagged;
 	char *tag;
-	char *signature; /* not actually implemented */
+	char *signature;
 };

 extern struct tag *lookup_tag(const unsigned char *sha1);
-- 
1.6.2.rc1.28.g05ef4.dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH/RFC 1/6] tag: read signature
  2009-02-22 18:06 [PATCH/RFC 1/6] tag: read signature Marc-André Lureau
@ 2009-02-22 18:18 ` Junio C Hamano
  2009-02-22 18:25   ` Marc-André Lureau
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2009-02-22 18:18 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: git

Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> diff --git a/tag.h b/tag.h
> index 7a0cb00..bc2cab3 100644
> --- a/tag.h
> +++ b/tag.h
> @@ -9,7 +9,7 @@ struct tag {
>  	struct object object;
>  	struct object *tagged;
>  	char *tag;
> -	char *signature; /* not actually implemented */
> +	char *signature;
>  };

I do not speak for Daniel, but I think the original intent of "signature"
is about the GnuPG signature, not the "tagger" field.

And this is not an objection.  The use of GnuPG is accidental and at the
low level of the object layer like this codepath we would not necessarily
want to be married to it.  Grabbing and parsing the tagger field like your
patches 1/6 and 2/6 did would be more appropriate.

But then we would probably want to rename this field "tagger" (and then
the timestamp field you add in the next patch "tagger_date").

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH/RFC 1/6] tag: read signature
  2009-02-22 18:18 ` Junio C Hamano
@ 2009-02-22 18:25   ` Marc-André Lureau
  0 siblings, 0 replies; 3+ messages in thread
From: Marc-André Lureau @ 2009-02-22 18:25 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi

On Sun, Feb 22, 2009 at 8:18 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Marc-André Lureau <marcandre.lureau@gmail.com> writes:
>
>> diff --git a/tag.h b/tag.h
>> index 7a0cb00..bc2cab3 100644
>> --- a/tag.h
>> +++ b/tag.h
>> @@ -9,7 +9,7 @@ struct tag {
>>       struct object object;
>>       struct object *tagged;
>>       char *tag;
>> -     char *signature; /* not actually implemented */
>> +     char *signature;
>>  };
>
> I do not speak for Daniel, but I think the original intent of "signature"
> is about the GnuPG signature, not the "tagger" field.
>
> And this is not an objection.  The use of GnuPG is accidental and at the
> low level of the object layer like this codepath we would not necessarily
> want to be married to it.  Grabbing and parsing the tagger field like your
> patches 1/6 and 2/6 did would be more appropriate.
>
> But then we would probably want to rename this field "tagger" (and then
> the timestamp field you add in the next patch "tagger_date").
>

Yes, I though the same. But when I saw the way it was parsed before
(the value of sig_line), I was not sure about naming.
I agree it would be better to name it "tagger".

regards,

-- 
Marc-André Lureau
Sent from: Helsinki Southern Finland Finland.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-02-22 18:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-22 18:06 [PATCH/RFC 1/6] tag: read signature Marc-André Lureau
2009-02-22 18:18 ` Junio C Hamano
2009-02-22 18:25   ` Marc-André Lureau

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).