Re: [PATCH v4 6/6] for-each-ref: avoid color leakage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ramkumar Ramachandra <artagnon@xxxxxxxxx> writes:

> To make sure that an invocation like the following doesn't leak color,
>
>   $ git for-each-ref --format='%(subject)%(color:green)'
>
> auto-reset at the end of the format string when the last color token
> seen in the format string isn't a color-reset.
>
> Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx>
> ---
>  builtin/for-each-ref.c  | 29 +++++++++++++++++++++++++----
>  t/t6300-for-each-ref.sh |  2 +-
>  2 files changed, 26 insertions(+), 5 deletions(-)
>
> diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
> index 2ff4e54..04e35ba 100644
> --- a/builtin/for-each-ref.c
> +++ b/builtin/for-each-ref.c
> @@ -23,6 +23,7 @@ typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;
>  struct atom_value {
>  	const char *s;
>  	unsigned long ul; /* used for sorting when not FIELD_STR */
> +	int color : 2; /* 1 indicates color, 2 indicates color-reset */
>  };

Hmph.  It looks wasteful to have this information in atom_value.

Isn't a new single bit in "struct refinfo" all you need to keep
track of, to see the last %(color:something) you ever saw is for a
color that is not reset?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]