Add strbuf_read_file().
[gitweb.git] / builtin-tag.c
index 82ebda11b02b2fd1fad3e3687832bb222e84f500..fcbf9bbf18155b5e9b699bf12cd980561498992f 100644 (file)
@@ -22,7 +22,6 @@ static void launch_editor(const char *path, struct strbuf *buffer)
        const char *editor, *terminal;
        struct child_process child;
        const char *args[3];
-       int fd;
 
        editor = getenv("GIT_EDITOR");
        if (!editor && editor_program)
@@ -52,13 +51,9 @@ static void launch_editor(const char *path, struct strbuf *buffer)
        if (run_command(&child))
                die("There was a problem with the editor %s.", editor);
 
-       fd = open(path, O_RDONLY);
-       if (fd < 0)
-               die("could not open '%s': %s", path, strerror(errno));
-       if (strbuf_read(buffer, fd, 0) < 0) {
-               die("could not read message file '%s': %s", path, strerror(errno));
-       }
-       close(fd);
+       if (strbuf_read_file(buffer, path) < 0)
+               die("could not read message file '%s': %s",
+                   path, strerror(errno));
 }
 
 struct tag_filter {