1 /* Copyright (c) 2006-2014 Jonas Fonseca <jonas.fonseca@gmail.com>
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.
18 #include "tig/types.h"
25 enum reference_type type
;
26 char id
[SIZEOF_REV
]; /* Commit SHA1 ID */
27 unsigned int valid
:1; /* Is the ref still valid? */
28 char name
[1]; /* Ref name; tag or head names are shortened. */
31 #define is_initial_commit() (!get_ref_head())
32 #define is_head_commit(rev) (!strcmp((rev), "HEAD") || (get_ref_head() && !strncmp(rev, get_ref_head()->id, SIZEOF_REV - 1)))
33 #define ref_is_tag(ref) ((ref)->type == REFERENCE_TAG || (ref)->type == REFERENCE_LOCAL_TAG)
34 #define ref_is_remote(ref) ((ref)->type == REFERENCE_REMOTE || (ref)->type == REFERENCE_TRACKED_REMOTE)
36 #define foreach_ref_list(ref, id) for (ref = get_ref_list(id); ref; ref = ref->next)
38 const struct ref
*get_ref_head();
39 const struct ref
*get_ref_list(const char *id
);
40 const struct ref
*get_canonical_ref(const char *id
);
41 bool ref_list_contains_tag(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
);
45 int ref_compare(const struct ref
*ref1
, const struct ref
*ref2
);
46 void ref_update_env(struct argv_env
*env
, const struct ref
*ref
, bool clear
);
48 bool refs_contain_tag(void);
55 const struct ref_format
*get_ref_format(const struct ref
*ref
);
56 enum status_code
parse_ref_formats(const char *argv
[]);
60 /* vim: set ts=8 sw=8 noexpandtab: */