зеркало из https://github.com/microsoft/git.git
Notes API: get_note(): Return the note annotating the given object
Created by a simple cleanup and rename of lookup_notes(). Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
1ec666b092
Коммит
9b391f218a
15
notes.c
15
notes.c
|
@ -462,12 +462,13 @@ void remove_note(const unsigned char *object_sha1)
|
||||||
return note_tree_remove(&root_node, 0, &l);
|
return note_tree_remove(&root_node, 0, &l);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *lookup_notes(const unsigned char *object_sha1)
|
const unsigned char *get_note(const unsigned char *object_sha1)
|
||||||
{
|
{
|
||||||
struct leaf_node *found = note_tree_find(&root_node, 0, object_sha1);
|
struct leaf_node *found;
|
||||||
if (found)
|
|
||||||
return found->val_sha1;
|
assert(initialized);
|
||||||
return NULL;
|
found = note_tree_find(&root_node, 0, object_sha1);
|
||||||
|
return found ? found->val_sha1 : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_notes(void)
|
void free_notes(void)
|
||||||
|
@ -481,7 +482,7 @@ void format_note(const unsigned char *object_sha1, struct strbuf *sb,
|
||||||
const char *output_encoding, int flags)
|
const char *output_encoding, int flags)
|
||||||
{
|
{
|
||||||
static const char utf8[] = "utf-8";
|
static const char utf8[] = "utf-8";
|
||||||
unsigned char *sha1;
|
const unsigned char *sha1;
|
||||||
char *msg, *msg_p;
|
char *msg, *msg_p;
|
||||||
unsigned long linelen, msglen;
|
unsigned long linelen, msglen;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
|
@ -489,7 +490,7 @@ void format_note(const unsigned char *object_sha1, struct strbuf *sb,
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
init_notes(NULL, 0);
|
init_notes(NULL, 0);
|
||||||
|
|
||||||
sha1 = lookup_notes(object_sha1);
|
sha1 = get_note(object_sha1);
|
||||||
if (!sha1)
|
if (!sha1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
7
notes.h
7
notes.h
|
@ -28,6 +28,13 @@ void add_note(const unsigned char *object_sha1,
|
||||||
/* Remove the given note object from the internal notes tree structure */
|
/* Remove the given note object from the internal notes tree structure */
|
||||||
void remove_note(const unsigned char *object_sha1);
|
void remove_note(const unsigned char *object_sha1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the note object SHA1 containing the note data for the given object
|
||||||
|
*
|
||||||
|
* Return NULL if the given object has no notes.
|
||||||
|
*/
|
||||||
|
const unsigned char *get_note(const unsigned char *object_sha1);
|
||||||
|
|
||||||
/* Free (and de-initialize) the internal notes tree structure */
|
/* Free (and de-initialize) the internal notes tree structure */
|
||||||
void free_notes(void);
|
void free_notes(void);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче