ref-filter: add short modifier to 'tree' atom
Sometimes while using 'tree' atom, user might want to see abbrev hash instead of full 40 character hash. Just like 'objectname', it might be convenient for users to have the `:short` and `:short=<length>` option for printing 'tree' hash. Let's introduce `short` option to 'tree' atom. Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Heba Waly <heba.waly@gmail.com> Signed-off-by: Hariom Verma <hariom18599@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
87d3beb6e0
commit
837adb102f
@ -497,7 +497,7 @@ static struct {
|
||||
{ "objectsize", SOURCE_OTHER, FIELD_ULONG, objectsize_atom_parser },
|
||||
{ "objectname", SOURCE_OTHER, FIELD_STR, oid_atom_parser },
|
||||
{ "deltabase", SOURCE_OTHER, FIELD_STR, deltabase_atom_parser },
|
||||
{ "tree", SOURCE_OBJ },
|
||||
{ "tree", SOURCE_OBJ, FIELD_STR, oid_atom_parser },
|
||||
{ "parent", SOURCE_OBJ },
|
||||
{ "numparent", SOURCE_OBJ, FIELD_ULONG },
|
||||
{ "object", SOURCE_OBJ },
|
||||
@ -1005,10 +1005,9 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object
|
||||
continue;
|
||||
if (deref)
|
||||
name++;
|
||||
if (!strcmp(name, "tree")) {
|
||||
v->s = xstrdup(oid_to_hex(get_commit_tree_oid(commit)));
|
||||
}
|
||||
else if (!strcmp(name, "numparent")) {
|
||||
if (grab_oid(name, "tree", get_commit_tree_oid(commit), v, &used_atom[i]))
|
||||
continue;
|
||||
if (!strcmp(name, "numparent")) {
|
||||
v->value = commit_list_count(commit->parents);
|
||||
v->s = xstrfmt("%lu", (unsigned long)v->value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user