List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH 1/1] ui-log: highlight annotated tags in different color
@ 2018-06-05 10:47 list
  2018-06-05 11:03 ` john
  0 siblings, 1 reply; 5+ messages in thread
From: list @ 2018-06-05 10:47 UTC (permalink / raw)


From: Christian Hesse <mail at eworm.de>

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 cgit.css | 8 ++++++++
 ui-log.c | 7 ++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/cgit.css b/cgit.css
index 217a05a..05c4530 100644
--- a/cgit.css
+++ b/cgit.css
@@ -685,6 +685,14 @@ div#cgit a.tag-deco {
 	border: solid 1px #777700;
 }
 
+div#cgit a.tag-annotated-deco {
+	color: #000;
+	margin: 0px 0.5em;
+	padding: 0px 0.25em;
+	background-color: #ffcc88;
+	border: solid 1px #777700;
+}
+
 div#cgit a.remote-deco {
 	color: #000;
 	margin: 0px 0.5em;
diff --git a/ui-log.c b/ui-log.c
index 8e36fba..b8344a8 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -56,8 +56,10 @@ static void inspect_files(struct diff_filepair *pair)
 
 void show_commit_decorations(struct commit *commit)
 {
+	struct object_id peeled;
 	const struct name_decoration *deco;
 	static char buf[1024];
+	int is_annotated;
 
 	buf[sizeof(buf) - 1] = 0;
 	deco = get_name_decoration(&commit->object);
@@ -65,6 +67,7 @@ void show_commit_decorations(struct commit *commit)
 		return;
 	html("<span class='decoration'>");
 	while (deco) {
+		is_annotated = 0;
 		strncpy(buf, prettify_refname(deco->name), sizeof(buf) - 1);
 		switch(deco->type) {
 		case DECORATION_NONE:
@@ -77,7 +80,9 @@ void show_commit_decorations(struct commit *commit)
 				ctx.qry.showmsg, 0);
 			break;
 		case DECORATION_REF_TAG:
-			cgit_tag_link(buf, NULL, "tag-deco", buf);
+			if (!peel_ref(deco->name, &peeled))
+				is_annotated = !oidcmp(&commit->object.oid, &peeled);
+			cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf);
 			break;
 		case DECORATION_REF_REMOTE:
 			if (!ctx.repo->enable_remote_branches)


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

* [PATCH 1/1] ui-log: highlight annotated tags in different color
  2018-06-05 10:47 [PATCH 1/1] ui-log: highlight annotated tags in different color list
@ 2018-06-05 11:03 ` john
  2018-06-05 11:37   ` list
  0 siblings, 1 reply; 5+ messages in thread
From: john @ 2018-06-05 11:03 UTC (permalink / raw)


On Tue, Jun 05, 2018 at 12:47:52PM +0200, Christian Hesse wrote:
> Signed-off-by: Christian Hesse <mail at eworm.de>

Can you say a little about why this is desirable as a feature?

> ---
>  cgit.css | 8 ++++++++
>  ui-log.c | 7 ++++++-
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/cgit.css b/cgit.css
> index 217a05a..05c4530 100644
> --- a/cgit.css
> +++ b/cgit.css
> @@ -685,6 +685,14 @@ div#cgit a.tag-deco {
>  	border: solid 1px #777700;
>  }
>  
> +div#cgit a.tag-annotated-deco {
> +	color: #000;
> +	margin: 0px 0.5em;
> +	padding: 0px 0.25em;
> +	background-color: #ffcc88;
> +	border: solid 1px #777700;
> +}
> +
>  div#cgit a.remote-deco {
>  	color: #000;
>  	margin: 0px 0.5em;
> diff --git a/ui-log.c b/ui-log.c
> index 8e36fba..b8344a8 100644
> --- a/ui-log.c
> +++ b/ui-log.c
> @@ -56,8 +56,10 @@ static void inspect_files(struct diff_filepair *pair)
>  
>  void show_commit_decorations(struct commit *commit)
>  {
> +	struct object_id peeled;
>  	const struct name_decoration *deco;
>  	static char buf[1024];
> +	int is_annotated;

The two new declarations could be moved ...

>  	buf[sizeof(buf) - 1] = 0;
>  	deco = get_name_decoration(&commit->object);
> @@ -65,6 +67,7 @@ void show_commit_decorations(struct commit *commit)
>  		return;
>  	html("<span class='decoration'>");
>  	while (deco) {
> +		is_annotated = 0;

... here, which will make it more obvious that is_annotated is being
initialized correctly (it took me a minute to spot this and I initially
worried that is_annotated was used without initialization if peel_ref
fails).

>  		strncpy(buf, prettify_refname(deco->name), sizeof(buf) - 1);
>  		switch(deco->type) {
>  		case DECORATION_NONE:
> @@ -77,7 +80,9 @@ void show_commit_decorations(struct commit *commit)
>  				ctx.qry.showmsg, 0);
>  			break;
>  		case DECORATION_REF_TAG:
> -			cgit_tag_link(buf, NULL, "tag-deco", buf);
> +			if (!peel_ref(deco->name, &peeled))
> +				is_annotated = !oidcmp(&commit->object.oid, &peeled);
> +			cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf);
>  			break;
>  		case DECORATION_REF_REMOTE:
>  			if (!ctx.repo->enable_remote_branches)


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

* [PATCH 1/1] ui-log: highlight annotated tags in different color
  2018-06-05 11:03 ` john
@ 2018-06-05 11:37   ` list
  2018-06-05 11:40     ` [PATCH v2 " list
  0 siblings, 1 reply; 5+ messages in thread
From: list @ 2018-06-05 11:37 UTC (permalink / raw)


John Keeping <john at keeping.me.uk> on Tue, 2018/06/05 12:03:
> On Tue, Jun 05, 2018 at 12:47:52PM +0200, Christian Hesse wrote:
> > Signed-off-by: Christian Hesse <mail at eworm.de>  
> 
> Can you say a little about why this is desirable as a feature?

Annotated tags have some extra information... Descriptive text or signature.
Highlighting annotated tags in a different color show what tag may be worth
clicking for extra information.
I've always loved tig to show annotated tags in different color.

> > ---
> >  cgit.css | 8 ++++++++
> >  ui-log.c | 7 ++++++-
> >  2 files changed, 14 insertions(+), 1 deletion(-)
> > 
> > diff --git a/cgit.css b/cgit.css
> > index 217a05a..05c4530 100644
> > --- a/cgit.css
> > +++ b/cgit.css
> > @@ -685,6 +685,14 @@ div#cgit a.tag-deco {
> >  	border: solid 1px #777700;
> >  }
> >  
> > +div#cgit a.tag-annotated-deco {
> > +	color: #000;
> > +	margin: 0px 0.5em;
> > +	padding: 0px 0.25em;
> > +	background-color: #ffcc88;
> > +	border: solid 1px #777700;
> > +}
> > +
> >  div#cgit a.remote-deco {
> >  	color: #000;
> >  	margin: 0px 0.5em;
> > diff --git a/ui-log.c b/ui-log.c
> > index 8e36fba..b8344a8 100644
> > --- a/ui-log.c
> > +++ b/ui-log.c
> > @@ -56,8 +56,10 @@ static void inspect_files(struct diff_filepair *pair)
> >  
> >  void show_commit_decorations(struct commit *commit)
> >  {
> > +	struct object_id peeled;
> >  	const struct name_decoration *deco;
> >  	static char buf[1024];
> > +	int is_annotated;  
> 
> The two new declarations could be moved ...
> 
> >  	buf[sizeof(buf) - 1] = 0;
> >  	deco = get_name_decoration(&commit->object);
> > @@ -65,6 +67,7 @@ void show_commit_decorations(struct commit *commit)
> >  		return;
> >  	html("<span class='decoration'>");
> >  	while (deco) {
> > +		is_annotated = 0;  
> 
> ... here, which will make it more obvious that is_annotated is being
> initialized correctly (it took me a minute to spot this and I initially
> worried that is_annotated was used without initialization if peel_ref
> fails).

That's true, will update the patch and resend.

> >  		strncpy(buf, prettify_refname(deco->name), sizeof(buf) -
> > 1); switch(deco->type) {
> >  		case DECORATION_NONE:
> > @@ -77,7 +80,9 @@ void show_commit_decorations(struct commit *commit)
> >  				ctx.qry.showmsg, 0);
> >  			break;
> >  		case DECORATION_REF_TAG:
> > -			cgit_tag_link(buf, NULL, "tag-deco", buf);
> > +			if (!peel_ref(deco->name, &peeled))
> > +				is_annotated
> > = !oidcmp(&commit->object.oid, &peeled);
> > +			cgit_tag_link(buf, NULL, is_annotated ?
> > "tag-annotated-deco" : "tag-deco", buf); break;
> >  		case DECORATION_REF_REMOTE:
> >  			if (!ctx.repo->enable_remote_branches)  



-- 
main(a){char*c=/*    Schoene Gruesse                         */"B?IJj;MEH"
"CX:;",b;for(a/*    Best regards             my address:    */=0;b=c[a++];)
putchar(b-1/(/*    Chris            cc -ox -xc - && ./x    */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20180605/db816a12/attachment.asc>


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

* [PATCH v2 1/1] ui-log: highlight annotated tags in different color
  2018-06-05 11:37   ` list
@ 2018-06-05 11:40     ` list
  2018-06-05 14:26       ` john
  0 siblings, 1 reply; 5+ messages in thread
From: list @ 2018-06-05 11:40 UTC (permalink / raw)


From: Christian Hesse <mail at eworm.de>

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 cgit.css | 8 ++++++++
 ui-log.c | 6 +++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/cgit.css b/cgit.css
index 217a05a..05c4530 100644
--- a/cgit.css
+++ b/cgit.css
@@ -685,6 +685,14 @@ div#cgit a.tag-deco {
 	border: solid 1px #777700;
 }
 
+div#cgit a.tag-annotated-deco {
+	color: #000;
+	margin: 0px 0.5em;
+	padding: 0px 0.25em;
+	background-color: #ffcc88;
+	border: solid 1px #777700;
+}
+
 div#cgit a.remote-deco {
 	color: #000;
 	margin: 0px 0.5em;
diff --git a/ui-log.c b/ui-log.c
index 8e36fba..b5cd2f6 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -65,6 +65,8 @@ void show_commit_decorations(struct commit *commit)
 		return;
 	html("<span class='decoration'>");
 	while (deco) {
+		struct object_id peeled;
+		int is_annotated = 0;
 		strncpy(buf, prettify_refname(deco->name), sizeof(buf) - 1);
 		switch(deco->type) {
 		case DECORATION_NONE:
@@ -77,7 +79,9 @@ void show_commit_decorations(struct commit *commit)
 				ctx.qry.showmsg, 0);
 			break;
 		case DECORATION_REF_TAG:
-			cgit_tag_link(buf, NULL, "tag-deco", buf);
+			if (!peel_ref(deco->name, &peeled))
+				is_annotated = !oidcmp(&commit->object.oid, &peeled);
+			cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf);
 			break;
 		case DECORATION_REF_REMOTE:
 			if (!ctx.repo->enable_remote_branches)


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

* [PATCH v2 1/1] ui-log: highlight annotated tags in different color
  2018-06-05 11:40     ` [PATCH v2 " list
@ 2018-06-05 14:26       ` john
  0 siblings, 0 replies; 5+ messages in thread
From: john @ 2018-06-05 14:26 UTC (permalink / raw)


On Tue, Jun 05, 2018 at 01:40:13PM +0200, Christian Hesse wrote:
> From: Christian Hesse <mail at eworm.de>

It would be nice to include the rationale from your previous message in
the commit to it's easily accessible via git blame in the future.

But I don't think that's absolutely necessary, so:

Reviewed-by: John Keeping <john at keeping.me.uk>

> Signed-off-by: Christian Hesse <mail at eworm.de>
> ---
>  cgit.css | 8 ++++++++
>  ui-log.c | 6 +++++-
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/cgit.css b/cgit.css
> index 217a05a..05c4530 100644
> --- a/cgit.css
> +++ b/cgit.css
> @@ -685,6 +685,14 @@ div#cgit a.tag-deco {
>  	border: solid 1px #777700;
>  }
>  
> +div#cgit a.tag-annotated-deco {
> +	color: #000;
> +	margin: 0px 0.5em;
> +	padding: 0px 0.25em;
> +	background-color: #ffcc88;
> +	border: solid 1px #777700;
> +}
> +
>  div#cgit a.remote-deco {
>  	color: #000;
>  	margin: 0px 0.5em;
> diff --git a/ui-log.c b/ui-log.c
> index 8e36fba..b5cd2f6 100644
> --- a/ui-log.c
> +++ b/ui-log.c
> @@ -65,6 +65,8 @@ void show_commit_decorations(struct commit *commit)
>  		return;
>  	html("<span class='decoration'>");
>  	while (deco) {
> +		struct object_id peeled;
> +		int is_annotated = 0;
>  		strncpy(buf, prettify_refname(deco->name), sizeof(buf) - 1);
>  		switch(deco->type) {
>  		case DECORATION_NONE:
> @@ -77,7 +79,9 @@ void show_commit_decorations(struct commit *commit)
>  				ctx.qry.showmsg, 0);
>  			break;
>  		case DECORATION_REF_TAG:
> -			cgit_tag_link(buf, NULL, "tag-deco", buf);
> +			if (!peel_ref(deco->name, &peeled))
> +				is_annotated = !oidcmp(&commit->object.oid, &peeled);
> +			cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf);
>  			break;
>  		case DECORATION_REF_REMOTE:
>  			if (!ctx.repo->enable_remote_branches)


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

end of thread, other threads:[~2018-06-05 14:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05 10:47 [PATCH 1/1] ui-log: highlight annotated tags in different color list
2018-06-05 11:03 ` john
2018-06-05 11:37   ` list
2018-06-05 11:40     ` [PATCH v2 " list
2018-06-05 14:26       ` john

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).