Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Stop leaking the short hash of an object link
Diffstat (limited to 'source/ui-shared.c')
-rw-r--r--source/ui-shared.c11
1 file changed, 4 insertions, 7 deletions
diff --git a/source/ui-shared.c b/source/ui-shared.c
index 9ad398f..2760f64 100644
--- a/source/ui-shared.c
+++ b/source/ui-shared.c
@@ -1076,16 +1076,13 @@ void cgit_stats_link(const char *name, const char *title, const char *class,
void cgit_object_link(struct object *obj, int full)
{
const char *page;
- char *shortrev, *fullrev, *name;
+ char *fullrev, *name;
fullrev = oid_to_hex(&obj->oid);
- if (full) {
+ if (full)
name = cgit_fmt("%s %s", type_name(obj->type), fullrev);
- } else {
- shortrev = xstrdup(fullrev);
- shortrev[SHORT_HASH_LEN] = '\0';
- name = cgit_fmt("%s %s...", type_name(obj->type), shortrev);
- }
+ else
+ name = cgit_fmt("%s %.*s...", type_name(obj->type), SHORT_HASH_LEN, fullrev);
if (obj->type == OBJ_COMMIT) {
cgit_commit_link(name, NULL, NULL, ctx.qry.head, fullrev, NULL);
return;