git 5.0.0.beta.3 → 5.0.0.beta.4

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 (268) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +27 -0
  3. data/.github/copilot-instructions.md +3 -8
  4. data/.github/hooks/bin-setup-on-worktree.json +11 -0
  5. data/.github/hooks/run-bin-setup-once.sh +14 -0
  6. data/.github/skills/breaking-change-analysis/SKILL.md +6 -9
  7. data/.github/skills/ci-cd-troubleshooting/SKILL.md +2 -2
  8. data/.github/skills/command-implementation/REFERENCE.md +34 -33
  9. data/.github/skills/command-implementation/SKILL.md +5 -4
  10. data/.github/skills/command-test-conventions/SKILL.md +13 -9
  11. data/.github/skills/command-yard-documentation/SKILL.md +14 -6
  12. data/.github/skills/development-workflow/SKILL.md +20 -14
  13. data/.github/skills/facade-implementation/REFERENCE.md +19 -22
  14. data/.github/skills/facade-implementation/SKILL.md +0 -5
  15. data/.github/skills/facade-test-conventions/SKILL.md +4 -7
  16. data/.github/skills/facade-yard-documentation/SKILL.md +8 -2
  17. data/.github/skills/make-skill-template/SKILL.md +53 -3
  18. data/.github/skills/pr-readiness-review/SKILL.md +22 -2
  19. data/.github/skills/project-context/SKILL.md +16 -23
  20. data/.github/skills/pull-request-review/SKILL.md +2 -2
  21. data/.github/skills/rebase/SKILL.md +148 -0
  22. data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +1 -1
  23. data/.github/skills/resolve-feedback/SKILL.md +288 -0
  24. data/.github/skills/review-arguments-dsl/CHECKLIST.md +3 -3
  25. data/.github/skills/reviewing-skills/SKILL.md +28 -3
  26. data/.github/skills/test-debugging/SKILL.md +20 -19
  27. data/.github/skills/yard-documentation/SKILL.md +671 -483
  28. data/.github/skills/yard-documentation/element-rules.md +162 -0
  29. data/.github/skills-deprecated/README.md +21 -0
  30. data/.github/{skills → skills-deprecated}/extract-command-from-lib/SKILL.md +9 -9
  31. data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/SKILL.md +12 -12
  32. data/.github/workflows/continuous_integration.yml +3 -2
  33. data/.rubocop.yml +7 -39
  34. data/.yard-lint.yml +75 -0
  35. data/CONTRIBUTING.md +186 -174
  36. data/Gemfile +17 -0
  37. data/README.md +47 -12
  38. data/Rakefile +3 -21
  39. data/UPGRADING.md +219 -70
  40. data/docker/test/Dockerfile +32 -0
  41. data/docker/test/docker-compose.yml +0 -0
  42. data/git.gemspec +3 -4
  43. data/lib/git/author.rb +20 -1
  44. data/lib/git/branch.rb +26 -6
  45. data/lib/git/branch_delete_failure.rb +3 -0
  46. data/lib/git/branch_delete_result.rb +6 -3
  47. data/lib/git/branch_info.rb +6 -6
  48. data/lib/git/command_line/base.rb +6 -13
  49. data/lib/git/command_line/capturing.rb +67 -10
  50. data/lib/git/command_line/result.rb +0 -8
  51. data/lib/git/command_line/streaming.rb +45 -5
  52. data/lib/git/command_line.rb +4 -3
  53. data/lib/git/commands/add.rb +61 -53
  54. data/lib/git/commands/am/abort.rb +2 -2
  55. data/lib/git/commands/am/apply.rb +109 -98
  56. data/lib/git/commands/am/continue.rb +2 -2
  57. data/lib/git/commands/am/quit.rb +2 -2
  58. data/lib/git/commands/am/retry.rb +4 -2
  59. data/lib/git/commands/am/show_current_patch.rb +1 -1
  60. data/lib/git/commands/am/skip.rb +2 -2
  61. data/lib/git/commands/am.rb +2 -2
  62. data/lib/git/commands/apply.rb +7 -2
  63. data/lib/git/commands/archive/list_formats.rb +3 -3
  64. data/lib/git/commands/archive.rb +7 -2
  65. data/lib/git/commands/arguments.rb +1370 -359
  66. data/lib/git/commands/base.rb +111 -13
  67. data/lib/git/commands/branch/copy.rb +29 -21
  68. data/lib/git/commands/branch/create.rb +72 -68
  69. data/lib/git/commands/branch/delete.rb +25 -17
  70. data/lib/git/commands/branch/list.rb +76 -60
  71. data/lib/git/commands/branch/move.rb +29 -21
  72. data/lib/git/commands/branch/set_upstream.rb +8 -8
  73. data/lib/git/commands/branch/show_current.rb +3 -3
  74. data/lib/git/commands/branch/unset_upstream.rb +4 -8
  75. data/lib/git/commands/branch.rb +2 -2
  76. data/lib/git/commands/cat_file/batch.rb +36 -20
  77. data/lib/git/commands/cat_file/filtered.rb +12 -12
  78. data/lib/git/commands/cat_file/raw.rb +13 -13
  79. data/lib/git/commands/cat_file.rb +4 -4
  80. data/lib/git/commands/checkout/branch.rb +7 -5
  81. data/lib/git/commands/checkout/files.rb +5 -4
  82. data/lib/git/commands/checkout.rb +4 -4
  83. data/lib/git/commands/checkout_index.rb +5 -4
  84. data/lib/git/commands/clean.rb +6 -4
  85. data/lib/git/commands/clone.rb +5 -4
  86. data/lib/git/commands/commit.rb +5 -4
  87. data/lib/git/commands/commit_tree.rb +5 -4
  88. data/lib/git/commands/config_option_syntax/add.rb +7 -4
  89. data/lib/git/commands/config_option_syntax/get.rb +9 -5
  90. data/lib/git/commands/config_option_syntax/get_all.rb +7 -4
  91. data/lib/git/commands/config_option_syntax/get_color.rb +8 -4
  92. data/lib/git/commands/config_option_syntax/get_color_bool.rb +7 -4
  93. data/lib/git/commands/config_option_syntax/get_regexp.rb +8 -4
  94. data/lib/git/commands/config_option_syntax/get_urlmatch.rb +8 -4
  95. data/lib/git/commands/config_option_syntax/list.rb +8 -4
  96. data/lib/git/commands/config_option_syntax/remove_section.rb +7 -2
  97. data/lib/git/commands/config_option_syntax/rename_section.rb +7 -2
  98. data/lib/git/commands/config_option_syntax/replace_all.rb +7 -2
  99. data/lib/git/commands/config_option_syntax/set.rb +7 -2
  100. data/lib/git/commands/config_option_syntax/unset.rb +7 -4
  101. data/lib/git/commands/config_option_syntax/unset_all.rb +7 -2
  102. data/lib/git/commands/describe.rb +5 -4
  103. data/lib/git/commands/diff.rb +13 -12
  104. data/lib/git/commands/diff_files.rb +7 -6
  105. data/lib/git/commands/diff_index.rb +10 -7
  106. data/lib/git/commands/fetch.rb +6 -4
  107. data/lib/git/commands/fsck.rb +6 -4
  108. data/lib/git/commands/gc.rb +6 -4
  109. data/lib/git/commands/grep.rb +6 -5
  110. data/lib/git/commands/init.rb +6 -4
  111. data/lib/git/commands/log.rb +287 -285
  112. data/lib/git/commands/ls_files.rb +69 -65
  113. data/lib/git/commands/ls_remote.rb +62 -56
  114. data/lib/git/commands/ls_tree.rb +50 -46
  115. data/lib/git/commands/maintenance/register.rb +25 -23
  116. data/lib/git/commands/maintenance/run.rb +7 -2
  117. data/lib/git/commands/maintenance/start.rb +7 -2
  118. data/lib/git/commands/maintenance/stop.rb +7 -2
  119. data/lib/git/commands/maintenance/unregister.rb +7 -2
  120. data/lib/git/commands/merge/abort.rb +2 -2
  121. data/lib/git/commands/merge/continue.rb +2 -2
  122. data/lib/git/commands/merge/quit.rb +2 -2
  123. data/lib/git/commands/merge/start.rb +7 -2
  124. data/lib/git/commands/merge.rb +2 -2
  125. data/lib/git/commands/merge_base.rb +7 -2
  126. data/lib/git/commands/mv.rb +7 -2
  127. data/lib/git/commands/name_rev.rb +7 -2
  128. data/lib/git/commands/pull.rb +7 -2
  129. data/lib/git/commands/push.rb +7 -2
  130. data/lib/git/commands/read_tree.rb +7 -2
  131. data/lib/git/commands/remote/add.rb +7 -2
  132. data/lib/git/commands/remote/get_url.rb +4 -2
  133. data/lib/git/commands/remote/list.rb +4 -2
  134. data/lib/git/commands/remote/prune.rb +4 -2
  135. data/lib/git/commands/remote/remove.rb +4 -2
  136. data/lib/git/commands/remote/rename.rb +4 -2
  137. data/lib/git/commands/remote/set_branches.rb +9 -2
  138. data/lib/git/commands/remote/set_head.rb +12 -5
  139. data/lib/git/commands/remote/set_url.rb +9 -2
  140. data/lib/git/commands/remote/set_url_add.rb +11 -2
  141. data/lib/git/commands/remote/set_url_delete.rb +9 -2
  142. data/lib/git/commands/remote/show.rb +18 -12
  143. data/lib/git/commands/remote/update.rb +19 -12
  144. data/lib/git/commands/remote.rb +2 -2
  145. data/lib/git/commands/repack.rb +67 -63
  146. data/lib/git/commands/reset.rb +51 -44
  147. data/lib/git/commands/rev_parse.rb +135 -128
  148. data/lib/git/commands/revert/abort.rb +2 -2
  149. data/lib/git/commands/revert/continue.rb +7 -2
  150. data/lib/git/commands/revert/quit.rb +2 -2
  151. data/lib/git/commands/revert/skip.rb +2 -2
  152. data/lib/git/commands/revert/start.rb +7 -2
  153. data/lib/git/commands/revert.rb +2 -2
  154. data/lib/git/commands/rm.rb +35 -36
  155. data/lib/git/commands/show.rb +1 -1
  156. data/lib/git/commands/show_ref/exclude_existing.rb +3 -4
  157. data/lib/git/commands/show_ref/exists.rb +15 -13
  158. data/lib/git/commands/show_ref/list.rb +39 -35
  159. data/lib/git/commands/show_ref/verify.rb +29 -27
  160. data/lib/git/commands/show_ref.rb +4 -4
  161. data/lib/git/commands/stash/apply.rb +31 -25
  162. data/lib/git/commands/stash/branch.rb +10 -8
  163. data/lib/git/commands/stash/clear.rb +7 -5
  164. data/lib/git/commands/stash/create.rb +10 -8
  165. data/lib/git/commands/stash/drop.rb +15 -9
  166. data/lib/git/commands/stash/list.rb +9 -5
  167. data/lib/git/commands/stash/pop.rb +21 -12
  168. data/lib/git/commands/stash/push.rb +20 -11
  169. data/lib/git/commands/stash/show.rb +21 -12
  170. data/lib/git/commands/stash/store.rb +19 -10
  171. data/lib/git/commands/stash.rb +2 -2
  172. data/lib/git/commands/status.rb +7 -2
  173. data/lib/git/commands/symbolic_ref/delete.rb +18 -14
  174. data/lib/git/commands/symbolic_ref/read.rb +24 -20
  175. data/lib/git/commands/symbolic_ref/update.rb +20 -17
  176. data/lib/git/commands/symbolic_ref.rb +4 -4
  177. data/lib/git/commands/tag/create.rb +45 -42
  178. data/lib/git/commands/tag/delete.rb +5 -3
  179. data/lib/git/commands/tag/list.rb +47 -44
  180. data/lib/git/commands/tag/verify.rb +12 -12
  181. data/lib/git/commands/tag.rb +2 -2
  182. data/lib/git/commands/update_ref/batch.rb +6 -1
  183. data/lib/git/commands/update_ref/delete.rb +19 -21
  184. data/lib/git/commands/update_ref/update.rb +22 -25
  185. data/lib/git/commands/update_ref.rb +4 -4
  186. data/lib/git/commands/version.rb +14 -11
  187. data/lib/git/commands/worktree/add.rb +50 -51
  188. data/lib/git/commands/worktree/list.rb +17 -17
  189. data/lib/git/commands/worktree/lock.rb +12 -12
  190. data/lib/git/commands/worktree/move.rb +16 -16
  191. data/lib/git/commands/worktree/prune.rb +2 -2
  192. data/lib/git/commands/worktree/remove.rb +2 -2
  193. data/lib/git/commands/worktree/repair.rb +2 -2
  194. data/lib/git/commands/worktree/unlock.rb +2 -2
  195. data/lib/git/commands/write_tree.rb +2 -2
  196. data/lib/git/commands.rb +4 -3
  197. data/lib/git/config.rb +47 -1
  198. data/lib/git/configuring.rb +89 -15
  199. data/lib/git/detached_head_info.rb +4 -1
  200. data/lib/git/diff.rb +2 -5
  201. data/lib/git/diff_file_numstat_info.rb +3 -1
  202. data/lib/git/diff_file_patch_info.rb +3 -1
  203. data/lib/git/diff_file_raw_info.rb +3 -1
  204. data/lib/git/diff_info.rb +8 -15
  205. data/lib/git/diff_path_status.rb +16 -3
  206. data/lib/git/diff_result.rb +3 -1
  207. data/lib/git/diff_stats.rb +15 -0
  208. data/lib/git/dirstat_info.rb +24 -8
  209. data/lib/git/encoding_utils.rb +32 -1
  210. data/lib/git/errors.rb +19 -9
  211. data/lib/git/escaped_path.rb +55 -3
  212. data/lib/git/execution_context/repository.rb +15 -0
  213. data/lib/git/execution_context.rb +76 -74
  214. data/lib/git/file_ref.rb +6 -3
  215. data/lib/git/fsck_object.rb +8 -0
  216. data/lib/git/fsck_result.rb +26 -15
  217. data/lib/git/log.rb +152 -5
  218. data/lib/git/object.rb +284 -8
  219. data/lib/git/parsers/branch.rb +18 -0
  220. data/lib/git/parsers/cat_file.rb +2 -2
  221. data/lib/git/parsers/diff.rb +213 -5
  222. data/lib/git/parsers/fsck.rb +11 -0
  223. data/lib/git/parsers/ls_remote.rb +1 -1
  224. data/lib/git/parsers/stash.rb +51 -0
  225. data/lib/git/parsers/tag.rb +38 -0
  226. data/lib/git/remote.rb +34 -2
  227. data/lib/git/repository/branching.rb +23 -21
  228. data/lib/git/repository/committing.rb +46 -6
  229. data/lib/git/repository/context_helpers.rb +45 -16
  230. data/lib/git/repository/diffing.rb +32 -23
  231. data/lib/git/repository/factories.rb +153 -28
  232. data/lib/git/repository/inspecting.rb +1 -1
  233. data/lib/git/repository/logging.rb +169 -30
  234. data/lib/git/repository/maintenance.rb +1 -1
  235. data/lib/git/repository/merging.rb +3 -3
  236. data/lib/git/repository/object_operations.rb +108 -14
  237. data/lib/git/repository/remote_operations.rb +150 -171
  238. data/lib/git/repository/shared_private.rb +7 -5
  239. data/lib/git/repository/staging.rb +36 -12
  240. data/lib/git/repository/stashing.rb +16 -16
  241. data/lib/git/repository/status_operations.rb +1 -1
  242. data/lib/git/repository/worktree_operations.rb +1 -1
  243. data/lib/git/repository.rb +123 -63
  244. data/lib/git/stash.rb +16 -21
  245. data/lib/git/stash_info.rb +4 -4
  246. data/lib/git/stashes.rb +20 -26
  247. data/lib/git/status.rb +21 -7
  248. data/lib/git/tag_delete_failure.rb +3 -0
  249. data/lib/git/tag_delete_result.rb +6 -3
  250. data/lib/git/tag_info.rb +1 -0
  251. data/lib/git/url.rb +12 -5
  252. data/lib/git/version.rb +6 -4
  253. data/lib/git/version_constraint.rb +4 -0
  254. data/lib/git.rb +398 -314
  255. data/redesign/3_architecture_implementation.md +59 -29
  256. data/redesign/Phase 4 - Step B.md +921 -0
  257. data/redesign/Phase 4 - Step C.md +833 -0
  258. data/redesign/c1a-public-api-scope.tsv +256 -0
  259. data/redesign/phase-4-step-b-test-audit.tsv +485 -0
  260. data/tasks/yard.rake +24 -17
  261. metadata +24 -57
  262. data/commitlint.test +0 -4
  263. data/lib/git/args_builder.rb +0 -103
  264. data/lib/git/command_line_result.rb +0 -8
  265. data/lib/git/deprecation.rb +0 -9
  266. data/tasks/test.rake +0 -25
  267. /data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/KEYWORD_ARG_REMEDIATION.md +0 -0
  268. /data/.github/{skills → skills-deprecated}/review-backward-compatibility/SKILL.md +0 -0
@@ -17,7 +17,7 @@ module Git
17
17
  #
18
18
  # Included by {Git::Repository}.
19
19
  #
20
- # @api public
20
+ # @api private
21
21
  #
22
22
  module RemoteOperations # rubocop:disable Metrics/ModuleLength
23
23
  # Key normalizations for {#fetch} options
@@ -71,62 +71,60 @@ module Git
71
71
  # @example Fetch and include all tags
72
72
  # repo.fetch('origin', tags: true)
73
73
  #
74
- # @overload fetch(remote = 'origin', opts = {})
74
+ # @param remote [String, Hash, nil] the remote name or URL to fetch from
75
75
  #
76
- # @param remote [String, Hash, nil] the remote name or URL to fetch from
76
+ # When a Hash is given it is treated as `opts` and `remote` defaults to
77
+ # `nil` (which omits the remote positional argument and lets git use the
78
+ # configured default).
77
79
  #
78
- # When a Hash is given it is treated as `opts` and `remote` defaults to
79
- # `nil` (which omits the remote positional argument and lets git use the
80
- # configured default).
80
+ # @param opts [Hash] options for the fetch command
81
81
  #
82
- # @param opts [Hash] options for the fetch command
82
+ # @option opts [Boolean, nil] :all (nil) fetch from all configured remotes
83
+ # (`--all`)
83
84
  #
84
- # @option opts [Boolean, nil] :all (nil) fetch from all configured remotes
85
- # (`--all`)
85
+ # @option opts [Boolean, nil] :tags (nil) fetch all tags from the remote
86
+ # (`--tags`)
86
87
  #
87
- # @option opts [Boolean, nil] :tags (nil) fetch all tags from the remote
88
- # (`--tags`)
88
+ # Alias: `:t`
89
89
  #
90
- # Alias: `:t`
90
+ # @option opts [Boolean, nil] :prune (nil) remove remote-tracking references
91
+ # that no longer exist on the remote (`--prune`)
91
92
  #
92
- # @option opts [Boolean, nil] :prune (nil) remove remote-tracking references
93
- # that no longer exist on the remote (`--prune`)
93
+ # Alias: `:p`
94
94
  #
95
- # Alias: `:p`
95
+ # @option opts [Boolean, nil] :prune_tags (nil) remove local tags that no
96
+ # longer exist on the remote (`--prune-tags`)
96
97
  #
97
- # @option opts [Boolean, nil] :prune_tags (nil) remove local tags that no
98
- # longer exist on the remote (`--prune-tags`)
98
+ # Alias: `:P`. The legacy dash-style key `:'prune-tags'` is also accepted
99
+ # and normalized automatically.
99
100
  #
100
- # Alias: `:P`. The legacy dash-style key `:'prune-tags'` is also accepted
101
- # and normalized automatically.
101
+ # @option opts [Boolean, nil] :force (nil) override the fast-forward check
102
+ # when using explicit refspecs (`--force`)
102
103
  #
103
- # @option opts [Boolean, nil] :force (nil) override the fast-forward check
104
- # when using explicit refspecs (`--force`)
104
+ # Alias: `:f`
105
105
  #
106
- # Alias: `:f`
106
+ # @option opts [Boolean, nil] :update_head_ok (nil) allow `git fetch` to
107
+ # update the branch pointed to by `HEAD` (`--update-head-ok`)
107
108
  #
108
- # @option opts [Boolean, nil] :update_head_ok (nil) allow `git fetch` to
109
- # update the branch pointed to by `HEAD` (`--update-head-ok`)
109
+ # Alias: `:u`. The legacy dash-style key `:'update-head-ok'` is also
110
+ # accepted and normalized automatically.
110
111
  #
111
- # Alias: `:u`. The legacy dash-style key `:'update-head-ok'` is also
112
- # accepted and normalized automatically.
112
+ # @option opts [Boolean, nil] :unshallow (nil) convert a shallow clone into a
113
+ # full repository (`--unshallow`)
113
114
  #
114
- # @option opts [Boolean, nil] :unshallow (nil) convert a shallow clone into a
115
- # full repository (`--unshallow`)
115
+ # @option opts [String, Integer] :depth (nil) limit history to N commits from
116
+ # each branch tip (`--depth=N`)
116
117
  #
117
- # @option opts [String, Integer] :depth (nil) limit history to N commits
118
- # from each branch tip (`--depth=N`)
118
+ # @option opts [String, Array<String>] :ref (nil) one or more refspecs to
119
+ # fetch; forwarded as positional arguments after the remote name. An explicit
120
+ # `remote` is required when `:ref` is given.
119
121
  #
120
- # @option opts [String, Array<String>] :ref (nil) one or more refspecs to
121
- # fetch; forwarded as positional arguments after the remote name. An
122
- # explicit `remote` is required when `:ref` is given.
122
+ # @return [String] the merged stdout from the fetch command
123
123
  #
124
- # @return [String] the merged stdout from the fetch command
124
+ # @raise [ArgumentError] when unsupported option keys are provided or `:ref`
125
+ # is supplied without an explicit remote
125
126
  #
126
- # @raise [ArgumentError] when unsupported option keys are provided or `:ref`
127
- # is supplied without an explicit remote
128
- #
129
- # @raise [Git::FailedError] when git exits with a non-zero status
127
+ # @raise [Git::FailedError] when git exits with a non-zero status
130
128
  #
131
129
  def fetch(remote = 'origin', opts = {})
132
130
  remote, opts = Private.resolve_fetch_target(remote, opts)
@@ -171,29 +169,27 @@ module Git
171
169
  # @example Pull allowing unrelated histories
172
170
  # repo.pull('origin', 'main', allow_unrelated_histories: true)
173
171
  #
174
- # @overload pull(remote = nil, branch = nil, opts = {})
175
- #
176
- # @param remote [String, nil] the remote name or URL to pull from
172
+ # @param remote [String, nil] the remote name or URL to pull from
177
173
  #
178
- # When nil, git uses the tracking remote for the current branch.
174
+ # When nil, git uses the tracking remote for the current branch.
179
175
  #
180
- # @param branch [String, nil] the remote branch name to pull
176
+ # @param branch [String, nil] the remote branch name to pull
181
177
  #
182
- # When nil, git uses the tracking branch for the current branch.
183
- # A branch may not be specified without also specifying a remote.
178
+ # When nil, git uses the tracking branch for the current branch.
179
+ # A branch may not be specified without also specifying a remote.
184
180
  #
185
- # @param opts [Hash] options for the pull command
181
+ # @param opts [Hash] options for the pull command
186
182
  #
187
- # @option opts [Boolean, nil] :allow_unrelated_histories (nil) allow merging
188
- # histories that do not share a common ancestor
189
- # (`--allow-unrelated-histories`)
183
+ # @option opts [Boolean, nil] :allow_unrelated_histories (nil) allow merging
184
+ # histories that do not share a common ancestor
185
+ # (`--allow-unrelated-histories`)
190
186
  #
191
- # @return [String] the stdout from the pull command
187
+ # @return [String] the stdout from the pull command
192
188
  #
193
- # @raise [ArgumentError] when a branch is given without a remote, or when
194
- # unsupported option keys are provided
189
+ # @raise [ArgumentError] when a branch is given without a remote, or when
190
+ # unsupported option keys are provided
195
191
  #
196
- # @raise [Git::FailedError] when git exits with a non-zero status
192
+ # @raise [Git::FailedError] when git exits with a non-zero status
197
193
  #
198
194
  def pull(remote = nil, branch = nil, opts = {})
199
195
  raise ArgumentError, 'You must specify a remote if a branch is specified' if remote.nil? && !branch.nil?
@@ -240,122 +236,46 @@ module Git
240
236
  # @example Mirror all refs to a named remote
241
237
  # repo.push('origin', mirror: true)
242
238
  #
243
- # @overload push(options = {})
244
- # Push using the current branch's default remote and push configuration
245
- #
246
- # @param options [Hash] push options (see option list below)
247
- #
248
- # @option options [Boolean, nil] :all (nil) push all branches (`--all`)
249
- #
250
- # @option options [Boolean, nil] :mirror (nil) push all refs under
251
- # `refs/` to the remote (`--mirror`)
252
- #
253
- # When `:tags` is also given, the separate tags push is suppressed.
254
- #
255
- # @option options [Boolean, nil] :tags (nil) push all refs under
256
- # `refs/tags/` in a second `git push` invocation (`--tags`)
257
- #
258
- # When `:mirror` is also given, the tags push is suppressed because
259
- # `--mirror` already includes tags.
260
- #
261
- # @option options [Boolean, nil] :force (nil) force updates,
262
- # overriding the fast-forward check (`--force`)
263
- #
264
- # Alias: `:f`
265
- #
266
- # @option options [Boolean, nil] :delete (nil) delete the named refs
267
- # from the remote (`--delete`)
268
- #
269
- # @option options [String, Array<String>] :push_option (nil) one or
270
- # more server-side push option values (`--push-option=<value>`,
271
- # repeatable)
272
- #
273
- # @return [String] the stdout from the push command
274
- #
275
- # @overload push(remote, options = {})
276
- # Push to the given remote using the current branch's default push configuration
277
- #
278
- # @param remote [String] the remote name or URL to push to
279
- #
280
- # @param options [Hash] push options (see option list below)
281
- #
282
- # @option options [Boolean, nil] :all (nil) push all branches (`--all`)
283
- #
284
- # @option options [Boolean, nil] :mirror (nil) push all refs under
285
- # `refs/` to the remote (`--mirror`)
286
- #
287
- # When `:tags` is also given, the separate tags push is suppressed.
239
+ # @param remote [String, Hash, nil] the remote name or URL to push to
288
240
  #
289
- # @option options [Boolean, nil] :tags (nil) push all refs under
290
- # `refs/tags/` in a second `git push` invocation (`--tags`)
241
+ # When a Hash is given it is treated as `opts` and `remote` defaults to
242
+ # `nil` so git uses the configured default push target.
291
243
  #
292
- # When `:mirror` is also given, the tags push is suppressed because
293
- # `--mirror` already includes tags.
244
+ # @param branch [String, Hash, nil] the branch name or refspec to push
294
245
  #
295
- # @option options [Boolean, nil] :force (nil) force updates,
296
- # overriding the fast-forward check (`--force`)
246
+ # When a Hash is given it is treated as `opts` and `branch` defaults to
247
+ # `nil`. A branch may not be specified without also specifying a remote.
297
248
  #
298
- # Alias: `:f`
249
+ # @param opts [Hash, Boolean, nil] options for the push command
299
250
  #
300
- # @option options [Boolean, nil] :delete (nil) delete the named refs
301
- # from the remote (`--delete`)
251
+ # For backward compatibility, a Boolean is interpreted as
252
+ # `tags: <Boolean>`.
302
253
  #
303
- # @option options [String, Array<String>] :push_option (nil) one or
304
- # more server-side push option values (`--push-option=<value>`,
305
- # repeatable)
254
+ # @option opts [Boolean, nil] :all (nil) push all branches (`--all`)
306
255
  #
307
- # @return [String] the stdout from the push command
256
+ # @option opts [Boolean, nil] :mirror (nil) push all refs under `refs/` to
257
+ # the remote (`--mirror`)
308
258
  #
309
- # @overload push(remote, branch, options = {})
310
- # Push a branch or refspec to the given remote
259
+ # @option opts [Boolean, nil] :tags (nil) push all refs under `refs/tags/`
260
+ # in a second `git push` invocation (`--tags`)
311
261
  #
312
- # @param remote [String] the remote name or URL to push to
262
+ # When `:mirror` is also given, the tags push is suppressed because
263
+ # `--mirror` already includes tags.
313
264
  #
314
- # @param branch [String] the branch name or refspec to push
265
+ # @option opts [Boolean, nil] :force (nil) force updates, overriding the
266
+ # fast-forward check (`--force`)
315
267
  #
316
- # @param options [Hash] push options (see option list below)
268
+ # Alias: `:f`
317
269
  #
318
- # @option options [Boolean, nil] :all (nil) push all branches (`--all`)
270
+ # @option opts [Boolean, nil] :delete (nil) delete the named refs from the
271
+ # remote (`--delete`)
319
272
  #
320
- # @option options [Boolean, nil] :mirror (nil) push all refs under
321
- # `refs/` to the remote (`--mirror`)
273
+ # @option opts [String, Array<String>] :push_option (nil) one or more
274
+ # server-side push option values (`--push-option=<value>`, repeatable)
322
275
  #
323
- # When `:tags` is also given, the separate tags push is suppressed.
276
+ # @return [String] the stdout from the push command
324
277
  #
325
- # @option options [Boolean, nil] :tags (nil) push all refs under
326
- # `refs/tags/` in a second `git push` invocation (`--tags`)
327
- #
328
- # When `:mirror` is also given, the tags push is suppressed because
329
- # `--mirror` already includes tags.
330
- #
331
- # @option options [Boolean, nil] :force (nil) force updates,
332
- # overriding the fast-forward check (`--force`)
333
- #
334
- # Alias: `:f`
335
- #
336
- # @option options [Boolean, nil] :delete (nil) delete the named refs
337
- # from the remote (`--delete`)
338
- #
339
- # @option options [String, Array<String>] :push_option (nil) one or
340
- # more server-side push option values (`--push-option=<value>`,
341
- # repeatable)
342
- #
343
- # @return [String] the stdout from the push command
344
- #
345
- # @raise [ArgumentError] if `remote` is nil when `branch` is given
346
- #
347
- # @overload push(remote, branch, tags)
348
- # Backward-compatible shorthand for `push(remote, branch, tags: tags)`
349
- #
350
- # @param remote [String] the remote name or URL to push to
351
- #
352
- # @param branch [String] the branch name or refspec to push
353
- #
354
- # @param tags [Boolean] whether to push all tags; equivalent to `tags: tags`
355
- #
356
- # @return [String] the stdout from the push command
357
- #
358
- # @raise [ArgumentError] if a branch is given and remote is nil
278
+ # @raise [ArgumentError] when `branch` is given without `remote`
359
279
  #
360
280
  # @raise [ArgumentError] when unsupported option keys are provided
361
281
  #
@@ -425,8 +345,6 @@ module Git
425
345
  Git::Remote.new(self, name)
426
346
  end
427
347
 
428
- # @deprecated Use {#remote_add} instead.
429
- #
430
348
  # @param name [String] the name for the new remote
431
349
  #
432
350
  # @param url [String, Git::Repository] the URL of the remote repository
@@ -451,6 +369,8 @@ module Git
451
369
  #
452
370
  # @raise [Git::FailedError] when git exits with a non-zero status
453
371
  #
372
+ # @deprecated Use {#remote_add} instead
373
+ #
454
374
  def add_remote(name, url, opts = {})
455
375
  Git::Deprecation.warn(
456
376
  'Git::Repository#add_remote is deprecated and will be removed in v6.0.0. ' \
@@ -469,7 +389,7 @@ module Git
469
389
  #
470
390
  # @param name [String] the name of the remote to remove
471
391
  #
472
- # @return [Git::CommandLineResult] the result of calling `git remote remove`
392
+ # @return [Git::CommandLine::Result] the result of calling `git remote remove`
473
393
  #
474
394
  # @raise [Git::FailedError] when git exits with a non-zero status
475
395
  #
@@ -477,14 +397,14 @@ module Git
477
397
  Git::Commands::Remote::Remove.new(@execution_context).call(name)
478
398
  end
479
399
 
480
- # @deprecated Use {#remote_remove} instead.
481
- #
482
400
  # @param name [String] the name of the remote to remove
483
401
  #
484
- # @return [Git::CommandLineResult] the result of calling `git remote remove`
402
+ # @return [Git::CommandLine::Result] the result of calling `git remote remove`
485
403
  #
486
404
  # @raise [Git::FailedError] when git exits with a non-zero status
487
405
  #
406
+ # @deprecated Use {#remote_remove} instead
407
+ #
488
408
  def remove_remote(name)
489
409
  Git::Deprecation.warn(
490
410
  'Git::Repository#remove_remote is deprecated and will be removed in v6.0.0. ' \
@@ -522,8 +442,6 @@ module Git
522
442
  Git::Remote.new(self, name)
523
443
  end
524
444
 
525
- # @deprecated Use {#remote_set_url} instead.
526
- #
527
445
  # @param name [String] the name of the remote to update
528
446
  #
529
447
  # @param url [String, Git::Repository] the new URL for the remote
@@ -535,6 +453,8 @@ module Git
535
453
  #
536
454
  # @raise [Git::FailedError] when git exits with a non-zero status
537
455
  #
456
+ # @deprecated Use {#remote_set_url} instead
457
+ #
538
458
  def set_remote_url(name, url)
539
459
  Git::Deprecation.warn(
540
460
  'Git::Repository#set_remote_url is deprecated and will be removed in v6.0.0. ' \
@@ -665,12 +585,6 @@ module Git
665
585
  # # => {"head"=>{ref: "HEAD", sha: "abc123"},
666
586
  # # "branches"=>{"main"=>{ref: "refs", sha: "abc123"}}}
667
587
  #
668
- # @note The `:ref` value in each pair is only the **first path segment** of the
669
- # full git ref (e.g. `"refs"` for `refs/heads/main`), not the complete ref
670
- # path. This matches the behavior of 4.x. See
671
- # [issue 1416](https://github.com/ruby-git/ruby-git/issues/1416) for the
672
- # planned fix.
673
- #
674
588
  # @example List all refs from a named remote
675
589
  # repo.ls_remote('origin')
676
590
  # # => {"head"=>..., "branches"=>..., "tags"=>...}
@@ -708,6 +622,12 @@ module Git
708
622
  #
709
623
  # @raise [Git::FailedError] if git exits outside the allowed range (exit code > 2)
710
624
  #
625
+ # @note The `:ref` value in each pair is only the **first path segment** of the
626
+ # full git ref (e.g. `"refs"` for `refs/heads/main`), not the complete ref
627
+ # path. This matches the behavior of 4.x. See
628
+ # [issue 1416](https://github.com/ruby-git/ruby-git/issues/1416) for the
629
+ # planned fix.
630
+ #
711
631
  def ls_remote(location = nil, opts = {})
712
632
  SharedPrivate.assert_valid_opts!(LS_REMOTE_ALLOWED_OPTS, **opts)
713
633
  repository = location || '.'
@@ -730,8 +650,14 @@ module Git
730
650
  # would otherwise be silently promoted to the remote-name slot) is rejected.
731
651
  #
732
652
  # @param remote [String, Hash, nil] the remote name, or an options hash
653
+ #
733
654
  # @param opts [Hash] the options hash when remote is given positionally
734
655
  #
656
+ # @option opts [String, Array<String>, nil] :ref (nil) one or more refspecs
657
+ # forwarded after the remote name
658
+ #
659
+ # Requires an explicit `remote`.
660
+ #
735
661
  # @return [Array(String, Hash), Array(nil, Hash)] the resolved remote and opts
736
662
  #
737
663
  # @raise [ArgumentError] when :ref is supplied without an explicit remote
@@ -757,6 +683,11 @@ module Git
757
683
  #
758
684
  # @param opts [Hash] the raw options hash passed by the caller
759
685
  #
686
+ # @option opts [Object] :'prune-tags' a legacy dash-style fetch option value
687
+ #
688
+ # @option opts [Object] :'update-head-ok' a legacy dash-style fetch option
689
+ # value
690
+ #
760
691
  # @return [Hash] a new hash with all applicable keys normalized
761
692
  #
762
693
  # @api private
@@ -777,10 +708,25 @@ module Git
777
708
  # `{ tags: opts }` for backward compatibility
778
709
  #
779
710
  # @param remote [String, Hash, nil] remote name, URL, or opts hash
711
+ #
780
712
  # @param branch [String, Hash, nil] branch/refspec, or opts hash
713
+ #
781
714
  # @param opts [Hash, Boolean, nil] options hash or legacy Boolean shorthand
782
715
  #
783
- # @return [Array(String|nil, String|nil, Hash)] normalized [remote, branch, opts]
716
+ # @option opts [Boolean, nil] :all (nil) push all branches
717
+ #
718
+ # @option opts [Boolean, nil] :mirror (nil) mirror all refs
719
+ #
720
+ # @option opts [Boolean, nil] :tags (nil) push all tags
721
+ #
722
+ # @option opts [Boolean, nil] :delete (nil) delete refs on the remote
723
+ #
724
+ # @option opts [Boolean, nil] :force (nil) force updates
725
+ #
726
+ # @option opts [String, Array<String>] :push_option (nil) one or more
727
+ # push-option values
728
+ #
729
+ # @return [Array((String, nil), (String, nil), Hash)] normalized [remote, branch, opts]
784
730
  #
785
731
  # @api private
786
732
  #
@@ -809,11 +755,25 @@ module Git
809
755
  # {push_tags_separately?} is true.
810
756
  #
811
757
  # @param execution_context [Git::ExecutionContext::Repository] the repository execution context
758
+ #
812
759
  # @param remote [String, nil] remote name or URL
760
+ #
813
761
  # @param branch [String, nil] branch or refspec
762
+ #
814
763
  # @param opts [Hash] push options (`:tags` key will be stripped)
815
764
  #
816
- # @return [Git::CommandLineResult]
765
+ # @option opts [Boolean, nil] :all (nil) push all branches
766
+ #
767
+ # @option opts [Boolean, nil] :mirror (nil) mirror all refs
768
+ #
769
+ # @option opts [Boolean, nil] :delete (nil) delete refs on the remote
770
+ #
771
+ # @option opts [Boolean, nil] :force (nil) force updates
772
+ #
773
+ # @option opts [String, Array<String>] :push_option (nil) one or more
774
+ # push-option values
775
+ #
776
+ # @return [Git::CommandLine::Result]
817
777
  #
818
778
  # @api private
819
779
  #
@@ -830,6 +790,11 @@ module Git
830
790
  #
831
791
  # @param opts [Hash] the normalized push options
832
792
  #
793
+ # @option opts [Boolean, nil] :tags (nil) request a separate tags push
794
+ #
795
+ # @option opts [Boolean, nil] :mirror (nil) indicates refs are mirrored and
796
+ # tags are already covered
797
+ #
833
798
  # @return [Boolean]
834
799
  #
835
800
  # @api private
@@ -841,10 +806,17 @@ module Git
841
806
  # Issue the tags push (second push when `:tags` is requested without `:mirror`)
842
807
  #
843
808
  # @param execution_context [Git::ExecutionContext::Repository] the repository execution context
809
+ #
844
810
  # @param remote [String, nil] remote name or URL
811
+ #
845
812
  # @param opts [Hash] push options (`:tags` key included to emit `--tags`)
846
813
  #
847
- # @return [Git::CommandLineResult]
814
+ # @option opts [Boolean, nil] :tags (nil) emit `--tags`
815
+ #
816
+ # @option opts [String, Array<String>] :push_option (nil) one or more
817
+ # push-option values
818
+ #
819
+ # @return [Git::CommandLine::Result]
848
820
  #
849
821
  # @api private
850
822
  #
@@ -859,6 +831,13 @@ module Git
859
831
  #
860
832
  # @param opts [Hash] the raw options hash passed by the caller
861
833
  #
834
+ # @option opts [Boolean, nil] :with_fetch (nil) deprecated alias for
835
+ # immediate fetch behavior
836
+ #
837
+ # @option opts [Boolean, nil] :fetch (nil) fetch from the remote after adding
838
+ #
839
+ # @option opts [String, nil] :track (nil) track the given branch during fetch
840
+ #
862
841
  # @return [Hash] a new hash with all applicable keys normalized
863
842
  #
864
843
  # @api private
@@ -17,7 +17,7 @@ module Git
17
17
  module SharedPrivate
18
18
  module_function
19
19
 
20
- # Validate that `options` contains only keys listed in `allowed`
20
+ # Validate that candidate option keys are listed in `allowed`
21
21
  #
22
22
  # Used by facade methods to enforce that only documented options (those
23
23
  # named in `@option` tags) are accepted, even when the underlying command
@@ -32,14 +32,16 @@ module Git
32
32
  #
33
33
  # @param allowed [Array<Symbol>] the keys permitted by the facade method
34
34
  #
35
- # @param options [Hash] the options hash provided by the caller
35
+ # @param candidate_keywords [Hash<Symbol, Object>] the keywords to validate
36
+ #
37
+ # @option candidate_keywords [Object] key_name a candidate keyword value
36
38
  #
37
39
  # @return [void]
38
40
  #
39
- # @raise [ArgumentError] when `options` contains any key not in `allowed`
41
+ # @raise [ArgumentError] when any candidate key is not in `allowed`
40
42
  #
41
- def assert_valid_opts!(allowed, **options)
42
- unknown = options.keys - allowed
43
+ def assert_valid_opts!(allowed, **candidate_keywords)
44
+ unknown = candidate_keywords.keys - allowed
43
45
  return if unknown.empty?
44
46
 
45
47
  raise ArgumentError, "Unknown options: #{unknown.join(', ')}"
@@ -19,7 +19,7 @@ module Git
19
19
  #
20
20
  # Included by {Git::Repository}.
21
21
  #
22
- # @api public
22
+ # @api private
23
23
  #
24
24
  module Staging
25
25
  # Option keys accepted by {#add}
@@ -94,25 +94,28 @@ module Git
94
94
 
95
95
  # Reset the current HEAD to a specified state with `--hard`
96
96
  #
97
- # @deprecated Use {#reset} with `hard: true` instead.
97
+ # @example Hard reset to HEAD
98
+ # repo.reset_hard
98
99
  #
99
- # @example Hard reset to HEAD
100
- # repo.reset_hard
101
- #
102
- # @example Hard reset to a specific commit
103
- # repo.reset_hard('HEAD~1')
100
+ # @example Hard reset to a specific commit
101
+ # repo.reset_hard('HEAD~1')
104
102
  #
105
103
  # @param commitish [String, nil] the commit or tree-ish to reset to;
106
104
  # defaults to HEAD when `nil`
107
105
  #
108
106
  # @param opts [Hash] options passed through to {#reset}
109
107
  #
108
+ # @option opts [Boolean, nil] :hard (nil) ignored; this method always forces
109
+ # `hard: true`
110
+ #
110
111
  # @return [String] git's stdout from the reset
111
112
  #
112
113
  # @raise [ArgumentError] when unsupported options are provided
113
114
  #
114
115
  # @raise [Git::FailedError] when git exits with a non-zero exit status
115
116
  #
117
+ # @deprecated Use {#reset} with `hard: true` instead
118
+ #
116
119
  def reset_hard(commitish = nil, opts = {})
117
120
  Git::Deprecation.warn(
118
121
  'Git::Repository::Staging#reset_hard is deprecated and will be removed in a future version. ' \
@@ -421,29 +424,47 @@ module Git
421
424
  #
422
425
  # @param opts [Hash] the caller-provided clean options
423
426
  #
427
+ # @option opts [Boolean, nil] :ff (nil) deprecated alias for requesting a
428
+ # double-force clean
429
+ #
430
+ # @option opts [Boolean, nil] :force_force (nil) deprecated alias for
431
+ # requesting a double-force clean
432
+ #
433
+ # @option opts [Boolean, Integer, nil] :force (nil) existing force value
434
+ # merged with deprecated options when present
435
+ #
424
436
  # @return [Hash] a new options hash with deprecated keys translated
425
437
  #
426
438
  # @raise [ArgumentError] when a deprecated value is not `true`, `false`, or `nil`
427
439
  #
428
440
  def migrate_clean_legacy_options(opts)
429
- opts = deprecate_clean_option(opts, :ff, ':ff option is deprecated. Use force: 2 instead.')
430
- deprecate_clean_option(opts, :force_force, ':force_force option is deprecated. Use force: 2 instead.')
441
+ opts = deprecate_clean_option(:ff, ':ff option is deprecated. Use force: 2 instead.', opts)
442
+ deprecate_clean_option(:force_force, ':force_force option is deprecated. Use force: 2 instead.', opts)
431
443
  end
432
444
 
433
445
  # Translate a single deprecated clean option key onto `:force`
434
446
  #
435
- # @param opts [Hash] the clean options
436
- #
437
447
  # @param key [Symbol] the deprecated option key (`:ff` or `:force_force`)
438
448
  #
439
449
  # @param message [String] the deprecation message to emit
440
450
  #
451
+ # @param opts [Hash] the clean options
452
+ #
453
+ # @option opts [Boolean, nil] :ff (nil) deprecated alias for requesting a
454
+ # double-force clean
455
+ #
456
+ # @option opts [Boolean, nil] :force_force (nil) deprecated alias for
457
+ # requesting a double-force clean
458
+ #
459
+ # @option opts [Boolean, Integer, nil] :force (nil) existing force value
460
+ # updated when the deprecated key is true
461
+ #
441
462
  # @return [Hash] a new options hash with the deprecated key removed
442
463
  #
443
464
  # @raise [ArgumentError] when the deprecated value is not `true`, `false`,
444
465
  # or `nil`
445
466
  #
446
- def deprecate_clean_option(opts, key, message)
467
+ def deprecate_clean_option(key, message, opts)
447
468
  return opts unless opts.key?(key)
448
469
 
449
470
  opts = opts.dup
@@ -461,6 +482,9 @@ module Git
461
482
  #
462
483
  # @param opts [Hash] the clean options
463
484
  #
485
+ # @option opts [Boolean, Integer, nil] :force (nil) the clean force value
486
+ # to inspect
487
+ #
464
488
  # @return [Boolean] true if `:force` was set to a non-nil value, false
465
489
  # otherwise
466
490
  #