@@ -41,6 +41,7 @@ void setup_ref_filter_porcelain_msg(void)
41
41
42
42
typedef enum { FIELD_STR , FIELD_ULONG , FIELD_TIME } cmp_type ;
43
43
typedef enum { COMPARE_EQUAL , COMPARE_UNEQUAL , COMPARE_NONE } cmp_status ;
44
+ typedef enum { SOURCE_NONE = 0 , SOURCE_OBJ , SOURCE_OTHER } info_source ;
44
45
45
46
struct align {
46
47
align_type position ;
@@ -73,6 +74,7 @@ struct refname_atom {
73
74
static struct used_atom {
74
75
const char * name ;
75
76
cmp_type type ;
77
+ info_source source ;
76
78
union {
77
79
char color [COLOR_MAXLEN ];
78
80
struct align align ;
@@ -380,49 +382,50 @@ static int head_atom_parser(const struct ref_format *format, struct used_atom *a
380
382
381
383
static struct {
382
384
const char * name ;
385
+ info_source source ;
383
386
cmp_type cmp_type ;
384
387
int (* parser )(const struct ref_format * format , struct used_atom * atom ,
385
388
const char * arg , struct strbuf * err );
386
389
} valid_atom [] = {
387
- { "refname" , FIELD_STR , refname_atom_parser },
388
- { "objecttype" },
389
- { "objectsize" , FIELD_ULONG },
390
- { "objectname" , FIELD_STR , objectname_atom_parser },
391
- { "tree" },
392
- { "parent" },
393
- { "numparent" , FIELD_ULONG },
394
- { "object" },
395
- { "type" },
396
- { "tag" },
397
- { "author" },
398
- { "authorname" },
399
- { "authoremail" },
400
- { "authordate" , FIELD_TIME },
401
- { "committer" },
402
- { "committername" },
403
- { "committeremail" },
404
- { "committerdate" , FIELD_TIME },
405
- { "tagger" },
406
- { "taggername" },
407
- { "taggeremail" },
408
- { "taggerdate" , FIELD_TIME },
409
- { "creator" },
410
- { "creatordate" , FIELD_TIME },
411
- { "subject" , FIELD_STR , subject_atom_parser },
412
- { "body" , FIELD_STR , body_atom_parser },
413
- { "trailers" , FIELD_STR , trailers_atom_parser },
414
- { "contents" , FIELD_STR , contents_atom_parser },
415
- { "upstream" , FIELD_STR , remote_ref_atom_parser },
416
- { "push" , FIELD_STR , remote_ref_atom_parser },
417
- { "symref" , FIELD_STR , refname_atom_parser },
418
- { "flag" },
419
- { "HEAD" , FIELD_STR , head_atom_parser },
420
- { "color" , FIELD_STR , color_atom_parser },
421
- { "align" , FIELD_STR , align_atom_parser },
422
- { "end" },
423
- { "if" , FIELD_STR , if_atom_parser },
424
- { "then" },
425
- { "else" },
390
+ { "refname" , SOURCE_NONE , FIELD_STR , refname_atom_parser },
391
+ { "objecttype" , SOURCE_OTHER },
392
+ { "objectsize" , SOURCE_OTHER , FIELD_ULONG },
393
+ { "objectname" , SOURCE_OTHER , FIELD_STR , objectname_atom_parser },
394
+ { "tree" , SOURCE_OBJ },
395
+ { "parent" , SOURCE_OBJ },
396
+ { "numparent" , SOURCE_OBJ , FIELD_ULONG },
397
+ { "object" , SOURCE_OBJ },
398
+ { "type" , SOURCE_OBJ },
399
+ { "tag" , SOURCE_OBJ },
400
+ { "author" , SOURCE_OBJ },
401
+ { "authorname" , SOURCE_OBJ },
402
+ { "authoremail" , SOURCE_OBJ },
403
+ { "authordate" , SOURCE_OBJ , FIELD_TIME },
404
+ { "committer" , SOURCE_OBJ },
405
+ { "committername" , SOURCE_OBJ },
406
+ { "committeremail" , SOURCE_OBJ },
407
+ { "committerdate" , SOURCE_OBJ , FIELD_TIME },
408
+ { "tagger" , SOURCE_OBJ },
409
+ { "taggername" , SOURCE_OBJ },
410
+ { "taggeremail" , SOURCE_OBJ },
411
+ { "taggerdate" , SOURCE_OBJ , FIELD_TIME },
412
+ { "creator" , SOURCE_OBJ },
413
+ { "creatordate" , SOURCE_OBJ , FIELD_TIME },
414
+ { "subject" , SOURCE_OBJ , FIELD_STR , subject_atom_parser },
415
+ { "body" , SOURCE_OBJ , FIELD_STR , body_atom_parser },
416
+ { "trailers" , SOURCE_OBJ , FIELD_STR , trailers_atom_parser },
417
+ { "contents" , SOURCE_OBJ , FIELD_STR , contents_atom_parser },
418
+ { "upstream" , SOURCE_NONE , FIELD_STR , remote_ref_atom_parser },
419
+ { "push" , SOURCE_NONE , FIELD_STR , remote_ref_atom_parser },
420
+ { "symref" , SOURCE_NONE , FIELD_STR , refname_atom_parser },
421
+ { "flag" , SOURCE_NONE },
422
+ { "HEAD" , SOURCE_NONE , FIELD_STR , head_atom_parser },
423
+ { "color" , SOURCE_NONE , FIELD_STR , color_atom_parser },
424
+ { "align" , SOURCE_NONE , FIELD_STR , align_atom_parser },
425
+ { "end" , SOURCE_NONE },
426
+ { "if" , SOURCE_NONE , FIELD_STR , if_atom_parser },
427
+ { "then" , SOURCE_NONE },
428
+ { "else" , SOURCE_NONE },
426
429
};
427
430
428
431
#define REF_FORMATTING_STATE_INIT { 0, NULL }
@@ -498,6 +501,7 @@ static int parse_ref_filter_atom(const struct ref_format *format,
498
501
REALLOC_ARRAY (used_atom , used_atom_cnt );
499
502
used_atom [at ].name = xmemdupz (atom , ep - atom );
500
503
used_atom [at ].type = valid_atom [i ].cmp_type ;
504
+ used_atom [at ].source = valid_atom [i ].source ;
501
505
if (arg ) {
502
506
arg = used_atom [at ].name + (arg - atom ) + 1 ;
503
507
if (!* arg ) {
0 commit comments