git 1.19.1 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +5 -1
  3. data/AI_POLICY.md +24 -0
  4. data/CHANGELOG.md +689 -0
  5. data/CODE_OF_CONDUCT.md +25 -0
  6. data/CONTRIBUTING.md +1175 -97
  7. data/GOVERNANCE.md +106 -0
  8. data/LICENSE +1 -1
  9. data/MAINTAINERS.md +17 -4
  10. data/README.md +476 -320
  11. data/UPGRADING.md +1138 -0
  12. data/git.gemspec +124 -36
  13. data/lib/git/author.rb +39 -7
  14. data/lib/git/author_info.rb +66 -0
  15. data/lib/git/branch.rb +615 -65
  16. data/lib/git/branch_delete_failure.rb +34 -0
  17. data/lib/git/branch_delete_result.rb +66 -0
  18. data/lib/git/branch_info.rb +237 -0
  19. data/lib/git/branches.rb +167 -44
  20. data/lib/git/command_line/base.rb +247 -0
  21. data/lib/git/command_line/capturing.rb +308 -0
  22. data/lib/git/command_line/result.rb +88 -0
  23. data/lib/git/command_line/streaming.rb +236 -0
  24. data/lib/git/command_line.rb +52 -0
  25. data/lib/git/commands/add.rb +139 -0
  26. data/lib/git/commands/am/abort.rb +43 -0
  27. data/lib/git/commands/am/apply.rb +263 -0
  28. data/lib/git/commands/am/continue.rb +43 -0
  29. data/lib/git/commands/am/quit.rb +43 -0
  30. data/lib/git/commands/am/retry.rb +49 -0
  31. data/lib/git/commands/am/show_current_patch.rb +64 -0
  32. data/lib/git/commands/am/skip.rb +42 -0
  33. data/lib/git/commands/am.rb +33 -0
  34. data/lib/git/commands/apply.rb +242 -0
  35. data/lib/git/commands/archive/list_formats.rb +46 -0
  36. data/lib/git/commands/archive.rb +145 -0
  37. data/lib/git/commands/arguments.rb +4521 -0
  38. data/lib/git/commands/base.rb +502 -0
  39. data/lib/git/commands/branch/copy.rb +102 -0
  40. data/lib/git/commands/branch/create.rb +177 -0
  41. data/lib/git/commands/branch/delete.rb +88 -0
  42. data/lib/git/commands/branch/list.rb +178 -0
  43. data/lib/git/commands/branch/move.rb +102 -0
  44. data/lib/git/commands/branch/set_upstream.rb +86 -0
  45. data/lib/git/commands/branch/show_current.rb +49 -0
  46. data/lib/git/commands/branch/unset_upstream.rb +53 -0
  47. data/lib/git/commands/branch.rb +34 -0
  48. data/lib/git/commands/cat_file/batch.rb +385 -0
  49. data/lib/git/commands/cat_file/filtered.rb +105 -0
  50. data/lib/git/commands/cat_file/raw.rb +271 -0
  51. data/lib/git/commands/cat_file.rb +49 -0
  52. data/lib/git/commands/checkout/branch.rb +153 -0
  53. data/lib/git/commands/checkout/files.rb +116 -0
  54. data/lib/git/commands/checkout.rb +38 -0
  55. data/lib/git/commands/checkout_index.rb +106 -0
  56. data/lib/git/commands/clean.rb +102 -0
  57. data/lib/git/commands/clone.rb +241 -0
  58. data/lib/git/commands/commit.rb +273 -0
  59. data/lib/git/commands/commit_tree.rb +101 -0
  60. data/lib/git/commands/config_option_syntax/add.rb +86 -0
  61. data/lib/git/commands/config_option_syntax/get.rb +121 -0
  62. data/lib/git/commands/config_option_syntax/get_all.rb +118 -0
  63. data/lib/git/commands/config_option_syntax/get_color.rb +95 -0
  64. data/lib/git/commands/config_option_syntax/get_color_bool.rb +96 -0
  65. data/lib/git/commands/config_option_syntax/get_regexp.rb +119 -0
  66. data/lib/git/commands/config_option_syntax/get_urlmatch.rb +111 -0
  67. data/lib/git/commands/config_option_syntax/list.rb +111 -0
  68. data/lib/git/commands/config_option_syntax/remove_section.rb +79 -0
  69. data/lib/git/commands/config_option_syntax/rename_section.rb +83 -0
  70. data/lib/git/commands/config_option_syntax/replace_all.rb +109 -0
  71. data/lib/git/commands/config_option_syntax/set.rb +119 -0
  72. data/lib/git/commands/config_option_syntax/unset.rb +92 -0
  73. data/lib/git/commands/config_option_syntax/unset_all.rb +94 -0
  74. data/lib/git/commands/config_option_syntax.rb +56 -0
  75. data/lib/git/commands/describe.rb +156 -0
  76. data/lib/git/commands/diff.rb +657 -0
  77. data/lib/git/commands/diff_files.rb +519 -0
  78. data/lib/git/commands/diff_index.rb +499 -0
  79. data/lib/git/commands/fetch.rb +354 -0
  80. data/lib/git/commands/fsck.rb +138 -0
  81. data/lib/git/commands/gc.rb +134 -0
  82. data/lib/git/commands/grep.rb +339 -0
  83. data/lib/git/commands/init.rb +101 -0
  84. data/lib/git/commands/log.rb +634 -0
  85. data/lib/git/commands/ls_files.rb +195 -0
  86. data/lib/git/commands/ls_remote.rb +161 -0
  87. data/lib/git/commands/ls_tree.rb +135 -0
  88. data/lib/git/commands/maintenance/register.rb +77 -0
  89. data/lib/git/commands/maintenance/run.rb +109 -0
  90. data/lib/git/commands/maintenance/start.rb +71 -0
  91. data/lib/git/commands/maintenance/stop.rb +60 -0
  92. data/lib/git/commands/maintenance/unregister.rb +84 -0
  93. data/lib/git/commands/maintenance.rb +31 -0
  94. data/lib/git/commands/merge/abort.rb +44 -0
  95. data/lib/git/commands/merge/continue.rb +44 -0
  96. data/lib/git/commands/merge/quit.rb +46 -0
  97. data/lib/git/commands/merge/start.rb +250 -0
  98. data/lib/git/commands/merge.rb +28 -0
  99. data/lib/git/commands/merge_base.rb +91 -0
  100. data/lib/git/commands/mv.rb +82 -0
  101. data/lib/git/commands/name_rev.rb +119 -0
  102. data/lib/git/commands/pull.rb +382 -0
  103. data/lib/git/commands/push.rb +251 -0
  104. data/lib/git/commands/read_tree.rb +154 -0
  105. data/lib/git/commands/remote/add.rb +96 -0
  106. data/lib/git/commands/remote/get_url.rb +68 -0
  107. data/lib/git/commands/remote/list.rb +56 -0
  108. data/lib/git/commands/remote/prune.rb +63 -0
  109. data/lib/git/commands/remote/remove.rb +52 -0
  110. data/lib/git/commands/remote/rename.rb +76 -0
  111. data/lib/git/commands/remote/set_branches.rb +70 -0
  112. data/lib/git/commands/remote/set_head.rb +89 -0
  113. data/lib/git/commands/remote/set_url.rb +78 -0
  114. data/lib/git/commands/remote/set_url_add.rb +70 -0
  115. data/lib/git/commands/remote/set_url_delete.rb +71 -0
  116. data/lib/git/commands/remote/show.rb +77 -0
  117. data/lib/git/commands/remote/update.rb +79 -0
  118. data/lib/git/commands/remote.rb +42 -0
  119. data/lib/git/commands/repack.rb +281 -0
  120. data/lib/git/commands/reset.rb +154 -0
  121. data/lib/git/commands/rev_parse.rb +304 -0
  122. data/lib/git/commands/revert/abort.rb +45 -0
  123. data/lib/git/commands/revert/continue.rb +62 -0
  124. data/lib/git/commands/revert/quit.rb +47 -0
  125. data/lib/git/commands/revert/skip.rb +44 -0
  126. data/lib/git/commands/revert/start.rb +158 -0
  127. data/lib/git/commands/revert.rb +29 -0
  128. data/lib/git/commands/rm.rb +113 -0
  129. data/lib/git/commands/show.rb +632 -0
  130. data/lib/git/commands/show_ref/exclude_existing.rb +119 -0
  131. data/lib/git/commands/show_ref/exists.rb +80 -0
  132. data/lib/git/commands/show_ref/list.rb +149 -0
  133. data/lib/git/commands/show_ref/verify.rb +122 -0
  134. data/lib/git/commands/show_ref.rb +42 -0
  135. data/lib/git/commands/stash/apply.rb +81 -0
  136. data/lib/git/commands/stash/branch.rb +67 -0
  137. data/lib/git/commands/stash/clear.rb +43 -0
  138. data/lib/git/commands/stash/create.rb +60 -0
  139. data/lib/git/commands/stash/drop.rb +73 -0
  140. data/lib/git/commands/stash/list.rb +43 -0
  141. data/lib/git/commands/stash/pop.rb +87 -0
  142. data/lib/git/commands/stash/push.rb +112 -0
  143. data/lib/git/commands/stash/show.rb +158 -0
  144. data/lib/git/commands/stash/store.rb +72 -0
  145. data/lib/git/commands/stash.rb +38 -0
  146. data/lib/git/commands/status.rb +174 -0
  147. data/lib/git/commands/symbolic_ref/delete.rb +72 -0
  148. data/lib/git/commands/symbolic_ref/read.rb +99 -0
  149. data/lib/git/commands/symbolic_ref/update.rb +79 -0
  150. data/lib/git/commands/symbolic_ref.rb +38 -0
  151. data/lib/git/commands/tag/create.rb +142 -0
  152. data/lib/git/commands/tag/delete.rb +57 -0
  153. data/lib/git/commands/tag/list.rb +146 -0
  154. data/lib/git/commands/tag/verify.rb +71 -0
  155. data/lib/git/commands/tag.rb +26 -0
  156. data/lib/git/commands/update_ref/batch.rb +145 -0
  157. data/lib/git/commands/update_ref/delete.rb +90 -0
  158. data/lib/git/commands/update_ref/update.rb +103 -0
  159. data/lib/git/commands/update_ref.rb +42 -0
  160. data/lib/git/commands/version.rb +60 -0
  161. data/lib/git/commands/worktree/add.rb +139 -0
  162. data/lib/git/commands/worktree/list.rb +64 -0
  163. data/lib/git/commands/worktree/lock.rb +58 -0
  164. data/lib/git/commands/worktree/management_base.rb +51 -0
  165. data/lib/git/commands/worktree/move.rb +66 -0
  166. data/lib/git/commands/worktree/prune.rb +67 -0
  167. data/lib/git/commands/worktree/remove.rb +63 -0
  168. data/lib/git/commands/worktree/repair.rb +76 -0
  169. data/lib/git/commands/worktree/unlock.rb +47 -0
  170. data/lib/git/commands/worktree.rb +43 -0
  171. data/lib/git/commands/write_tree.rb +68 -0
  172. data/lib/git/commands.rb +88 -0
  173. data/lib/git/config.rb +72 -5
  174. data/lib/git/config_entry_info.rb +106 -0
  175. data/lib/git/configuring.rb +795 -0
  176. data/lib/git/detached_head_info.rb +57 -0
  177. data/lib/git/diff.rb +437 -86
  178. data/lib/git/diff_file_numstat_info.rb +31 -0
  179. data/lib/git/diff_file_patch_info.rb +136 -0
  180. data/lib/git/diff_file_raw_info.rb +129 -0
  181. data/lib/git/diff_info.rb +162 -0
  182. data/lib/git/diff_path_status.rb +107 -0
  183. data/lib/git/diff_result.rb +34 -0
  184. data/lib/git/diff_stats.rb +111 -0
  185. data/lib/git/dirstat_info.rb +102 -0
  186. data/lib/git/encoding_utils.rb +32 -1
  187. data/lib/git/errors.rb +285 -0
  188. data/lib/git/escaped_path.rb +57 -5
  189. data/lib/git/execution_context/global.rb +31 -0
  190. data/lib/git/execution_context/repository.rb +151 -0
  191. data/lib/git/execution_context.rb +559 -0
  192. data/lib/git/factories.rb +813 -0
  193. data/lib/git/file_ref.rb +77 -0
  194. data/lib/git/fsck_object.rb +56 -0
  195. data/lib/git/fsck_result.rb +132 -0
  196. data/lib/git/log.rb +306 -90
  197. data/lib/git/object.rb +563 -141
  198. data/lib/git/parsers/branch.rb +240 -0
  199. data/lib/git/parsers/cat_file.rb +111 -0
  200. data/lib/git/parsers/config_entry.rb +110 -0
  201. data/lib/git/parsers/diff.rb +792 -0
  202. data/lib/git/parsers/fsck.rb +144 -0
  203. data/lib/git/parsers/grep.rb +42 -0
  204. data/lib/git/parsers/ls_remote.rb +79 -0
  205. data/lib/git/parsers/ls_tree.rb +58 -0
  206. data/lib/git/parsers/remote.rb +162 -0
  207. data/lib/git/parsers/stash.rb +292 -0
  208. data/lib/git/parsers/status.rb +251 -0
  209. data/lib/git/parsers/tag.rb +341 -0
  210. data/lib/git/parsers/worktree.rb +185 -0
  211. data/lib/git/path_resolver.rb +206 -0
  212. data/lib/git/remote.rb +165 -12
  213. data/lib/git/remote_info.rb +203 -0
  214. data/lib/git/repository/branching.rb +964 -0
  215. data/lib/git/repository/committing.rb +246 -0
  216. data/lib/git/repository/context_helpers.rb +293 -0
  217. data/lib/git/repository/diffing.rb +785 -0
  218. data/lib/git/repository/inspecting.rb +252 -0
  219. data/lib/git/repository/logging.rb +410 -0
  220. data/lib/git/repository/maintenance.rb +65 -0
  221. data/lib/git/repository/merging.rb +451 -0
  222. data/lib/git/repository/object_operations.rb +1551 -0
  223. data/lib/git/repository/remote_operations.rb +984 -0
  224. data/lib/git/repository/shared_private.rb +120 -0
  225. data/lib/git/repository/staging.rb +587 -0
  226. data/lib/git/repository/stashing.rb +623 -0
  227. data/lib/git/repository/status_operations.rb +249 -0
  228. data/lib/git/repository/worktree_operations.rb +339 -0
  229. data/lib/git/repository.rb +484 -2
  230. data/lib/git/stash.rb +109 -12
  231. data/lib/git/stash_info.rb +102 -0
  232. data/lib/git/stashes.rb +169 -26
  233. data/lib/git/status.rb +308 -122
  234. data/lib/git/status_file_info.rb +258 -0
  235. data/lib/git/status_info.rb +189 -0
  236. data/lib/git/tag_delete_failure.rb +34 -0
  237. data/lib/git/tag_delete_result.rb +66 -0
  238. data/lib/git/tag_info.rb +99 -0
  239. data/lib/git/url.rb +15 -8
  240. data/lib/git/version.rb +113 -2
  241. data/lib/git/version_constraint.rb +85 -0
  242. data/lib/git/worktree.rb +150 -8
  243. data/lib/git/worktree_info.rb +128 -0
  244. data/lib/git/worktrees.rb +118 -13
  245. data/lib/git.rb +632 -234
  246. metadata +369 -54
  247. data/.github/stale.yml +0 -25
  248. data/.github/workflows/continuous_integration.yml +0 -49
  249. data/.gitignore +0 -10
  250. data/Dockerfile.changelog-rs +0 -12
  251. data/Gemfile +0 -5
  252. data/ISSUE_TEMPLATE.md +0 -15
  253. data/PULL_REQUEST_TEMPLATE.md +0 -9
  254. data/RELEASING.md +0 -70
  255. data/Rakefile +0 -60
  256. data/lib/git/base/factory.rb +0 -99
  257. data/lib/git/base.rb +0 -711
  258. data/lib/git/command_line_result.rb +0 -86
  259. data/lib/git/failed_error.rb +0 -53
  260. data/lib/git/git_execute_error.rb +0 -7
  261. data/lib/git/index.rb +0 -5
  262. data/lib/git/lib.rb +0 -1328
  263. data/lib/git/path.rb +0 -31
  264. data/lib/git/signaled_error.rb +0 -50
  265. data/lib/git/working_directory.rb +0 -4
@@ -0,0 +1,657 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements the `git diff` command
8
+ #
9
+ # Compares commits, the index, and the working tree.
10
+ #
11
+ # @example Typical usage
12
+ # diff = Git::Commands::Diff.new(execution_context)
13
+ # diff.call(numstat: true, shortstat: true, src_prefix: 'a/', dst_prefix: 'b/')
14
+ # diff.call(patch: true, no_index: true, path: ['/path/a', '/path/b'])
15
+ # diff.call(patch: true, cached: true)
16
+ # diff.call('abc123', 'def456', raw: true, numstat: true, shortstat: true)
17
+ #
18
+ # @note `arguments` block audited against
19
+ # https://git-scm.com/docs/git-diff/2.53.0
20
+ #
21
+ # @see https://git-scm.com/docs/git-diff git-diff
22
+ #
23
+ # @see Git::Commands
24
+ #
25
+ # @api private
26
+ #
27
+ class Diff < Git::Commands::Base # rubocop:disable Metrics/ClassLength
28
+ arguments do
29
+ literal 'diff'
30
+
31
+ # Output format
32
+ flag_option %i[patch p u]
33
+ flag_option %i[no_patch s]
34
+ value_option %i[unified U], inline: true
35
+ value_option :output, inline: true
36
+ value_option :output_indicator_new, inline: true
37
+ value_option :output_indicator_old, inline: true
38
+ value_option :output_indicator_context, inline: true
39
+ flag_option :raw
40
+ flag_option :patch_with_raw
41
+ flag_option :indent_heuristic, negatable: true
42
+ flag_option :minimal
43
+ flag_option :patience
44
+ flag_option :histogram
45
+ value_option :anchored, inline: true, repeatable: true
46
+ value_option :diff_algorithm, inline: true
47
+ flag_or_value_option :stat, inline: true
48
+ value_option :stat_width, inline: true
49
+ value_option :stat_name_width, inline: true
50
+ value_option :stat_count, inline: true
51
+ value_option :stat_graph_width, inline: true
52
+ flag_option :compact_summary
53
+ flag_option :numstat
54
+ flag_option :shortstat
55
+ flag_or_value_option %i[dirstat X], inline: true
56
+ flag_option :cumulative
57
+ flag_or_value_option :dirstat_by_file, inline: true
58
+ flag_option :summary
59
+ flag_option :patch_with_stat
60
+ flag_option :z
61
+ flag_option :name_only
62
+ flag_option :name_status
63
+ flag_or_value_option :submodule, inline: true
64
+
65
+ # Color and word diff
66
+ flag_or_value_option :color, negatable: true, inline: true
67
+ flag_or_value_option :color_moved, negatable: true, inline: true
68
+ flag_or_value_option :color_moved_ws, negatable: true, inline: true
69
+ flag_or_value_option :word_diff, inline: true
70
+ value_option :word_diff_regex, inline: true
71
+ flag_or_value_option :color_words, inline: true
72
+
73
+ # Rename and copy detection
74
+ flag_option :no_renames
75
+ flag_option :rename_empty, negatable: true
76
+ flag_option :check
77
+ value_option :ws_error_highlight, inline: true
78
+ flag_option :full_index
79
+ flag_option :binary
80
+ flag_or_value_option :abbrev, inline: true
81
+ flag_or_value_option %i[break_rewrites B], inline: true
82
+ flag_or_value_option %i[find_renames M], inline: true
83
+ flag_or_value_option %i[find_copies C], inline: true
84
+ flag_option :find_copies_harder
85
+ flag_option %i[irreversible_delete D]
86
+ value_option :l, inline: true
87
+ value_option :diff_filter, inline: true
88
+
89
+ # Content search (pickaxe)
90
+ value_option :S, inline: true
91
+ value_option :G, inline: true
92
+ value_option :find_object, inline: true
93
+ flag_option :pickaxe_all
94
+ flag_option :pickaxe_regex
95
+
96
+ # Output ordering
97
+ value_option :O, inline: true
98
+ value_option :skip_to, inline: true
99
+ value_option :rotate_to, inline: true
100
+ flag_option :R
101
+
102
+ # Path scope and comparison
103
+ flag_or_value_option :relative, negatable: true, inline: true
104
+ flag_option %i[text a]
105
+
106
+ # Whitespace handling
107
+ flag_option :ignore_cr_at_eol
108
+ flag_option :ignore_space_at_eol
109
+ flag_option %i[ignore_space_change b]
110
+ flag_option %i[ignore_all_space w]
111
+ flag_option :ignore_blank_lines
112
+ value_option %i[ignore_matching_lines I], inline: true, repeatable: true
113
+ value_option :inter_hunk_context, inline: true
114
+ flag_option %i[function_context W]
115
+
116
+ # Behavior control
117
+ flag_option :exit_code
118
+ flag_option :quiet
119
+ flag_option :ext_diff, negatable: true
120
+ flag_option :textconv, negatable: true
121
+ flag_or_value_option :ignore_submodules, inline: true
122
+
123
+ # Prefix and path display
124
+ value_option :src_prefix, inline: true
125
+ value_option :dst_prefix, inline: true
126
+ flag_option :no_prefix
127
+ flag_option :default_prefix
128
+ value_option :line_prefix, inline: true
129
+ flag_option :ita_invisible_in_index
130
+ flag_option :ita_visible_in_index
131
+ value_option :max_depth, inline: true
132
+
133
+ # Combined diff format
134
+ flag_option :c
135
+ flag_option :cc
136
+ flag_option :combined_all_paths
137
+
138
+ # git diff-specific modes
139
+ flag_option %i[cached staged]
140
+ flag_option :merge_base
141
+ flag_option :no_index
142
+
143
+ # Merge conflict stage selection
144
+ flag_option %i[base 1]
145
+ flag_option %i[ours 2]
146
+ flag_option %i[theirs 3]
147
+ flag_option :'0'
148
+
149
+ operand :commit, repeatable: true
150
+ end_of_options
151
+ value_option :path, as_operand: true, repeatable: true
152
+ end
153
+
154
+ # Exit codes: 0 = success; with --exit-code: 1 = differences found;
155
+ # with --check: 2 = whitespace/conflict-marker errors
156
+ allow_exit_status 0..2
157
+
158
+ # @overload call(**options)
159
+ #
160
+ # Compare the index to the working tree
161
+ #
162
+ # @example
163
+ # Diff.new(ctx).call(numstat: true, src_prefix: 'a/', dst_prefix: 'b/')
164
+ #
165
+ # @param options [Hash] command options
166
+ #
167
+ # @return [Git::CommandLine::Result] the result of calling `git diff`
168
+ #
169
+ # @raise [ArgumentError] if unsupported options are provided
170
+ #
171
+ # @raise [Git::FailedError] if git exits outside the allowed range
172
+ # (exit code > 2)
173
+ #
174
+ # @api public
175
+ #
176
+ # @overload call(no_index: true, path:, **options)
177
+ #
178
+ # Compare two paths on the filesystem (outside git)
179
+ #
180
+ # Always use the `path:` keyword for the two filesystem paths so
181
+ # that paths beginning with `-` are safely separated by `--` and
182
+ # cannot be mistaken for flags by git.
183
+ #
184
+ # @example
185
+ # Diff.new(ctx).call(patch: true, no_index: true, path: ['/a', '/b'])
186
+ #
187
+ # @param path [Array<String>] two filesystem paths to compare
188
+ # (passed after `--`)
189
+ #
190
+ # @param options [Hash] command options
191
+ #
192
+ # @return [Git::CommandLine::Result] the result of calling `git diff`
193
+ #
194
+ # @raise [ArgumentError] if unsupported options are provided
195
+ #
196
+ # @raise [Git::FailedError] if git exits outside the allowed range
197
+ # (exit code > 2)
198
+ #
199
+ # @api public
200
+ #
201
+ # @overload call(commit = nil, cached:, **options)
202
+ #
203
+ # Compare the index to HEAD or the named commit
204
+ #
205
+ # @example
206
+ # Diff.new(ctx).call(patch: true, cached: true)
207
+ # Diff.new(ctx).call('HEAD~3', patch: true, cached: true)
208
+ #
209
+ # @param commit [String, nil] commit to compare the index against
210
+ # (defaults to HEAD)
211
+ #
212
+ # @param options [Hash] command options
213
+ #
214
+ # @return [Git::CommandLine::Result] the result of calling `git diff`
215
+ #
216
+ # @raise [ArgumentError] if unsupported options are provided
217
+ #
218
+ # @raise [Git::FailedError] if git exits outside the allowed range
219
+ # (exit code > 2)
220
+ #
221
+ # @api public
222
+ #
223
+ # @overload call(commit, **options)
224
+ #
225
+ # Compare the working tree to the named commit
226
+ #
227
+ # @example
228
+ # Diff.new(ctx).call('HEAD~3', numstat: true, shortstat: true)
229
+ #
230
+ # @param commit [String] commit reference to compare the working
231
+ # tree against
232
+ #
233
+ # @param options [Hash] command options
234
+ #
235
+ # @return [Git::CommandLine::Result] the result of calling `git diff`
236
+ #
237
+ # @raise [ArgumentError] if unsupported options are provided
238
+ #
239
+ # @raise [Git::FailedError] if git exits outside the allowed range
240
+ # (exit code > 2)
241
+ #
242
+ # @api public
243
+ #
244
+ # @overload call(commit, *commits, **options)
245
+ #
246
+ # Compare two or more commits or show a combined diff
247
+ #
248
+ # @example Compare two commits
249
+ # Diff.new(ctx).call('abc123', 'def456', raw: true, numstat: true)
250
+ #
251
+ # @example Combined diff of a merge commit
252
+ # Diff.new(ctx).call('main', 'feature-a', 'feature-b',
253
+ # merge_base: true)
254
+ #
255
+ # @param commit [String] first commit reference
256
+ #
257
+ # @param commits [Array<String>] additional commit references
258
+ #
259
+ # @param options [Hash] command options
260
+ #
261
+ # @option options [Boolean, nil] :patch (nil) generate patch output
262
+ #
263
+ # Alias: :p, :u
264
+ #
265
+ # @option options [Boolean, nil] :no_patch (nil) suppress all diff
266
+ # output
267
+ #
268
+ # Alias: :s
269
+ #
270
+ # @option options [Integer, String] :unified (nil) generate diffs
271
+ # with this many lines of context
272
+ #
273
+ # Alias: :U
274
+ #
275
+ # @option options [String] :output (nil) write output to a file
276
+ # instead of stdout
277
+ #
278
+ # @option options [String] :output_indicator_new (nil) character
279
+ # to indicate new lines in the patch
280
+ #
281
+ # @option options [String] :output_indicator_old (nil) character
282
+ # to indicate old lines in the patch
283
+ #
284
+ # @option options [String] :output_indicator_context (nil)
285
+ # character to indicate context lines in the patch
286
+ #
287
+ # @option options [Boolean, nil] :raw (nil) generate the diff in raw
288
+ # format
289
+ #
290
+ # @option options [Boolean, nil] :patch_with_raw (nil) synonym for
291
+ # `--patch --raw`
292
+ #
293
+ # @option options [Boolean, nil] :indent_heuristic (nil) enable the
294
+ # indent heuristic for patch readability (`--indent-heuristic`)
295
+ #
296
+ # @option options [Boolean, nil] :no_indent_heuristic (nil) disable
297
+ # the indent heuristic (`--no-indent-heuristic`)
298
+ #
299
+ # @option options [Boolean, nil] :minimal (nil) spend extra time to
300
+ # produce the smallest possible diff
301
+ #
302
+ # @option options [Boolean, nil] :patience (nil) use the patience
303
+ # diff algorithm
304
+ #
305
+ # @option options [Boolean, nil] :histogram (nil) use the histogram
306
+ # diff algorithm
307
+ #
308
+ # @option options [String, Array<String>] :anchored (nil)
309
+ # generate a diff using the anchored diff algorithm
310
+ #
311
+ # Pass an array for multiple anchored texts. Maps to
312
+ # `--anchored=<text>`.
313
+ #
314
+ # @option options [String] :diff_algorithm (nil) choose a diff
315
+ # algorithm (`patience`, `minimal`, `histogram`, or `myers`)
316
+ #
317
+ # @option options [Boolean, String, nil] :stat (nil) generate a
318
+ # diffstat
319
+ #
320
+ # Pass `true` for `--stat`; pass a string like
321
+ # `'100,40,10'` for `--stat=100,40,10`.
322
+ #
323
+ # @option options [Integer, String] :stat_width (nil) limit the
324
+ # width of `--stat` output
325
+ #
326
+ # @option options [Integer, String] :stat_name_width (nil) limit
327
+ # the filename width of `--stat` output
328
+ #
329
+ # @option options [Integer, String] :stat_count (nil) limit the
330
+ # number of lines in `--stat` output
331
+ #
332
+ # @option options [Integer, String] :stat_graph_width (nil) limit
333
+ # the graph width of `--stat` output
334
+ #
335
+ # @option options [Boolean, nil] :compact_summary (nil) output a
336
+ # condensed summary of extended header information
337
+ #
338
+ # @option options [Boolean, nil] :numstat (nil) show per-file
339
+ # insertion/deletion counts in decimal notation
340
+ #
341
+ # @option options [Boolean, nil] :shortstat (nil) output only the
342
+ # aggregate totals line from `--stat`
343
+ #
344
+ # @option options [Boolean, String, nil] :dirstat (nil) output the
345
+ # distribution of relative amount of changes per sub-directory
346
+ #
347
+ # Pass `true` for `--dirstat`; pass a string like
348
+ # `'lines,cumulative'` for `--dirstat=lines,cumulative`.
349
+ #
350
+ # Alias: :X
351
+ #
352
+ # @option options [Boolean, nil] :cumulative (nil) synonym for
353
+ # `--dirstat=cumulative`
354
+ #
355
+ # @option options [Boolean, String, nil] :dirstat_by_file (nil)
356
+ # synonym for `--dirstat=files,...`
357
+ #
358
+ # @option options [Boolean, nil] :summary (nil) output a condensed
359
+ # summary of extended header information
360
+ #
361
+ # @option options [Boolean, nil] :patch_with_stat (nil) synonym for
362
+ # `--patch --stat`
363
+ #
364
+ # @option options [Boolean, nil] :z (nil) use NUL as output field
365
+ # terminators
366
+ #
367
+ # @option options [Boolean, nil] :name_only (nil) show only the name
368
+ # of each changed file
369
+ #
370
+ # @option options [Boolean, nil] :name_status (nil) show only the
371
+ # name and status of each changed file
372
+ #
373
+ # @option options [Boolean, String, nil] :submodule (nil) specify how
374
+ # differences in submodules are shown
375
+ #
376
+ # Pass `true` for `--submodule`; pass a string like `'log'`
377
+ # or `'diff'` for `--submodule=<format>`.
378
+ #
379
+ # @option options [Boolean, String, nil] :color (nil) show colored
380
+ # diff
381
+ #
382
+ # Pass `true` for `--color` or a string like `'always'` for
383
+ # `--color=always`.
384
+ #
385
+ # @option options [Boolean, nil] :no_color (nil) disable colored
386
+ # diff (`--no-color`)
387
+ #
388
+ # @option options [Boolean, String, nil] :color_moved (nil) color
389
+ # moved lines differently
390
+ #
391
+ # Pass `true` for `--color-moved` or a string like `'zebra'`
392
+ # for `--color-moved=zebra`.
393
+ #
394
+ # @option options [Boolean, nil] :no_color_moved (nil) disable
395
+ # coloring moved lines (`--no-color-moved`)
396
+ #
397
+ # @option options [Boolean, String, nil] :color_moved_ws (nil)
398
+ # configure how whitespace is handled for move detection
399
+ #
400
+ # Pass `true` for `--color-moved-ws` or a string like
401
+ # `'ignore-all-space'` for
402
+ # `--color-moved-ws=ignore-all-space`.
403
+ #
404
+ # @option options [Boolean, nil] :no_color_moved_ws (nil) disable
405
+ # whitespace handling for move detection
406
+ # (`--no-color-moved-ws`)
407
+ #
408
+ # @option options [Boolean, String, nil] :word_diff (nil) show a
409
+ # word diff
410
+ #
411
+ # Pass `true` for `--word-diff`; pass a string like `'color'`
412
+ # for `--word-diff=color`.
413
+ #
414
+ # @option options [String] :word_diff_regex (nil) use this regex
415
+ # to decide what a word is
416
+ #
417
+ # @option options [Boolean, String, nil] :color_words (nil) equivalent
418
+ # to `--word-diff=color` plus optional regex
419
+ #
420
+ # @option options [Boolean, nil] :no_renames (nil) turn off rename
421
+ # detection
422
+ #
423
+ # @option options [Boolean, nil] :rename_empty (nil) use empty blobs
424
+ # as rename source (`--rename-empty`)
425
+ #
426
+ # @option options [Boolean, nil] :no_rename_empty (nil) do not use
427
+ # empty blobs as rename source (`--no-rename-empty`)
428
+ #
429
+ # @option options [Boolean, nil] :check (nil) warn if changes
430
+ # introduce conflict markers or whitespace errors
431
+ #
432
+ # @option options [String] :ws_error_highlight (nil) highlight
433
+ # whitespace errors in `context`, `old`, or `new` lines
434
+ #
435
+ # @option options [Boolean, nil] :full_index (nil) show full
436
+ # pre- and post-image blob object names
437
+ #
438
+ # @option options [Boolean, nil] :binary (nil) output a binary diff
439
+ # that can be applied with `git apply`
440
+ #
441
+ # @option options [Boolean, String, nil] :abbrev (nil) show only a
442
+ # partial prefix of object names
443
+ #
444
+ # Pass `true` for `--abbrev`; pass a string for
445
+ # `--abbrev=<n>`.
446
+ #
447
+ # @option options [Boolean, String, nil] :break_rewrites (nil) break
448
+ # complete rewrite changes into delete/create pairs
449
+ #
450
+ # Alias: :B
451
+ #
452
+ # @option options [Boolean, String, nil] :find_renames (nil) detect
453
+ # renames, optionally specifying a similarity threshold
454
+ #
455
+ # Alias: :M
456
+ #
457
+ # @option options [Boolean, String, nil] :find_copies (nil) detect
458
+ # copies as well as renames
459
+ #
460
+ # Alias: :C
461
+ #
462
+ # @option options [Boolean, nil] :find_copies_harder (nil) inspect
463
+ # all files as candidates for the source of copy
464
+ #
465
+ # @option options [Boolean, nil] :irreversible_delete (nil) omit
466
+ # the preimage for deletes
467
+ #
468
+ # Alias: :D
469
+ #
470
+ # @option options [Integer, String] :l (nil) prevent rename/copy
471
+ # detection from running if the number of targets exceeds this
472
+ #
473
+ # @option options [String] :diff_filter (nil) select only files
474
+ # matching the specified status letters
475
+ #
476
+ # @option options [String] :S (nil) look for differences that
477
+ # change the number of occurrences of a string
478
+ #
479
+ # @option options [String] :G (nil) look for differences whose
480
+ # patch text contains added/removed lines matching a regex
481
+ #
482
+ # @option options [String] :find_object (nil) look for
483
+ # differences that change the number of occurrences of an
484
+ # object
485
+ #
486
+ # @option options [Boolean, nil] :pickaxe_all (nil) when `-S` or
487
+ # `-G` finds a change, show all changes in that changeset
488
+ #
489
+ # @option options [Boolean, nil] :pickaxe_regex (nil) treat the
490
+ # `-S` string as an extended POSIX regular expression
491
+ #
492
+ # @option options [String] :O (nil) control the order in which
493
+ # files appear in the output
494
+ #
495
+ # @option options [String] :skip_to (nil) discard files before
496
+ # the named file from the output
497
+ #
498
+ # @option options [String] :rotate_to (nil) move files before
499
+ # the named file to the end of the output
500
+ #
501
+ # @option options [Boolean, nil] :R (nil) swap two inputs (reverse
502
+ # diff)
503
+ #
504
+ # @option options [Boolean, String, nil] :relative (nil) show
505
+ # pathnames relative to a subdirectory
506
+ #
507
+ # Pass `true` for `--relative` or a string for
508
+ # `--relative=<path>`.
509
+ #
510
+ # @option options [Boolean, nil] :no_relative (nil) show pathnames
511
+ # relative to the working directory (`--no-relative`)
512
+ #
513
+ # @option options [Boolean, nil] :text (nil) treat all files as
514
+ # text
515
+ #
516
+ # Alias: :a
517
+ #
518
+ # @option options [Boolean, nil] :ignore_cr_at_eol (nil) ignore
519
+ # carriage-return at end of line
520
+ #
521
+ # @option options [Boolean, nil] :ignore_space_at_eol (nil) ignore
522
+ # changes in whitespace at end of line
523
+ #
524
+ # @option options [Boolean, nil] :ignore_space_change (nil) ignore
525
+ # changes in amount of whitespace
526
+ #
527
+ # Alias: :b
528
+ #
529
+ # @option options [Boolean, nil] :ignore_all_space (nil) ignore
530
+ # whitespace when comparing lines
531
+ #
532
+ # Alias: :w
533
+ #
534
+ # @option options [Boolean, nil] :ignore_blank_lines (nil) ignore
535
+ # changes whose lines are all blank
536
+ #
537
+ # @option options [String, Array<String>] :ignore_matching_lines
538
+ # (nil) ignore changes whose all lines match the given regex
539
+ #
540
+ # Pass an array for multiple patterns. Maps to
541
+ # `--ignore-matching-lines=<regex>`.
542
+ #
543
+ # Alias: :I
544
+ #
545
+ # @option options [Integer, String] :inter_hunk_context (nil)
546
+ # show the context between diff hunks, fusing nearby hunks
547
+ #
548
+ # @option options [Boolean, nil] :function_context (nil) show whole
549
+ # function as context lines for each change
550
+ #
551
+ # Alias: :W
552
+ #
553
+ # @option options [Boolean, nil] :exit_code (nil) make the program
554
+ # exit with codes similar to `diff(1)`
555
+ #
556
+ # @option options [Boolean, nil] :quiet (nil) disable all output of
557
+ # the program
558
+ #
559
+ # @option options [Boolean, nil] :ext_diff (nil) allow an external
560
+ # diff helper (`--ext-diff`)
561
+ #
562
+ # @option options [Boolean, nil] :no_ext_diff (nil) disallow an
563
+ # external diff helper (`--no-ext-diff`)
564
+ #
565
+ # @option options [Boolean, nil] :textconv (nil) allow external
566
+ # text conversion filters for binary files (`--textconv`)
567
+ #
568
+ # @option options [Boolean, nil] :no_textconv (nil) disallow
569
+ # external text conversion filters for binary files
570
+ # (`--no-textconv`)
571
+ #
572
+ # @option options [Boolean, String, nil] :ignore_submodules (nil)
573
+ # ignore changes to submodules in the diff
574
+ #
575
+ # Pass `true` for `--ignore-submodules`; pass a string like
576
+ # `'all'` for `--ignore-submodules=all`.
577
+ #
578
+ # @option options [String] :src_prefix (nil) source prefix for
579
+ # diff headers (e.g. `'a/'`)
580
+ #
581
+ # @option options [String] :dst_prefix (nil) destination prefix
582
+ # for diff headers (e.g. `'b/'`)
583
+ #
584
+ # @option options [Boolean, nil] :no_prefix (nil) do not show any
585
+ # source or destination prefix
586
+ #
587
+ # @option options [Boolean, nil] :default_prefix (nil) use the
588
+ # default source and destination prefixes
589
+ #
590
+ # @option options [String] :line_prefix (nil) prepend an
591
+ # additional prefix to every line of output
592
+ #
593
+ # @option options [Boolean, nil] :ita_invisible_in_index (nil) make
594
+ # intent-to-add entries appear as new files in `git diff`
595
+ #
596
+ # @option options [Boolean, nil] :ita_visible_in_index (nil) revert
597
+ # `--ita-invisible-in-index`
598
+ #
599
+ # @option options [Integer, String] :max_depth (nil) descend at
600
+ # most this many levels of directories per pathspec
601
+ #
602
+ # @option options [Boolean, nil] :cached (nil) compare the index to
603
+ # HEAD or a named commit
604
+ #
605
+ # Alias: :staged
606
+ #
607
+ # @option options [Boolean, nil] :merge_base (nil) use merge base
608
+ # of commits
609
+ #
610
+ # @option options [Boolean, nil] :no_index (nil) compare two
611
+ # filesystem paths outside a repo
612
+ #
613
+ # @option options [Boolean, nil] :base (nil) compare working tree
614
+ # with the base version (stage #1)
615
+ #
616
+ # Alias: :"1"
617
+ #
618
+ # @option options [Boolean, nil] :ours (nil) compare working tree
619
+ # with our branch (stage #2)
620
+ #
621
+ # Alias: :"2"
622
+ #
623
+ # @option options [Boolean, nil] :theirs (nil) compare working tree
624
+ # with their branch (stage #3)
625
+ #
626
+ # Alias: :"3"
627
+ #
628
+ # @option options [Boolean, nil] :"0" (nil) omit diff output for
629
+ # unmerged entries
630
+ #
631
+ # @option options [Boolean, nil] :c (nil) produce a combined diff
632
+ # (useful when showing a merge)
633
+ #
634
+ # @option options [Boolean, nil] :cc (nil) produce a dense combined
635
+ # diff (useful when showing a merge)
636
+ #
637
+ # @option options [Boolean, nil] :combined_all_paths (nil) show
638
+ # paths from all parents of a combined diff
639
+ #
640
+ # @option options [Array<String>] :path (nil) zero or more paths
641
+ # to limit diff to
642
+ #
643
+ # @return [Git::CommandLine::Result] the result of calling
644
+ # `git diff`
645
+ #
646
+ # @raise [ArgumentError] if unsupported options are provided
647
+ #
648
+ # @raise [Git::FailedError] if git exits outside the allowed
649
+ # range (exit code > 2)
650
+ #
651
+ # @api public
652
+ def call(*, **)
653
+ super
654
+ end
655
+ end
656
+ end
657
+ end