git 5.6.0 → 6.0.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/CHANGELOG.md +132 -16
- data/CONTRIBUTING.md +44 -31
- data/README.md +135 -67
- data/UPGRADING.md +915 -268
- data/git.gemspec +6 -8
- data/lib/git/author_info.rb +1 -2
- data/lib/git/commands/base.rb +22 -2
- data/lib/git/commands/cat_file/raw.rb +0 -68
- data/lib/git/commands/maintenance/register.rb +0 -4
- data/lib/git/commands/maintenance/run.rb +0 -4
- data/lib/git/commands/maintenance/start.rb +0 -4
- data/lib/git/commands/maintenance/stop.rb +0 -4
- data/lib/git/commands/maintenance/unregister.rb +0 -4
- data/lib/git/commands/maintenance.rb +0 -2
- data/lib/git/commands/show_ref/exclude_existing.rb +1 -1
- data/lib/git/commands/show_ref/exists.rb +0 -5
- data/lib/git/commands/show_ref/list.rb +1 -1
- data/lib/git/commands/show_ref/verify.rb +1 -1
- data/lib/git/commands/show_ref.rb +1 -1
- data/lib/git/commands/worktree/repair.rb +0 -5
- data/lib/git/diff_path_status.rb +2 -2
- data/lib/git/encoding_utils.rb +25 -0
- data/lib/git/errors.rb +23 -5
- data/lib/git/factories.rb +361 -125
- data/lib/git/log.rb +3 -75
- data/lib/git/object.rb +4 -185
- data/lib/git/path_resolver.rb +104 -36
- data/lib/git/repository/branching.rb +21 -189
- data/lib/git/repository/committing.rb +0 -25
- data/lib/git/repository/context_helpers.rb +249 -155
- data/lib/git/repository/diffing.rb +2 -44
- data/lib/git/repository/merging.rb +32 -54
- data/lib/git/repository/object_operations.rb +121 -338
- data/lib/git/repository/remote_operations.rb +7 -219
- data/lib/git/repository/staging.rb +6 -184
- data/lib/git/repository/stashing.rb +126 -130
- data/lib/git/repository/status_operations.rb +1 -54
- data/lib/git/repository/worktree_operations.rb +31 -118
- data/lib/git/repository.rb +20 -299
- data/lib/git/system_call_guard.rb +95 -0
- data/lib/git/version.rb +1 -1
- data/lib/git.rb +47 -364
- metadata +25 -19
- data/lib/git/author.rb +0 -46
- data/lib/git/branch.rb +0 -693
- data/lib/git/branches.rb +0 -194
- data/lib/git/remote.rb +0 -191
- data/lib/git/stash.rb +0 -124
- data/lib/git/stashes.rb +0 -198
- data/lib/git/status.rb +0 -384
- data/lib/git/worktree.rb +0 -180
- data/lib/git/worktrees.rb +0 -152
data/git.gemspec
CHANGED
|
@@ -38,11 +38,12 @@ Gem::Specification.new do |spec|
|
|
|
38
38
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
39
39
|
|
|
40
40
|
spec.require_paths = ['lib']
|
|
41
|
-
spec.required_ruby_version = '>= 3.
|
|
42
|
-
spec.requirements = ['git 2.
|
|
41
|
+
spec.required_ruby_version = '>= 3.3.0'
|
|
42
|
+
spec.requirements = ['git 2.43.0 or greater']
|
|
43
43
|
|
|
44
|
-
spec.add_dependency 'activesupport', '>=
|
|
45
|
-
spec.add_dependency 'addressable', '~> 2.
|
|
44
|
+
spec.add_dependency 'activesupport', '>= 7.0.9'
|
|
45
|
+
spec.add_dependency 'addressable', '~> 2.9'
|
|
46
|
+
spec.add_dependency 'logger', '~> 1.6'
|
|
46
47
|
spec.add_dependency 'process_executer', '~> 4.1'
|
|
47
48
|
spec.add_dependency 'rchardet', '~> 1.9'
|
|
48
49
|
|
|
@@ -74,9 +75,6 @@ Gem::Specification.new do |spec|
|
|
|
74
75
|
# is also a C extension and so could not install on JRuby regardless.
|
|
75
76
|
install_docs = mri
|
|
76
77
|
|
|
77
|
-
# yard-lint requires Ruby >= 3.3.
|
|
78
|
-
install_yard_lint = install_docs && Gem.ruby_version >= Gem::Version.new('3.3.0')
|
|
79
|
-
|
|
80
78
|
# i18n 1.15+ uses Fiber.[] (Ruby 3.2 Fiber storage), which TruffleRuby < 34.0.0 does
|
|
81
79
|
# not implement, so those runtimes hold at the last release that works there.
|
|
82
80
|
pin_old_i18n = RUBY_ENGINE == 'truffleruby' &&
|
|
@@ -98,7 +96,7 @@ Gem::Specification.new do |spec|
|
|
|
98
96
|
spec.add_development_dependency 'simplecov-rspec', '~> 1.1'
|
|
99
97
|
spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.28' if install_docs
|
|
100
98
|
spec.add_development_dependency 'yard_example_test', '~> 0.2', '>= 0.2.1' if install_docs
|
|
101
|
-
spec.add_development_dependency 'yard-lint', '~> 1.8' if
|
|
99
|
+
spec.add_development_dependency 'yard-lint', '~> 1.8' if install_docs
|
|
102
100
|
|
|
103
101
|
# Specify which files should be added to the gem when it is released.
|
|
104
102
|
#
|
data/lib/git/author_info.rb
CHANGED
|
@@ -4,8 +4,7 @@ module Git
|
|
|
4
4
|
# Immutable value object representing an author or committer identity
|
|
5
5
|
#
|
|
6
6
|
# This is a lightweight, immutable data structure holding the identity data
|
|
7
|
-
# git records for commit authors, committers, and taggers.
|
|
8
|
-
# mutable {Git::Author}, which is deprecated.
|
|
7
|
+
# git records for commit authors, committers, and taggers.
|
|
9
8
|
#
|
|
10
9
|
# @example Construct from individual values
|
|
11
10
|
# info = Git::AuthorInfo.new(
|
data/lib/git/commands/base.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'git/commands/arguments'
|
|
4
|
+
require 'git/system_call_guard'
|
|
4
5
|
require 'git/version'
|
|
5
6
|
require 'git/version_constraint'
|
|
6
7
|
|
|
@@ -451,6 +452,10 @@ module Git
|
|
|
451
452
|
# Pass an empty string when the process should receive no input (e.g.
|
|
452
453
|
# when `--batch-all-objects` is used and git enumerates objects itself).
|
|
453
454
|
#
|
|
455
|
+
# Both ends of the pipe are closed by the time this method returns or
|
|
456
|
+
# raises, whether the failure happens in the block, in the writer thread,
|
|
457
|
+
# or before the writer thread can be started.
|
|
458
|
+
#
|
|
454
459
|
# @example Feed bound object names to a git batch command
|
|
455
460
|
# bound = args_definition.bind(*args, **kwargs)
|
|
456
461
|
# stdin_content = Array(bound.object).map { |object| "#{object}\n" }.join
|
|
@@ -462,6 +467,13 @@ module Git
|
|
|
462
467
|
#
|
|
463
468
|
# @return [Object] the value returned by the block
|
|
464
469
|
#
|
|
470
|
+
# @raise [Git::Error] if the pipe cannot be created (for example, when the
|
|
471
|
+
# process is out of file descriptors); the `SystemCallError` is the `cause`
|
|
472
|
+
#
|
|
473
|
+
# @raise [Git::Error] if the writer thread cannot be started (for example,
|
|
474
|
+
# when the process cannot allocate another thread); the `ThreadError` is
|
|
475
|
+
# the `cause`
|
|
476
|
+
#
|
|
465
477
|
# @yield [reader] the read end of the pipe
|
|
466
478
|
#
|
|
467
479
|
# @yieldparam reader [IO] the read end of the pipe; valid only for the
|
|
@@ -470,11 +482,14 @@ module Git
|
|
|
470
482
|
# @yieldreturn [Object] the block's return value, which becomes the method's return value
|
|
471
483
|
#
|
|
472
484
|
def with_stdin(content)
|
|
473
|
-
reader, writer = IO.pipe
|
|
485
|
+
reader, writer = Git::SystemCallGuard.call('Failed to create a pipe for stdin') { IO.pipe }
|
|
474
486
|
writer_thread = start_stdin_writer(content, writer)
|
|
475
487
|
yield reader
|
|
476
488
|
ensure
|
|
477
|
-
reader.close unless reader.closed?
|
|
489
|
+
reader.close unless reader.nil? || reader.closed?
|
|
490
|
+
# The writer thread owns writer and closes it when it finishes. Close it
|
|
491
|
+
# here only when the thread was never started (Thread.new raised).
|
|
492
|
+
writer.close if writer_thread.nil? && !(writer.nil? || writer.closed?)
|
|
478
493
|
writer_thread&.join
|
|
479
494
|
end
|
|
480
495
|
|
|
@@ -488,6 +503,9 @@ module Git
|
|
|
488
503
|
#
|
|
489
504
|
# @return [Thread] thread writing content to the pipe
|
|
490
505
|
#
|
|
506
|
+
# @raise [Git::Error] if the thread cannot be started; the `ThreadError` is
|
|
507
|
+
# the `cause`
|
|
508
|
+
#
|
|
491
509
|
def start_stdin_writer(content, writer)
|
|
492
510
|
Thread.new do
|
|
493
511
|
writer.write(content) unless content.empty?
|
|
@@ -496,6 +514,8 @@ module Git
|
|
|
496
514
|
ensure
|
|
497
515
|
writer.close unless writer.closed?
|
|
498
516
|
end
|
|
517
|
+
rescue ThreadError => e
|
|
518
|
+
raise Git::Error, "Failed to start the stdin writer thread: #{e.message}"
|
|
499
519
|
end
|
|
500
520
|
end
|
|
501
521
|
end
|
|
@@ -49,14 +49,6 @@ module Git
|
|
|
49
49
|
# See https://git-scm.com/docs/git-cat-file#Documentation/git-cat-file.txt--s
|
|
50
50
|
flag_option :s
|
|
51
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
52
|
# Map committer/author identities through the mailmap before reporting size
|
|
61
53
|
# See https://git-scm.com/docs/git-cat-file#Documentation/git-cat-file.txt---use-mailmap
|
|
62
54
|
flag_option :use_mailmap, negatable: true
|
|
@@ -93,13 +85,6 @@ module Git
|
|
|
93
85
|
#
|
|
94
86
|
# @param options [Hash] command options
|
|
95
87
|
#
|
|
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
88
|
# @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
|
|
104
89
|
#
|
|
105
90
|
# @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
|
|
@@ -121,13 +106,6 @@ module Git
|
|
|
121
106
|
#
|
|
122
107
|
# @param options [Hash] command options
|
|
123
108
|
#
|
|
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
109
|
# @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
|
|
132
110
|
#
|
|
133
111
|
# @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
|
|
@@ -149,13 +127,6 @@ module Git
|
|
|
149
127
|
#
|
|
150
128
|
# @param options [Hash] command options
|
|
151
129
|
#
|
|
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
130
|
# @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
|
|
160
131
|
#
|
|
161
132
|
# @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
|
|
@@ -177,13 +148,6 @@ module Git
|
|
|
177
148
|
#
|
|
178
149
|
# @param options [Hash] command options
|
|
179
150
|
#
|
|
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
151
|
# @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
|
|
188
152
|
#
|
|
189
153
|
# @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
|
|
@@ -205,13 +169,6 @@ module Git
|
|
|
205
169
|
#
|
|
206
170
|
# @param options [Hash] command options
|
|
207
171
|
#
|
|
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
172
|
# @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
|
|
216
173
|
#
|
|
217
174
|
# @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
|
|
@@ -228,7 +185,6 @@ module Git
|
|
|
228
185
|
# @option options [Numeric, nil] :timeout (nil) abort the command after this many seconds
|
|
229
186
|
#
|
|
230
187
|
def call(*, **)
|
|
231
|
-
warn_allow_unknown_type_deprecated(**)
|
|
232
188
|
bound = args_definition.bind(*, **)
|
|
233
189
|
validate_version!(bound.execution_options)
|
|
234
190
|
result = execute_command(bound)
|
|
@@ -241,30 +197,6 @@ module Git
|
|
|
241
197
|
|
|
242
198
|
result
|
|
243
199
|
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
200
|
end
|
|
269
201
|
end
|
|
270
202
|
end
|
|
@@ -22,8 +22,6 @@ module Git
|
|
|
22
22
|
# @api private
|
|
23
23
|
#
|
|
24
24
|
class Register < Git::Commands::Base
|
|
25
|
-
requires_git_version '2.30.0'
|
|
26
|
-
|
|
27
25
|
arguments do
|
|
28
26
|
literal 'maintenance'
|
|
29
27
|
literal 'register'
|
|
@@ -65,8 +63,6 @@ module Git
|
|
|
65
63
|
#
|
|
66
64
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
67
65
|
#
|
|
68
|
-
# @raise [Git::VersionError] if git version is below 2.30.0
|
|
69
|
-
#
|
|
70
66
|
# @api public
|
|
71
67
|
def call(*, **)
|
|
72
68
|
super
|
|
@@ -28,8 +28,6 @@ module Git
|
|
|
28
28
|
# @api private
|
|
29
29
|
#
|
|
30
30
|
class Run < Git::Commands::Base
|
|
31
|
-
requires_git_version '2.30.0'
|
|
32
|
-
|
|
33
31
|
arguments do
|
|
34
32
|
literal 'maintenance'
|
|
35
33
|
literal 'run'
|
|
@@ -100,8 +98,6 @@ module Git
|
|
|
100
98
|
#
|
|
101
99
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
102
100
|
#
|
|
103
|
-
# @raise [Git::VersionError] if git version is below 2.30.0
|
|
104
|
-
#
|
|
105
101
|
# @api public
|
|
106
102
|
end
|
|
107
103
|
end
|
|
@@ -22,8 +22,6 @@ module Git
|
|
|
22
22
|
# @api private
|
|
23
23
|
#
|
|
24
24
|
class Start < Git::Commands::Base
|
|
25
|
-
requires_git_version '2.30.0'
|
|
26
|
-
|
|
27
25
|
arguments do
|
|
28
26
|
literal 'maintenance'
|
|
29
27
|
literal 'start'
|
|
@@ -63,8 +61,6 @@ module Git
|
|
|
63
61
|
# @raise [ArgumentError] if unsupported options are provided
|
|
64
62
|
#
|
|
65
63
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
66
|
-
#
|
|
67
|
-
# @raise [Git::VersionError] if git version is below 2.30.0
|
|
68
64
|
end
|
|
69
65
|
end
|
|
70
66
|
end
|
|
@@ -19,8 +19,6 @@ module Git
|
|
|
19
19
|
# @api private
|
|
20
20
|
#
|
|
21
21
|
class Stop < Git::Commands::Base
|
|
22
|
-
requires_git_version '2.30.0'
|
|
23
|
-
|
|
24
22
|
arguments do
|
|
25
23
|
literal 'maintenance'
|
|
26
24
|
literal 'stop'
|
|
@@ -52,8 +50,6 @@ module Git
|
|
|
52
50
|
# @raise [ArgumentError] if unsupported options are provided
|
|
53
51
|
#
|
|
54
52
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
55
|
-
#
|
|
56
|
-
# @raise [Git::VersionError] if git version is below 2.30.0
|
|
57
53
|
end
|
|
58
54
|
end
|
|
59
55
|
end
|
|
@@ -22,8 +22,6 @@ module Git
|
|
|
22
22
|
# @api private
|
|
23
23
|
#
|
|
24
24
|
class Unregister < Git::Commands::Base
|
|
25
|
-
requires_git_version '2.30.0'
|
|
26
|
-
|
|
27
25
|
arguments do
|
|
28
26
|
literal 'maintenance'
|
|
29
27
|
literal 'unregister'
|
|
@@ -75,8 +73,6 @@ module Git
|
|
|
75
73
|
#
|
|
76
74
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
77
75
|
#
|
|
78
|
-
# @raise [Git::VersionError] if git version is below 2.30.0
|
|
79
|
-
#
|
|
80
76
|
# @api public
|
|
81
77
|
end
|
|
82
78
|
end
|
|
@@ -19,8 +19,6 @@ module Git
|
|
|
19
19
|
# - {Maintenance::Register} — add repository to maintenance config
|
|
20
20
|
# - {Maintenance::Unregister} — remove repository from maintenance config
|
|
21
21
|
#
|
|
22
|
-
# All subcommands require Git 2.30.0 or later.
|
|
23
|
-
#
|
|
24
22
|
# @see https://git-scm.com/docs/git-maintenance git-maintenance documentation
|
|
25
23
|
#
|
|
26
24
|
# @api private
|
|
@@ -16,7 +16,7 @@ module Git
|
|
|
16
16
|
#
|
|
17
17
|
# For standard ref listing, use {Git::Commands::ShowRef::List}.
|
|
18
18
|
# For strict per-ref verification, use {Git::Commands::ShowRef::Verify}.
|
|
19
|
-
# For a boolean existence check
|
|
19
|
+
# For a boolean existence check, use {Git::Commands::ShowRef::Exists}.
|
|
20
20
|
#
|
|
21
21
|
# @example Filter refs that do not exist locally
|
|
22
22
|
# cmd = Git::Commands::ShowRef::ExcludeExisting.new(execution_context)
|
|
@@ -25,11 +25,6 @@ module Git
|
|
|
25
25
|
# result = cmd.call('refs/heads/main')
|
|
26
26
|
# result.status.exitstatus # => 0 (exists) or 2 (not found)
|
|
27
27
|
#
|
|
28
|
-
# @note Requires git 2.43 or later
|
|
29
|
-
#
|
|
30
|
-
# Earlier versions do not recognise the `--exists` flag and will exit
|
|
31
|
-
# non-zero with an "unknown option" error.
|
|
32
|
-
#
|
|
33
28
|
# @note `arguments` block audited against https://git-scm.com/docs/git-show-ref/2.53.0
|
|
34
29
|
#
|
|
35
30
|
# @see Git::Commands::ShowRef
|
|
@@ -16,7 +16,7 @@ module Git
|
|
|
16
16
|
#
|
|
17
17
|
# For strict per-ref verification, use {Git::Commands::ShowRef::Verify}.
|
|
18
18
|
# For stdin-based filtering, use {Git::Commands::ShowRef::ExcludeExisting}.
|
|
19
|
-
# For a simple boolean existence check
|
|
19
|
+
# For a simple boolean existence check, use {Git::Commands::ShowRef::Exists}.
|
|
20
20
|
#
|
|
21
21
|
# @example List all refs
|
|
22
22
|
# cmd = Git::Commands::ShowRef::List.new(execution_context)
|
|
@@ -18,7 +18,7 @@ module Git
|
|
|
18
18
|
#
|
|
19
19
|
# For pattern-based listing, use {ShowRef::List}.
|
|
20
20
|
# For stdin-based filtering, use {ShowRef::ExcludeExisting}.
|
|
21
|
-
# For a silent boolean check
|
|
21
|
+
# For a silent boolean check, use {ShowRef::Exists}.
|
|
22
22
|
#
|
|
23
23
|
# @example Verify a single ref
|
|
24
24
|
# cmd = Git::Commands::ShowRef::Verify.new(execution_context)
|
|
@@ -18,7 +18,7 @@ module Git
|
|
|
18
18
|
# - {ShowRef::ExcludeExisting} — stdin-based filter for ref names, excluding
|
|
19
19
|
# refs that already exist in the repository
|
|
20
20
|
# (`git show-ref --exclude-existing[=<pattern>]`)
|
|
21
|
-
# - {ShowRef::Exists} — boolean existence check without output
|
|
21
|
+
# - {ShowRef::Exists} — boolean existence check without output
|
|
22
22
|
# (`git show-ref --exists <ref>`)
|
|
23
23
|
#
|
|
24
24
|
# @example List all refs matching a pattern
|
|
@@ -34,9 +34,6 @@ module Git
|
|
|
34
34
|
operand :path, repeatable: true
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
# git worktree repair was introduced in git 2.29.0
|
|
38
|
-
requires_git_version '2.29.0'
|
|
39
|
-
|
|
40
37
|
# @!method call(*)
|
|
41
38
|
#
|
|
42
39
|
# @overload call(*path, **options)
|
|
@@ -67,8 +64,6 @@ module Git
|
|
|
67
64
|
#
|
|
68
65
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
69
66
|
#
|
|
70
|
-
# @raise [Git::VersionError] if git version is below 2.29.0
|
|
71
|
-
#
|
|
72
67
|
# @api public
|
|
73
68
|
end
|
|
74
69
|
end
|
data/lib/git/diff_path_status.rb
CHANGED
|
@@ -72,12 +72,12 @@ module Git
|
|
|
72
72
|
|
|
73
73
|
private
|
|
74
74
|
|
|
75
|
-
# Lazily fetches and caches the path status from the
|
|
75
|
+
# Lazily fetches and caches the path status from the repository
|
|
76
76
|
#
|
|
77
77
|
# @return [Hash{String => String}] a mapping of file paths to status codes
|
|
78
78
|
#
|
|
79
79
|
def fetch_path_status
|
|
80
|
-
@fetch_path_status ||= @base.
|
|
80
|
+
@fetch_path_status ||= @base.diff_path_status(@from, @to, path_limiter: @path_limiter).to_h
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
# Sets up legacy (base, from, to, path_limiter) instance state
|
data/lib/git/encoding_utils.rb
CHANGED
|
@@ -48,6 +48,13 @@ module Git
|
|
|
48
48
|
|
|
49
49
|
# Returns the given string converted to {Git::EncodingUtils.default_encoding}
|
|
50
50
|
#
|
|
51
|
+
# When the string is not valid in its own encoding, the source encoding is
|
|
52
|
+
# taken from {Git::EncodingUtils.detected_encoding}. rchardet can name an
|
|
53
|
+
# encoding Ruby has no converter for (`UTF-7` and the two unusual-octet-order
|
|
54
|
+
# `UCS-4` forms, each assigned from a byte-order mark). In that case the
|
|
55
|
+
# invalid bytes are replaced with `String#scrub` instead, which keeps any
|
|
56
|
+
# valid multibyte sequences on the same line.
|
|
57
|
+
#
|
|
51
58
|
# @param str [String] the string to normalize
|
|
52
59
|
#
|
|
53
60
|
# @return [String] the original or transcoded string in
|
|
@@ -59,6 +66,24 @@ module Git
|
|
|
59
66
|
return str.encode(default_encoding, str.encoding, **encoding_options) if str.valid_encoding?
|
|
60
67
|
|
|
61
68
|
str.encode(default_encoding, detected_encoding(str), **encoding_options)
|
|
69
|
+
rescue Encoding::ConverterNotFoundError
|
|
70
|
+
scrub_to_default_encoding(str)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Returns the given string with its invalid bytes replaced, in
|
|
74
|
+
# {Git::EncodingUtils.default_encoding}
|
|
75
|
+
#
|
|
76
|
+
# `String#scrub` returns the string in its own encoding, so the result is
|
|
77
|
+
# transcoded afterward. On the gem's own call path the string is already
|
|
78
|
+
# tagged UTF-8 and that step is a no-op.
|
|
79
|
+
#
|
|
80
|
+
# @param str [String] the string to scrub
|
|
81
|
+
#
|
|
82
|
+
# @return [String] the scrubbed string in {Git::EncodingUtils.default_encoding}
|
|
83
|
+
#
|
|
84
|
+
def self.scrub_to_default_encoding(str)
|
|
85
|
+
str.scrub.encode(default_encoding, **encoding_options)
|
|
62
86
|
end
|
|
87
|
+
private_class_method :scrub_to_default_encoding
|
|
63
88
|
end
|
|
64
89
|
end
|
data/lib/git/errors.rb
CHANGED
|
@@ -6,11 +6,21 @@ module Git
|
|
|
6
6
|
# Base class for all custom git module errors
|
|
7
7
|
#
|
|
8
8
|
# The git gem will only raise an `ArgumentError` or an error that is a subclass of
|
|
9
|
-
# `Git::Error`.
|
|
9
|
+
# `Git::Error`.
|
|
10
10
|
#
|
|
11
11
|
# It is recommended to rescue `Git::Error` to catch any runtime error raised by
|
|
12
12
|
# this gem unless you need more specific error handling.
|
|
13
13
|
#
|
|
14
|
+
# Operating system errors from the gem's own filesystem operations, such as
|
|
15
|
+
# reading a `.git` pointer file or creating a temporary file, are raised as
|
|
16
|
+
# `Git::Error`. The original `SystemCallError` is available through `cause`.
|
|
17
|
+
#
|
|
18
|
+
# The promise covers errors the gem raises from its own operations. An error
|
|
19
|
+
# raised by a block your code passes to a method such as `chdir` propagates
|
|
20
|
+
# unchanged, and when `Git::Deprecation.behavior` is `:raise` a deprecated call
|
|
21
|
+
# raises `ActiveSupport::DeprecationException`, which is intentionally not a
|
|
22
|
+
# `Git::Error`.
|
|
23
|
+
#
|
|
14
24
|
# Git's custom errors are arranged in the following class heirarchy:
|
|
15
25
|
#
|
|
16
26
|
# ```text
|
|
@@ -75,12 +85,20 @@ module Git
|
|
|
75
85
|
|
|
76
86
|
# An alias for Git::Error
|
|
77
87
|
#
|
|
78
|
-
# Git::GitExecuteError
|
|
79
|
-
# compatibility. It is
|
|
88
|
+
# Git::GitExecuteError is an alias for Git::Error kept for backwards
|
|
89
|
+
# compatibility. It is an ActiveSupport::Deprecation::DeprecatedConstantProxy,
|
|
90
|
+
# so any use of it, including instantiating it and matching it in a `rescue`
|
|
91
|
+
# clause, emits a deprecation warning through Git::Deprecation. The
|
|
92
|
+
# reflective methods that debuggers and IRB call, such as `inspect` and
|
|
93
|
+
# `name`, do not warn. It will be removed in a future major release.
|
|
80
94
|
#
|
|
81
|
-
# @deprecated Use Git::Error instead
|
|
95
|
+
# @deprecated Use Git::Error instead. Will be removed in a future major release.
|
|
82
96
|
#
|
|
83
|
-
GitExecuteError = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(
|
|
97
|
+
GitExecuteError = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(
|
|
98
|
+
'Git::GitExecuteError', 'Git::Error', Git::Deprecation,
|
|
99
|
+
message: 'Git::GitExecuteError is deprecated and will be removed in a future major release. ' \
|
|
100
|
+
'Use Git::Error instead.'
|
|
101
|
+
)
|
|
84
102
|
|
|
85
103
|
# Raised when a git command fails or exits because of an uncaught signal
|
|
86
104
|
#
|