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

[PATCH 01/19] revision.h: avoid bit fields in struct rev_info

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
May 8, 2019, 11:12 UTC
Message-ID
<20190508111249.15262-2-pclouds@gmail.com>
In-Reply-To
<20190508111249.15262-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 rev_info variables around, memory consumption is not at all a concern.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 revision.h | 164 ++++++++++++++++++++++++++---------------------------
 1 file changed, 82 insertions(+), 82 deletions(-)
diff --git a/revision.h b/revision.h
index 4134dc6029..01e4c42274 100644
--- a/revision.h
+++ b/revision.h
@@ -107,95 +107,95 @@ struct rev_info {
 
 	unsigned int early_output;
 
-	unsigned int	ignore_missing:1,
-			ignore_missing_links:1;
+	unsigned int ignore_missing;
+	unsigned int ignore_missing_links;
 
 	/* Traversal flags */
-	unsigned int	dense:1,
-			prune:1,
-			no_walk:2,
-			remove_empty_trees:1,
-			simplify_history:1,
-			topo_order:1,
-			simplify_merges:1,
-			simplify_by_decoration:1,
-			single_worktree:1,
-			tag_objects:1,
-			tree_objects:1,
-			blob_objects:1,
-			verify_objects:1,
-			edge_hint:1,
-			edge_hint_aggressive:1,
-			limited:1,
-			unpacked:1,
-			boundary:2,
-			count:1,
-			left_right:1,
-			left_only:1,
-			right_only:1,
-			rewrite_parents:1,
-			print_parents:1,
-			show_decorations:1,
-			reverse:1,
-			reverse_output_stage:1,
-			cherry_pick:1,
-			cherry_mark:1,
-			bisect:1,
-			ancestry_path:1,
-			first_parent_only:1,
-			line_level_traverse:1,
-			tree_blobs_in_commit_order:1,
-
-			/*
-			 * Blobs are shown without regard for their existence.
-			 * But not so for trees: unless exclude_promisor_objects
-			 * is set and the tree in question is a promisor object;
-			 * OR ignore_missing_links is set, the revision walker
-			 * dies with a "bad tree object HASH" message when
-			 * encountering a missing tree. For callers that can
-			 * handle missing trees and want them to be filterable
-			 * and showable, set this to true. The revision walker
-			 * will filter and show such a missing tree as usual,
-			 * but will not attempt to recurse into this tree
-			 * object.
-			 */
-			do_not_die_on_missing_tree:1,
-
-			/* for internal use only */
-			exclude_promisor_objects:1;
+	unsigned int dense;
+	unsigned int prune;
+	unsigned int no_walk;
+	unsigned int remove_empty_trees;
+	unsigned int simplify_history;
+	unsigned int topo_order;
+	unsigned int simplify_merges;
+	unsigned int simplify_by_decoration;
+	unsigned int single_worktree;
+	unsigned int tag_objects;
+	unsigned int tree_objects;
+	unsigned int blob_objects;
+	unsigned int verify_objects;
+	unsigned int edge_hint;
+	unsigned int edge_hint_aggressive;
+	unsigned int limited;
+	unsigned int unpacked;
+	unsigned int boundary;
+	unsigned int count;
+	unsigned int left_right;
+	unsigned int left_only;
+	unsigned int right_only;
+	unsigned int rewrite_parents;
+	unsigned int print_parents;
+	unsigned int show_decorations;
+	unsigned int reverse;
+	unsigned int reverse_output_stage;
+	unsigned int cherry_pick;
+	unsigned int cherry_mark;
+	unsigned int bisect;
+	unsigned int ancestry_path;
+	unsigned int first_parent_only;
+	unsigned int line_level_traverse;
+	unsigned int tree_blobs_in_commit_order;
+
+	/*
+	 * Blobs are shown without regard for their existence.
+	 * But not so for trees: unless exclude_promisor_objects
+	 * is set and the tree in question is a promisor object;
+	 * OR ignore_missing_links is set, the revision walker
+	 * dies with a "bad tree object HASH" message when
+	 * encountering a missing tree. For callers that can
+	 * handle missing trees and want them to be filterable
+	 * and showable, set this to true. The revision walker
+	 * will filter and show such a missing tree as usual,
+	 * but will not attempt to recurse into this tree
+	 * object.
+	 */
+	unsigned int do_not_die_on_missing_tree;
+
+	/* for internal use only */
+	unsigned int exclude_promisor_objects;
 
 	/* Diff flags */
-	unsigned int	diff:1,
-			full_diff:1,
-			show_root_diff:1,
-			no_commit_id:1,
-			verbose_header:1,
-			ignore_merges:1,
-			combine_merges:1,
-			combined_all_paths:1,
-			dense_combined_merges:1,
-			always_show_header:1;
+	unsigned int diff;
+	unsigned int full_diff;
+	unsigned int show_root_diff;
+	unsigned int no_commit_id;
+	unsigned int verbose_header;
+	unsigned int ignore_merges;
+	unsigned int combine_merges;
+	unsigned int combined_all_paths;
+	unsigned int dense_combined_merges;
+	unsigned int always_show_header;
 
 	/* Format info */
-	unsigned int	shown_one:1,
-			shown_dashes:1,
-			show_merge:1,
-			show_notes:1,
-			show_notes_given:1,
-			show_signature:1,
-			pretty_given:1,
-			abbrev_commit:1,
-			abbrev_commit_given:1,
-			zero_commit:1,
-			use_terminator:1,
-			missing_newline:1,
-			date_mode_explicit:1,
-			preserve_subject:1;
-	unsigned int	disable_stdin:1;
+	unsigned int shown_one;
+	unsigned int shown_dashes;
+	unsigned int show_merge;
+	unsigned int show_notes;
+	unsigned int show_notes_given;
+	unsigned int show_signature;
+	unsigned int pretty_given;
+	unsigned int abbrev_commit;
+	unsigned int abbrev_commit_given;
+	unsigned int zero_commit;
+	unsigned int use_terminator;
+	unsigned int missing_newline;
+	unsigned int date_mode_explicit;
+	unsigned int preserve_subject;
+	unsigned int disable_stdin;
 	/* --show-linear-break */
-	unsigned int	track_linear:1,
-			track_first_time:1,
-			linear:1;
+	unsigned int track_linear;
+	unsigned int track_first_time;
+	unsigned int linear;
 
 	struct date_mode date_mode;
 	int		expand_tabs_in_log; /* unset if negative */
-- 
2.21.0.1141.gd54ac2cb17
Previous: Nguyễn Thái Ngọc DuyNext: Derrick Stolee
Message 2 of 25 in “Convert revision.c to parseopt part 1/4”
  1. 00/19 Convert revision.c to parseopt part 1/4Nguyễn Thái Ngọc Duy, May 8, 2019
  2. 01/19 revision.h: avoid bit fields in struct rev_infoNguyễn Thái Ngọc Duy, May 8, 2019
  3. Derrick StoleeMay 8, 2019
  4. Duy NguyenMay 8, 2019
  5. Derrick StoleeMay 8, 2019
  6. Duy NguyenMay 9, 2019
  7. Derrick StoleeMay 9, 2019
  8. 02/19 revision.h: move repo field downNguyễn Thái Ngọc Duy, May 8, 2019
  9. 03/19 revision.c: prepare to convert handle_revision_pseudo_opt()Nguyễn Thái Ngọc Duy, May 8, 2019
  10. 04/19 rev-parseopt: convert --allNguyễn Thái Ngọc Duy, May 8, 2019
  11. 05/19 rev-parseopt: convert --branchesNguyễn Thái Ngọc Duy, May 8, 2019
  12. 06/19 rev-parseopt: convert --bisectNguyễn Thái Ngọc Duy, May 8, 2019
  13. 07/19 rev-parseopt: convert --tagsNguyễn Thái Ngọc Duy, May 8, 2019
  14. 08/19 rev-parseopt: convert --remotesNguyễn Thái Ngọc Duy, May 8, 2019
  15. 09/19 rev-parseopt: convert --globNguyễn Thái Ngọc Duy, May 8, 2019
  16. 10/19 rev-parseopt: convert --excludeNguyễn Thái Ngọc Duy, May 8, 2019
  17. 11/19 rev-parseopt: convert --reflogNguyễn Thái Ngọc Duy, May 8, 2019
  18. 12/19 rev-parseopt: convert --indexed-objectsNguyễn Thái Ngọc Duy, May 8, 2019
  19. 13/19 rev-parseopt: convert --notNguyễn Thái Ngọc Duy, May 8, 2019
  20. 14/19 rev-parseopt: convert --no-walk and --do-walkNguyễn Thái Ngọc Duy, May 8, 2019
  21. 15/19 rev-parseopt: convert --single-worktreeNguyễn Thái Ngọc Duy, May 8, 2019
  22. 16/19 rev-parseopt: prepare to convert handle_revision_opt()Nguyễn Thái Ngọc Duy, May 8, 2019
  23. 17/19 rev-parseopt: convert --max-countNguyễn Thái Ngọc Duy, May 8, 2019
  24. 18/19 rev-parseopt: convert --skipNguyễn Thái Ngọc Duy, May 8, 2019
  25. 19/19 rev-parseopt: convert --min-age and --max-ageNguyễn Thái Ngọc Duy, May 8, 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.