]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-update-index.c
Drop strbuf's 'eof' marker, and make read_line a first class citizen.
[git.git] / builtin-update-index.c
index a7a4574f2bff2a7db4a1c25aa4a514ad99760381..45e33f5584b6c61cb64d7b408c89917320487f43 100644 (file)
@@ -4,7 +4,6 @@
  * Copyright (C) Linus Torvalds, 2005
  */
 #include "cache.h"
-#include "strbuf.h"
 #include "quote.h"
 #include "cache-tree.h"
 #include "tree-walk.h"
@@ -303,7 +302,7 @@ static void update_one(const char *path, const char *prefix, int prefix_length)
 static void read_index_info(int line_termination)
 {
        struct strbuf buf;
-       strbuf_init(&buf);
+       strbuf_init(&buf, 0);
        while (1) {
                char *ptr, *tab;
                char *path_name;
@@ -328,8 +327,7 @@ static void read_index_info(int line_termination)
                 * This format is to put higher order stages into the
                 * index file and matches git-ls-files --stage output.
                 */
-               read_line(&buf, stdin, line_termination);
-               if (buf.eof)
+               if (strbuf_getline(&buf, stdin, line_termination) == EOF)
                        break;
 
                errno = 0;
@@ -392,6 +390,7 @@ static void read_index_info(int line_termination)
        bad_line:
                die("malformed index info %s", buf.buf);
        }
+       strbuf_release(&buf);
 }
 
 static const char update_index_usage[] =
@@ -716,12 +715,11 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
        }
        if (read_from_stdin) {
                struct strbuf buf;
-               strbuf_init(&buf);
+               strbuf_init(&buf, 0);
                while (1) {
                        char *path_name;
                        const char *p;
-                       read_line(&buf, stdin, line_termination);
-                       if (buf.eof)
+                       if (strbuf_getline(&buf, stdin, line_termination) == EOF)
                                break;
                        if (line_termination && buf.buf[0] == '"')
                                path_name = unquote_c_style(buf.buf, NULL);
@@ -736,6 +734,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
                        if (path_name != buf.buf)
                                free(path_name);
                }
+               strbuf_release(&buf);
        }
 
  finish: