Blame


1 5261c201 2018-04-01 stsp /*
2 5261c201 2018-04-01 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 5261c201 2018-04-01 stsp *
4 5261c201 2018-04-01 stsp * Permission to use, copy, modify, and distribute this software for any
5 5261c201 2018-04-01 stsp * purpose with or without fee is hereby granted, provided that the above
6 5261c201 2018-04-01 stsp * copyright notice and this permission notice appear in all copies.
7 5261c201 2018-04-01 stsp *
8 5261c201 2018-04-01 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 5261c201 2018-04-01 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 5261c201 2018-04-01 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 5261c201 2018-04-01 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 5261c201 2018-04-01 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 5261c201 2018-04-01 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 5261c201 2018-04-01 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 5261c201 2018-04-01 stsp */
16 5261c201 2018-04-01 stsp
17 5261c201 2018-04-01 stsp /* A reference which points to an arbitrary object. */
18 5261c201 2018-04-01 stsp struct got_reference;
19 5261c201 2018-04-01 stsp
20 5261c201 2018-04-01 stsp /* Well-known reference names. */
21 5261c201 2018-04-01 stsp #define GOT_REF_HEAD "HEAD"
22 5261c201 2018-04-01 stsp #define GOT_REF_ORIG_HEAD "ORIG_HEAD"
23 5261c201 2018-04-01 stsp #define GOT_REF_MERGE_HEAD "MERGE_HEAD"
24 5261c201 2018-04-01 stsp #define GOT_REF_FETCH_HEAD "FETCH_HEAD"
25 5261c201 2018-04-01 stsp
26 5261c201 2018-04-01 stsp struct got_repository;
27 5261c201 2018-04-01 stsp struct got_object_id;
28 5261c201 2018-04-01 stsp
29 0c60ce5a 2018-04-02 stsp /*
30 0c60ce5a 2018-04-02 stsp * Attempt to open the reference with the provided name in a repository.
31 0c60ce5a 2018-04-02 stsp * The caller must dispose of it with got_ref_close().
32 0c60ce5a 2018-04-02 stsp */
33 6c34b1aa 2019-03-18 stsp const struct got_error *got_ref_open(struct got_reference **,
34 5261c201 2018-04-01 stsp struct got_repository *, const char *);
35 0c60ce5a 2018-04-02 stsp
36 5892cdd6 2019-03-10 stsp /*
37 5892cdd6 2019-03-10 stsp * Allocate a new reference for a given object ID.
38 5892cdd6 2019-03-10 stsp * The caller must dispose of it with got_ref_close().
39 5892cdd6 2019-03-10 stsp */
40 5892cdd6 2019-03-10 stsp const struct got_error *got_ref_alloc(struct got_reference **, const char *,
41 5892cdd6 2019-03-10 stsp struct got_object_id *);
42 5892cdd6 2019-03-10 stsp
43 0c60ce5a 2018-04-02 stsp /* Dispose of a reference. */
44 5261c201 2018-04-01 stsp void got_ref_close(struct got_reference *);
45 0c60ce5a 2018-04-02 stsp
46 0bd18d37 2019-02-01 stsp /* Get the name of the reference. */
47 0bd18d37 2019-02-01 stsp const char *got_ref_get_name(struct got_reference *);
48 0bd18d37 2019-02-01 stsp
49 0c60ce5a 2018-04-02 stsp /*
50 0c60ce5a 2018-04-02 stsp * Create a duplicate copy of a reference.
51 0c60ce5a 2018-04-02 stsp * The caller must dispose of this copy with got_ref_close().
52 0c60ce5a 2018-04-02 stsp */
53 5261c201 2018-04-01 stsp struct got_reference *got_ref_dup(struct got_reference *);
54 0c60ce5a 2018-04-02 stsp
55 0c60ce5a 2018-04-02 stsp /* Attempt to resolve a reference to an object ID. */
56 5261c201 2018-04-01 stsp const struct got_error *got_ref_resolve(struct got_object_id **,
57 5261c201 2018-04-01 stsp struct got_repository *, struct got_reference *);
58 0c60ce5a 2018-04-02 stsp
59 271d2a38 2018-12-25 stsp /*
60 271d2a38 2018-12-25 stsp * Return a string representation of a reference.
61 271d2a38 2018-12-25 stsp * The caller must dispose of it with free(3).
62 271d2a38 2018-12-25 stsp */
63 5261c201 2018-04-01 stsp char *got_ref_to_str(struct got_reference *);
64 199a4027 2019-02-02 stsp
65 199a4027 2019-02-02 stsp /* A list of references and the object ID which they resolve to. */
66 199a4027 2019-02-02 stsp struct got_reflist_entry {
67 199a4027 2019-02-02 stsp SIMPLEQ_ENTRY(got_reflist_entry) entry;
68 199a4027 2019-02-02 stsp struct got_reference *ref;
69 199a4027 2019-02-02 stsp struct got_object_id *id;
70 199a4027 2019-02-02 stsp };
71 199a4027 2019-02-02 stsp SIMPLEQ_HEAD(got_reflist_head, got_reflist_entry);
72 199a4027 2019-02-02 stsp
73 199a4027 2019-02-02 stsp /* Append all known references to a caller-provided ref list head. */
74 199a4027 2019-02-02 stsp const struct got_error *got_ref_list(struct got_reflist_head *,
75 199a4027 2019-02-02 stsp struct got_repository *);
76 9e672c74 2019-03-11 stsp
77 e2e879a0 2019-03-11 stsp /* Free all references on a ref list. */
78 e2e879a0 2019-03-11 stsp void got_ref_list_free(struct got_reflist_head *);
79 e2e879a0 2019-03-11 stsp
80 b249b824 2019-05-09 stsp /* Indicate whether the provided reference is symbolic (points at another
81 b249b824 2019-05-09 stsp * refernce) or not (points at an object ID). */
82 b249b824 2019-05-09 stsp int got_ref_is_symbolic(struct got_reference *);
83 b249b824 2019-05-09 stsp
84 b249b824 2019-05-09 stsp /* Change the object ID a reference points to. */
85 b249b824 2019-05-09 stsp const struct got_error *
86 b249b824 2019-05-09 stsp got_ref_change_ref(struct got_reference *, struct got_object_id *);
87 b249b824 2019-05-09 stsp
88 b249b824 2019-05-09 stsp /* Change the reference name a symbolic reference points to. */
89 b249b824 2019-05-09 stsp const struct got_error *got_ref_change_symref(struct got_reference *,
90 b249b824 2019-05-09 stsp char *);
91 b249b824 2019-05-09 stsp
92 9e672c74 2019-03-11 stsp /* Write a reference to its on-disk path in the repository. */
93 9e672c74 2019-03-11 stsp const struct got_error *got_ref_write(struct got_reference *,
94 9e672c74 2019-03-11 stsp struct got_repository *);
95 2d2e1378 2019-03-11 stsp
96 2d2e1378 2019-03-11 stsp /* Delete a reference from its on-disk path in the repository. */
97 2d2e1378 2019-03-11 stsp const struct got_error *got_ref_delete(struct got_reference *,
98 2d2e1378 2019-03-11 stsp struct got_repository *);