Merge branch 'tb/dedup-crlf-tests'
[gitweb.git] / t / helper / test-ref-store.c
index a436bfdb053c966db7fcc1a2def7266889b028bf..fba85e7da58fb124b409de502e9bb4f9a7d8f5b5 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]);
 
@@ -138,7 +156,7 @@ static int cmd_for_each_reflog(struct ref_store *refs, const char **argv)
 }
 
 static int each_reflog(struct object_id *old_oid, struct object_id *new_oid,
-                      const char *committer, unsigned long timestamp,
+                      const char *committer, timestamp_t timestamp,
                       int tz, const char *msg, void *cb_data)
 {
        printf("%s %s %s %"PRItime" %d %s\n",