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,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements the `git merge-base` command to find common ancestors
8
+ #
9
+ # Finds as good common ancestors as possible for use in a three-way merge.
10
+ # Given two or more commits, it outputs a common ancestor reachable from
11
+ # all of them through the parent relationship.
12
+ #
13
+ # @example Find merge bases of two branches
14
+ # merge_base = Git::Commands::MergeBase.new(execution_context)
15
+ # merge_base.call('main', 'feature')
16
+ # merge_base.call('main', 'feature', all: true)
17
+ # merge_base.call('main', 'b1', 'b2', octopus: true)
18
+ # merge_base.call('main', 'feature', fork_point: true)
19
+ #
20
+ # @note `arguments` block audited against
21
+ # https://git-scm.com/docs/git-merge-base/2.53.0
22
+ #
23
+ # @see https://git-scm.com/docs/git-merge-base git-merge-base
24
+ #
25
+ # @api private
26
+ #
27
+ class MergeBase < Git::Commands::Base
28
+ arguments do
29
+ literal 'merge-base'
30
+
31
+ # Operation modes
32
+ flag_option :octopus
33
+ flag_option :independent
34
+ flag_option :is_ancestor
35
+ flag_option :fork_point
36
+
37
+ # Options
38
+ flag_option %i[all a]
39
+
40
+ end_of_options
41
+ operand :commit, repeatable: true, required: true
42
+ end
43
+
44
+ # git merge-base --fork-point returns exit code 1 when no fork point is
45
+ # found; --is-ancestor returns exit code 1 when the first commit is not an
46
+ # ancestor (both are valid non-error exits)
47
+ allow_exit_status 0..1
48
+
49
+ # @!method call(*, **options)
50
+ #
51
+ # @param options [Hash] command options
52
+ #
53
+ # @option options [Boolean, nil] :octopus (nil) command option key; see overload docs
54
+ # for the full option list
55
+ #
56
+ # @overload call(*commit, **options)
57
+ #
58
+ # Execute the `git merge-base` command
59
+ #
60
+ # @param commit [Array<String>] two or more commit SHAs, branch names,
61
+ # or refs to find common ancestor(s) of
62
+ #
63
+ # @param options [Hash] command options
64
+ #
65
+ # @option options [Boolean, nil] :octopus (nil) compute best common
66
+ # ancestor for an n-way merge (intersection of all merge bases)
67
+ #
68
+ # @option options [Boolean, nil] :independent (nil) list commits not
69
+ # reachable from any other; useful for finding minimal merge points
70
+ #
71
+ # @option options [Boolean, nil] :is_ancestor (nil) check if the first
72
+ # commit is an ancestor of the second; exits 0 if true, 1 if not
73
+ #
74
+ # @option options [Boolean, nil] :fork_point (nil) find the fork point
75
+ # where a branch diverged from another, consulting the reflog
76
+ #
77
+ # @option options [Boolean, nil] :all (nil) output all merge bases instead
78
+ # of just one when multiple equally good bases exist
79
+ #
80
+ # Alias: :a
81
+ #
82
+ # @return [Git::CommandLine::Result] the result of calling
83
+ # `git merge-base`
84
+ #
85
+ # @raise [ArgumentError] if unsupported options are provided
86
+ #
87
+ # @raise [Git::FailedError] if git exits outside the allowed range
88
+ # (exit code > 1)
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements `git mv` to move or rename a file, a directory, or a symlink
8
+ #
9
+ # The index is updated after successful completion, but the change must still
10
+ # be committed.
11
+ #
12
+ # @example Move a single file
13
+ # mv = Git::Commands::Mv.new(execution_context)
14
+ # mv.call('old_name.rb', 'new_name.rb')
15
+ #
16
+ # @example Move multiple files to a directory
17
+ # mv = Git::Commands::Mv.new(execution_context)
18
+ # mv.call('file1.rb', 'file2.rb', 'destination_dir/')
19
+ #
20
+ # @example Force overwrite if destination exists
21
+ # mv = Git::Commands::Mv.new(execution_context)
22
+ # mv.call('source.rb', 'dest.rb', force: true)
23
+ #
24
+ # @note `arguments` block audited against https://git-scm.com/docs/git-mv/2.53.0
25
+ #
26
+ # @see https://git-scm.com/docs/git-mv git-mv
27
+ #
28
+ # @see Git::Commands
29
+ #
30
+ # @api private
31
+ #
32
+ class Mv < Git::Commands::Base
33
+ arguments do
34
+ literal 'mv'
35
+ flag_option %i[verbose v]
36
+ flag_option %i[force f]
37
+ flag_option %i[dry_run n]
38
+ flag_option :k
39
+ end_of_options
40
+ operand :source, repeatable: true, required: true
41
+ operand :destination, required: true
42
+ end
43
+
44
+ # @!method call(*, **options)
45
+ #
46
+ # @param options [Hash] command options
47
+ #
48
+ # @option options [Boolean, nil] :verbose (nil) command option key; see overload
49
+ # docs for the full option list
50
+ #
51
+ # @overload call(*source, destination, **options)
52
+ #
53
+ # Execute the git mv command
54
+ #
55
+ # @param source [Array<String>] one or more source file(s) or directories to move
56
+ #
57
+ # @param destination [String] the destination file or directory
58
+ #
59
+ # @param options [Hash] command options
60
+ #
61
+ # @option options [Boolean, nil] :verbose (nil) report the names of files as they are moved
62
+ #
63
+ # Alias: `:v`
64
+ #
65
+ # @option options [Boolean, nil] :force (nil) force renaming or moving even if the destination exists
66
+ #
67
+ # Alias: `:f`
68
+ #
69
+ # @option options [Boolean, nil] :dry_run (nil) do nothing; only show what would happen
70
+ #
71
+ # Alias: `:n`
72
+ #
73
+ # @option options [Boolean, nil] :k (nil) skip move or rename actions which would lead to an error
74
+ #
75
+ # @return [Git::CommandLine::Result] the result of calling `git mv`
76
+ #
77
+ # @raise [ArgumentError] if unsupported options are provided
78
+ #
79
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements the `git name-rev` command
8
+ #
9
+ # Finds symbolic names suitable for human digestion for revisions given
10
+ # in any format parsable by `git rev-parse`.
11
+ #
12
+ # @example Find the symbolic name for a commit
13
+ # name_rev = Git::Commands::NameRev.new(execution_context)
14
+ # result = name_rev.call('abc123')
15
+ #
16
+ # @example Use only tags for naming
17
+ # name_rev = Git::Commands::NameRev.new(execution_context)
18
+ # result = name_rev.call('abc123', tags: true)
19
+ #
20
+ # @example List all commits reachable from all refs
21
+ # name_rev = Git::Commands::NameRev.new(execution_context)
22
+ # result = name_rev.call(all: true)
23
+ #
24
+ # @example Filter refs by pattern
25
+ # name_rev = Git::Commands::NameRev.new(execution_context)
26
+ # result = name_rev.call('abc123', refs: ['heads/*', 'tags/*'])
27
+ #
28
+ # @note `arguments` block audited against https://git-scm.com/docs/git-name-rev/2.53.0
29
+ #
30
+ # @see https://git-scm.com/docs/git-name-rev git-name-rev
31
+ #
32
+ # @api private
33
+ #
34
+ class NameRev < Git::Commands::Base
35
+ arguments do
36
+ literal 'name-rev'
37
+
38
+ # Ref filtering
39
+ flag_option :tags
40
+ value_option :refs, inline: true, repeatable: true
41
+ flag_option :no_refs
42
+ value_option :exclude, inline: true, repeatable: true
43
+ flag_option :no_exclude
44
+
45
+ # Output control
46
+ flag_option :all
47
+ flag_option :annotate_stdin
48
+ flag_option :name_only
49
+ flag_option :no_undefined
50
+ flag_option :always
51
+
52
+ end_of_options
53
+
54
+ operand :commit_ish, repeatable: true
55
+ end
56
+
57
+ # @!method call(*, **options)
58
+ #
59
+ # @param options [Hash] command options
60
+ #
61
+ # @option options [Boolean, nil] :tags (nil) command option key; see overload docs
62
+ # for the full option list
63
+ #
64
+ # @overload call(*commit_ish, **options)
65
+ #
66
+ # Execute the `git name-rev` command
67
+ #
68
+ # @param commit_ish [Array<String>] zero or more commit-ish objects
69
+ # to find symbolic names for
70
+ #
71
+ # @param options [Hash] command options
72
+ #
73
+ # @option options [Boolean, nil] :tags (nil) use only tags to name
74
+ # the commits, not branch names
75
+ #
76
+ # @option options [String, Array<String>] :refs (nil) only use refs
77
+ # whose names match the given shell pattern
78
+ #
79
+ # When given multiple times, uses refs whose names match any of the
80
+ # given shell patterns. Maps to `--refs=<pattern>`.
81
+ #
82
+ # @option options [Boolean, nil] :no_refs (nil) clear all previously given
83
+ # `--refs` patterns
84
+ #
85
+ # @option options [String, Array<String>] :exclude (nil) do not use
86
+ # any ref whose name matches the given shell pattern
87
+ #
88
+ # When given multiple times, a ref is excluded when it matches any
89
+ # of the given patterns. Maps to `--exclude=<pattern>`.
90
+ #
91
+ # @option options [Boolean, nil] :no_exclude (nil) clear all previously
92
+ # given `--exclude` patterns
93
+ #
94
+ # @option options [Boolean, nil] :all (nil) list all commits reachable
95
+ # from all refs
96
+ #
97
+ # @option options [Boolean, nil] :annotate_stdin (nil) transform stdin by
98
+ # substituting all 40-character SHA-1 hexes with their symbolic
99
+ # names. Maps to `--annotate-stdin`.
100
+ #
101
+ # @option options [Boolean, nil] :name_only (nil) print only the symbolic
102
+ # name, not the SHA-1
103
+ #
104
+ # @option options [Boolean, nil] :no_undefined (nil) die with non-zero
105
+ # exit code when a reference is undefined, instead of printing
106
+ # `undefined`
107
+ #
108
+ # @option options [Boolean, nil] :always (nil) show uniquely abbreviated
109
+ # commit object as fallback
110
+ #
111
+ # @return [Git::CommandLine::Result] the result of calling
112
+ # `git name-rev`
113
+ #
114
+ # @raise [ArgumentError] if unsupported options are provided
115
+ #
116
+ # @raise [Git::FailedError] if git exits with a non-zero status
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,382 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements the `git pull` command
8
+ #
9
+ # Incorporates changes from a remote repository into the current branch.
10
+ # In its default mode, `git pull` is shorthand for `git fetch` followed
11
+ # by `git merge FETCH_HEAD`.
12
+ #
13
+ # @example Pull from the default remote
14
+ # pull = Git::Commands::Pull.new(execution_context)
15
+ # pull.call
16
+ #
17
+ # @example Pull from a named remote
18
+ # pull = Git::Commands::Pull.new(execution_context)
19
+ # pull.call('origin')
20
+ #
21
+ # @example Pull a specific branch from a remote
22
+ # pull = Git::Commands::Pull.new(execution_context)
23
+ # pull.call('origin', 'main')
24
+ #
25
+ # @example Pull with rebase instead of merge
26
+ # pull = Git::Commands::Pull.new(execution_context)
27
+ # pull.call('origin', rebase: true)
28
+ #
29
+ # @example Pull with allow-unrelated-histories
30
+ # pull = Git::Commands::Pull.new(execution_context)
31
+ # pull.call('origin', 'feature', allow_unrelated_histories: true)
32
+ #
33
+ # @example Pull and suppress the merge-commit editor
34
+ # pull = Git::Commands::Pull.new(execution_context)
35
+ # pull.call('origin', no_edit: true)
36
+ #
37
+ # @note `arguments` block audited against
38
+ # https://git-scm.com/docs/git-pull/2.53.0
39
+ #
40
+ # @see https://git-scm.com/docs/git-pull git-pull
41
+ #
42
+ # @see Git::Commands
43
+ #
44
+ # @api private
45
+ #
46
+ class Pull < Git::Commands::Base
47
+ arguments do
48
+ literal 'pull'
49
+
50
+ # General options
51
+ flag_option %i[quiet q]
52
+ flag_option %i[verbose v]
53
+ flag_or_value_option :recurse_submodules,
54
+ negatable: true, inline: true
55
+
56
+ # Merge options
57
+ flag_option :commit, negatable: true
58
+ flag_option %i[edit e], negatable: true
59
+ value_option :cleanup, inline: true
60
+ flag_option :ff_only
61
+ flag_option :ff, negatable: true
62
+ flag_or_value_option %i[gpg_sign S], negatable: true, inline: true
63
+ flag_or_value_option :log, negatable: true, inline: true
64
+ flag_option :signoff, negatable: true
65
+ flag_option :stat
66
+ flag_option %i[no_stat n]
67
+ flag_option :compact_summary
68
+ flag_option :squash, negatable: true
69
+ flag_option :verify, negatable: true
70
+ value_option %i[strategy s], inline: true
71
+ value_option %i[strategy_option X], inline: true, repeatable: true
72
+ flag_option :verify_signatures, negatable: true
73
+ flag_option :summary, negatable: true
74
+ flag_option :autostash, negatable: true
75
+ flag_option :allow_unrelated_histories
76
+ flag_or_value_option %i[rebase r], negatable: true, inline: true
77
+
78
+ # Fetch options
79
+ flag_option :all, negatable: true
80
+ flag_option %i[append a]
81
+ flag_option :atomic
82
+ value_option :depth, inline: true
83
+ value_option :deepen, inline: true
84
+ value_option :shallow_since, inline: true
85
+ value_option :shallow_exclude, inline: true, repeatable: true
86
+ flag_option :unshallow
87
+ flag_option :update_shallow
88
+ value_option :negotiation_tip, inline: true, repeatable: true
89
+ flag_option :negotiate_only
90
+ flag_option :dry_run
91
+ flag_option :porcelain
92
+ flag_option %i[force f]
93
+ flag_option %i[keep k]
94
+ flag_option :prefetch
95
+ flag_option %i[prune p]
96
+ flag_option %i[tags t], negatable: true
97
+ value_option :refmap, inline: true, repeatable: true
98
+ value_option %i[jobs j], inline: true
99
+ flag_option :set_upstream
100
+ value_option :upload_pack
101
+ flag_option :progress, negatable: true
102
+ value_option %i[server_option o], inline: true, repeatable: true
103
+ flag_option :show_forced_updates, negatable: true
104
+ flag_option %i[ipv4 4]
105
+ flag_option %i[ipv6 6]
106
+
107
+ # Execution options (not emitted as CLI flags)
108
+ execution_option :timeout
109
+
110
+ end_of_options
111
+ operand :repository
112
+ operand :refspec, repeatable: true
113
+ end
114
+
115
+ # @!method call(*, **options)
116
+ #
117
+ # @param options [Hash] command options
118
+ #
119
+ # @option options [Boolean, nil] :quiet (nil) command option key; see overload
120
+ # docs for the full option list
121
+ #
122
+ # Execute the `git pull` command
123
+ #
124
+ # @overload call(repository = nil, *refspecs, **options)
125
+ #
126
+ # @param repository [String, nil] The remote name or URL to pull from
127
+ #
128
+ # When nil, git uses the default remote for the current branch.
129
+ #
130
+ # @param refspecs [Array<String>] Zero or more refspecs specifying which refs to fetch
131
+ # and merge
132
+ #
133
+ # Each may be a branch name or refspec pattern.
134
+ #
135
+ # @param options [Hash] command options
136
+ #
137
+ # @option options [Boolean, nil] :quiet (nil) suppress all output
138
+ #
139
+ # Alias: :q
140
+ #
141
+ # @option options [Boolean, nil] :verbose (nil) enable verbose output during fetch and merge
142
+ #
143
+ # Alias: :v
144
+ #
145
+ # @option options [Boolean, String, nil] :recurse_submodules (nil) control submodule
146
+ # commit fetching (`--recurse-submodules`)
147
+ #
148
+ # Pass a string such as `'yes'`, `'on-demand'`, or `'no'` for
149
+ # `--recurse-submodules=<value>`.
150
+ #
151
+ # @option options [Boolean, nil] :no_recurse_submodules (nil) disable submodule
152
+ # commit fetching (`--no-recurse-submodules`)
153
+ #
154
+ # @option options [Boolean, nil] :commit (nil) perform the merge and commit the result
155
+ # (`--commit`)
156
+ #
157
+ # @option options [Boolean, nil] :no_commit (nil) merge but do not commit the result
158
+ # (`--no-commit`)
159
+ #
160
+ # @option options [Boolean, nil] :edit (nil) open an editor for the merge commit message
161
+ # (`--edit`)
162
+ #
163
+ # Alias: :e
164
+ #
165
+ # @option options [Boolean, nil] :no_edit (nil) do not open an editor for the merge commit
166
+ # message (`--no-edit`)
167
+ #
168
+ # @option options [String] :cleanup (nil) merge-message cleanup mode
169
+ #
170
+ # Determines how the merge message is cleaned up before committing.
171
+ # For example, `'strip'`, `'whitespace'`, `'verbatim'`, `'scissors'`, `'default'`.
172
+ #
173
+ # @option options [Boolean, nil] :ff_only (nil) require fast-forward merge or up-to-date HEAD
174
+ #
175
+ # Refuses to merge unless the current HEAD is already up to date or the
176
+ # merge can be resolved as a fast-forward.
177
+ #
178
+ # @option options [Boolean, nil] :ff (nil) allow fast-forward merge (`--ff`)
179
+ #
180
+ # @option options [Boolean, nil] :no_ff (nil) disable fast-forward merge, always creating a
181
+ # merge commit (`--no-ff`)
182
+ #
183
+ # @option options [Boolean, String, nil] :gpg_sign (nil) GPG-sign the resulting merge commit
184
+ # (`--gpg-sign`)
185
+ #
186
+ # Pass a key-ID string to select the signing key. Alias: :S
187
+ #
188
+ # @option options [Boolean, nil] :no_gpg_sign (nil) countermand commit.gpgSign configuration
189
+ # (`--no-gpg-sign`)
190
+ #
191
+ # @option options [Boolean, Integer, nil] :log (nil) include one-line descriptions from
192
+ # the actual commits being merged in log message (`--log`)
193
+ #
194
+ # Pass an integer for `--log=<n>`.
195
+ #
196
+ # @option options [Boolean, nil] :no_log (nil) disable inclusion of one-line descriptions
197
+ # from merged commits (`--no-log`)
198
+ #
199
+ # @option options [Boolean, nil] :signoff (nil) add a `Signed-off-by` trailer to the
200
+ # resulting merge commit message (`--signoff`)
201
+ #
202
+ # @option options [Boolean, nil] :no_signoff (nil) remove a `Signed-off-by` trailer from
203
+ # the merge commit message (`--no-signoff`)
204
+ #
205
+ # @option options [Boolean, nil] :stat (nil) show a diffstat at the end of the merge
206
+ #
207
+ # @option options [Boolean, nil] :no_stat (nil) do not show a diffstat at the end of the merge
208
+ #
209
+ # Alias: :n
210
+ #
211
+ # @option options [Boolean, nil] :compact_summary (nil) show a compact summary after the merge
212
+ #
213
+ # @option options [Boolean, nil] :squash (nil) squash pulled commits into a single commit
214
+ # (`--squash`)
215
+ #
216
+ # @option options [Boolean, nil] :no_squash (nil) override `--squash` option (`--no-squash`)
217
+ #
218
+ # @option options [Boolean, nil] :verify (nil) run pre-merge and commit-msg hooks
219
+ # (`--verify`)
220
+ #
221
+ # @option options [Boolean, nil] :no_verify (nil) bypass pre-merge and commit-msg hooks
222
+ # (`--no-verify`)
223
+ #
224
+ # @option options [String] :strategy (nil) use the given merge strategy
225
+ #
226
+ # For example, `'ort'`, `'recursive'`, `'resolve'`, `'octopus'`, `'ours'`, `'subtree'`.
227
+ # Alias: :s
228
+ #
229
+ # @option options [String, Array<String>] :strategy_option (nil) pass option(s) to
230
+ # the merge strategy
231
+ #
232
+ # Can be a single value or array. For example, `'ours'`, `'theirs'`, `'patience'`.
233
+ # Alias: :X
234
+ #
235
+ # @option options [Boolean, nil] :verify_signatures (nil) verify that the tip commit of
236
+ # the side branch being merged is signed with a valid key (`--verify-signatures`)
237
+ #
238
+ # @option options [Boolean, nil] :no_verify_signatures (nil) do not verify the signature of
239
+ # the side branch tip commit (`--no-verify-signatures`)
240
+ #
241
+ # @option options [Boolean, nil] :summary (nil) show a summary after the merge (`--summary`)
242
+ #
243
+ # @option options [Boolean, nil] :no_summary (nil) do not show a summary after the merge
244
+ # (`--no-summary`)
245
+ #
246
+ # @option options [Boolean, nil] :autostash (nil) automatically create a temporary stash entry
247
+ # before the operation begins (`--autostash`)
248
+ #
249
+ # @option options [Boolean, nil] :no_autostash (nil) disable automatic stashing before the
250
+ # operation (`--no-autostash`)
251
+ #
252
+ # @option options [Boolean, nil] :allow_unrelated_histories (nil) allow pulling from a
253
+ # repository that shares no common history with the current repository
254
+ #
255
+ # @option options [Boolean, String, nil] :rebase (nil) rebase the current branch on
256
+ # top of the upstream branch after fetching (`--rebase`)
257
+ #
258
+ # Pass a string such as `'merges'` or `'interactive'` for `--rebase=<value>`.
259
+ # Alias: :r
260
+ #
261
+ # @option options [Boolean, nil] :no_rebase (nil) override earlier `--rebase` option
262
+ # (`--no-rebase`)
263
+ #
264
+ # @option options [Boolean, nil] :all (nil) fetch all remotes (`--all`)
265
+ #
266
+ # @option options [Boolean, nil] :no_all (nil) do not fetch all remotes (`--no-all`)
267
+ #
268
+ # @option options [Boolean, nil] :append (nil) append ref names and object names fetched to
269
+ # the existing contents of `.git/FETCH_HEAD`
270
+ #
271
+ # Alias: :a
272
+ #
273
+ # @option options [Boolean, nil] :atomic (nil) use an atomic transaction to update local refs
274
+ #
275
+ # @option options [String] :depth (nil) limit fetching to the given number of commits
276
+ #
277
+ # Fetches only the specified number of commits from the tip of each
278
+ # remote branch history.
279
+ #
280
+ # @option options [String] :deepen (nil) deepen or shorten history of a shallow repository
281
+ #
282
+ # @option options [String] :shallow_since (nil) deepen or shorten history to include all
283
+ # reachable commits after the given date
284
+ #
285
+ # @option options [String, Array<String>] :shallow_exclude (nil) exclude commits reachable
286
+ # from the specified remote branch or tag
287
+ #
288
+ # Repeatable.
289
+ #
290
+ # @option options [Boolean, nil] :unshallow (nil) convert a shallow repository to a complete one
291
+ #
292
+ # If the source is shallow, fetches as much as possible.
293
+ #
294
+ # @option options [Boolean, nil] :update_shallow (nil) accept refs that update `.git/shallow`
295
+ #
296
+ # @option options [String, Array<String>] :negotiation_tip (nil) report only commits
297
+ # reachable from the given tips during negotiation
298
+ #
299
+ # Repeatable.
300
+ #
301
+ # @option options [Boolean, nil] :negotiate_only (nil) do not fetch; only print ancestries
302
+ # between the local repository and the remote
303
+ #
304
+ # @option options [Boolean, nil] :dry_run (nil) show what would be done without making changes
305
+ #
306
+ # @option options [Boolean, nil] :porcelain (nil) give the output in a stable, easy-to-parse
307
+ # format for scripts
308
+ #
309
+ # @option options [Boolean, nil] :force (nil) override the check for a non-fast-forward update
310
+ #
311
+ # Alias: :f
312
+ #
313
+ # @option options [Boolean, nil] :keep (nil) keep the downloaded pack
314
+ #
315
+ # Alias: :k
316
+ #
317
+ # @option options [Boolean, nil] :prefetch (nil) modify the configured refspec to place
318
+ # all refs into the `refs/prefetch/` namespace
319
+ #
320
+ # @option options [Boolean, nil] :prune (nil) remove remote-tracking references that no longer
321
+ # exist on the remote before fetching
322
+ #
323
+ # Alias: :p
324
+ #
325
+ # @option options [Boolean, nil] :tags (nil) fetch all tags from the remote (`--tags`)
326
+ #
327
+ # Alias: :t
328
+ #
329
+ # @option options [Boolean, nil] :no_tags (nil) disable automatic tag following
330
+ # (`--no-tags`)
331
+ #
332
+ # @option options [String, Array<String>] :refmap (nil) override fetch refspecs for
333
+ # remote-tracking branch mapping
334
+ #
335
+ # Repeatable.
336
+ #
337
+ # @option options [String] :jobs (nil) number of submodules fetched in parallel
338
+ #
339
+ # Alias: :j
340
+ #
341
+ # @option options [Boolean, nil] :set_upstream (nil) add upstream (tracking) reference for
342
+ # the current branch
343
+ #
344
+ # @option options [String] :upload_pack (nil) path to `git-upload-pack` on the remote
345
+ #
346
+ # @option options [Boolean, nil] :progress (nil) force progress status display (`--progress`)
347
+ #
348
+ # @option options [Boolean, nil] :no_progress (nil) suppress progress status display
349
+ # (`--no-progress`)
350
+ #
351
+ # @option options [String, Array<String>] :server_option (nil) transmit the given
352
+ # string to the server when communicating using protocol version 2
353
+ #
354
+ # Repeatable. Alias: :o
355
+ #
356
+ # @option options [Boolean, nil] :show_forced_updates (nil) check whether a local branch is
357
+ # force-updated during fetch (`--show-forced-updates`)
358
+ #
359
+ # @option options [Boolean, nil] :no_show_forced_updates (nil) disable checking for force
360
+ # updates (`--no-show-forced-updates`)
361
+ #
362
+ # @option options [Boolean, nil] :ipv4 (nil) use IPv4 addresses only, ignoring IPv6 addresses
363
+ #
364
+ # Alias: :'4'
365
+ #
366
+ # @option options [Boolean, nil] :ipv6 (nil) use IPv6 addresses only, ignoring IPv4 addresses
367
+ #
368
+ # Alias: :'6'
369
+ #
370
+ # @option options [Numeric, nil] :timeout (nil) timeout in seconds for the command
371
+ #
372
+ # If nil, uses the global timeout from {Git::Config}.
373
+ #
374
+ # @return [Git::CommandLine::Result] the result of calling `git pull`
375
+ #
376
+ # @raise [ArgumentError] if argument validation fails (e.g., unsupported options
377
+ # are provided or option values are invalid)
378
+ #
379
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
380
+ end
381
+ end
382
+ end