summaryrefslogtreecommitdiff
path: root/notes-utils.c
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-utils.c
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-utils.c')
-rw-r--r--notes-utils.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/notes-utils.c b/notes-utils.c
index 299e34bccc..24a33616a4 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -37,7 +37,7 @@ void commit_notes(struct notes_tree *t, const char *msg)
if (!t)
t = &default_notes_tree;
- if (!t->initialized || !t->ref || !*t->ref)
+ if (!t->initialized || !t->update_ref || !*t->update_ref)
die(_("Cannot commit uninitialized/unreferenced notes tree"));
if (!t->dirty)
return; /* don't have to commit an unchanged tree */
@@ -48,7 +48,7 @@ void commit_notes(struct notes_tree *t, const char *msg)
create_notes_commit(t, NULL, buf.buf, buf.len, commit_sha1);
strbuf_insert(&buf, 0, "notes: ", 7); /* commit message starts at index 7 */
- update_ref(buf.buf, t->ref, commit_sha1, NULL, 0,
+ update_ref(buf.buf, t->update_ref, commit_sha1, NULL, 0,
UPDATE_REFS_DIE_ON_ERR);
strbuf_release(&buf);
@@ -148,7 +148,7 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)
free(c);
return NULL;
}
- c->trees = load_notes_trees(c->refs);
+ c->trees = load_notes_trees(c->refs, NOTES_INIT_WRITABLE);
string_list_clear(c->refs, 0);
free(c->refs);
return c;