From: Karthik Nayak <karthik.188@xxxxxxxxx> Add support for %(objectname:size=X) where X is a number. This will print the first X characters of an objectname. The minimum value for X is 5. Hence any value lesser than 5 will default to 5 characters. Mentored-by: Christian Couder <christian.couder@xxxxxxxxx> Mentored-by: Matthieu Moy <matthieu.moy@xxxxxxxxxxxxxxx> Signed-off-by: Karthik Nayak <karthik.188@xxxxxxxxx> --- ref-filter.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ref-filter.c b/ref-filter.c index 0a34924..4c5e3f8 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -196,6 +196,8 @@ static void *get_obj(const unsigned char *sha1, struct object **obj, unsigned lo static int grab_objectname(const char *name, const unsigned char *sha1, struct atom_value *v) { + const char *p; + if (!strcmp(name, "objectname")) { char *s = xmalloc(41); strcpy(s, sha1_to_hex(sha1)); @@ -206,6 +208,13 @@ static int grab_objectname(const char *name, const unsigned char *sha1, v->s = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV)); return 1; } + if (skip_prefix(name, "objectname:size=", &p)) { + unsigned int size = atoi(p); + if (size < 5) + size = 5; + v->s = xstrdup(find_unique_abbrev(sha1, size)); + return 1; + } return 0; } -- 2.4.6 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html