aboutsummaryrefslogtreecommitdiff
path: root/builtin-tag.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-12-07 15:13:02 -0800
committerJunio C Hamano <gitster@pobox.com>2008-12-07 15:13:02 -0800
commit3a59bb22db24ff90c173ffb462fe67902a213d96 (patch)
treeaa4f56dcd531c232ea18a5242805e86cd50ced76 /builtin-tag.c
parent2dd620286e84e4e76226a3511af6d14755b8c809 (diff)
parent1c2ed59de2d14ad6ee9daa4d4f7254297d9a3830 (diff)
downloadgit-3a59bb22db24ff90c173ffb462fe67902a213d96.tar.gz
git-3a59bb22db24ff90c173ffb462fe67902a213d96.tar.xz
Merge branch 'maint'
* maint: GIT 1.6.0.5 "git diff <tree>{3,}": do not reverse order of arguments tag: delete TAG_EDITMSG only on successful tag gitweb: Make project specific override for 'grep' feature work http.c: use 'git_config_string' to get 'curl_http_proxy' fetch-pack: Avoid memcpy() with src==dst
Diffstat (limited to 'builtin-tag.c')
-rw-r--r--builtin-tag.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/builtin-tag.c b/builtin-tag.c
index d339971fa..a39849989 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -253,6 +253,15 @@ static void write_tag_body(int fd, const unsigned char *sha1)
free(buf);
}
+static int build_tag_object(struct strbuf *buf, int sign, unsigned char *result)
+{
+ if (sign && do_sign(buf) < 0)
+ return error("unable to sign the tag");
+ if (write_sha1_file(buf->buf, buf->len, tag_type, result) < 0)
+ return error("unable to write tag file");
+ return 0;
+}
+
static void create_tag(const unsigned char *object, const char *tag,
struct strbuf *buf, int message, int sign,
unsigned char *prev, unsigned char *result)
@@ -260,6 +269,7 @@ static void create_tag(const unsigned char *object, const char *tag,
enum object_type type;
char header_buf[1024];
int header_len;
+ char *path = NULL;
type = sha1_object_info(object, NULL);
if (type <= OBJ_NONE)
@@ -279,7 +289,6 @@ static void create_tag(const unsigned char *object, const char *tag,
die("tag header too big.");
if (!message) {
- char *path;
int fd;
/* write the template message before editing: */
@@ -300,9 +309,6 @@ static void create_tag(const unsigned char *object, const char *tag,
"Please supply the message using either -m or -F option.\n");
exit(1);
}
-
- unlink(path);
- free(path);
}
stripspace(buf, 1);
@@ -312,10 +318,16 @@ static void create_tag(const unsigned char *object, const char *tag,
strbuf_insert(buf, 0, header_buf, header_len);
- if (sign && do_sign(buf) < 0)
- die("unable to sign the tag");
- if (write_sha1_file(buf->buf, buf->len, tag_type, result) < 0)
- die("unable to write tag file");
+ if (build_tag_object(buf, sign, result) < 0) {
+ if (path)
+ fprintf(stderr, "The tag message has been left in %s\n",
+ path);
+ exit(128);
+ }
+ if (path) {
+ unlink(path);
+ free(path);
+ }
}
struct msg_arg {