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

[PATCH 09/14] diff.h: avoid bit fields in struct diff_flags

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 27, 2019, 00:35 UTC
Message-ID
<20190127003535.28341-10-pclouds@gmail.com>
In-Reply-To
<20190127003535.28341-1-pclouds@gmail.com>

Bitfield addresses cannot be passed around in a pointer. This makes it hard to use parse-options to set/unset them. Turn this struct to normal integers. This of course increases the size of this struct multiple times, but since we only have a handful of diff_options variables around, memory consumption is not at all a concern.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff.h | 66 +++++++++++++++++++++++++++++-----------------------------
 1 file changed, 33 insertions(+), 33 deletions(-)
diff --git a/diff.h b/diff.h
index c872a41344..8abe1649d0 100644
--- a/diff.h
+++ b/diff.h
@@ -64,39 +64,39 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)
 
 #define DIFF_FLAGS_INIT { 0 }
 struct diff_flags {
-	unsigned recursive:1;
-	unsigned tree_in_recursive:1;
-	unsigned binary:1;
-	unsigned text:1;
-	unsigned full_index:1;
-	unsigned silent_on_remove:1;
-	unsigned find_copies_harder:1;
-	unsigned follow_renames:1;
-	unsigned rename_empty:1;
-	unsigned has_changes:1;
-	unsigned quick:1;
-	unsigned no_index:1;
-	unsigned allow_external:1;
-	unsigned exit_with_status:1;
-	unsigned reverse_diff:1;
-	unsigned check_failed:1;
-	unsigned relative_name:1;
-	unsigned ignore_submodules:1;
-	unsigned dirstat_cumulative:1;
-	unsigned dirstat_by_file:1;
-	unsigned allow_textconv:1;
-	unsigned textconv_set_via_cmdline:1;
-	unsigned diff_from_contents:1;
-	unsigned dirty_submodules:1;
-	unsigned ignore_untracked_in_submodules:1;
-	unsigned ignore_dirty_submodules:1;
-	unsigned override_submodule_config:1;
-	unsigned dirstat_by_line:1;
-	unsigned funccontext:1;
-	unsigned default_follow_renames:1;
-	unsigned stat_with_summary:1;
-	unsigned suppress_diff_headers:1;
-	unsigned dual_color_diffed_diffs:1;
+	unsigned recursive;
+	unsigned tree_in_recursive;
+	unsigned binary;
+	unsigned text;
+	unsigned full_index;
+	unsigned silent_on_remove;
+	unsigned find_copies_harder;
+	unsigned follow_renames;
+	unsigned rename_empty;
+	unsigned has_changes;
+	unsigned quick;
+	unsigned no_index;
+	unsigned allow_external;
+	unsigned exit_with_status;
+	unsigned reverse_diff;
+	unsigned check_failed;
+	unsigned relative_name;
+	unsigned ignore_submodules;
+	unsigned dirstat_cumulative;
+	unsigned dirstat_by_file;
+	unsigned allow_textconv;
+	unsigned textconv_set_via_cmdline;
+	unsigned diff_from_contents;
+	unsigned dirty_submodules;
+	unsigned ignore_untracked_in_submodules;
+	unsigned ignore_dirty_submodules;
+	unsigned override_submodule_config;
+	unsigned dirstat_by_line;
+	unsigned funccontext;
+	unsigned default_follow_renames;
+	unsigned stat_with_summary;
+	unsigned suppress_diff_headers;
+	unsigned dual_color_diffed_diffs;
 };
 
 static inline void diff_flags_or(struct diff_flags *a,
-- 
2.20.1.560.g70ca8b83ee
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 13 of 19 in “nd/diff-parseopt part 1”
  1. 00/14 nd/diff-parseopt part 1Nguyễn Thái Ngọc Duy, Jan 27, 2019
  2. 01/14 parse-options.h: remove extern on function prototypesNguyễn Thái Ngọc Duy, Jan 27, 2019
  3. 02/14 parse-options: add one-shot modeNguyễn Thái Ngọc Duy, Jan 27, 2019
  4. 03/14 parse-options: disable option abbreviation with PARSE_OPT_KEEP_UNKNOWNNguyễn Thái Ngọc Duy, Jan 27, 2019
  5. 04/14 parse-options: add OPT_BITOP()Nguyễn Thái Ngọc Duy, Jan 27, 2019
  6. 05/14 parse-options: stop abusing 'callback' for lowlevel callbacksNguyễn Thái Ngọc Duy, Jan 27, 2019
  7. 06/14 parse-options: avoid magic return codesNguyễn Thái Ngọc Duy, Jan 27, 2019
  8. 07/14 parse-options: allow ll_callback with OPTION_CALLBACKNguyễn Thái Ngọc Duy, Jan 27, 2019
  9. Derrick StoleeApr 15, 2019
  10. Duy NguyenApr 16, 2019
  11. Derrick StoleeApr 16, 2019
  12. 08/14 diff.h: keep forward struct declarations sortedNguyễn Thái Ngọc Duy, Jan 27, 2019
  13. 09/14 diff.h: avoid bit fields in struct diff_flagsNguyễn Thái Ngọc Duy, Jan 27, 2019
  14. 10/14 diff.c: prepare to use parse_options() for parsingNguyễn Thái Ngọc Duy, Jan 27, 2019
  15. 11/14 diff.c: convert -u|-p|--patchNguyễn Thái Ngọc Duy, Jan 27, 2019
  16. 12/14 diff.c: convert -U|--unifiedNguyễn Thái Ngọc Duy, Jan 27, 2019
  17. 13/14 diff.c: convert -W|--[no-]function-contextNguyễn Thái Ngọc Duy, Jan 27, 2019
  18. 14/14 diff.c: convert --rawNguyễn Thái Ngọc Duy, Jan 27, 2019
  19. Junio C HamanoJan 28, 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.