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

[PATCHv2 6/6] diff: use HAS_MULTI_BITS instead of counting bits manually

From
Stefan Beller <sbeller@google.com>
Date
Jan 4, 2018, 22:50 UTC
Message-ID
<20180104225044.191220-7-sbeller@google.com>
In-Reply-To
<20180104225044.191220-1-sbeller@google.com>
This aligns the style to the previous patch.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 diff.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/diff.c b/diff.c
index 42858d4c7d..c2ee81a1fa 100644
--- a/diff.c
+++ b/diff.c
@@ -4107,20 +4107,15 @@ void diff_setup(struct diff_options *options)
 
 void diff_setup_done(struct diff_options *options)
 {
-	int count = 0;
+	unsigned check_mask = DIFF_FORMAT_NAME |
+			      DIFF_FORMAT_NAME_STATUS |
+			      DIFF_FORMAT_CHECKDIFF |
+			      DIFF_FORMAT_NO_OUTPUT;
 
 	if (options->set_default)
 		options->set_default(options);
 
-	if (options->output_format & DIFF_FORMAT_NAME)
-		count++;
-	if (options->output_format & DIFF_FORMAT_NAME_STATUS)
-		count++;
-	if (options->output_format & DIFF_FORMAT_CHECKDIFF)
-		count++;
-	if (options->output_format & DIFF_FORMAT_NO_OUTPUT)
-		count++;
-	if (count > 1)
+	if (HAS_MULTI_BITS(options->output_format & check_mask))
 		die(_("--name-only, --name-status, --check and -s are mutually exclusive"));
 
 	if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
-- 
2.16.0.rc0.223.g4a4ac83678-goog
Previous: Stefan Beller
Message 19 of 19 in “pickaxe refactorings and a new mode to find blobs (WAS: diffcore: add a pickaxe option to find a specific blob)”
  1. 0/5 pickaxe refactorings and a new mode to find blobs (WAS: diffcore: add a pickaxe option to find a specific blob)Stefan Beller, Jan 3, 2018
  2. 1/5 diff.h: Make pickaxe_opts an unsigned bit fieldStefan Beller, Jan 3, 2018
  3. Junio C HamanoJan 3, 2018
  4. 2/5 diff: migrate diff_flags.pickaxe_ignore_case to a pickaxe_opts bitStefan Beller, Jan 3, 2018
  5. 4/5 diffcore: add a pickaxe option to find a specific blobStefan Beller, Jan 3, 2018
  6. 4/5 diffcore: add a pickaxe option to find a specific blobStefan Beller, Jan 3, 2018
  7. 5/5 diff: properly error out when combining multiple pickaxe optionsStefan Beller, Jan 3, 2018
  8. Jacob KellerJan 3, 2018
  9. Junio C HamanoJan 3, 2018
  10. Stefan BellerJan 3, 2018
  11. 3/5 diff: introduce DIFF_PICKAXE_KINDS_MASKStefan Beller, Jan 3, 2018
  12. Junio C HamanoJan 3, 2018
  13. 0/6 pickaxe refactorings and a new mode to find blobs (WAS: diffcore: add a pickaxe option to find a specific blob)Stefan Beller, Jan 4, 2018
  14. 1/6 diff.h: Make pickaxe_opts an unsigned bit fieldStefan Beller, Jan 4, 2018
  15. 3/6 diff: introduce DIFF_PICKAXE_KINDS_MASKStefan Beller, Jan 4, 2018
  16. 4/6 diffcore: add a pickaxe option to find a specific blobStefan Beller, Jan 4, 2018
  17. 5/6 diff: properly error out when combining multiple pickaxe optionsStefan Beller, Jan 4, 2018
  18. 2/6 diff: migrate diff_flags.pickaxe_ignore_case to a pickaxe_opts bitStefan Beller, Jan 4, 2018
  19. 6/6 diff: use HAS_MULTI_BITS instead of counting bits manuallyStefan Beller, Jan 4, 2018

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.