X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-tag.c;h=66e5a5830792471a44c9211d4eafcf2b1ff6f0dd;hb=9d3014566302ad0d3d378b0a1653959b3118066d;hp=fcbf9bbf18155b5e9b699bf12cd980561498992f;hpb=a9390b9fcefb18c4ccdb521086a051bc9112e03d;p=git.git diff --git a/builtin-tag.c b/builtin-tag.c index fcbf9bbf1..66e5a5830 100644 --- a/builtin-tag.c +++ b/builtin-tag.c @@ -51,7 +51,7 @@ static void launch_editor(const char *path, struct strbuf *buffer) if (run_command(&child)) die("There was a problem with the editor %s.", editor); - if (strbuf_read_file(buffer, path) < 0) + if (strbuf_read_file(buffer, path, 0) < 0) die("could not read message file '%s': %s", path, strerror(errno)); } @@ -291,14 +291,11 @@ static void create_tag(const unsigned char *object, const char *tag, free(path); } - strbuf_setlen(buf, stripspace(buf->buf, buf->len, 1)); + stripspace(buf, 1); if (!message && !buf->len) die("no tag message?"); - /* insert the header and add the '\n' if needed: */ - if (buf->len) - strbuf_addch(buf, '\n'); strbuf_insert(buf, 0, header_buf, header_len); if (sign && do_sign(buf) < 0) @@ -359,8 +356,6 @@ int cmd_tag(int argc, const char **argv, const char *prefix) continue; } if (!strcmp(arg, "-F")) { - int fd; - annotate = 1; i++; if (i == argc) @@ -368,17 +363,14 @@ int cmd_tag(int argc, const char **argv, const char *prefix) if (message) die("only one -F or -m option is allowed."); - if (!strcmp(argv[i], "-")) - fd = 0; - else { - fd = open(argv[i], O_RDONLY); - if (fd < 0) - die("could not open '%s': %s", + if (!strcmp(argv[i], "-")) { + if (strbuf_read(&buf, 0, 1024) < 0) + die("cannot read %s", argv[i]); + } else { + if (strbuf_read_file(&buf, argv[i], 1024) < 0) + die("could not open or read '%s': %s", argv[i], strerror(errno)); } - if (strbuf_read(&buf, fd, 1024) < 0) { - die("cannot read %s", argv[i]); - } message = 1; continue; }