git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/4] commit.h: add 'type' to struct name_decoration

From
Nazri Ramliy <ayiehere@gmail.com>
Date
Jun 19, 2010, 01:37 UTC
Message-ID
<1276911456-18466-1-git-send-email-ayiehere@gmail.com>
In-Reply-To
<7vtyp11k9x.fsf@alter.siamese.dyndns.org>
This allows for semantically better handling of decoration type.
Signed-off-by: Nazri Ramliy <ayiehere@gmail.com>
---
I have splitted the patch into four logical commits:
      1. commit.h: add 'type' to struct name_decoration
      2. log-tree.c: Use struct name_decoration's type for classifying decoration
      3. log --decorate: Colorize commit decorations
      4. Allow customizable coloring of commit decorations

This should make it easier for you (or anyone else) to spot any problem with my approach in colorizing --decorate stuff.

This is the first commit, and the rest will follow suit.
My reply to your comments are as follows:
On Fri, Jun 18, 2010 at 4:22 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Configuration variable names are either 2-level or 3-level.  There are
> existing examples for <slot> (e.g. color.branch.<slot>).

Fixed. Now the slots are no longer tied to log, and they are named like this:

        color.decorate.reflocal
        color.decorate.refremote
        color.decorate.reftag
        color.decorate.refstash
        color.decorate.refhead

This should allow for handling different type of decorations in the future.

Show 10 quoted lines
> I don't think any of the above belongs to "decorate.c", which is the
> generic mechanism to annotate commits with arbitrary data.  The Porcelain
> feature "log --decorate" is just one user that happens to use refname as
> that "arbitrary data", and that is what you are coloring.  The code for
> that is in log-tree.c, I think.
>
>> diff --git a/decorate.h b/decorate.h
>> index e732804..d593d32 100644
>
> So is any change to this file.
Fixed. decorate.[ch] is no longer affected by this series.
> When color is not in use (e.g. output is not going to the terminal), you
> would lose "tag: " prefix, wouldn't you?

No. The "tag: " prefix is not lost. It will be shown by show_decorations() if the type of the decoration matches DECORATION_REF_TAG.

Show 8 quoted lines
>> +     else if (!prefixcmp(refname, "refs/stash"))
>> +             type = DECORATION_STASH;
>> +     else if (!prefixcmp(refname, "HEAD"))
>> +             type = DECORATION_HEAD;
>
> I suspect that users would expect DECORATION_HEAD to be used to highlight
> the object at the tip of the current branch, but I also suspect this code
> would not do so.

No the code would not do so. It would only colorize the literal printed 'HEAD' string. The current --decorate shows only 'HEAD' for symbolic refs (is this the right term for it?) and nothing else (it seems that way to me, I might be wrong here).

nazri
 commit.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/commit.h b/commit.h
index 6ef88dc..ba818fc 100644
--- a/commit.h
+++ b/commit.h
@@ -28,6 +28,7 @@ extern const char *commit_type;
 extern struct decoration name_decoration;
 struct name_decoration {
 	struct name_decoration *next;
+	int type;
 	char name[1];
 };
 
-- 
1.7.1.245.g7c42e.dirty
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 9 in “Colorize commit decorations”
  1. Colorize commit decorationsNazri Ramliy, Jun 17, 2010
  2. Junio C HamanoJun 17, 2010
  3. 1/4 commit.h: add 'type' to struct name_decorationNazri Ramliy, Jun 19, 2010
  4. Junio C HamanoJun 22, 2010
  5. Allow customizable commit decorations colorsNazri Ramliy, Jun 23, 2010
  6. Allow customizable commit decorations colorsNazri Ramliy, Jun 24, 2010
  7. 2/4 log-tree.c: Use struct name_decoration's type for classifying decorationNazri Ramliy, Jun 19, 2010
  8. 3/4 log --decorate: Colorize commit decorationsNazri Ramliy, Jun 19, 2010
  9. 4/4 Allow customizable coloring of commit decorationsNazri Ramliy, Jun 19, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.