1
1
#include "cache.h"
2
- #include "commit.h"
3
2
#include "notes.h"
4
3
#include "utf8.h"
5
4
#include "strbuf.h"
@@ -24,10 +23,10 @@ struct int_node {
24
23
/*
25
24
* Leaf nodes come in two variants, note entries and subtree entries,
26
25
* distinguished by the LSb of the leaf node pointer (see above).
27
- * As a note entry, the key is the SHA1 of the referenced commit , and the
26
+ * As a note entry, the key is the SHA1 of the referenced object , and the
28
27
* value is the SHA1 of the note object.
29
28
* As a subtree entry, the key is the prefix SHA1 (w/trailing NULs) of the
30
- * referenced commit , using the last byte of the key to store the length of
29
+ * referenced object , using the last byte of the key to store the length of
31
30
* the prefix. The value is the SHA1 of the tree object containing the notes
32
31
* subtree.
33
32
*/
@@ -210,7 +209,7 @@ static void note_tree_insert(struct int_node *tree, unsigned char n,
210
209
if (concatenate_notes (l -> val_sha1 ,
211
210
entry -> val_sha1 ))
212
211
die ("failed to concatenate note %s "
213
- "into note %s for commit %s" ,
212
+ "into note %s for object %s" ,
214
213
sha1_to_hex (entry -> val_sha1 ),
215
214
sha1_to_hex (l -> val_sha1 ),
216
215
sha1_to_hex (l -> key_sha1 ));
@@ -298,7 +297,7 @@ static int get_sha1_hex_segment(const char *hex, unsigned int hex_len,
298
297
static void load_subtree (struct leaf_node * subtree , struct int_node * node ,
299
298
unsigned int n )
300
299
{
301
- unsigned char commit_sha1 [20 ];
300
+ unsigned char object_sha1 [20 ];
302
301
unsigned int prefix_len ;
303
302
void * buf ;
304
303
struct tree_desc desc ;
@@ -311,23 +310,23 @@ static void load_subtree(struct leaf_node *subtree, struct int_node *node,
311
310
312
311
prefix_len = subtree -> key_sha1 [19 ];
313
312
assert (prefix_len * 2 >= n );
314
- memcpy (commit_sha1 , subtree -> key_sha1 , prefix_len );
313
+ memcpy (object_sha1 , subtree -> key_sha1 , prefix_len );
315
314
while (tree_entry (& desc , & entry )) {
316
315
int len = get_sha1_hex_segment (entry .path , strlen (entry .path ),
317
- commit_sha1 + prefix_len , 20 - prefix_len );
316
+ object_sha1 + prefix_len , 20 - prefix_len );
318
317
if (len < 0 )
319
318
continue ; /* entry.path is not a SHA1 sum. Skip */
320
319
len += prefix_len ;
321
320
322
321
/*
323
- * If commit SHA1 is complete (len == 20), assume note object
324
- * If commit SHA1 is incomplete (len < 20), assume note subtree
322
+ * If object SHA1 is complete (len == 20), assume note object
323
+ * If object SHA1 is incomplete (len < 20), assume note subtree
325
324
*/
326
325
if (len <= 20 ) {
327
326
unsigned char type = PTR_TYPE_NOTE ;
328
327
struct leaf_node * l = (struct leaf_node * )
329
328
xcalloc (sizeof (struct leaf_node ), 1 );
330
- hashcpy (l -> key_sha1 , commit_sha1 );
329
+ hashcpy (l -> key_sha1 , object_sha1 );
331
330
hashcpy (l -> val_sha1 , entry .sha1 );
332
331
if (len < 20 ) {
333
332
if (!S_ISDIR (entry .mode ))
@@ -343,22 +342,22 @@ static void load_subtree(struct leaf_node *subtree, struct int_node *node,
343
342
344
343
static void initialize_notes (const char * notes_ref_name )
345
344
{
346
- unsigned char sha1 [20 ], commit_sha1 [20 ];
345
+ unsigned char sha1 [20 ], object_sha1 [20 ];
347
346
unsigned mode ;
348
347
struct leaf_node root_tree ;
349
348
350
- if (!notes_ref_name || read_ref (notes_ref_name , commit_sha1 ) ||
351
- get_tree_entry (commit_sha1 , "" , sha1 , & mode ))
349
+ if (!notes_ref_name || read_ref (notes_ref_name , object_sha1 ) ||
350
+ get_tree_entry (object_sha1 , "" , sha1 , & mode ))
352
351
return ;
353
352
354
353
hashclr (root_tree .key_sha1 );
355
354
hashcpy (root_tree .val_sha1 , sha1 );
356
355
load_subtree (& root_tree , & root_node , 0 );
357
356
}
358
357
359
- static unsigned char * lookup_notes (const unsigned char * commit_sha1 )
358
+ static unsigned char * lookup_notes (const unsigned char * object_sha1 )
360
359
{
361
- struct leaf_node * found = note_tree_find (& root_node , 0 , commit_sha1 );
360
+ struct leaf_node * found = note_tree_find (& root_node , 0 , object_sha1 );
362
361
if (found )
363
362
return found -> val_sha1 ;
364
363
return NULL ;
@@ -371,7 +370,7 @@ void free_notes(void)
371
370
initialized = 0 ;
372
371
}
373
372
374
- void get_commit_notes (const struct commit * commit , struct strbuf * sb ,
373
+ void format_note (const unsigned char * object_sha1 , struct strbuf * sb ,
375
374
const char * output_encoding , int flags )
376
375
{
377
376
static const char utf8 [] = "utf-8" ;
@@ -390,7 +389,7 @@ void get_commit_notes(const struct commit *commit, struct strbuf *sb,
390
389
initialized = 1 ;
391
390
}
392
391
393
- sha1 = lookup_notes (commit -> object . sha1 );
392
+ sha1 = lookup_notes (object_sha1 );
394
393
if (!sha1 )
395
394
return ;
396
395
0 commit comments