git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH] Prettify log decorations even more
@ 2009-05-06 22:45 Felipe Contreras
  2009-05-08  7:45 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Felipe Contreras @ 2009-05-06 22:45 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

"tag: v1.6.2.5" looks much better than "tag: refs/tags/v1.6.2.5".

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 log-tree.c |    1 +
 refs.c     |    3 +--
 refs.h     |    3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/log-tree.c b/log-tree.c
index 5bd29e6..59d63eb 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -25,6 +25,7 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
 	struct object *obj = parse_object(sha1);
 	if (!obj)
 		return 0;
+	refname = prettify_refname(refname);
 	add_name_decoration("", refname, obj);
 	while (obj->type == OBJ_TAG) {
 		obj = ((struct tag *)obj)->tagged;
diff --git a/refs.c b/refs.c
index e65a3b4..e74461e 100644
--- a/refs.c
+++ b/refs.c
@@ -750,9 +750,8 @@ int check_ref_format(const char *ref)
 	}
 }
 
-const char *prettify_ref(const struct ref *ref)
+const char *prettify_refname(const char *name)
 {
-	const char *name = ref->name;
 	return name + (
 		!prefixcmp(name, "refs/heads/") ? 11 :
 		!prefixcmp(name, "refs/tags/") ? 10 :
diff --git a/refs.h b/refs.h
index 29d17a4..3de5e1c 100644
--- a/refs.h
+++ b/refs.h
@@ -80,7 +80,8 @@ extern int for_each_reflog(each_ref_fn, void *);
 #define CHECK_REF_FORMAT_WILDCARD (-3)
 extern int check_ref_format(const char *target);
 
-extern const char *prettify_ref(const struct ref *ref);
+extern const char *prettify_refname(const char *refname);
+#define prettify_ref(ref) prettify_refname((ref)->name)
 extern char *shorten_unambiguous_ref(const char *ref, int strict);
 
 /** rename ref, return 0 on success **/
-- 
1.6.3.rc4.14.g96da.dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC/PATCH] Prettify log decorations even more
  2009-05-06 22:45 [RFC/PATCH] Prettify log decorations even more Felipe Contreras
@ 2009-05-08  7:45 ` Jeff King
  2009-05-08  7:49   ` Felipe Contreras
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2009-05-08  7:45 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git, Junio C Hamano

On Thu, May 07, 2009 at 01:45:48AM +0300, Felipe Contreras wrote:

> -extern const char *prettify_ref(const struct ref *ref);
> +extern const char *prettify_refname(const char *refname);
> +#define prettify_ref(ref) prettify_refname((ref)->name)

I think it is an improvement for this function to take just the name,
but I don't see much point in keeping the crufty #define compatibility.
I would just fix up the few callers, as it really is just
s/ref/ref->name/.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC/PATCH] Prettify log decorations even more
  2009-05-08  7:45 ` Jeff King
@ 2009-05-08  7:49   ` Felipe Contreras
  0 siblings, 0 replies; 3+ messages in thread
From: Felipe Contreras @ 2009-05-08  7:49 UTC (permalink / raw)
  To: Jeff King; +Cc: git, Junio C Hamano

On Fri, May 8, 2009 at 10:45 AM, Jeff King <peff@peff.net> wrote:
> On Thu, May 07, 2009 at 01:45:48AM +0300, Felipe Contreras wrote:
>
>> -extern const char *prettify_ref(const struct ref *ref);
>> +extern const char *prettify_refname(const char *refname);
>> +#define prettify_ref(ref) prettify_refname((ref)->name)
>
> I think it is an improvement for this function to take just the name,
> but I don't see much point in keeping the crufty #define compatibility.
> I would just fix up the few callers, as it really is just
> s/ref/ref->name/.

Good, I started doing that but I thought it would create a big diff
and perhaps it was best to send some RFC before.

Will do that.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-08  7:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-06 22:45 [RFC/PATCH] Prettify log decorations even more Felipe Contreras
2009-05-08  7:45 ` Jeff King
2009-05-08  7:49   ` Felipe Contreras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).