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

[PATCH 00/76] Convert diff opt parser to parse_options()

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 17, 2019, 13:04 UTC
Message-ID
<20190117130615.18732-1-pclouds@gmail.com>

This series converts diff option parsing to using parse-options. There are a couple benefits of using parse-options, including "git <cmd> -h" output, completion and less duplicate work.

This is the first half. The second one would be converting the option parser in revision.c. After that, the end game is, any command can take a 'struct option[]' somewhere from diff/rev code, remove the options they are not interested, then merge with their own options and do parse_options() just once. There will be no separate parse phase for revision/diff anymore.

I sent a sneak peek [1] last year and got two good comments. I take it people at least did not oppose to this. The most interesting parts are at the top and bottom. The middle is just boring conversion, usually one option per patch.

This will conflict with pw/diff-color-moved-ws-fix on 'pu' because that series adds --no-color-moved-ws option. I redid the same thing in 73/76 so that conflict resolution could be simply taking this side of change.

This series is also available for fetching here
https://gitlab.com/pclouds/git/commits/diff-opt-parse-options
[1] http://public-inbox.org/git/20181227162536.15895-1-pclouds@gmail.com/
Nguyễn Thái Ngọc Duy (76):
  parse-options.h: remove extern on function prototypes
  parse-options: add one-shot mode
  parse-options: allow keep-unknown + stop-at-non-opt combination
  parse-options: disable option abbreviation with PARSE_OPT_KEEP_UNKNOWN
  parse-options: add OPT_BITOP()
  parse-options: stop abusing 'callback' for lowlevel callbacks
  parse-options: avoid magic return codes
  parse-options: allow ll_callback with OPTION_CALLBACK
  diff.h: keep forward struct declarations sorted
  diff.h: avoid bit fields in struct diff_flags
  diff.c: prepare to use parse_options() for parsing
  diff.c: convert -u|-p|--patch
  diff.c: convert -U|--unified
  diff.c: convert -W|--[no-]function-context
  diff.c: convert --raw
  diff.c: convert --patch-with-raw
  diff.c: convert --numstat and --shortstat
  diff.c: convert --dirstat and friends
  diff.c: convert --check
  diff.c: convert --summary
  diff.c: convert --patch-with-stat
  diff.c: convert --name-only
  diff.c: convert --name-status
  diff.c: convert -s|--no-patch
  diff.c: convert --stat*
  diff.c: convert --[no-]compact-summary
  diff.c: convert --output-*
  diff.c: convert -B|--break-rewrites
  diff.c: convert -M|--find-renames
  diff.c: convert -D|--irreversible-delete
  diff.c: convert -C|--find-copies
  diff.c: convert --find-copies-harder
  diff.c: convert --no-renames|--[no--rename-empty
  diff.c: convert --relative
  diff.c: convert --[no-]minimal
  diff.c: convert --ignore-some-changes
  diff.c: convert --[no-]indent-heuristic
  diff.c: convert --patience
  diff.c: convert --histogram
  diff.c: convert --diff-algorithm
  diff.c: convert --anchored
  diff.c: convert --binary
  diff.c: convert --full-index
  diff.c: convert -a|--text
  diff.c: convert -R
  diff.c: convert --[no-]follow
  diff.c: convert --[no-]color
  diff.c: convert --word-diff
  diff.c: convert --word-diff-regex
  diff.c: convert --color-words
  diff.c: convert --exit-code
  diff.c: convert --quiet
  diff.c: convert --ext-diff
  diff.c: convert --textconv
  diff.c: convert --ignore-submodules
  diff.c: convert --submodule
  diff.c: convert --ws-error-highlight
  diff.c: convert --ita-[in]visible-in-index
  diff.c: convert -z
  diff.c: convert -l
  diff.c: convert -S|-G
  diff.c: convert --pickaxe-all|--pickaxe-regex
  diff.c: convert -O
  diff.c: convert --find-object
  diff.c: convert --diff-filter
  diff.c: convert --[no-]abbrev
  diff.c: convert --[src|dst]-prefix
  diff.c: convert --line-prefix
  diff.c: convert --no-prefix
  diff.c: convert --inter-hunk-context
  diff.c: convert --color-moved
  diff.c: convert --color-moved-ws
  diff.c: allow --no-color-moved-ws
  range-diff: use parse_options() instead of diff_opt_parse()
  diff --no-index: use parse_options() instead of diff_opt_parse()
  am: avoid diff_opt_parse()
 Documentation/diff-options.txt |   24 +-
 builtin/am.c                   |    4 +-
 builtin/blame.c                |    2 +-
 builtin/diff.c                 |   21 +-
 builtin/merge.c                |    9 +-
 builtin/range-diff.c           |   26 +-
 builtin/update-index.c         |   41 +-
 diff-no-index.c                |   49 +-
 diff.c                         | 1136 ++++++++++++++++++++------------
 diff.h                         |   85 +--
 parse-options-cb.c             |   11 +-
 parse-options.c                |  152 +++--
 parse-options.h                |  114 ++--
 t/t4053-diff-no-index.sh       |    3 +-
 t/t7800-difftool.sh            |    4 +-
 15 files changed, 1054 insertions(+), 627 deletions(-)
-- 
2.20.0.482.g66447595a7
Next: Nguyễn Thái Ngọc Duy
Message 1 of 88 in “Convert diff opt parser to parse_options()”
  1. 00/76 Convert diff opt parser to parse_options()Nguyễn Thái Ngọc Duy, Jan 17, 2019
  2. 01/76 parse-options.h: remove extern on function prototypesNguyễn Thái Ngọc Duy, Jan 17, 2019
  3. 02/76 parse-options: add one-shot modeNguyễn Thái Ngọc Duy, Jan 17, 2019
  4. 03/76 parse-options: allow keep-unknown + stop-at-non-opt combinationNguyễn Thái Ngọc Duy, Jan 17, 2019
  5. Stefan BellerJan 17, 2019
  6. 04/76 parse-options: disable option abbreviation with PARSE_OPT_KEEP_UNKNOWNNguyễn Thái Ngọc Duy, Jan 17, 2019
  7. 05/76 parse-options: add OPT_BITOP()Nguyễn Thái Ngọc Duy, Jan 17, 2019
  8. 06/76 parse-options: stop abusing 'callback' for lowlevel callbacksNguyễn Thái Ngọc Duy, Jan 17, 2019
  9. 07/76 parse-options: avoid magic return codesNguyễn Thái Ngọc Duy, Jan 17, 2019
  10. 08/76 parse-options: allow ll_callback with OPTION_CALLBACKNguyễn Thái Ngọc Duy, Jan 17, 2019
  11. 09/76 diff.h: keep forward struct declarations sortedNguyễn Thái Ngọc Duy, Jan 17, 2019
  12. 10/76 diff.h: avoid bit fields in struct diff_flagsNguyễn Thái Ngọc Duy, Jan 17, 2019
  13. 11/76 diff.c: prepare to use parse_options() for parsingNguyễn Thái Ngọc Duy, Jan 17, 2019
  14. 12/76 diff.c: convert -u|-p|--patchNguyễn Thái Ngọc Duy, Jan 17, 2019
  15. 13/76 diff.c: convert -U|--unifiedNguyễn Thái Ngọc Duy, Jan 17, 2019
  16. 14/76 diff.c: convert -W|--[no-]function-contextNguyễn Thái Ngọc Duy, Jan 17, 2019
  17. 15/76 diff.c: convert --rawNguyễn Thái Ngọc Duy, Jan 17, 2019
  18. 16/76 diff.c: convert --patch-with-rawNguyễn Thái Ngọc Duy, Jan 17, 2019
  19. 17/76 diff.c: convert --numstat and --shortstatNguyễn Thái Ngọc Duy, Jan 17, 2019
  20. 18/76 diff.c: convert --dirstat and friendsNguyễn Thái Ngọc Duy, Jan 17, 2019
  21. 19/76 diff.c: convert --checkNguyễn Thái Ngọc Duy, Jan 17, 2019
  22. 20/76 diff.c: convert --summaryNguyễn Thái Ngọc Duy, Jan 17, 2019
  23. 21/76 diff.c: convert --patch-with-statNguyễn Thái Ngọc Duy, Jan 17, 2019
  24. 22/76 diff.c: convert --name-onlyNguyễn Thái Ngọc Duy, Jan 17, 2019
  25. 23/76 diff.c: convert --name-statusNguyễn Thái Ngọc Duy, Jan 17, 2019
  26. 24/76 diff.c: convert -s|--no-patchNguyễn Thái Ngọc Duy, Jan 17, 2019
  27. 25/76 diff.c: convert --stat*Nguyễn Thái Ngọc Duy, Jan 17, 2019
  28. SZEDER GáborJan 19, 2019
  29. 26/76 diff.c: convert --[no-]compact-summaryNguyễn Thái Ngọc Duy, Jan 17, 2019
  30. 27/76 diff.c: convert --output-*Nguyễn Thái Ngọc Duy, Jan 17, 2019
  31. 28/76 diff.c: convert -B|--break-rewritesNguyễn Thái Ngọc Duy, Jan 17, 2019
  32. Johannes SchindelinJan 21, 2019
  33. 29/76 diff.c: convert -M|--find-renamesNguyễn Thái Ngọc Duy, Jan 17, 2019
  34. 30/76 diff.c: convert -D|--irreversible-deleteNguyễn Thái Ngọc Duy, Jan 17, 2019
  35. 31/76 diff.c: convert -C|--find-copiesNguyễn Thái Ngọc Duy, Jan 17, 2019
  36. 32/76 diff.c: convert --find-copies-harderNguyễn Thái Ngọc Duy, Jan 17, 2019
  37. 33/76 diff.c: convert --no-renames|--[no--rename-emptyNguyễn Thái Ngọc Duy, Jan 17, 2019
  38. 34/76 diff.c: convert --relativeNguyễn Thái Ngọc Duy, Jan 17, 2019
  39. 35/76 diff.c: convert --[no-]minimalNguyễn Thái Ngọc Duy, Jan 17, 2019
  40. 36/76 diff.c: convert --ignore-some-changesNguyễn Thái Ngọc Duy, Jan 17, 2019
  41. 37/76 diff.c: convert --[no-]indent-heuristicNguyễn Thái Ngọc Duy, Jan 17, 2019
  42. 38/76 diff.c: convert --patienceNguyễn Thái Ngọc Duy, Jan 17, 2019
  43. 39/76 diff.c: convert --histogramNguyễn Thái Ngọc Duy, Jan 17, 2019
  44. 40/76 diff.c: convert --diff-algorithmNguyễn Thái Ngọc Duy, Jan 17, 2019
  45. 41/76 diff.c: convert --anchoredNguyễn Thái Ngọc Duy, Jan 17, 2019
  46. 42/76 diff.c: convert --binaryNguyễn Thái Ngọc Duy, Jan 17, 2019
  47. 43/76 diff.c: convert --full-indexNguyễn Thái Ngọc Duy, Jan 17, 2019
  48. 44/76 diff.c: convert -a|--textNguyễn Thái Ngọc Duy, Jan 17, 2019
  49. 45/76 diff.c: convert -RNguyễn Thái Ngọc Duy, Jan 17, 2019
  50. 46/76 diff.c: convert --[no-]followNguyễn Thái Ngọc Duy, Jan 17, 2019
  51. 47/76 diff.c: convert --[no-]colorNguyễn Thái Ngọc Duy, Jan 17, 2019
  52. 48/76 diff.c: convert --word-diffNguyễn Thái Ngọc Duy, Jan 17, 2019
  53. 49/76 diff.c: convert --word-diff-regexNguyễn Thái Ngọc Duy, Jan 17, 2019
  54. 50/76 diff.c: convert --color-wordsNguyễn Thái Ngọc Duy, Jan 17, 2019
  55. 51/76 diff.c: convert --exit-codeNguyễn Thái Ngọc Duy, Jan 17, 2019
  56. 52/76 diff.c: convert --quietNguyễn Thái Ngọc Duy, Jan 17, 2019
  57. 53/76 diff.c: convert --ext-diffNguyễn Thái Ngọc Duy, Jan 17, 2019
  58. 54/76 diff.c: convert --textconvNguyễn Thái Ngọc Duy, Jan 17, 2019
  59. 55/76 diff.c: convert --ignore-submodulesNguyễn Thái Ngọc Duy, Jan 17, 2019
  60. 56/76 diff.c: convert --submoduleNguyễn Thái Ngọc Duy, Jan 17, 2019
  61. 57/76 diff.c: convert --ws-error-highlightNguyễn Thái Ngọc Duy, Jan 17, 2019
  62. 58/76 diff.c: convert --ita-[in]visible-in-indexNguyễn Thái Ngọc Duy, Jan 17, 2019
  63. 59/76 diff.c: convert -zNguyễn Thái Ngọc Duy, Jan 17, 2019
  64. 60/76 diff.c: convert -lNguyễn Thái Ngọc Duy, Jan 17, 2019
  65. 61/76 diff.c: convert -S|-GNguyễn Thái Ngọc Duy, Jan 17, 2019
  66. 62/76 diff.c: convert --pickaxe-all|--pickaxe-regexNguyễn Thái Ngọc Duy, Jan 17, 2019
  67. 63/76 diff.c: convert -ONguyễn Thái Ngọc Duy, Jan 17, 2019
  68. Johannes SchindelinJan 21, 2019
  69. 64/76 diff.c: convert --find-objectNguyễn Thái Ngọc Duy, Jan 17, 2019
  70. 65/76 diff.c: convert --diff-filterNguyễn Thái Ngọc Duy, Jan 17, 2019
  71. 66/76 diff.c: convert --[no-]abbrevNguyễn Thái Ngọc Duy, Jan 17, 2019
  72. 67/76 diff.c: convert --[src|dst]-prefixNguyễn Thái Ngọc Duy, Jan 17, 2019
  73. 68/76 diff.c: convert --line-prefixNguyễn Thái Ngọc Duy, Jan 17, 2019
  74. 69/76 diff.c: convert --no-prefixNguyễn Thái Ngọc Duy, Jan 17, 2019
  75. 70/76 diff.c: convert --inter-hunk-contextNguyễn Thái Ngọc Duy, Jan 17, 2019
  76. SZEDER GáborJan 19, 2019
  77. 71/76 diff.c: convert --color-movedNguyễn Thái Ngọc Duy, Jan 17, 2019
  78. 72/76 diff.c: convert --color-moved-wsNguyễn Thái Ngọc Duy, Jan 17, 2019
  79. 73/76 diff.c: allow --no-color-moved-wsNguyễn Thái Ngọc Duy, Jan 17, 2019
  80. 74/76 range-diff: use parse_options() instead of diff_opt_parse()Nguyễn Thái Ngọc Duy, Jan 17, 2019
  81. Stefan BellerJan 17, 2019
  82. Duy NguyenJan 18, 2019
  83. 75/76 diff --no-index: use parse_options() instead of diff_opt_parse()Nguyễn Thái Ngọc Duy, Jan 17, 2019
  84. 76/76 am: avoid diff_opt_parse()Nguyễn Thái Ngọc Duy, Jan 17, 2019
  85. Johannes SchindelinJan 17, 2019
  86. Duy NguyenJan 18, 2019
  87. Ævar Arnfjörð BjarmasonJan 17, 2019
  88. Stefan BellerJan 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.