git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] log: prettier decorations
@ 2009-05-13 21:22 Felipe Contreras
  2009-05-13 21:22 ` [PATCH 1/3] Change prettify_ref to prettify_refname Felipe Contreras
  2009-05-13 21:28 ` [PATCH 0/3] log: prettier decorations Jeff King
  0 siblings, 2 replies; 7+ messages in thread
From: Felipe Contreras @ 2009-05-13 21:22 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Jeff King, Felipe Contreras

Hi,

This patch series simply improves log decorations so that they look like:

(tag: v1.6.3.1, origin/maint, master)

Instead of:

(tag: refs/tags/v1.6.3.1, refs/remotes/origin/maint, refs/heads/master)

In order to do that I had to change prettify_ref to prettify_refname because
add_ref_decoration doesn't have the ref object.

Felipe Contreras (3):
  Change prettify_ref to prettify_refname
  Prettify log decorations even more
  Fix test for new log decorate

 builtin-fetch.c                   |    2 +-
 builtin-send-pack.c               |    4 ++--
 log-tree.c                        |    1 +
 refs.c                            |    3 +--
 refs.h                            |    2 +-
 t/t4013/diff.log_--decorate_--all |    6 +++---
 transport.c                       |    4 ++--
 7 files changed, 11 insertions(+), 11 deletions(-)

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

* [PATCH 1/3] Change prettify_ref to prettify_refname
  2009-05-13 21:22 [PATCH 0/3] log: prettier decorations Felipe Contreras
@ 2009-05-13 21:22 ` Felipe Contreras
  2009-05-13 21:22   ` [PATCH 2/3] Prettify log decorations even more Felipe Contreras
  2009-05-13 21:28 ` [PATCH 0/3] log: prettier decorations Jeff King
  1 sibling, 1 reply; 7+ messages in thread
From: Felipe Contreras @ 2009-05-13 21:22 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Jeff King, Felipe Contreras

In preparation to be used when the ref object is not available

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin-fetch.c     |    2 +-
 builtin-send-pack.c |    4 ++--
 refs.c              |    3 +--
 refs.h              |    2 +-
 transport.c         |    4 ++--
 5 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/builtin-fetch.c b/builtin-fetch.c
index 3c998ea..ebd0c08 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -197,7 +197,7 @@ static int update_local_ref(struct ref *ref,
 	struct commit *current = NULL, *updated;
 	enum object_type type;
 	struct branch *current_branch = branch_get(NULL);
-	const char *pretty_ref = prettify_ref(ref);
+	const char *pretty_ref = prettify_refname(ref->name);
 
 	*display = 0;
 	type = sha1_object_info(ref->new_sha1, NULL);
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index d5a1c48..b2279b0 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -174,9 +174,9 @@ static void print_ref_status(char flag, const char *summary, struct ref *to, str
 {
 	fprintf(stderr, " %c %-*s ", flag, SUMMARY_WIDTH, summary);
 	if (from)
-		fprintf(stderr, "%s -> %s", prettify_ref(from), prettify_ref(to));
+		fprintf(stderr, "%s -> %s", prettify_refname(from->name), prettify_refname(to->name));
 	else
-		fputs(prettify_ref(to), stderr);
+		fputs(prettify_refname(to->name), stderr);
 	if (msg) {
 		fputs(" (", stderr);
 		fputs(msg, stderr);
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..c11f6a6 100644
--- a/refs.h
+++ b/refs.h
@@ -80,7 +80,7 @@ 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);
 extern char *shorten_unambiguous_ref(const char *ref, int strict);
 
 /** rename ref, return 0 on success **/
diff --git a/transport.c b/transport.c
index 3dfb03c..38c7f57 100644
--- a/transport.c
+++ b/transport.c
@@ -732,9 +732,9 @@ static void print_ref_status(char flag, const char *summary, struct ref *to, str
 {
 	fprintf(stderr, " %c %-*s ", flag, SUMMARY_WIDTH, summary);
 	if (from)
-		fprintf(stderr, "%s -> %s", prettify_ref(from), prettify_ref(to));
+		fprintf(stderr, "%s -> %s", prettify_refname(from->name), prettify_refname(to->name));
 	else
-		fputs(prettify_ref(to), stderr);
+		fputs(prettify_refname(to->name), stderr);
 	if (msg) {
 		fputs(" (", stderr);
 		fputs(msg, stderr);
-- 
1.6.3.1

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

* [PATCH 2/3] Prettify log decorations even more
  2009-05-13 21:22 ` [PATCH 1/3] Change prettify_ref to prettify_refname Felipe Contreras
@ 2009-05-13 21:22   ` Felipe Contreras
  2009-05-13 21:22     ` [PATCH 3/3] Fix test for new log decorate Felipe Contreras
  0 siblings, 1 reply; 7+ messages in thread
From: Felipe Contreras @ 2009-05-13 21:22 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Jeff King, 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 +
 1 files changed, 1 insertions(+), 0 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;
-- 
1.6.3.1

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

* [PATCH 3/3] Fix test for new log decorate
  2009-05-13 21:22   ` [PATCH 2/3] Prettify log decorations even more Felipe Contreras
@ 2009-05-13 21:22     ` Felipe Contreras
  0 siblings, 0 replies; 7+ messages in thread
From: Felipe Contreras @ 2009-05-13 21:22 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Jeff King, Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t4013/diff.log_--decorate_--all |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t4013/diff.log_--decorate_--all b/t/t4013/diff.log_--decorate_--all
index 12da8ac..954210e 100644
--- a/t/t4013/diff.log_--decorate_--all
+++ b/t/t4013/diff.log_--decorate_--all
@@ -1,12 +1,12 @@
 $ git log --decorate --all
-commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (refs/heads/master)
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (master)
 Merge: 9a6d494 c7a2ab9
 Author: A U Thor <author@example.com>
 Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side'
 
-commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (refs/heads/side)
+commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (side)
 Author: A U Thor <author@example.com>
 Date:   Mon Jun 26 00:03:00 2006 +0000
 
@@ -26,7 +26,7 @@ Date:   Mon Jun 26 00:01:00 2006 +0000
     
     This is the second commit.
 
-commit 444ac553ac7612cc88969031b02b3767fb8a353a (refs/heads/initial)
+commit 444ac553ac7612cc88969031b02b3767fb8a353a (initial)
 Author: A U Thor <author@example.com>
 Date:   Mon Jun 26 00:00:00 2006 +0000
 
-- 
1.6.3.1

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

* Re: [PATCH 0/3] log: prettier decorations
  2009-05-13 21:22 [PATCH 0/3] log: prettier decorations Felipe Contreras
  2009-05-13 21:22 ` [PATCH 1/3] Change prettify_ref to prettify_refname Felipe Contreras
@ 2009-05-13 21:28 ` Jeff King
  2009-05-13 21:32   ` [PATCH 2/2] Prettify log decorations even more Felipe Contreras
  2009-05-13 21:34   ` [PATCH 0/3] log: prettier decorations Felipe Contreras
  1 sibling, 2 replies; 7+ messages in thread
From: Jeff King @ 2009-05-13 21:28 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git, Junio C Hamano

On Thu, May 14, 2009 at 12:22:03AM +0300, Felipe Contreras wrote:

> In order to do that I had to change prettify_ref to prettify_refname because
> add_ref_decoration doesn't have the ref object.

Thanks, this 1/3 looks fine to me.

But:

> Felipe Contreras (3):
>   Change prettify_ref to prettify_refname
>   Prettify log decorations even more
>   Fix test for new log decorate

Shouldn't 2/3 and 3/3 just be squashed together? It looks like 3/3 fixes
tests broken in 2/3, so you are hurting bisectability if they don't
happen together.

Other than that, I think the intent of the change and the implementation
look fine.

-Peff

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

* [PATCH 2/2] Prettify log decorations even more
  2009-05-13 21:28 ` [PATCH 0/3] log: prettier decorations Jeff King
@ 2009-05-13 21:32   ` Felipe Contreras
  2009-05-13 21:34   ` [PATCH 0/3] log: prettier decorations Felipe Contreras
  1 sibling, 0 replies; 7+ messages in thread
From: Felipe Contreras @ 2009-05-13 21:32 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Jeff King, 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 +
 t/t4013/diff.log_--decorate_--all |    6 +++---
 2 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/t/t4013/diff.log_--decorate_--all b/t/t4013/diff.log_--decorate_--all
index 12da8ac..954210e 100644
--- a/t/t4013/diff.log_--decorate_--all
+++ b/t/t4013/diff.log_--decorate_--all
@@ -1,12 +1,12 @@
 $ git log --decorate --all
-commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (refs/heads/master)
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (master)
 Merge: 9a6d494 c7a2ab9
 Author: A U Thor <author@example.com>
 Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side'
 
-commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (refs/heads/side)
+commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (side)
 Author: A U Thor <author@example.com>
 Date:   Mon Jun 26 00:03:00 2006 +0000
 
@@ -26,7 +26,7 @@ Date:   Mon Jun 26 00:01:00 2006 +0000
     
     This is the second commit.
 
-commit 444ac553ac7612cc88969031b02b3767fb8a353a (refs/heads/initial)
+commit 444ac553ac7612cc88969031b02b3767fb8a353a (initial)
 Author: A U Thor <author@example.com>
 Date:   Mon Jun 26 00:00:00 2006 +0000
 
-- 
1.6.3.1

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

* Re: [PATCH 0/3] log: prettier decorations
  2009-05-13 21:28 ` [PATCH 0/3] log: prettier decorations Jeff King
  2009-05-13 21:32   ` [PATCH 2/2] Prettify log decorations even more Felipe Contreras
@ 2009-05-13 21:34   ` Felipe Contreras
  1 sibling, 0 replies; 7+ messages in thread
From: Felipe Contreras @ 2009-05-13 21:34 UTC (permalink / raw)
  To: Jeff King; +Cc: git, Junio C Hamano

On Thu, May 14, 2009 at 12:28 AM, Jeff King <peff@peff.net> wrote:
> On Thu, May 14, 2009 at 12:22:03AM +0300, Felipe Contreras wrote:
>
>> In order to do that I had to change prettify_ref to prettify_refname because
>> add_ref_decoration doesn't have the ref object.
>
> Thanks, this 1/3 looks fine to me.
>
> But:
>
>> Felipe Contreras (3):
>>   Change prettify_ref to prettify_refname
>>   Prettify log decorations even more
>>   Fix test for new log decorate
>
> Shouldn't 2/3 and 3/3 just be squashed together? It looks like 3/3 fixes
> tests broken in 2/3, so you are hurting bisectability if they don't
> happen together.

Yeah, I thought so too. Maybe I should trust my instinct a bit more =P

> Other than that, I think the intent of the change and the implementation
> look fine.

Cool. I squashed them and re-sent.

-- 
Felipe Contreras

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

end of thread, other threads:[~2009-05-13 21:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-13 21:22 [PATCH 0/3] log: prettier decorations Felipe Contreras
2009-05-13 21:22 ` [PATCH 1/3] Change prettify_ref to prettify_refname Felipe Contreras
2009-05-13 21:22   ` [PATCH 2/3] Prettify log decorations even more Felipe Contreras
2009-05-13 21:22     ` [PATCH 3/3] Fix test for new log decorate Felipe Contreras
2009-05-13 21:28 ` [PATCH 0/3] log: prettier decorations Jeff King
2009-05-13 21:32   ` [PATCH 2/2] Prettify log decorations even more Felipe Contreras
2009-05-13 21:34   ` [PATCH 0/3] log: prettier decorations 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).