aboutsummaryrefslogtreecommitdiff
path: root/builtin-tag.c
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2007-09-27 15:25:55 +0200
committerJunio C Hamano <gitster@pobox.com>2007-09-29 21:26:10 -0700
commit387e7e19d7eb5444be8da8e99ed7491989dc1cbb (patch)
treeb1fcd32479e6d22abc0e2060e70ea7846fa2b273 /builtin-tag.c
parentb315c5c08139c0d3c1e4867a305334e29da01d07 (diff)
downloadgit-387e7e19d7eb5444be8da8e99ed7491989dc1cbb.tar.gz
git-387e7e19d7eb5444be8da8e99ed7491989dc1cbb.tar.xz
strbuf_read_file enhancement, and use it.
* make strbuf_read_file take a size hint (works like strbuf_read) * use it in a couple of places. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-tag.c')
-rw-r--r--builtin-tag.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/builtin-tag.c b/builtin-tag.c
index 6132cac21..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));
}
@@ -356,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)
@@ -365,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;
}