Say when --track is useful in the git-checkout docs.
[gitweb.git] / builtin-checkout-index.c
index 29ea6fdc6232c1071d88524fa5c11d5ba1882dee..75377b9cab75ac75c6d5d7f79fdcf64bdb27cff2 100644 (file)
@@ -36,6 +36,7 @@
  * 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"
@@ -45,7 +46,7 @@
 static int line_termination = '\n';
 static int checkout_stage; /* default to checkout stage0 */
 static int to_tempfile;
-static char topath[4][MAXPATHLEN+1];
+static char topath[4][PATH_MAX + 1];
 
 static struct checkout state;
 
@@ -122,7 +123,7 @@ static int checkout_file(const char *name, int prefix_length)
        return -1;
 }
 
-static int checkout_all(const char *prefix, int prefix_length)
+static void checkout_all(const char *prefix, int prefix_length)
 {
        int i, errs = 0;
        struct cache_entry* last_ce = NULL;
@@ -153,7 +154,6 @@ static int checkout_all(const char *prefix, int prefix_length)
                 * exit with the same code as die().
                 */
                exit(128);
-       return 0;
 }
 
 static const char checkout_cache_usage[] =
@@ -203,10 +203,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());
-                       if (newfd < 0)
-                               die("cannot open index.lock file.");
+                               newfd = hold_locked_index(&lock_file, 1);
                        continue;
                }
                if (!strcmp(arg, "-z")) {
@@ -224,12 +221,12 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
                        to_tempfile = 1;
                        continue;
                }
-               if (!strncmp(arg, "--prefix=", 9)) {
+               if (!prefixcmp(arg, "--prefix=")) {
                        state.base_dir = arg+9;
                        state.base_dir_len = strlen(state.base_dir);
                        continue;
                }
-               if (!strncmp(arg, "--stage=", 8)) {
+               if (!prefixcmp(arg, "--stage=")) {
                        if (!strcmp(arg + 8, "all")) {
                                to_tempfile = 1;
                                checkout_stage = CHECKOUT_ALL;
@@ -303,7 +300,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;
 }