{"thread":{"id":"22170","subject":"Re: [PATCH] fast-import: tag may point to any object type","startedAt":"2010-01-11T05:02:45Z","lastAt":"2010-01-14T04:44:19Z","messageCount":5,"participants":["Shawn O. Pearce","Dmitry Potapov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"299140","messageId":"1263186165-23920-1-git-send-email-dpotapov@gmail.com","threadId":"22170","inReplyTo":null,"subject":"[PATCH] fast-import: tag may point to any object type","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2010-01-11T05:02:45Z","receivedAt":"2010-01-11T05:02:45Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"If you tried to export the official git repository, and then to import it\nback then git-fast-import would die complaining that \"Mark :1 not a commit\".\n\nAccordingly to a generated crash file, Mark 1 is not a commit but a blob,\nwhich is pointed by junio-gpg-pub tag. Because git-tag allows to create such\ntags, git-fast-import should import them.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n fast-import.c |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex cd87049..e99990d 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2305,6 +2305,7 @@ static void parse_new_tag(void)\n \tstruct tag *t;\n \tuintmax_t from_mark = 0;\n \tunsigned char sha1[20];\n+\tenum object_type type = OBJ_COMMIT;\n \n \t/* Obtain the new tag name from the rest of our command */\n \tsp = strchr(command_buf.buf, ' ') + 1;\n@@ -2329,8 +2330,7 @@ static void parse_new_tag(void)\n \t\tstruct object_entry *oe;\n \t\tfrom_mark = strtoumax(from + 1, NULL, 10);\n \t\toe = find_mark(from_mark);\n-\t\tif (oe->type != OBJ_COMMIT)\n-\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", from_mark);\n+\t\ttype = oe->type;\n \t\thashcpy(sha1, oe->sha1);\n \t} else if (!get_sha1(from, sha1)) {\n \t\tunsigned long size;\n@@ -2362,7 +2362,7 @@ static void parse_new_tag(void)\n \t\t    \"object %s\\n\"\n \t\t    \"type %s\\n\"\n \t\t    \"tag %s\\n\",\n-\t\t    sha1_to_hex(sha1), commit_type, t->name);\n+\t\t    sha1_to_hex(sha1), typename(type), t->name);\n \tif (tagger)\n \t\tstrbuf_addf(&new_data,\n \t\t\t    \"tagger %s\\n\", tagger);\n-- \n1.6.6\n\n"},{"id":"131296","messageId":"20100111171454.GO32155@spearce.org","threadId":"22170","inReplyTo":"1263186165-23920-1-git-send-email-dpotapov@gmail.com","subject":"Re: [PATCH] fast-import: tag may point to any object type","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2010-01-11T17:14:54Z","receivedAt":"2010-01-11T17:14:54Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Dmitry Potapov <dpotapov@gmail.com> wrote:\n> If you tried to export the official git repository, and then to import it\n> back then git-fast-import would die complaining that \"Mark :1 not a commit\".\n> \n> Accordingly to a generated crash file, Mark 1 is not a commit but a blob,\n> which is pointed by junio-gpg-pub tag. Because git-tag allows to create such\n> tags, git-fast-import should import them.\n> \n> Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>\n> ---\n>  fast-import.c |    6 +++---\n>  1 files changed, 3 insertions(+), 3 deletions(-)\n> \n> diff --git a/fast-import.c b/fast-import.c\n> index cd87049..e99990d 100644\n> --- a/fast-import.c\n> +++ b/fast-import.c\n> @@ -2305,6 +2305,7 @@ static void parse_new_tag(void)\n>  \tstruct tag *t;\n>  \tuintmax_t from_mark = 0;\n>  \tunsigned char sha1[20];\n> +\tenum object_type type = OBJ_COMMIT;\n\nNAK.\n\nYour patch is the right idea.  But you need to make sure all of\nthe branch arms are handled correctly.\n\nThat is, if we do this, the get_sha1() on line 2459 should also\npermit non-commit objects, and the lookup_branch() earlier up on\nline 2451 should do \"type = OBJ_COMMIT\".\n  \n-- \nShawn.\n"},{"id":"131463","messageId":"20100113123532.GC10586@dpotapov.dyndns.org","threadId":"22170","inReplyTo":"20100111171454.GO32155@spearce.org","subject":"[PATCH v2] fast-import: tag may point to any object type","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2010-01-13T12:35:32Z","receivedAt":"2010-01-13T12:35:32Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"If you tried to export the official git repository, and then to import it\nback then git-fast-import would die complaining that \"Mark :1 not a commit\".\n\nAccordingly to a generated crash file, Mark 1 is not a commit but a blob,\nwhich is pointed by junio-gpg-pub tag. Because git-tag allows to create such\ntags, git-fast-import should import them.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n\nOn Mon, Jan 11, 2010 at 09:14:54AM -0800, Shawn O. Pearce wrote:\n> \n> Your patch is the right idea.  But you need to make sure all of\n> the branch arms are handled correctly.\n> \n> That is, if we do this, the get_sha1() on line 2459 should also\n> permit non-commit objects, and the lookup_branch() earlier up on\n> line 2451 should do \"type = OBJ_COMMIT\".\n\nThank you for guideliness. I do not understand this code well.\nI hope I got it right this time.\n\n fast-import.c |   10 ++++++----\n 1 files changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex cd87049..4fdf809 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2305,6 +2305,7 @@ static void parse_new_tag(void)\n \tstruct tag *t;\n \tuintmax_t from_mark = 0;\n \tunsigned char sha1[20];\n+\tenum object_type type;\n \n \t/* Obtain the new tag name from the rest of our command */\n \tsp = strchr(command_buf.buf, ' ') + 1;\n@@ -2325,19 +2326,20 @@ static void parse_new_tag(void)\n \ts = lookup_branch(from);\n \tif (s) {\n \t\thashcpy(sha1, s->sha1);\n+\t\ttype = OBJ_COMMIT;\n \t} else if (*from == ':') {\n \t\tstruct object_entry *oe;\n \t\tfrom_mark = strtoumax(from + 1, NULL, 10);\n \t\toe = find_mark(from_mark);\n-\t\tif (oe->type != OBJ_COMMIT)\n-\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", from_mark);\n+\t\ttype = oe->type;\n \t\thashcpy(sha1, oe->sha1);\n \t} else if (!get_sha1(from, sha1)) {\n \t\tunsigned long size;\n \t\tchar *buf;\n \n+\t\ttype = sha1_object_info(sha1, NULL);\n \t\tbuf = read_object_with_reference(sha1,\n-\t\t\tcommit_type, &size, sha1);\n+\t\t\ttypename(type), &size, sha1);\n \t\tif (!buf || size < 46)\n \t\t\tdie(\"Not a valid commit: %s\", from);\n \t\tfree(buf);\n@@ -2362,7 +2364,7 @@ static void parse_new_tag(void)\n \t\t    \"object %s\\n\"\n \t\t    \"type %s\\n\"\n \t\t    \"tag %s\\n\",\n-\t\t    sha1_to_hex(sha1), commit_type, t->name);\n+\t\t    sha1_to_hex(sha1), typename(type), t->name);\n \tif (tagger)\n \t\tstrbuf_addf(&new_data,\n \t\t\t    \"tagger %s\\n\", tagger);\n-- \n1.6.6.137.g1acb\n"},{"id":"131494","messageId":"20100113172456.GB18625@spearce.org","threadId":"22170","inReplyTo":"20100113123532.GC10586@dpotapov.dyndns.org","subject":"Re: [PATCH v2] fast-import: tag may point to any object type","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2010-01-13T17:24:56Z","receivedAt":"2010-01-13T17:24:56Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Dmitry Potapov <dpotapov@gmail.com> wrote:\n> If you tried to export the official git repository, and then to import it\n> back then git-fast-import would die complaining that \"Mark :1 not a commit\".\n...\n> diff --git a/fast-import.c b/fast-import.c\n> index cd87049..4fdf809 100644\n> --- a/fast-import.c\n> +++ b/fast-import.c\n> @@ -2325,19 +2326,20 @@ static void parse_new_tag(void)\n>  \t} else if (!get_sha1(from, sha1)) {\n>  \t\tunsigned long size;\n>  \t\tchar *buf;\n>  \n> +\t\ttype = sha1_object_info(sha1, NULL);\n>  \t\tbuf = read_object_with_reference(sha1,\n> -\t\t\tcommit_type, &size, sha1);\n> +\t\t\ttypename(type), &size, sha1);\n\nThis is better spelled as:\n\n  buf = read_sha1_file(sha1, &type, &size);\n\nBut otherwise the patch looks correct now, thanks.\n\nIf you could make this one change, add my\n\n  Acked-by: Shawn O. Pearce <spearce@spearce.org>\n\nand resend so Junio can apply, thanks.\n\n-- \nShawn.\n"},{"id":"131576","messageId":"20100114044419.GE10586@dpotapov.dyndns.org","threadId":"22170","inReplyTo":"20100113172456.GB18625@spearce.org","subject":"[PATCH v3] fast-import: tag may point to any object type","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2010-01-14T04:44:19Z","receivedAt":"2010-01-14T04:44:19Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"If you tried to export the official git repository, and then to import it\nback then git-fast-import would die complaining that \"Mark :1 not a commit\".\n\nAccordingly to a generated crash file, Mark 1 is not a commit but a blob,\nwhich is pointed by junio-gpg-pub tag. Because git-tag allows to create such\ntags, git-fast-import should import them.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\nOn Wed, Jan 13, 2010 at 09:24:56AM -0800, Shawn O. Pearce wrote:\n> Dmitry Potapov <dpotapov@gmail.com> wrote:\n> >  \n> > +\t\ttype = sha1_object_info(sha1, NULL);\n> >  \t\tbuf = read_object_with_reference(sha1,\n> > -\t\t\tcommit_type, &size, sha1);\n> > +\t\t\ttypename(type), &size, sha1);\n> \n> This is better spelled as:\n> \n>   buf = read_sha1_file(sha1, &type, &size);\n\nThank you for correction.\n\n> \n> But otherwise the patch looks correct now, thanks.\n> \n> If you could make this one change, add my\n> \n>   Acked-by: Shawn O. Pearce <spearce@spearce.org>\n> \n> and resend so Junio can apply, thanks.\n\n fast-import.c |   10 +++++-----\n 1 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex cd87049..60d0aa2 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2305,6 +2305,7 @@ static void parse_new_tag(void)\n \tstruct tag *t;\n \tuintmax_t from_mark = 0;\n \tunsigned char sha1[20];\n+\tenum object_type type;\n \n \t/* Obtain the new tag name from the rest of our command */\n \tsp = strchr(command_buf.buf, ' ') + 1;\n@@ -2325,19 +2326,18 @@ static void parse_new_tag(void)\n \ts = lookup_branch(from);\n \tif (s) {\n \t\thashcpy(sha1, s->sha1);\n+\t\ttype = OBJ_COMMIT;\n \t} else if (*from == ':') {\n \t\tstruct object_entry *oe;\n \t\tfrom_mark = strtoumax(from + 1, NULL, 10);\n \t\toe = find_mark(from_mark);\n-\t\tif (oe->type != OBJ_COMMIT)\n-\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", from_mark);\n+\t\ttype = oe->type;\n \t\thashcpy(sha1, oe->sha1);\n \t} else if (!get_sha1(from, sha1)) {\n \t\tunsigned long size;\n \t\tchar *buf;\n \n-\t\tbuf = read_object_with_reference(sha1,\n-\t\t\tcommit_type, &size, sha1);\n+\t\tbuf = read_sha1_file(sha1, &type, &size);\n \t\tif (!buf || size < 46)\n \t\t\tdie(\"Not a valid commit: %s\", from);\n \t\tfree(buf);\n@@ -2362,7 +2362,7 @@ static void parse_new_tag(void)\n \t\t    \"object %s\\n\"\n \t\t    \"type %s\\n\"\n \t\t    \"tag %s\\n\",\n-\t\t    sha1_to_hex(sha1), commit_type, t->name);\n+\t\t    sha1_to_hex(sha1), typename(type), t->name);\n \tif (tagger)\n \t\tstrbuf_addf(&new_data,\n \t\t\t    \"tagger %s\\n\", tagger);\n-- \n1.6.6.137.g1acb\n"}]}