git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH] fast-export, fast-import: Let tags specify an internal name

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 21, 2021, 08:03 UTC
Message-ID
<8735vk3vyq.fsf@evledraar.gmail.com>
In-Reply-To
<20210420190552.822138-1-lukeshu@lukeshu.com>
On Tue, Apr 20 2021, Luke Shumaker wrote:
Show 9 quoted lines
> -static void handle_tag(const char *name, struct tag *tag)
> +static void handle_tag(const char *refname, struct tag *tag)
>  {
>  	unsigned long size;
>  	enum object_type type;
>  	char *buf;
> -	const char *tagger, *tagger_end, *message;
> +	const char *refbasename;
> +	const char *tagname, *tagname_end, *tagger, *tagger_end, *message;

Let's put the new "*tagname, *tagname_end" on its own line, the current convention is to not conflate unrelated variable declarations on the same line (as e.g. the existing "message" and "tagger" does.

Show 12 quoted lines
>  	size_t message_size = 0;
>  	struct object *tagged;
>  	int tagged_mark;
> @@ -800,6 +801,11 @@ static void handle_tag(const char *name, struct tag *tag)
>  		message += 2;
>  		message_size = strlen(message);
>  	}
> +	tagname = memmem(buf, message ? message - buf : size, "\ntag ", 5);
> +	if (!tagname)
> +		die("malformed tag %s", oid_to_hex(&tag->object.oid));
> +	tagname += 5;
> +	tagname_end = strchrnul(tagname, '\n');

So it's no longer possible to export a reporitory with a missing "tag" entry in a tag? Maybe OK, but we have an escape hatch for it with fsck, we don't need one here?

In any case a test for it would be good to have.
Show 17 quoted lines
> @@ -884,14 +890,19 @@ static void handle_tag(const char *name, struct tag *tag)
>  
>  	if (tagged->type == OBJ_TAG) {
>  		printf("reset %s\nfrom %s\n\n",
> -		       name, oid_to_hex(&null_oid));
> +		       refname, oid_to_hex(&null_oid));
>  	}
> -	skip_prefix(name, "refs/tags/", &name);
> -	printf("tag %s\n", name);
> +	refbasename = refname;
> +	skip_prefix(refbasename, "refs/tags/", &refbasename);
> +	printf("tag %s\n", refbasename);
>  	if (mark_tags) {
>  		mark_next_object(&tag->object);
>  		printf("mark :%"PRIu32"\n", last_idnum);
>  	}
> +	if ((size_t)(tagname_end - tagname) != strlen(refbasename) ||

Would be more readable IMO to have a temporary variable for that "tagname_end - tagname", then just cast that and use it here.

> +	    strncmp(tagname, refbasename, (size_t)(tagname_end - tagname)))
and here.
Show 11 quoted lines
> @@ -2803,6 +2803,13 @@ static void parse_new_tag(const char *arg)
>  	read_next_command();
>  	parse_mark();
>  
> +	/* name ... */
> +	if (skip_prefix(command_buf.buf, "name ", &v)) {
> +		name = strdupa(v);
> +		read_next_command();
> +	} else
> +		name = NULL;
> +

Skip this whole (stylistically incorrect, should have {}) and just initialize it to NULL when you declare the variable?

Previous: Elijah NewrenNext: Luke Shumaker
Message 15 of 20 in “fast-export, fast-import: Let tags specify an internal name”
  1. fast-export, fast-import: Let tags specify an internal nameLuke Shumaker, Apr 20, 2021
  2. Junio C HamanoApr 20, 2021
  3. Ævar Arnfjörð BjarmasonApr 21, 2021
  4. Luke ShumakerApr 21, 2021
  5. Junio C HamanoApr 21, 2021
  6. Elijah NewrenApr 21, 2021
  7. Luke ShumakerApr 21, 2021
  8. Elijah NewrenApr 21, 2021
  9. Ævar Arnfjörð BjarmasonApr 22, 2021
  10. Elijah NewrenApr 21, 2021
  11. Junio C HamanoApr 21, 2021
  12. Elijah NewrenApr 21, 2021
  13. Ævar Arnfjörð BjarmasonApr 22, 2021
  14. Elijah NewrenApr 22, 2021
  15. Ævar Arnfjörð BjarmasonApr 21, 2021
  16. Luke ShumakerApr 21, 2021
  17. Luke ShumakerApr 21, 2021
  18. Elijah NewrenApr 21, 2021
  19. Junio C HamanoApr 21, 2021
  20. Luke ShumakerApr 23, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.