Merge branch 'tb/dedup-crlf-tests'
[gitweb.git] / t / helper / test-ref-store.c
index 2d84c45ffe99d1d5430345a32d1386804c3c495d..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,10 +156,10 @@ 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 %lu %d %s\n",
+       printf("%s %s %s %"PRItime" %d %s\n",
               oid_to_hex(old_oid), oid_to_hex(new_oid),
               committer, timestamp, tz, msg);
        return 0;