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

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

From
HGHariom Verma via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 17, 2019, 17:46 UTC
Message-ID
<838478a185322572ed4747eb484b678a8e2d7ac6.1571334411.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.382.v2.git.1571334411.gitgitgadget@gmail.com>
From: Hariom Verma <hariom18599@gmail.com>

We are looking at bitfield constants, and elsewhere in the Git source code, such cases are handled via bit shift operators rather than octal numbers, which also makes it easier to spot holes in the range (if, say, 1<<5 was missing, it is easier to spot it between 1<<4 and 1<<6 than it is to spot a missing 040 between a 020 and a 0100).

Signed-off-by: Hariom Verma <hariom18599@gmail.com>
---
 builtin/blame.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index e946ba6cd9..10185ccdc6 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -319,18 +319,18 @@ static const char *format_time(timestamp_t time, const char *tz_str,
 	return time_buf.buf;
 }
 
-#define OUTPUT_ANNOTATE_COMPAT	001
-#define OUTPUT_LONG_OBJECT_NAME	002
-#define OUTPUT_RAW_TIMESTAMP	004
-#define OUTPUT_PORCELAIN	010
-#define OUTPUT_SHOW_NAME	020
-#define OUTPUT_SHOW_NUMBER	040
-#define OUTPUT_SHOW_SCORE	0100
-#define OUTPUT_NO_AUTHOR	0200
-#define OUTPUT_SHOW_EMAIL	0400
-#define OUTPUT_LINE_PORCELAIN	01000
-#define OUTPUT_COLOR_LINE	02000
-#define OUTPUT_SHOW_AGE_WITH_COLOR	04000
+#define OUTPUT_ANNOTATE_COMPAT      (1U<<0)
+#define OUTPUT_LONG_OBJECT_NAME     (1U<<1)
+#define OUTPUT_RAW_TIMESTAMP        (1U<<2)
+#define OUTPUT_PORCELAIN            (1U<<3)
+#define OUTPUT_SHOW_NAME            (1U<<4)
+#define OUTPUT_SHOW_NUMBER          (1U<<5)
+#define OUTPUT_SHOW_SCORE           (1U<<6)
+#define OUTPUT_NO_AUTHOR            (1U<<7)
+#define OUTPUT_SHOW_EMAIL           (1U<<8)
+#define OUTPUT_LINE_PORCELAIN       (1U<<9)
+#define OUTPUT_COLOR_LINE           (1U<<10)
+#define OUTPUT_SHOW_AGE_WITH_COLOR  (1U<<11)
 
 static void emit_porcelain_details(struct blame_origin *suspect, int repeat)
 {
-- 
gitgitgadget
Previous: Hariom Verma via GitGitGadget
Message 9 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.