2 * Copyright (c) 2017 Stefan Sperling <stsp@openbsd.org>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include "got_error.h"
22 #include "got_object.h"
24 #include "got_repository.h"
26 #define RUN_TEST(expr, name) \
27 if (!(expr)) { printf("test %s failed", (name)); failure = 1; }
29 #define GOT_REPO_PATH "../../../"
32 repo_resolve_head_ref(const char *repo_path)
34 const struct got_error *err;
35 struct got_repository *repo;
36 struct got_reference *head_ref;
37 struct got_object_id *id;
40 err = got_repo_open(&repo, repo_path);
41 if (err != NULL || repo == NULL)
43 err = got_ref_open(&head_ref, repo, GOT_REF_HEAD);
44 if (err != NULL || head_ref == NULL)
46 err = got_ref_resolve(&id, repo, head_ref);
47 if (err != NULL || head_ref == NULL)
50 got_ref_close(head_ref);
56 main(int argc, const char *argv[])
59 const char *repo_path;
62 repo_path = GOT_REPO_PATH;
66 fprintf(stderr, "usage: repository_test [REPO_PATH]\n");
70 RUN_TEST(repo_resolve_head_ref(repo_path), "resolve_head_ref");
72 return failure ? 1 : 0;