Merge branch 'sk/status-short-branch-color-config'
[gitweb.git] / t / helper / test-ref-store.c
index 2d84c45ffe99d1d5430345a32d1386804c3c495d..4a487c014e08794a818704735101e85a6781c14a 100644 (file)
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "refs.h"
+#include "worktree.h"
 
 static const char *notnull(const char *arg, const char *name)
 {
@@ -32,6 +33,23 @@ static const char **get_store(const char **argv, struct ref_store **refs)
                strbuf_release(&sb);
 
                *refs = get_submodule_ref_store(gitdir);
+       } else if (skip_prefix(argv[0], "worktree:", &gitdir)) {
+               struct worktree **p, **worktrees = get_worktrees(0);
+
+               for (p = worktrees; *p; p++) {
+                       struct worktree *wt = *p;
+
+                       if (!wt->id) {
+                               /* special case for main worktree */
+                               if (!strcmp(gitdir, "main"))
+                                       break;
+                       } else if (!strcmp(gitdir, wt->id))
+                               break;
+               }
+               if (!*p)
+                       die("no such worktree: %s", gitdir);
+
+               *refs = get_worktree_ref_store(*p);
        } else
                die("unknown backend %s", argv[0]);