{"thread":{"id":"21928","subject":"[RFC/PATCH] tag: display original sha1 of deleted/overwritten tag","startedAt":"2009-12-10T12:34:56Z","lastAt":"2009-12-10T14:09:49Z","messageCount":4,"participants":["Zoltán Füzesi"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"129683","messageId":"1260448496-527-1-git-send-email-zfuzesi@eaglet.hu","threadId":"21928","inReplyTo":null,"subject":"[RFC/PATCH] tag: display original sha1 of deleted/overwritten tag","fromName":"Zoltán Füzesi","fromEmail":"zfuzesi@eaglet.hu","sentAt":"2009-12-10T12:34:56Z","receivedAt":"2009-12-10T12:34:56Z","isPatch":true,"sender":{"key":"zfuzesi@eaglet.hu","avatar":null},"body":"It makes possible to undo accidental tag deletion and overwriting.\n\nSigned-off-by: Zoltán Füzesi <zfuzesi@eaglet.hu>\n---\nThis patch was created in response to this feature request:\nhttp://article.gmane.org/gmane.comp.version-control.git/135016\nI named it \"RFC\" because of the overwriting part.\n\n builtin-tag.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-tag.c b/builtin-tag.c\nindex c479018..8dca364 100644\n--- a/builtin-tag.c\n+++ b/builtin-tag.c\n@@ -140,7 +140,7 @@ static int delete_tag(const char *name, const char *ref,\n {\n \tif (delete_ref(ref, sha1, 0))\n \t\treturn 1;\n-\tprintf(\"Deleted tag '%s'\\n\", name);\n+\tprintf(\"Deleted tag '%s' %s\\n\", name, sha1_to_hex(sha1));\n \treturn 0;\n }\n \n@@ -479,6 +479,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\tdie(\"%s: cannot lock the ref\", ref);\n \tif (write_ref_sha1(lock, object, NULL) < 0)\n \t\tdie(\"%s: cannot update the ref\", ref);\n+\telse if (force && hashcmp(object, prev))\n+\t\tprintf(\"Overwritten tag '%s' (%s)\\n\", ref, sha1_to_hex(prev));\n \n \tstrbuf_release(&buf);\n \treturn 0;\n-- \n1.6.6.rc2\n"},{"id":"129688","messageId":"1260451579-4400-1-git-send-email-zfuzesi@eaglet.hu","threadId":"21928","inReplyTo":"1260448496-527-1-git-send-email-zfuzesi@eaglet.hu","subject":"[RFC/PATCH v2] tag: display original sha1 of deleted/overwritten tag","fromName":"Zoltán Füzesi","fromEmail":"zfuzesi@eaglet.hu","sentAt":"2009-12-10T13:26:19Z","receivedAt":"2009-12-10T13:26:19Z","isPatch":true,"sender":{"key":"zfuzesi@eaglet.hu","avatar":null},"body":"It makes possible to undo accidental tag deletion and overwriting.\n\nSigned-off-by: Zoltán Füzesi <zfuzesi@eaglet.hu>\n---\nThis patch was created in response to this feature request:\nhttp://article.gmane.org/gmane.comp.version-control.git/135016\nI named it \"RFC\" because of the overwriting part.\n\nv2: works when tag object is created.\n\n builtin-tag.c |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-tag.c b/builtin-tag.c\nindex c479018..1265b84 100644\n--- a/builtin-tag.c\n+++ b/builtin-tag.c\n@@ -140,7 +140,7 @@ static int delete_tag(const char *name, const char *ref,\n {\n \tif (delete_ref(ref, sha1, 0))\n \t\treturn 1;\n-\tprintf(\"Deleted tag '%s'\\n\", name);\n+\tprintf(\"Deleted tag '%s' %s\\n\", name, sha1_to_hex(sha1));\n \treturn 0;\n }\n \n@@ -363,7 +363,7 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)\n int cmd_tag(int argc, const char **argv, const char *prefix)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n-\tunsigned char object[20], prev[20];\n+\tunsigned char object[20], prev[20], tag_object[20];\n \tchar ref[PATH_MAX];\n \tconst char *object_ref, *tag;\n \tstruct ref_lock *lock;\n@@ -472,13 +472,15 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \n \tif (annotate)\n \t\tcreate_tag(object, tag, &buf, msg.given || msgfile,\n-\t\t\t   sign, prev, object);\n+\t\t\t   sign, prev, tag_object);\n \n \tlock = lock_any_ref_for_update(ref, prev, 0);\n \tif (!lock)\n \t\tdie(\"%s: cannot lock the ref\", ref);\n \tif (write_ref_sha1(lock, object, NULL) < 0)\n \t\tdie(\"%s: cannot update the ref\", ref);\n+\telse if (force && hashcmp(object, prev))\n+\t\tprintf(\"Overwritten tag '%s' (%s)\\n\", ref, sha1_to_hex(prev));\n \n \tstrbuf_release(&buf);\n \treturn 0;\n-- \n1.6.6.rc2\n"},{"id":"129691","messageId":"1260453537-6156-1-git-send-email-zfuzesi@eaglet.hu","threadId":"21928","inReplyTo":"1260451579-4400-1-git-send-email-zfuzesi@eaglet.hu","subject":"[RFC/PATCH v3] tag: display original sha1 of deleted/overwritten tag","fromName":"Zoltán Füzesi","fromEmail":"zfuzesi@eaglet.hu","sentAt":"2009-12-10T13:58:57Z","receivedAt":"2009-12-10T13:58:57Z","isPatch":true,"sender":{"key":"zfuzesi@eaglet.hu","avatar":null},"body":"It makes possible to undo accidental tag deletion and overwriting.\n\nSigned-off-by: Zoltán Füzesi <zfuzesi@eaglet.hu>\n---\nThis patch was created in response to this feature request:\nhttp://article.gmane.org/gmane.comp.version-control.git/135016\nI named it \"RFC\" because of the overwriting part.\n\nv3: works when tag object is created (I should slow down...)\n\n builtin-tag.c |   10 ++++++----\n 1 files changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-tag.c b/builtin-tag.c\nindex c479018..1404a0e 100644\n--- a/builtin-tag.c\n+++ b/builtin-tag.c\n@@ -140,7 +140,7 @@ static int delete_tag(const char *name, const char *ref,\n {\n \tif (delete_ref(ref, sha1, 0))\n \t\treturn 1;\n-\tprintf(\"Deleted tag '%s'\\n\", name);\n+\tprintf(\"Deleted tag '%s' %s\\n\", name, sha1_to_hex(sha1));\n \treturn 0;\n }\n \n@@ -363,7 +363,7 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)\n int cmd_tag(int argc, const char **argv, const char *prefix)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n-\tunsigned char object[20], prev[20];\n+\tunsigned char object[20], prev[20], tag_object[20];\n \tchar ref[PATH_MAX];\n \tconst char *object_ref, *tag;\n \tstruct ref_lock *lock;\n@@ -472,13 +472,15 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \n \tif (annotate)\n \t\tcreate_tag(object, tag, &buf, msg.given || msgfile,\n-\t\t\t   sign, prev, object);\n+\t\t\t   sign, prev, tag_object);\n \n \tlock = lock_any_ref_for_update(ref, prev, 0);\n \tif (!lock)\n \t\tdie(\"%s: cannot lock the ref\", ref);\n-\tif (write_ref_sha1(lock, object, NULL) < 0)\n+\tif (write_ref_sha1(lock, annotate ? tag_object : object, NULL) < 0)\n \t\tdie(\"%s: cannot update the ref\", ref);\n+\telse if (force && hashcmp(object, prev))\n+\t\tprintf(\"Overwritten tag '%s' (%s)\\n\", ref, sha1_to_hex(prev));\n \n \tstrbuf_release(&buf);\n \treturn 0;\n-- \n1.6.6.rc2\n"},{"id":"129694","messageId":"9ab80d150912100609m29bf4862yc7b1abd680c96c54@mail.gmail.com","threadId":"21928","inReplyTo":"1260453537-6156-1-git-send-email-zfuzesi@eaglet.hu","subject":"Re: [RFC/PATCH v3] tag: display original sha1 of deleted/overwritten tag","fromName":"Zoltán Füzesi","fromEmail":"zfuzesi@eaglet.hu","sentAt":"2009-12-10T14:09:49Z","receivedAt":"2009-12-10T14:09:49Z","isPatch":true,"sender":{"key":"zfuzesi@eaglet.hu","avatar":null},"body":"Forget v2 and v3, v1 is the good one. Sorry.\n\n2009/12/10 Zoltán Füzesi <zfuzesi@eaglet.hu>:\n> It makes possible to undo accidental tag deletion and overwriting.\n>\n> Signed-off-by: Zoltán Füzesi <zfuzesi@eaglet.hu>\n> ---\n> This patch was created in response to this feature request:\n> http://article.gmane.org/gmane.comp.version-control.git/135016\n> I named it \"RFC\" because of the overwriting part.\n>\n> v3: works when tag object is created (I should slow down...)\n>\n>  builtin-tag.c |   10 ++++++----\n>  1 files changed, 6 insertions(+), 4 deletions(-)\n>\n> diff --git a/builtin-tag.c b/builtin-tag.c\n> index c479018..1404a0e 100644\n> --- a/builtin-tag.c\n> +++ b/builtin-tag.c\n> @@ -140,7 +140,7 @@ static int delete_tag(const char *name, const char *ref,\n>  {\n>        if (delete_ref(ref, sha1, 0))\n>                return 1;\n> -       printf(\"Deleted tag '%s'\\n\", name);\n> +       printf(\"Deleted tag '%s' %s\\n\", name, sha1_to_hex(sha1));\n>        return 0;\n>  }\n>\n> @@ -363,7 +363,7 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)\n>  int cmd_tag(int argc, const char **argv, const char *prefix)\n>  {\n>        struct strbuf buf = STRBUF_INIT;\n> -       unsigned char object[20], prev[20];\n> +       unsigned char object[20], prev[20], tag_object[20];\n>        char ref[PATH_MAX];\n>        const char *object_ref, *tag;\n>        struct ref_lock *lock;\n> @@ -472,13 +472,15 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n>\n>        if (annotate)\n>                create_tag(object, tag, &buf, msg.given || msgfile,\n> -                          sign, prev, object);\n> +                          sign, prev, tag_object);\n>\n>        lock = lock_any_ref_for_update(ref, prev, 0);\n>        if (!lock)\n>                die(\"%s: cannot lock the ref\", ref);\n> -       if (write_ref_sha1(lock, object, NULL) < 0)\n> +       if (write_ref_sha1(lock, annotate ? tag_object : object, NULL) < 0)\n>                die(\"%s: cannot update the ref\", ref);\n> +       else if (force && hashcmp(object, prev))\n> +               printf(\"Overwritten tag '%s' (%s)\\n\", ref, sha1_to_hex(prev));\n>\n>        strbuf_release(&buf);\n>        return 0;\n> --\n> 1.6.6.rc2\n>\n>\n"}]}