Re: [PATCH 2/7] sha1_file, link: write link objects to the database

2013-04-05 Thread Ramkumar Ramachandra
Ramkumar Ramachandra wrote:
> This needs to be replaced by a .git/config parser.  However, I can't
> use the parser from config.c as-it-is, because it expects a section
> like [core] to be present.  So, we have to refactor it to optionally
> parse section-less configs.

Er, sorry about the thinko: I meant that edit-link should use the
.git/config parser.  This one is just fine.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/7] sha1_file, link: write link objects to the database

2013-04-05 Thread Ramkumar Ramachandra
Ramkumar Ramachandra wrote:
> diff --git a/link.c b/link.c
> index bb20a51..349646d 100644
> --- a/link.c
> +++ b/link.c
> @@ -20,8 +20,30 @@ struct link *lookup_link(const unsigned char *sha1)
>
>  int parse_link_buffer(struct link *item, void *buffer, unsigned long size)
>  {
> +   char *bufptr = buffer;
> +   char *tail = buffer + size;
> +   char *eol;
> +
> if (item->object.parsed)
> return 0;
> item->object.parsed = 1;
> +   while (bufptr < tail) {
> +   eol = strchr(bufptr, '\n');
> +   *eol = '\0';
> +   if (!prefixcmp(bufptr, "upstream_url = "))
> +   item->upstream_url = xstrdup(bufptr + 15);
> +   else if (!prefixcmp(bufptr, "checkout_rev = "))
> +   item->checkout_rev = xstrdup(bufptr + 15);
> +   else if (!prefixcmp(bufptr, "ref_name = "))
> +   item->ref_name = xstrdup(bufptr + 11);
> +   else if (!prefixcmp(bufptr, "floating = "))
> +   item->floating = atoi(bufptr + 11);
> +   else if (!prefixcmp(bufptr, "statthrough = "))
> +   item->statthrough = atoi(bufptr + 14);
> +   else
> +   return error("Parse error in link buffer");
> +
> +   bufptr = eol + 1;
> +   }
> return 0;
>  }

This needs to be replaced by a .git/config parser.  However, I can't
use the parser from config.c as-it-is, because it expects a section
like [core] to be present.  So, we have to refactor it to optionally
parse section-less configs.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html