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

Re: [PATCH 1/1] builtin/blame.c: constants into bit shift format

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 17, 2019, 07:38 UTC
Message-ID
<xmqqr23b7ref.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<3b4b8e0353d705ea649c9fb608c021b35e6d8f5b.1571250635.git.gitgitgadget@gmail.com>
"Hariom Verma via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 13 quoted lines
> -#define OUTPUT_SHOW_AGE_WITH_COLOR	04000
> +#define OUTPUT_ANNOTATE_COMPAT      (1<<0)
> +#define OUTPUT_LONG_OBJECT_NAME     (1<<1)
> +#define OUTPUT_RAW_TIMESTAMP        (1<<2)
> +#define OUTPUT_PORCELAIN            (1<<3)
> +#define OUTPUT_SHOW_NAME            (1<<4)
> +#define OUTPUT_SHOW_NUMBER          (1<<5)
> +#define OUTPUT_SHOW_SCORE           (1<<6)
> +#define OUTPUT_NO_AUTHOR            (1<<7)
> +#define OUTPUT_SHOW_EMAIL           (1<<8)
> +#define OUTPUT_LINE_PORCELAIN       (1<<9)
> +#define OUTPUT_COLOR_LINE           (1<<10)
> +#define OUTPUT_SHOW_AGE_WITH_COLOR  (1<<11)

For these small shift counts it probably would not matter, but it may be a good discipline to make sure they are treated as constants of an unsigned type (i.e. write them as (1U<<0) etc.). It probably starts to matter when you reach 1<<31 if these are bits stuffed into "unsigned int" on 32-bit arch.

One advantage of octal and hexadecimal notations have is that 0x80000000 is automatically unsigned, IIRC, on such an archtecture.

Previous: Pratyush YadavNext: Junio C Hamano
Message 6 of 9 in “builtin/blame.c: bit field constants into bit shift format”
  1. 0/1 builtin/blame.c: bit field constants into bit shift formatHariom Verma via GitGitGadget, Oct 16, 2019
  2. 1/1 builtin/blame.c: constants into bit shift formatHariom Verma via GitGitGadget, Oct 16, 2019
  3. Pratyush YadavOct 16, 2019
  4. Jonathan TanOct 16, 2019
  5. Pratyush YadavOct 16, 2019
  6. Junio C HamanoOct 17, 2019
  7. Junio C HamanoOct 17, 2019
  8. 0/1 builtin/blame.c: bit field constants into bit shift formatHariom Verma via GitGitGadget, Oct 17, 2019
  9. 1/1 builtin/blame.c: constants into bit shift formatHariom Verma via GitGitGadget, Oct 17, 2019

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.