Blame


1 9139e004 2023-07-17 thomas /*
2 9139e004 2023-07-17 thomas * Copyright (c) 2023 Mark Jamsek <mark@jamsek.dev>
3 9139e004 2023-07-17 thomas *
4 9139e004 2023-07-17 thomas * Permission to use, copy, modify, and distribute this software for any
5 9139e004 2023-07-17 thomas * purpose with or without fee is hereby granted, provided that the above
6 9139e004 2023-07-17 thomas * copyright notice and this permission notice appear in all copies.
7 9139e004 2023-07-17 thomas *
8 9139e004 2023-07-17 thomas * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 9139e004 2023-07-17 thomas * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 9139e004 2023-07-17 thomas * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 9139e004 2023-07-17 thomas * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 9139e004 2023-07-17 thomas * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 9139e004 2023-07-17 thomas * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 9139e004 2023-07-17 thomas * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 9139e004 2023-07-17 thomas */
16 9139e004 2023-07-17 thomas
17 9139e004 2023-07-17 thomas /*
18 9139e004 2023-07-17 thomas * Commit keywords to specify references in the repository
19 9139e004 2023-07-17 thomas * (cf. svn keywords, fossil special tags, hg revsets).
20 9139e004 2023-07-17 thomas */
21 9139e004 2023-07-17 thomas #define GOT_KEYWORD_BASE "base" /* work tree base commit */
22 9139e004 2023-07-17 thomas #define GOT_KEYWORD_HEAD "head" /* worktree/repo HEAD commit */
23 9139e004 2023-07-17 thomas
24 9139e004 2023-07-17 thomas /*
25 9139e004 2023-07-17 thomas * Parse a commit id string for keywords and/or lineage modifiers "(+|-)[N]".
26 9139e004 2023-07-17 thomas * Valid keywords are "base" or "head" and must be prefixed with a ":".
27 9139e004 2023-07-17 thomas * Lineage modifiers must be prefixed with a ":" and may suffix keywords or
28 9139e004 2023-07-17 thomas * reference names:
29 9139e004 2023-07-17 thomas * :keyword:(+/-)N Nth generation descendant/antecedent of keyword
30 9139e004 2023-07-17 thomas * :keyword:(+/-) 1st generation descendant/antecedent of keyword
31 9139e004 2023-07-17 thomas * :keyword commit pointed to by keyword
32 9139e004 2023-07-17 thomas * ref:(+/-)[N] Nth generation descendant/antecedent of ref
33 9139e004 2023-07-17 thomas * If a match is found, return the corresponding commit id string in the
34 9139e004 2023-07-17 thomas * char ** out parameter, of which the caller takes ownership and must free.
35 9139e004 2023-07-17 thomas * Otherwise it will contain NULL, indicating a match was not found.
36 9139e004 2023-07-17 thomas * If the modifier is greater than the number of ancestors/descendants, the id
37 9139e004 2023-07-17 thomas * string of the oldest/most recent commit (i.e., ROOT/HEAD) will be returned.
38 9139e004 2023-07-17 thomas */
39 9139e004 2023-07-17 thomas const struct got_error *got_keyword_to_idstr(char **, const char *,
40 9139e004 2023-07-17 thomas struct got_repository *, struct got_worktree *);