Move refs helpers to refs module
[tig.git] / include / refs.h
blob56869446d8045104daec96173ccaf0f3deb57372
1 /* Copyright (c) 2006-2013 Jonas Fonseca <fonseca@diku.dk>
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License as
5 * published by the Free Software Foundation; either version 2 of
6 * the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef TIG_REFS_H
15 #define TIG_REFS_H
17 #include "tig.h"
19 struct ref {
20 char id[SIZEOF_REV]; /* Commit SHA1 ID */
21 unsigned int head:1; /* Is it the current HEAD? */
22 unsigned int tag:1; /* Is it a tag? */
23 unsigned int ltag:1; /* If so, is the tag local? */
24 unsigned int remote:1; /* Is it a remote ref? */
25 unsigned int replace:1; /* Is it a replace ref? */
26 unsigned int tracked:1; /* Is it the remote for the current HEAD? */
27 unsigned int valid:1; /* Is the ref still valid? */
28 char name[1]; /* Ref name; tag or head names are shortened. */
31 struct ref_list {
32 char id[SIZEOF_REV]; /* Commit SHA1 ID */
33 size_t size; /* Number of refs. */
34 struct ref **refs; /* References for this ID. */
37 #define is_initial_commit() (!get_ref_head())
38 #define is_head_commit(rev) (!strcmp((rev), "HEAD") || (get_ref_head() && !strncmp(rev, get_ref_head()->id, SIZEOF_REV - 1)))
40 struct ref *get_ref_head();
41 struct ref_list *get_ref_list(const char *id);
42 void foreach_ref(bool (*visitor)(void *data, const struct ref *ref), void *data);
43 int load_refs(bool force);
44 int add_ref(const char *id, char *name, const char *remote_name, const char *head);
46 #endif
48 /* vim: set ts=8 sw=8 noexpandtab: */