]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-checkout-index.c
Drop strbuf's 'eof' marker, and make read_line a first class citizen.
[git.git] / builtin-checkout-index.c
index afe4b0e4520f47f1dace1383bfc2b364b1b1def0..a18ecc4bab7541477144402d4d680277d95c4e9a 100644 (file)
@@ -36,8 +36,8 @@
  * of "-a" causing problems (not possible in the above example,
  * but get used to it in scripting!).
  */
+#include "builtin.h"
 #include "cache.h"
-#include "strbuf.h"
 #include "quote.h"
 #include "cache-tree.h"
 
@@ -202,10 +202,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
                if (!strcmp(arg, "-u") || !strcmp(arg, "--index")) {
                        state.refresh_cache = 1;
                        if (newfd < 0)
-                               newfd = hold_lock_file_for_update
-                                       (&lock_file, get_index_file(), 1);
-                       if (newfd < 0)
-                               die("cannot open index.lock file.");
+                               newfd = hold_locked_index(&lock_file, 1);
                        continue;
                }
                if (!strcmp(arg, "-z")) {
@@ -276,13 +273,11 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
                struct strbuf buf;
                if (all)
                        die("git-checkout-index: don't mix '--all' and '--stdin'");
-               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);
@@ -295,6 +290,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
                        if (path_name != buf.buf)
                                free(path_name);
                }
+               strbuf_release(&buf);
        }
 
        if (all)
@@ -302,7 +298,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
 
        if (0 <= newfd &&
            (write_cache(newfd, active_cache, active_nr) ||
-            close(newfd) || commit_lock_file(&lock_file)))
+            close(newfd) || commit_locked_index(&lock_file)))
                die("Unable to write new index file");
        return 0;
 }