summaryrefslogtreecommitdiff
path: root/notes.h
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2015-10-08 11:54:43 +0900
committerJunio C Hamano <gitster@pobox.com>2016-01-12 15:10:01 -0800
commitee76f92fe883305c1260952f5b325b0503311fc9 (patch)
tree6cea77bd1955070b9f56832d803ac0b70448f59f /notes.h
parent754884255bb580df159e58defa81cdd30b5c430c (diff)
downloadgit-ee76f92fe883305c1260952f5b325b0503311fc9.tar.gz
notes: allow treeish expressions as notes refmh/notes-allow-reading-treeish
init_notes() is the main point of entry to the notes API. It ensures that the input can be used as ref, because it needs a ref to update to store notes tree after modifying it. There however are many use cases where notes tree is only read, e.g. "git log --notes=...". Any notes-shaped treeish could be used for such purpose, but it is not allowed due to existing restriction. Allow treeish expressions to be used in the case the notes tree is going to be used without write "permissions". Add a flag to distinguish whether the notes tree is intended to be used read-only, or will be updated. With this change, operations that use notes read-only can be fed any notes-shaped tree-ish can be used, e.g. git log --notes=notes@{1}. Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes.h')
-rw-r--r--notes.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/notes.h b/notes.h
index 2a3f923380..e5d67fd375 100644
--- a/notes.h
+++ b/notes.h
@@ -44,6 +44,7 @@ extern struct notes_tree {
struct int_node *root;
struct non_note *first_non_note, *prev_non_note;
char *ref;
+ char *update_ref;
combine_notes_fn combine_notes;
int initialized;
int dirty;
@@ -72,6 +73,13 @@ const char *default_notes_ref(void);
#define NOTES_INIT_EMPTY 1
/*
+ * By default, the notes tree is only readable, and the notes ref can be
+ * any treeish. The notes tree can however be made writable with this flag,
+ * in which case only strict ref names can be used.
+ */
+#define NOTES_INIT_WRITABLE 2
+
+/*
* Initialize the given notes_tree with the notes tree structure at the given
* ref. If given ref is NULL, the value of the $GIT_NOTES_REF environment
* variable is used, and if that is missing, the default notes ref is used
@@ -276,7 +284,7 @@ void format_display_notes(const unsigned char *object_sha1,
* Load the notes tree from each ref listed in 'refs'. The output is
* an array of notes_tree*, terminated by a NULL.
*/
-struct notes_tree **load_notes_trees(struct string_list *refs);
+struct notes_tree **load_notes_trees(struct string_list *refs, int flags);
/*
* Add all refs that match 'glob' to the 'list'.