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

Re: [PATCH 0/3] convert diff flags to be stored in a struct

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 29, 2017, 01:22 UTC
Message-ID
<xmqq60aybvdp.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171027222853.180981-1-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
Show 6 quoted lines
> There has be some desire to add additional flags to the diff machineery
> (https://public-inbox.org/git/20171024000931.14814-1-sbeller@google.com/) but
> due to the limits of the number of bits in an unsigned int on some systems we
> can't add any additonal flags to the 'flags' variable.  This series converts
> the flags to be stored in bitfields in a struct instead of in bit positions in
> an unsigned int.

I haven't checked the patches yet, but its smallness look promising. One reason why I didn't do this myself long time ago was because I suspected that we may be passing an unsigned int that is a collection of flags as a parameter in many codepaths (to which I did not see a good conversion once we start using discrete bitfields in a struct, without passing a "flags" struct instead, which felt somewhat ugly).

> Some thoughts:
>  * We may want to do a follow on patch to convert all the flags from being in
>    uppercase to lower case.

If and only if we do not use macros to set/clr/test, this makes a lot of sense. Otherwise, probably not.

>  * Maybe we can figure out how to remove the 'touched_flags' things (since its
>    only used in one place) and then we may even be able to stop needing to use
>    macros to set/clr/test the flags.

Yup. That is closely tied with the above one, but back then we didn't think of a better implementation than the "this was given from the command line" vs "this was initialized and kept", so we need some thought.

Thanks for starting this.
Show 14 quoted lines
> Brandon Williams (3):
>   add: use DIFF_OPT_SET macro to set a diff flag
>   reset: use DIFF_OPT_SET macro to set a diff flag
>   diff: convert flags to be stored in bitfields
>
>  builtin/add.c    |  2 +-
>  builtin/commit.c |  7 +++--
>  builtin/log.c    |  2 +-
>  builtin/reset.c  |  2 +-
>  diff-lib.c       |  6 ++--
>  diff.c           |  3 +-
>  diff.h           | 96 +++++++++++++++++++++++++++++++++-----------------------
>  sequencer.c      |  5 +--
>  8 files changed, 72 insertions(+), 51 deletions(-)
Previous: Brandon WilliamsNext: Stefan Beller
Message 12 of 47 in “convert diff flags to be stored in a struct”
  1. 0/3 convert diff flags to be stored in a structBrandon Williams, Oct 27, 2017
  2. 1/3 add: use DIFF_OPT_SET macro to set a diff flagBrandon Williams, Oct 27, 2017
  3. 2/3 reset: use DIFF_OPT_SET macro to set a diff flagBrandon Williams, Oct 27, 2017
  4. Junio C HamanoOct 29, 2017
  5. Brandon WilliamsOct 30, 2017
  6. 3/3 diff: convert flags to be stored in bitfieldsBrandon Williams, Oct 27, 2017
  7. Junio C HamanoOct 29, 2017
  8. Junio C HamanoOct 30, 2017
  9. Brandon WilliamsOct 30, 2017
  10. Junio C HamanoOct 31, 2017
  11. Brandon WilliamsOct 30, 2017
  12. Junio C HamanoOct 29, 2017
  13. Stefan BellerOct 29, 2017
  14. 0/4 convert diff flags to be stored in a structBrandon Williams, Oct 30, 2017
  15. 1/4 add, reset: use DIFF_OPT_SET macro to set a diff flagBrandon Williams, Oct 30, 2017
  16. 2/4 diff: convert flags to be stored in bitfieldsBrandon Williams, Oct 30, 2017
  17. Junio C HamanoOct 31, 2017
  18. 5/4 diff: avoid returning a struct by value from diff_flags_or()Junio C Hamano, Oct 31, 2017
  19. Brandon WilliamsOct 31, 2017
  20. 4/4 diff: remove touched flagsBrandon Williams, Oct 30, 2017
  21. 3/4 diff: add flag to indicate textconv was set via cmdlineBrandon Williams, Oct 30, 2017
  22. Stefan BellerOct 30, 2017
  23. Brandon WilliamsOct 30, 2017
  24. Brandon WilliamsOct 30, 2017
  25. Junio C HamanoOct 31, 2017
  26. 5/4 diff: set TEXTCONV_VIA_CMDLINE only when it is set to trueJunio C Hamano, Oct 31, 2017
  27. Brandon WilliamsOct 31, 2017
  28. 5/4 diff: remove DIFF_OPT_TST macroBrandon Williams, Oct 30, 2017
  29. 7/4 diff: remove DIFF_OPT_CLR macroBrandon Williams, Oct 30, 2017
  30. 6/4 diff: remove DIFF_OPT_SET macroBrandon Williams, Oct 30, 2017
  31. 8/4 diff: make struct diff_flags members lowercaseBrandon Williams, Oct 30, 2017
  32. 0/8 convert diff flags to be stored in a structBrandon Williams, Oct 31, 2017
  33. 1/8 add, reset: use DIFF_OPT_SET macro to set a diff flagBrandon Williams, Oct 31, 2017
  34. 2/8 diff: convert flags to be stored in bitfieldsBrandon Williams, Oct 31, 2017
  35. Stefan BellerOct 31, 2017
  36. Junio C HamanoNov 1, 2017
  37. Stefan BellerNov 1, 2017
  38. 4/8 diff: remove touched flagsBrandon Williams, Oct 31, 2017
  39. 5/8 diff: remove DIFF_OPT_TST macroBrandon Williams, Oct 31, 2017
  40. 3/8 diff: add flag to indicate textconv was set via cmdlineBrandon Williams, Oct 31, 2017
  41. 6/8 diff: remove DIFF_OPT_SET macroBrandon Williams, Oct 31, 2017
  42. 7/8 diff: remove DIFF_OPT_CLR macroBrandon Williams, Oct 31, 2017
  43. Stefan BellerOct 31, 2017
  44. Junio C HamanoNov 1, 2017
  45. 8/8 diff: make struct diff_flags members lowercaseBrandon Williams, Oct 31, 2017
  46. Stefan BellerOct 31, 2017
  47. Junio C HamanoNov 1, 2017

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.