Blob


1 /*
2 * Copyright (c) 2023 Mark Jamsek <mark@jamsek.dev>
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 /*
18 * Commit keywords to specify references in the repository
19 * (cf. svn keywords, fossil special tags, hg revsets).
20 */
21 #define GOT_KEYWORD_BASE "base" /* work tree base commit */
22 #define GOT_KEYWORD_HEAD "head" /* worktree/repo HEAD commit */
24 /*
25 * Parse a commit id string for keywords and/or lineage modifiers "(+|-)[N]".
26 * Valid keywords are "base" or "head" and must be prefixed with a ":".
27 * Lineage modifiers must be prefixed with a ":" and may suffix keywords or
28 * reference names:
29 * :keyword:(+/-)N Nth generation descendant/antecedent of keyword
30 * :keyword:(+/-) 1st generation descendant/antecedent of keyword
31 * :keyword commit pointed to by keyword
32 * ref:(+/-)[N] Nth generation descendant/antecedent of ref
33 * If a match is found, return the corresponding commit id string in the
34 * char ** out parameter, of which the caller takes ownership and must free.
35 * Otherwise it will contain NULL, indicating a match was not found.
36 * If the modifier is greater than the number of ancestors/descendants, the id
37 * string of the oldest/most recent commit (i.e., ROOT/HEAD) will be returned.
38 */
39 const struct got_error *got_keyword_to_idstr(char **, const char *,
40 struct got_repository *, struct got_worktree *);