{"thread":{"id":"43668","subject":"[PATCH] pack-refs: Store the full name of the ref even when packing only tags.","startedAt":"2006-11-02T11:13:32Z","lastAt":"2006-11-02T11:13:32Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"296507","messageId":"871wom5cf7.fsf@wine.dyndns.org","threadId":"43668","inReplyTo":null,"subject":"[PATCH] pack-refs: Store the full name of the ref even when packing only tags.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2006-11-02T11:13:32Z","receivedAt":"2006-11-02T11:13:32Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Using for_each_tag_ref() to enumerate tags is wrong since it removes\nthe refs/tags/ prefix, we need to always use for_each_ref() and filter\nout non-tag references in the callback.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n builtin-pack-refs.c |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-pack-refs.c b/builtin-pack-refs.c\nindex 1087657..042d271 100644\n--- a/builtin-pack-refs.c\n+++ b/builtin-pack-refs.c\n@@ -12,6 +12,7 @@ struct ref_to_prune {\n \n struct pack_refs_cb_data {\n \tint prune;\n+\tint all;\n \tstruct ref_to_prune *ref_to_prune;\n \tFILE *refs_file;\n };\n@@ -29,6 +30,8 @@ static int handle_one_ref(const char *pa\n {\n \tstruct pack_refs_cb_data *cb = cb_data;\n \n+\tif (!cb->all && strncmp(path, \"refs/tags/\", 10))\n+\t\treturn 0;\n \t/* Do not pack the symbolic refs */\n \tif (!(flags & REF_ISSYMREF))\n \t\tfprintf(cb->refs_file, \"%s %s\\n\", sha1_to_hex(sha1), path);\n@@ -68,7 +71,6 @@ int cmd_pack_refs(int argc, const char *\n {\n \tint fd, i;\n \tstruct pack_refs_cb_data cbdata;\n-\tint (*iterate_ref)(each_ref_fn, void *) = for_each_tag_ref;\n \n \tmemset(&cbdata, 0, sizeof(cbdata));\n \n@@ -79,7 +81,7 @@ int cmd_pack_refs(int argc, const char *\n \t\t\tcontinue;\n \t\t}\n \t\tif (!strcmp(arg, \"--all\")) {\n-\t\t\titerate_ref = for_each_ref;\n+\t\t\tcbdata.all = 1;\n \t\t\tcontinue;\n \t\t}\n \t\t/* perhaps other parameters later... */\n@@ -93,7 +95,7 @@ int cmd_pack_refs(int argc, const char *\n \tif (!cbdata.refs_file)\n \t\tdie(\"unable to create ref-pack file structure (%s)\",\n \t\t    strerror(errno));\n-\titerate_ref(handle_one_ref, &cbdata);\n+\tfor_each_ref(handle_one_ref, &cbdata);\n \tfflush(cbdata.refs_file);\n \tfsync(fd);\n \tfclose(cbdata.refs_file);\n-- \n1.4.3.3.gac1f\n\n-- \nAlexandre Julliard\n"}]}