Blob


1 /*
2 * Copyright (c) 2017 Stefan Sperling <stsp@openbsd.org>
3 *
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.
7 *
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.
15 */
17 /* A symbolic reference. */
18 struct got_symref {
19 char *name;
20 char *ref;
21 };
23 /* A non-symbolic reference (there is no better designation). */
24 struct got_ref {
25 char *name;
26 u_int8_t sha1[SHA1_DIGEST_LENGTH];
27 };
29 /* A reference which points to an arbitrary object. */
30 struct got_reference {
31 unsigned int flags;
32 #define GOT_REF_IS_SYMBOLIC 0x01
34 union {
35 struct got_ref ref;
36 struct got_symref symref;
37 } ref;
38 };
40 /* Well-known reference names. */
41 #define GOT_REF_HEAD "HEAD"
42 #define GOT_REF_ORIG_HEAD "ORIG_HEAD"
43 #define GOT_REF_MERGE_HEAD "MERGE_HEAD"
44 #define GOT_REF_FETCH_HEAD "FETCH_HEAD"
46 struct got_repository;
47 struct got_object_id;
49 const struct got_error * got_ref_open(struct got_reference **,
50 struct got_repository *, const char *);
51 void got_ref_close(struct got_reference *);
52 struct got_reference *got_ref_dup(struct got_reference *);
53 const struct got_error *got_ref_resolve(struct got_object_id **,
54 struct got_repository *, struct got_reference *);