add: speed up cmd_add() by utilizing read_cache_preload()
[gitweb.git] / worktree.c
index 28989cf06ef4bd15b3b97f86ae9fd32c4b78401f..b0d0b5426da0d1cbe8d7b6ff569c7511569cf0a3 100644 (file)
@@ -217,7 +217,11 @@ struct worktree *find_worktree(struct worktree **list,
 
        if (prefix)
                arg = to_free = prefix_filename(prefix, arg);
-       path = real_pathdup(arg, 1);
+       path = real_pathdup(arg, 0);
+       if (!path) {
+               free(to_free);
+               return NULL;
+       }
        for (; *list; list++)
                if (!fspathcmp(path, real_path((*list)->path)))
                        break;
@@ -338,7 +342,7 @@ void update_worktree_location(struct worktree *wt, const char *path_)
        struct strbuf path = STRBUF_INIT;
 
        if (is_main_worktree(wt))
-               die("BUG: can't relocate main worktree");
+               BUG("can't relocate main worktree");
 
        strbuf_realpath(&path, path_, 1);
        if (fspathcmp(wt->path, path.buf)) {