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.
- checksums.yaml +4 -4
- data/.yardopts +5 -1
- data/AI_POLICY.md +24 -0
- data/CHANGELOG.md +689 -0
- data/CODE_OF_CONDUCT.md +25 -0
- data/CONTRIBUTING.md +1175 -97
- data/GOVERNANCE.md +106 -0
- data/LICENSE +1 -1
- data/MAINTAINERS.md +17 -4
- data/README.md +476 -320
- data/UPGRADING.md +1138 -0
- data/git.gemspec +124 -36
- data/lib/git/author.rb +39 -7
- data/lib/git/author_info.rb +66 -0
- data/lib/git/branch.rb +615 -65
- data/lib/git/branch_delete_failure.rb +34 -0
- data/lib/git/branch_delete_result.rb +66 -0
- data/lib/git/branch_info.rb +237 -0
- data/lib/git/branches.rb +167 -44
- data/lib/git/command_line/base.rb +247 -0
- data/lib/git/command_line/capturing.rb +308 -0
- data/lib/git/command_line/result.rb +88 -0
- data/lib/git/command_line/streaming.rb +236 -0
- data/lib/git/command_line.rb +52 -0
- data/lib/git/commands/add.rb +139 -0
- data/lib/git/commands/am/abort.rb +43 -0
- data/lib/git/commands/am/apply.rb +263 -0
- data/lib/git/commands/am/continue.rb +43 -0
- data/lib/git/commands/am/quit.rb +43 -0
- data/lib/git/commands/am/retry.rb +49 -0
- data/lib/git/commands/am/show_current_patch.rb +64 -0
- data/lib/git/commands/am/skip.rb +42 -0
- data/lib/git/commands/am.rb +33 -0
- data/lib/git/commands/apply.rb +242 -0
- data/lib/git/commands/archive/list_formats.rb +46 -0
- data/lib/git/commands/archive.rb +145 -0
- data/lib/git/commands/arguments.rb +4521 -0
- data/lib/git/commands/base.rb +502 -0
- data/lib/git/commands/branch/copy.rb +102 -0
- data/lib/git/commands/branch/create.rb +177 -0
- data/lib/git/commands/branch/delete.rb +88 -0
- data/lib/git/commands/branch/list.rb +178 -0
- data/lib/git/commands/branch/move.rb +102 -0
- data/lib/git/commands/branch/set_upstream.rb +86 -0
- data/lib/git/commands/branch/show_current.rb +49 -0
- data/lib/git/commands/branch/unset_upstream.rb +53 -0
- data/lib/git/commands/branch.rb +34 -0
- data/lib/git/commands/cat_file/batch.rb +385 -0
- data/lib/git/commands/cat_file/filtered.rb +105 -0
- data/lib/git/commands/cat_file/raw.rb +271 -0
- data/lib/git/commands/cat_file.rb +49 -0
- data/lib/git/commands/checkout/branch.rb +153 -0
- data/lib/git/commands/checkout/files.rb +116 -0
- data/lib/git/commands/checkout.rb +38 -0
- data/lib/git/commands/checkout_index.rb +106 -0
- data/lib/git/commands/clean.rb +102 -0
- data/lib/git/commands/clone.rb +241 -0
- data/lib/git/commands/commit.rb +273 -0
- data/lib/git/commands/commit_tree.rb +101 -0
- data/lib/git/commands/config_option_syntax/add.rb +86 -0
- data/lib/git/commands/config_option_syntax/get.rb +121 -0
- data/lib/git/commands/config_option_syntax/get_all.rb +118 -0
- data/lib/git/commands/config_option_syntax/get_color.rb +95 -0
- data/lib/git/commands/config_option_syntax/get_color_bool.rb +96 -0
- data/lib/git/commands/config_option_syntax/get_regexp.rb +119 -0
- data/lib/git/commands/config_option_syntax/get_urlmatch.rb +111 -0
- data/lib/git/commands/config_option_syntax/list.rb +111 -0
- data/lib/git/commands/config_option_syntax/remove_section.rb +79 -0
- data/lib/git/commands/config_option_syntax/rename_section.rb +83 -0
- data/lib/git/commands/config_option_syntax/replace_all.rb +109 -0
- data/lib/git/commands/config_option_syntax/set.rb +119 -0
- data/lib/git/commands/config_option_syntax/unset.rb +92 -0
- data/lib/git/commands/config_option_syntax/unset_all.rb +94 -0
- data/lib/git/commands/config_option_syntax.rb +56 -0
- data/lib/git/commands/describe.rb +156 -0
- data/lib/git/commands/diff.rb +657 -0
- data/lib/git/commands/diff_files.rb +519 -0
- data/lib/git/commands/diff_index.rb +499 -0
- data/lib/git/commands/fetch.rb +354 -0
- data/lib/git/commands/fsck.rb +138 -0
- data/lib/git/commands/gc.rb +134 -0
- data/lib/git/commands/grep.rb +339 -0
- data/lib/git/commands/init.rb +101 -0
- data/lib/git/commands/log.rb +634 -0
- data/lib/git/commands/ls_files.rb +195 -0
- data/lib/git/commands/ls_remote.rb +161 -0
- data/lib/git/commands/ls_tree.rb +135 -0
- data/lib/git/commands/maintenance/register.rb +77 -0
- data/lib/git/commands/maintenance/run.rb +109 -0
- data/lib/git/commands/maintenance/start.rb +71 -0
- data/lib/git/commands/maintenance/stop.rb +60 -0
- data/lib/git/commands/maintenance/unregister.rb +84 -0
- data/lib/git/commands/maintenance.rb +31 -0
- data/lib/git/commands/merge/abort.rb +44 -0
- data/lib/git/commands/merge/continue.rb +44 -0
- data/lib/git/commands/merge/quit.rb +46 -0
- data/lib/git/commands/merge/start.rb +250 -0
- data/lib/git/commands/merge.rb +28 -0
- data/lib/git/commands/merge_base.rb +91 -0
- data/lib/git/commands/mv.rb +82 -0
- data/lib/git/commands/name_rev.rb +119 -0
- data/lib/git/commands/pull.rb +382 -0
- data/lib/git/commands/push.rb +251 -0
- data/lib/git/commands/read_tree.rb +154 -0
- data/lib/git/commands/remote/add.rb +96 -0
- data/lib/git/commands/remote/get_url.rb +68 -0
- data/lib/git/commands/remote/list.rb +56 -0
- data/lib/git/commands/remote/prune.rb +63 -0
- data/lib/git/commands/remote/remove.rb +52 -0
- data/lib/git/commands/remote/rename.rb +76 -0
- data/lib/git/commands/remote/set_branches.rb +70 -0
- data/lib/git/commands/remote/set_head.rb +89 -0
- data/lib/git/commands/remote/set_url.rb +78 -0
- data/lib/git/commands/remote/set_url_add.rb +70 -0
- data/lib/git/commands/remote/set_url_delete.rb +71 -0
- data/lib/git/commands/remote/show.rb +77 -0
- data/lib/git/commands/remote/update.rb +79 -0
- data/lib/git/commands/remote.rb +42 -0
- data/lib/git/commands/repack.rb +281 -0
- data/lib/git/commands/reset.rb +154 -0
- data/lib/git/commands/rev_parse.rb +304 -0
- data/lib/git/commands/revert/abort.rb +45 -0
- data/lib/git/commands/revert/continue.rb +62 -0
- data/lib/git/commands/revert/quit.rb +47 -0
- data/lib/git/commands/revert/skip.rb +44 -0
- data/lib/git/commands/revert/start.rb +158 -0
- data/lib/git/commands/revert.rb +29 -0
- data/lib/git/commands/rm.rb +113 -0
- data/lib/git/commands/show.rb +632 -0
- data/lib/git/commands/show_ref/exclude_existing.rb +119 -0
- data/lib/git/commands/show_ref/exists.rb +80 -0
- data/lib/git/commands/show_ref/list.rb +149 -0
- data/lib/git/commands/show_ref/verify.rb +122 -0
- data/lib/git/commands/show_ref.rb +42 -0
- data/lib/git/commands/stash/apply.rb +81 -0
- data/lib/git/commands/stash/branch.rb +67 -0
- data/lib/git/commands/stash/clear.rb +43 -0
- data/lib/git/commands/stash/create.rb +60 -0
- data/lib/git/commands/stash/drop.rb +73 -0
- data/lib/git/commands/stash/list.rb +43 -0
- data/lib/git/commands/stash/pop.rb +87 -0
- data/lib/git/commands/stash/push.rb +112 -0
- data/lib/git/commands/stash/show.rb +158 -0
- data/lib/git/commands/stash/store.rb +72 -0
- data/lib/git/commands/stash.rb +38 -0
- data/lib/git/commands/status.rb +174 -0
- data/lib/git/commands/symbolic_ref/delete.rb +72 -0
- data/lib/git/commands/symbolic_ref/read.rb +99 -0
- data/lib/git/commands/symbolic_ref/update.rb +79 -0
- data/lib/git/commands/symbolic_ref.rb +38 -0
- data/lib/git/commands/tag/create.rb +142 -0
- data/lib/git/commands/tag/delete.rb +57 -0
- data/lib/git/commands/tag/list.rb +146 -0
- data/lib/git/commands/tag/verify.rb +71 -0
- data/lib/git/commands/tag.rb +26 -0
- data/lib/git/commands/update_ref/batch.rb +145 -0
- data/lib/git/commands/update_ref/delete.rb +90 -0
- data/lib/git/commands/update_ref/update.rb +103 -0
- data/lib/git/commands/update_ref.rb +42 -0
- data/lib/git/commands/version.rb +60 -0
- data/lib/git/commands/worktree/add.rb +139 -0
- data/lib/git/commands/worktree/list.rb +64 -0
- data/lib/git/commands/worktree/lock.rb +58 -0
- data/lib/git/commands/worktree/management_base.rb +51 -0
- data/lib/git/commands/worktree/move.rb +66 -0
- data/lib/git/commands/worktree/prune.rb +67 -0
- data/lib/git/commands/worktree/remove.rb +63 -0
- data/lib/git/commands/worktree/repair.rb +76 -0
- data/lib/git/commands/worktree/unlock.rb +47 -0
- data/lib/git/commands/worktree.rb +43 -0
- data/lib/git/commands/write_tree.rb +68 -0
- data/lib/git/commands.rb +88 -0
- data/lib/git/config.rb +72 -5
- data/lib/git/config_entry_info.rb +106 -0
- data/lib/git/configuring.rb +795 -0
- data/lib/git/detached_head_info.rb +57 -0
- data/lib/git/diff.rb +437 -86
- data/lib/git/diff_file_numstat_info.rb +31 -0
- data/lib/git/diff_file_patch_info.rb +136 -0
- data/lib/git/diff_file_raw_info.rb +129 -0
- data/lib/git/diff_info.rb +162 -0
- data/lib/git/diff_path_status.rb +107 -0
- data/lib/git/diff_result.rb +34 -0
- data/lib/git/diff_stats.rb +111 -0
- data/lib/git/dirstat_info.rb +102 -0
- data/lib/git/encoding_utils.rb +32 -1
- data/lib/git/errors.rb +285 -0
- data/lib/git/escaped_path.rb +57 -5
- data/lib/git/execution_context/global.rb +31 -0
- data/lib/git/execution_context/repository.rb +151 -0
- data/lib/git/execution_context.rb +559 -0
- data/lib/git/factories.rb +813 -0
- data/lib/git/file_ref.rb +77 -0
- data/lib/git/fsck_object.rb +56 -0
- data/lib/git/fsck_result.rb +132 -0
- data/lib/git/log.rb +306 -90
- data/lib/git/object.rb +563 -141
- data/lib/git/parsers/branch.rb +240 -0
- data/lib/git/parsers/cat_file.rb +111 -0
- data/lib/git/parsers/config_entry.rb +110 -0
- data/lib/git/parsers/diff.rb +792 -0
- data/lib/git/parsers/fsck.rb +144 -0
- data/lib/git/parsers/grep.rb +42 -0
- data/lib/git/parsers/ls_remote.rb +79 -0
- data/lib/git/parsers/ls_tree.rb +58 -0
- data/lib/git/parsers/remote.rb +162 -0
- data/lib/git/parsers/stash.rb +292 -0
- data/lib/git/parsers/status.rb +251 -0
- data/lib/git/parsers/tag.rb +341 -0
- data/lib/git/parsers/worktree.rb +185 -0
- data/lib/git/path_resolver.rb +206 -0
- data/lib/git/remote.rb +165 -12
- data/lib/git/remote_info.rb +203 -0
- data/lib/git/repository/branching.rb +964 -0
- data/lib/git/repository/committing.rb +246 -0
- data/lib/git/repository/context_helpers.rb +293 -0
- data/lib/git/repository/diffing.rb +785 -0
- data/lib/git/repository/inspecting.rb +252 -0
- data/lib/git/repository/logging.rb +410 -0
- data/lib/git/repository/maintenance.rb +65 -0
- data/lib/git/repository/merging.rb +451 -0
- data/lib/git/repository/object_operations.rb +1551 -0
- data/lib/git/repository/remote_operations.rb +984 -0
- data/lib/git/repository/shared_private.rb +120 -0
- data/lib/git/repository/staging.rb +587 -0
- data/lib/git/repository/stashing.rb +623 -0
- data/lib/git/repository/status_operations.rb +249 -0
- data/lib/git/repository/worktree_operations.rb +339 -0
- data/lib/git/repository.rb +484 -2
- data/lib/git/stash.rb +109 -12
- data/lib/git/stash_info.rb +102 -0
- data/lib/git/stashes.rb +169 -26
- data/lib/git/status.rb +308 -122
- data/lib/git/status_file_info.rb +258 -0
- data/lib/git/status_info.rb +189 -0
- data/lib/git/tag_delete_failure.rb +34 -0
- data/lib/git/tag_delete_result.rb +66 -0
- data/lib/git/tag_info.rb +99 -0
- data/lib/git/url.rb +15 -8
- data/lib/git/version.rb +113 -2
- data/lib/git/version_constraint.rb +85 -0
- data/lib/git/worktree.rb +150 -8
- data/lib/git/worktree_info.rb +128 -0
- data/lib/git/worktrees.rb +118 -13
- data/lib/git.rb +632 -234
- metadata +369 -54
- data/.github/stale.yml +0 -25
- data/.github/workflows/continuous_integration.yml +0 -49
- data/.gitignore +0 -10
- data/Dockerfile.changelog-rs +0 -12
- data/Gemfile +0 -5
- data/ISSUE_TEMPLATE.md +0 -15
- data/PULL_REQUEST_TEMPLATE.md +0 -9
- data/RELEASING.md +0 -70
- data/Rakefile +0 -60
- data/lib/git/base/factory.rb +0 -99
- data/lib/git/base.rb +0 -711
- data/lib/git/command_line_result.rb +0 -86
- data/lib/git/failed_error.rb +0 -53
- data/lib/git/git_execute_error.rb +0 -7
- data/lib/git/index.rb +0 -5
- data/lib/git/lib.rb +0 -1328
- data/lib/git/path.rb +0 -31
- data/lib/git/signaled_error.rb +0 -50
- data/lib/git/working_directory.rb +0 -4
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
module CatFile
|
|
8
|
+
# Queries a single git object by name passed as a CLI argument
|
|
9
|
+
#
|
|
10
|
+
# Runs `git cat-file` in non-batch mode. Exactly one mode flag or a `<type>`
|
|
11
|
+
# operand must be supplied:
|
|
12
|
+
#
|
|
13
|
+
# - **`-e`** — exit 0 if the object exists and is valid, exit 1 otherwise;
|
|
14
|
+
# no output is written to stdout
|
|
15
|
+
# - **`-t`** — print the object type (`blob`, `tree`, `commit`, or `tag`)
|
|
16
|
+
# - **`-s`** — print the object size in bytes
|
|
17
|
+
# - **`-p`** — pretty-print the object content (format varies by type)
|
|
18
|
+
# - **`<type>`** — print the raw content after validating the object is of
|
|
19
|
+
# the given type (or trivially dereferenceable to it)
|
|
20
|
+
#
|
|
21
|
+
# For queries across multiple objects, use {CatFile::Batch}.
|
|
22
|
+
# For filter-processed content, use {CatFile::Filtered}.
|
|
23
|
+
#
|
|
24
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-cat-file/2.53.0
|
|
25
|
+
#
|
|
26
|
+
# @see Git::Commands::CatFile
|
|
27
|
+
#
|
|
28
|
+
# @see https://git-scm.com/docs/git-cat-file git-cat-file documentation
|
|
29
|
+
#
|
|
30
|
+
# @api private
|
|
31
|
+
#
|
|
32
|
+
class Raw < Base
|
|
33
|
+
arguments do
|
|
34
|
+
literal 'cat-file'
|
|
35
|
+
|
|
36
|
+
# Exit 0 if object exists and is valid; exit 1 otherwise (no output)
|
|
37
|
+
# See https://git-scm.com/docs/git-cat-file#Documentation/git-cat-file.txt--e
|
|
38
|
+
flag_option :e
|
|
39
|
+
|
|
40
|
+
# Pretty-print the object content based on its type
|
|
41
|
+
# See https://git-scm.com/docs/git-cat-file#Documentation/git-cat-file.txt--p
|
|
42
|
+
flag_option :p
|
|
43
|
+
|
|
44
|
+
# Print the object type (`blob`, `tree`, `commit`, or `tag`)
|
|
45
|
+
# See https://git-scm.com/docs/git-cat-file#Documentation/git-cat-file.txt--t
|
|
46
|
+
flag_option :t
|
|
47
|
+
|
|
48
|
+
# Print the object size in bytes
|
|
49
|
+
# See https://git-scm.com/docs/git-cat-file#Documentation/git-cat-file.txt--s
|
|
50
|
+
flag_option :s
|
|
51
|
+
|
|
52
|
+
# Allow -t and -s to query broken or corrupt objects of unknown type.
|
|
53
|
+
# Deprecated and removed in v6.0.0 (see issue 1709); passing it emits a
|
|
54
|
+
# deprecation warning. Git 2.28-2.49 honors it with -t and -s and rejects
|
|
55
|
+
# it in other modes; git 2.50+ accepts and ignores it everywhere (the
|
|
56
|
+
# unknown-type feature was removed).
|
|
57
|
+
# See https://git-scm.com/docs/git-cat-file/2.49.0#Documentation/git-cat-file.txt---allow-unknown-type
|
|
58
|
+
flag_option :allow_unknown_type
|
|
59
|
+
|
|
60
|
+
# Map committer/author identities through the mailmap before reporting size
|
|
61
|
+
# See https://git-scm.com/docs/git-cat-file#Documentation/git-cat-file.txt---use-mailmap
|
|
62
|
+
flag_option :use_mailmap, negatable: true
|
|
63
|
+
|
|
64
|
+
# Stream stdout to this IO object instead of buffering in memory.
|
|
65
|
+
# When provided, {#call} dispatches to the streaming execution path.
|
|
66
|
+
execution_option :out
|
|
67
|
+
|
|
68
|
+
# Abort the command after this many seconds.
|
|
69
|
+
execution_option :timeout
|
|
70
|
+
|
|
71
|
+
end_of_options
|
|
72
|
+
|
|
73
|
+
# Expected object type — one of `commit`, `tree`, `blob`, or `tag`.
|
|
74
|
+
# Git also accepts a type that the object is trivially dereferenceable to
|
|
75
|
+
# (e.g. `tree` against a commit ref, `blob` against a tag that points to one).
|
|
76
|
+
operand :type
|
|
77
|
+
|
|
78
|
+
# Object name: SHA, ref, `HEAD`, treeish path reference, etc.
|
|
79
|
+
operand :object, required: true
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Execute `git cat-file` for a single object.
|
|
83
|
+
#
|
|
84
|
+
# Exactly one mode must be selected: pass one of `e: true`, `p: true`,
|
|
85
|
+
# `t: true`, `s: true`, or a positional `type` argument.
|
|
86
|
+
#
|
|
87
|
+
# @overload call(object, e: true, **options)
|
|
88
|
+
# Check whether an object exists
|
|
89
|
+
#
|
|
90
|
+
# @param object [String] object name (SHA, ref, `HEAD`, treeish path, etc.)
|
|
91
|
+
#
|
|
92
|
+
# @param e [Boolean] enable existence-check mode
|
|
93
|
+
#
|
|
94
|
+
# @param options [Hash] command options
|
|
95
|
+
#
|
|
96
|
+
# @option options [Boolean, nil] :allow_unknown_type (nil) pass `--allow-unknown-type` through to git,
|
|
97
|
+
# which rejects it in this mode on git 2.28-2.49 and accepts it as a no-op
|
|
98
|
+
# on git 2.50 and later
|
|
99
|
+
#
|
|
100
|
+
# Deprecated and removed in v6.0.0; passing it emits a deprecation
|
|
101
|
+
# warning.
|
|
102
|
+
#
|
|
103
|
+
# @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
|
|
104
|
+
#
|
|
105
|
+
# @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
|
|
106
|
+
#
|
|
107
|
+
# @return [Git::CommandLine::Result] the result of calling `git cat-file`
|
|
108
|
+
#
|
|
109
|
+
# Exit status 0 means the object exists; exit status 1 means it does not
|
|
110
|
+
#
|
|
111
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
112
|
+
#
|
|
113
|
+
# @raise [Git::FailedError] if git exits with a status other than 0 or 1
|
|
114
|
+
#
|
|
115
|
+
# @overload call(object, t: true, **options)
|
|
116
|
+
# Print the object type
|
|
117
|
+
#
|
|
118
|
+
# @param object [String] object name
|
|
119
|
+
#
|
|
120
|
+
# @param t [Boolean] enable type-query mode
|
|
121
|
+
#
|
|
122
|
+
# @param options [Hash] command options
|
|
123
|
+
#
|
|
124
|
+
# @option options [Boolean, nil] :allow_unknown_type (nil) allow querying broken or corrupt objects of
|
|
125
|
+
# unknown type on git 2.28-2.49
|
|
126
|
+
#
|
|
127
|
+
# Deprecated and removed in v6.0.0; passing it emits a deprecation
|
|
128
|
+
# warning. Git 2.50 removed the unknown-type feature and accepts this
|
|
129
|
+
# flag as a no-op.
|
|
130
|
+
#
|
|
131
|
+
# @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
|
|
132
|
+
#
|
|
133
|
+
# @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
|
|
134
|
+
#
|
|
135
|
+
# @return [Git::CommandLine::Result] the result of calling `git cat-file`
|
|
136
|
+
#
|
|
137
|
+
# Stdout contains the object type string
|
|
138
|
+
#
|
|
139
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
140
|
+
#
|
|
141
|
+
# @raise [Git::FailedError] if the object does not exist
|
|
142
|
+
#
|
|
143
|
+
# @overload call(object, s: true, **options)
|
|
144
|
+
# Print the object size in bytes
|
|
145
|
+
#
|
|
146
|
+
# @param object [String] object name
|
|
147
|
+
#
|
|
148
|
+
# @param s [Boolean] enable size-query mode
|
|
149
|
+
#
|
|
150
|
+
# @param options [Hash] command options
|
|
151
|
+
#
|
|
152
|
+
# @option options [Boolean, nil] :allow_unknown_type (nil) allow querying broken or corrupt objects of
|
|
153
|
+
# unknown type on git 2.28-2.49
|
|
154
|
+
#
|
|
155
|
+
# Deprecated and removed in v6.0.0; passing it emits a deprecation
|
|
156
|
+
# warning. Git 2.50 removed the unknown-type feature and accepts this
|
|
157
|
+
# flag as a no-op.
|
|
158
|
+
#
|
|
159
|
+
# @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
|
|
160
|
+
#
|
|
161
|
+
# @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
|
|
162
|
+
#
|
|
163
|
+
# @return [Git::CommandLine::Result] the result of calling `git cat-file`
|
|
164
|
+
#
|
|
165
|
+
# Stdout contains the object size as a decimal string
|
|
166
|
+
#
|
|
167
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
168
|
+
#
|
|
169
|
+
# @raise [Git::FailedError] if the object does not exist
|
|
170
|
+
#
|
|
171
|
+
# @overload call(object, p: true, **options)
|
|
172
|
+
# Pretty-print the object content
|
|
173
|
+
#
|
|
174
|
+
# @param object [String] object name
|
|
175
|
+
#
|
|
176
|
+
# @param p [Boolean] enable pretty-print mode
|
|
177
|
+
#
|
|
178
|
+
# @param options [Hash] command options
|
|
179
|
+
#
|
|
180
|
+
# @option options [Boolean, nil] :allow_unknown_type (nil) pass `--allow-unknown-type` through to git,
|
|
181
|
+
# which rejects it in this mode on git 2.28-2.49 and accepts it as a no-op
|
|
182
|
+
# on git 2.50 and later
|
|
183
|
+
#
|
|
184
|
+
# Deprecated and removed in v6.0.0; passing it emits a deprecation
|
|
185
|
+
# warning.
|
|
186
|
+
#
|
|
187
|
+
# @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
|
|
188
|
+
#
|
|
189
|
+
# @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
|
|
190
|
+
#
|
|
191
|
+
# @return [Git::CommandLine::Result] the result of calling `git cat-file`
|
|
192
|
+
#
|
|
193
|
+
# Stdout contains the formatted object content
|
|
194
|
+
#
|
|
195
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
196
|
+
#
|
|
197
|
+
# @raise [Git::FailedError] if the object does not exist
|
|
198
|
+
#
|
|
199
|
+
# @overload call(type, object, **options)
|
|
200
|
+
# Print the raw content, validating the object is of the given type
|
|
201
|
+
#
|
|
202
|
+
# @param type [String] expected object type — `commit`, `tree`, `blob`, or `tag`
|
|
203
|
+
#
|
|
204
|
+
# @param object [String] object name
|
|
205
|
+
#
|
|
206
|
+
# @param options [Hash] command options
|
|
207
|
+
#
|
|
208
|
+
# @option options [Boolean, nil] :allow_unknown_type (nil) pass `--allow-unknown-type` through to git,
|
|
209
|
+
# which rejects it in this mode on git 2.28-2.49 and accepts it as a no-op
|
|
210
|
+
# on git 2.50 and later
|
|
211
|
+
#
|
|
212
|
+
# Deprecated and removed in v6.0.0; passing it emits a deprecation
|
|
213
|
+
# warning.
|
|
214
|
+
#
|
|
215
|
+
# @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
|
|
216
|
+
#
|
|
217
|
+
# @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
|
|
218
|
+
#
|
|
219
|
+
# @return [Git::CommandLine::Result] the result of calling `git cat-file`
|
|
220
|
+
#
|
|
221
|
+
# Stdout contains the raw object content
|
|
222
|
+
#
|
|
223
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
224
|
+
#
|
|
225
|
+
# @raise [Git::FailedError] if the object does not exist or is not of the
|
|
226
|
+
# given type
|
|
227
|
+
#
|
|
228
|
+
# @option options [Numeric, nil] :timeout (nil) abort the command after this many seconds
|
|
229
|
+
#
|
|
230
|
+
def call(*, **)
|
|
231
|
+
warn_allow_unknown_type_deprecated(**)
|
|
232
|
+
bound = args_definition.bind(*, **)
|
|
233
|
+
validate_version!(bound.execution_options)
|
|
234
|
+
result = execute_command(bound)
|
|
235
|
+
|
|
236
|
+
# `-e` treats exit 1 as a meaningful result (object not found), but any other
|
|
237
|
+
# non-zero exit (e.g. 128 for a corrupt object database) is still a failure.
|
|
238
|
+
# All other modes treat every non-zero exit as a failure.
|
|
239
|
+
allowed = result.status.success? || (bound.e? && result.status.exitstatus == 1)
|
|
240
|
+
raise Git::FailedError, result unless allowed
|
|
241
|
+
|
|
242
|
+
result
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
private
|
|
246
|
+
|
|
247
|
+
# Emit the deprecation warning when the `allow_unknown_type` keyword is passed
|
|
248
|
+
#
|
|
249
|
+
# Keys on the keyword being present, whatever its value: `false` and `nil`
|
|
250
|
+
# suppress the flag but still name a deprecated option.
|
|
251
|
+
#
|
|
252
|
+
# @param options [Hash] the keyword arguments passed to {#call}
|
|
253
|
+
#
|
|
254
|
+
# @option options [Boolean, nil] :allow_unknown_type the deprecated option;
|
|
255
|
+
# any value, including `false` and `nil`, triggers the warning
|
|
256
|
+
#
|
|
257
|
+
# @return [void]
|
|
258
|
+
#
|
|
259
|
+
def warn_allow_unknown_type_deprecated(**options)
|
|
260
|
+
return unless options.key?(:allow_unknown_type)
|
|
261
|
+
|
|
262
|
+
Git::Deprecation.warn(
|
|
263
|
+
'The allow_unknown_type option of Git::Commands::CatFile::Raw is deprecated ' \
|
|
264
|
+
'and will be removed in v6.0.0. Git 2.50 removed the unknown-type feature ' \
|
|
265
|
+
'and accepts --allow-unknown-type as a no-op.'
|
|
266
|
+
)
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'cat_file/batch'
|
|
4
|
+
require_relative 'cat_file/filtered'
|
|
5
|
+
require_relative 'cat_file/raw'
|
|
6
|
+
|
|
7
|
+
module Git
|
|
8
|
+
module Commands
|
|
9
|
+
# Commands for reading git object store content via `git cat-file`
|
|
10
|
+
#
|
|
11
|
+
# This module contains command classes split by invocation protocol:
|
|
12
|
+
#
|
|
13
|
+
# - {CatFile::Raw} — single object as a CLI argument; raw content, type, size, or
|
|
14
|
+
# existence check (`-e`, `-t`, `-s`, `-p`, `<type>`)
|
|
15
|
+
# - {CatFile::Filtered} — single object as a CLI argument; content after
|
|
16
|
+
# `.gitattributes` filter processing (`--textconv`, `--filters`)
|
|
17
|
+
# - {CatFile::Batch} — objects fed via stdin; all batch streaming modes
|
|
18
|
+
# (`--batch`, `--batch-check`, `--batch-command`)
|
|
19
|
+
#
|
|
20
|
+
# @example Check whether an object exists
|
|
21
|
+
# cmd = Git::Commands::CatFile::Raw.new(lib)
|
|
22
|
+
# result = cmd.call('HEAD', e: true)
|
|
23
|
+
# result.status.exitstatus # => 0 (exists) or 1 (not found)
|
|
24
|
+
#
|
|
25
|
+
# @example Pretty-print a single object
|
|
26
|
+
# cmd = Git::Commands::CatFile::Raw.new(lib)
|
|
27
|
+
# result = cmd.call('HEAD', p: true)
|
|
28
|
+
# result.stdout
|
|
29
|
+
# # => "tree abc1234...\nauthor ...\n\nCommit message\n"
|
|
30
|
+
#
|
|
31
|
+
# @example Fetch content after working-tree filters
|
|
32
|
+
# cmd = Git::Commands::CatFile::Filtered.new(lib)
|
|
33
|
+
# result = cmd.call('HEAD:README.md', filters: true)
|
|
34
|
+
# result.stdout
|
|
35
|
+
#
|
|
36
|
+
# @example Fetch metadata for several objects via batch
|
|
37
|
+
# cmd = Git::Commands::CatFile::Batch.new(lib)
|
|
38
|
+
# result = cmd.call('HEAD', 'v1.0', batch_check: true)
|
|
39
|
+
# result.stdout
|
|
40
|
+
# # => "abc1234... commit 250\nabc5678... tag 143\n"
|
|
41
|
+
#
|
|
42
|
+
# @see https://git-scm.com/docs/git-cat-file git-cat-file documentation
|
|
43
|
+
#
|
|
44
|
+
# @api private
|
|
45
|
+
#
|
|
46
|
+
module CatFile
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
module Checkout
|
|
8
|
+
# Implements the `git checkout` command for switching branches
|
|
9
|
+
#
|
|
10
|
+
# This command switches branches by updating the index and working tree
|
|
11
|
+
# to match the specified branch, and updating HEAD to point to that branch.
|
|
12
|
+
# It can also create new branches with the `-b` or `-B` options.
|
|
13
|
+
#
|
|
14
|
+
# @example Typical usage
|
|
15
|
+
# checkout = Git::Commands::Checkout::Branch.new(execution_context)
|
|
16
|
+
# checkout.call('main')
|
|
17
|
+
# checkout.call(b: 'feature-branch')
|
|
18
|
+
# checkout.call('origin/main', b: 'feature-branch', track: true)
|
|
19
|
+
# checkout.call('abc123', detach: true)
|
|
20
|
+
# checkout.call('main', force: true)
|
|
21
|
+
#
|
|
22
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-checkout/2.53.0
|
|
23
|
+
#
|
|
24
|
+
# @see Git::Commands::Checkout
|
|
25
|
+
#
|
|
26
|
+
# @see https://git-scm.com/docs/git-checkout git-checkout
|
|
27
|
+
#
|
|
28
|
+
# @api private
|
|
29
|
+
#
|
|
30
|
+
class Branch < Git::Commands::Base
|
|
31
|
+
arguments do
|
|
32
|
+
literal 'checkout'
|
|
33
|
+
flag_option %i[quiet q]
|
|
34
|
+
flag_option :progress, negatable: true
|
|
35
|
+
flag_option %i[force f]
|
|
36
|
+
value_option :b
|
|
37
|
+
value_option :B
|
|
38
|
+
flag_or_value_option %i[track t], negatable: true, inline: true
|
|
39
|
+
flag_option :guess, negatable: true
|
|
40
|
+
flag_option :l
|
|
41
|
+
flag_option %i[detach d]
|
|
42
|
+
value_option :orphan
|
|
43
|
+
flag_option %i[merge m]
|
|
44
|
+
flag_option :ignore_other_worktrees
|
|
45
|
+
flag_option :overwrite_ignore, negatable: true
|
|
46
|
+
|
|
47
|
+
# --recurse-submodules is technically available but has no effect on branch
|
|
48
|
+
# switching in older git versions. Included for completeness per the man page.
|
|
49
|
+
flag_option :recurse_submodules, negatable: true
|
|
50
|
+
|
|
51
|
+
execution_option :chdir
|
|
52
|
+
|
|
53
|
+
operand :branch
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @overload call(branch = nil, **options)
|
|
57
|
+
#
|
|
58
|
+
# Execute the git checkout command for branch switching
|
|
59
|
+
#
|
|
60
|
+
# @param branch [String, nil] the branch name, commit SHA, or ref to check
|
|
61
|
+
# out; when used with branch creation options (`:b`, `:B`, `:orphan`)
|
|
62
|
+
# this becomes the start point
|
|
63
|
+
#
|
|
64
|
+
# @param options [Hash] command options
|
|
65
|
+
#
|
|
66
|
+
# @option options [Boolean, nil] :quiet (nil) suppress feedback messages
|
|
67
|
+
#
|
|
68
|
+
# Alias: `:q`
|
|
69
|
+
#
|
|
70
|
+
# @option options [Boolean, nil] :progress (nil) force progress reporting even
|
|
71
|
+
# when not attached to a terminal (`--progress`)
|
|
72
|
+
#
|
|
73
|
+
# @option options [Boolean, nil] :no_progress (nil) disable progress reporting
|
|
74
|
+
# even when attached to a terminal (`--no-progress`)
|
|
75
|
+
#
|
|
76
|
+
# @option options [Boolean, nil] :force (nil) proceed even if the index or
|
|
77
|
+
# working tree differs from HEAD; discards local changes and untracked
|
|
78
|
+
# files that are in the way
|
|
79
|
+
#
|
|
80
|
+
# Alias: `:f`
|
|
81
|
+
#
|
|
82
|
+
# @option options [String] :b (nil) create a new branch with this name and
|
|
83
|
+
# switch to it; the positional `branch` argument becomes the start point
|
|
84
|
+
#
|
|
85
|
+
# @option options [String] :B (nil) like `:b`, but reset the branch to the
|
|
86
|
+
# start point if it already exists
|
|
87
|
+
#
|
|
88
|
+
# @option options [Boolean, String, nil] :track (nil) set up upstream tracking
|
|
89
|
+
# configuration; `true` emits `--track`, `'direct'` emits
|
|
90
|
+
# `--track=direct`, `'inherit'` emits `--track=inherit` (`--track`)
|
|
91
|
+
#
|
|
92
|
+
# Alias: `:t`
|
|
93
|
+
#
|
|
94
|
+
# @option options [Boolean, nil] :no_track (nil) do not set up branch tracking
|
|
95
|
+
# even if `branch.autoSetupMerge` is configured (`--no-track`)
|
|
96
|
+
#
|
|
97
|
+
# @option options [Boolean, nil] :guess (nil) automatically create and check out
|
|
98
|
+
# a local branch from a uniquely matching remote-tracking branch
|
|
99
|
+
# (`--guess`)
|
|
100
|
+
#
|
|
101
|
+
# @option options [Boolean, nil] :no_guess (nil) disable automatic remote branch
|
|
102
|
+
# matching (`--no-guess`)
|
|
103
|
+
#
|
|
104
|
+
# @option options [Boolean, nil] :l (nil) create the new branch's reflog
|
|
105
|
+
#
|
|
106
|
+
# @option options [Boolean, nil] :detach (nil) detach HEAD at the specified
|
|
107
|
+
# commit rather than pointing a branch at it
|
|
108
|
+
#
|
|
109
|
+
# Alias: `:d`
|
|
110
|
+
#
|
|
111
|
+
# @option options [String] :orphan (nil) create a new unborn branch with no
|
|
112
|
+
# history; the positional `branch` argument becomes the start point
|
|
113
|
+
#
|
|
114
|
+
# @option options [Boolean, nil] :merge (nil) perform a three-way merge when
|
|
115
|
+
# local modifications conflict with the target branch
|
|
116
|
+
#
|
|
117
|
+
# Alias: `:m`
|
|
118
|
+
#
|
|
119
|
+
# @option options [Boolean, nil] :ignore_other_worktrees (nil) check out the
|
|
120
|
+
# branch even if it is already in use by another worktree
|
|
121
|
+
#
|
|
122
|
+
# @option options [Boolean, nil] :overwrite_ignore (nil) silently overwrite
|
|
123
|
+
# ignored files when switching branches (`--overwrite-ignore`)
|
|
124
|
+
#
|
|
125
|
+
# @option options [Boolean, nil] :no_overwrite_ignore (nil) abort the checkout
|
|
126
|
+
# if ignored files would be overwritten (`--no-overwrite-ignore`)
|
|
127
|
+
#
|
|
128
|
+
# @option options [Boolean, nil] :recurse_submodules (nil) update all active
|
|
129
|
+
# submodule working trees to match the new branch
|
|
130
|
+
# (`--recurse-submodules`)
|
|
131
|
+
#
|
|
132
|
+
# @option options [Boolean, nil] :no_recurse_submodules (nil) do not update
|
|
133
|
+
# submodule working trees when switching branches
|
|
134
|
+
# (`--no-recurse-submodules`)
|
|
135
|
+
#
|
|
136
|
+
# @option options [String] :chdir (nil) change to this directory before
|
|
137
|
+
# running git; not passed to the git CLI
|
|
138
|
+
#
|
|
139
|
+
# @return [Git::CommandLine::Result] the result of calling `git checkout`
|
|
140
|
+
#
|
|
141
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
142
|
+
#
|
|
143
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
144
|
+
#
|
|
145
|
+
# @api public
|
|
146
|
+
#
|
|
147
|
+
def call(*, **)
|
|
148
|
+
super
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
module Checkout
|
|
8
|
+
# Implements the `git checkout` command for restoring working tree files
|
|
9
|
+
#
|
|
10
|
+
# This command replaces files in the working tree with versions from
|
|
11
|
+
# the index (when tree_ish is nil) or a specified tree-ish (commit,
|
|
12
|
+
# branch, tag, etc.).
|
|
13
|
+
#
|
|
14
|
+
# @example Restore working tree files
|
|
15
|
+
# files = Git::Commands::Checkout::Files.new(execution_context)
|
|
16
|
+
# files.call(pathspec: ['lib/foo.rb']) # from the index
|
|
17
|
+
# files.call('HEAD~1', pathspec: ['lib/foo.rb']) # from a specific commit
|
|
18
|
+
# files.call('main', pathspec: %w[lib/foo.rb lib/bar.rb]) # from a branch
|
|
19
|
+
# files.call(pathspec: ['conflicted.txt'], ours: true) # resolve conflict (ours)
|
|
20
|
+
# files.call('main', pathspec_from_file: 'paths.txt') # paths from a file
|
|
21
|
+
#
|
|
22
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-checkout/2.53.0
|
|
23
|
+
#
|
|
24
|
+
# @see Git::Commands::Checkout
|
|
25
|
+
#
|
|
26
|
+
# @see https://git-scm.com/docs/git-checkout git-checkout
|
|
27
|
+
#
|
|
28
|
+
# @api private
|
|
29
|
+
#
|
|
30
|
+
class Files < Git::Commands::Base
|
|
31
|
+
arguments do
|
|
32
|
+
literal 'checkout'
|
|
33
|
+
flag_option %i[force f]
|
|
34
|
+
flag_option :ours
|
|
35
|
+
flag_option :theirs
|
|
36
|
+
flag_option %i[merge m]
|
|
37
|
+
value_option :conflict, inline: true
|
|
38
|
+
flag_option :overlay, negatable: true
|
|
39
|
+
flag_option :ignore_skip_worktree_bits
|
|
40
|
+
value_option :pathspec_from_file, inline: true
|
|
41
|
+
flag_option :pathspec_file_nul
|
|
42
|
+
|
|
43
|
+
execution_option :chdir
|
|
44
|
+
|
|
45
|
+
operand :tree_ish
|
|
46
|
+
end_of_options
|
|
47
|
+
value_option :pathspec, as_operand: true, repeatable: true
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @overload call(tree_ish = nil, **options)
|
|
51
|
+
#
|
|
52
|
+
# Execute the git checkout command for restoring files
|
|
53
|
+
#
|
|
54
|
+
# @param tree_ish [String, nil] The commit, branch, or tree to restore
|
|
55
|
+
# files from
|
|
56
|
+
#
|
|
57
|
+
# When `nil`, files are restored from the index
|
|
58
|
+
#
|
|
59
|
+
# @param options [Hash] command options
|
|
60
|
+
#
|
|
61
|
+
# @option options [Boolean, nil] :force (nil) ignore unmerged entries
|
|
62
|
+
#
|
|
63
|
+
# Alias: `:f`
|
|
64
|
+
#
|
|
65
|
+
# @option options [Boolean, nil] :ours (nil) for unmerged paths, check out
|
|
66
|
+
# stage #2 (our version)
|
|
67
|
+
#
|
|
68
|
+
# @option options [Boolean, nil] :theirs (nil) for unmerged paths, check out
|
|
69
|
+
# stage #3 (their version)
|
|
70
|
+
#
|
|
71
|
+
# @option options [Boolean, nil] :merge (nil) recreate the conflicted merge in
|
|
72
|
+
# the specified paths; cannot be used when checking out from a tree-ish
|
|
73
|
+
#
|
|
74
|
+
# Alias: `:m`
|
|
75
|
+
#
|
|
76
|
+
# @option options [String] :conflict (nil) conflict marker style; valid
|
|
77
|
+
# values are `'merge'`, `'diff3'`, and `'zdiff3'`
|
|
78
|
+
#
|
|
79
|
+
# @option options [Boolean, nil] :overlay (nil) never remove files from the
|
|
80
|
+
# index or working tree that are not present in the tree-ish (`--overlay`)
|
|
81
|
+
#
|
|
82
|
+
# @option options [Boolean, nil] :no_overlay (nil) remove files not present
|
|
83
|
+
# in the tree-ish from the index and working tree (`--no-overlay`)
|
|
84
|
+
#
|
|
85
|
+
# @option options [Boolean, nil] :ignore_skip_worktree_bits (nil) in sparse
|
|
86
|
+
# checkout mode, ignore sparse patterns and update all files matched by
|
|
87
|
+
# pathspec
|
|
88
|
+
#
|
|
89
|
+
# @option options [String] :pathspec_from_file (nil) read pathspec from
|
|
90
|
+
# this file; pass `'-'` to read from stdin
|
|
91
|
+
#
|
|
92
|
+
# @option options [Boolean, nil] :pathspec_file_nul (nil) with
|
|
93
|
+
# `:pathspec_from_file`, separate pathspec elements with NUL instead of
|
|
94
|
+
# newline
|
|
95
|
+
#
|
|
96
|
+
# @option options [Array<String>, String] :pathspec (nil) the files or
|
|
97
|
+
# directories to restore
|
|
98
|
+
#
|
|
99
|
+
# @option options [String] :chdir (nil) change to this directory before
|
|
100
|
+
# running git; not passed to the git CLI
|
|
101
|
+
#
|
|
102
|
+
# @return [Git::CommandLine::Result] the result of calling `git checkout`
|
|
103
|
+
#
|
|
104
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
105
|
+
#
|
|
106
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
107
|
+
#
|
|
108
|
+
# @api public
|
|
109
|
+
#
|
|
110
|
+
def call(*, **)
|
|
111
|
+
super
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'checkout/branch'
|
|
4
|
+
require_relative 'checkout/files'
|
|
5
|
+
|
|
6
|
+
module Git
|
|
7
|
+
module Commands
|
|
8
|
+
# Commands for switching branches and restoring files via `git checkout`
|
|
9
|
+
#
|
|
10
|
+
# This module contains command classes split by checkout mode:
|
|
11
|
+
#
|
|
12
|
+
# - {Checkout::Branch} — switch branches or create and switch to a new branch
|
|
13
|
+
# - {Checkout::Files} — restore working tree files from a given tree-ish
|
|
14
|
+
#
|
|
15
|
+
# @example Switch to an existing branch
|
|
16
|
+
# cmd = Git::Commands::Checkout::Branch.new(lib)
|
|
17
|
+
# cmd.call('main')
|
|
18
|
+
#
|
|
19
|
+
# @example Create and switch to a new branch
|
|
20
|
+
# cmd = Git::Commands::Checkout::Branch.new(lib)
|
|
21
|
+
# cmd.call('main', b: 'feature/new-feature')
|
|
22
|
+
#
|
|
23
|
+
# @example Restore a file from the index (discard uncommitted changes)
|
|
24
|
+
# cmd = Git::Commands::Checkout::Files.new(lib)
|
|
25
|
+
# cmd.call(pathspec: ['lib/my_file.rb'])
|
|
26
|
+
#
|
|
27
|
+
# @example Restore a file from a specific branch
|
|
28
|
+
# cmd = Git::Commands::Checkout::Files.new(lib)
|
|
29
|
+
# cmd.call('main', pathspec: ['lib/my_file.rb'])
|
|
30
|
+
#
|
|
31
|
+
# @see https://git-scm.com/docs/git-checkout git-checkout documentation
|
|
32
|
+
#
|
|
33
|
+
# @api private
|
|
34
|
+
#
|
|
35
|
+
module Checkout
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|