git 5.6.0 → 5.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb847c9e15258e66f25f6856a2ceb170213e9ae310d061035ef23501e6e0cd72
4
- data.tar.gz: eca3a73ec5bf9f979d4576375062ceaeb71a78b54f12660b3b4386c2920792e9
3
+ metadata.gz: a20c2b714fc915052748e7cf91d24aa45c7b65a6e6dfd61bab53ecac6852fba2
4
+ data.tar.gz: 6aa30cf77186f3640ca8429f9e70c406491aa6fde53b86e17510396955334cfc
5
5
  SHA512:
6
- metadata.gz: 3842eadabba8c7bead2147b438ca51597ca0acc129b7d33b41f942750d29cb7e5910b1ca92e3f50cf7bc440afb9f5ed203a97f38b72c19b09025f4e7317849f2
7
- data.tar.gz: 558adf7d3f23639b9143dcf3b9092739caba6415e066a8273f491f0589f3af06851dc15fd1776b2bad3e406d01429da76cce72c7e05f3c7ac57858bc3a771645
6
+ metadata.gz: f3534d942286512f6f7c10bb00359a55529f9d6823733e642d4faa720f25ae8fc30bfac69f51974aa37c64d268afa67826befc8cd3c43262137d0226d2bbd15a
7
+ data.tar.gz: 4b4da1ad058003d82334ffe2bea0c6424b348886cd6dceb696b18e2fa68c256d1f818bbc97ea29d7c510bf735423ab93dd9831ce9ff4d07a68b501f5ac21bdf0
data/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## [5.7.1](https://github.com/ruby-git/ruby-git/compare/v5.7.0...v5.7.1) (2026-10-28)
9
+
10
+
11
+ ### Other Changes
12
+
13
+ * Name the release that starts warning for the renamed aliases ([e5d6537](https://github.com/ruby-git/ruby-git/commit/e5d6537ad65395a6075ee6cb00718c94cd915036)), closes [#1923](https://github.com/ruby-git/ruby-git/issues/1923)
14
+
15
+ ## [5.7.0](https://github.com/ruby-git/ruby-git/compare/v5.6.1...v5.7.0) (2026-10-28)
16
+
17
+
18
+ ### Features
19
+
20
+ * **repository:** Deprecate the eight renamed facade aliases with warnings that name v6.0.0 ([8339117](https://github.com/ruby-git/ruby-git/commit/8339117e9fff5a1acadea73b4ccd385a5b0f1497)), closes [#1923](https://github.com/ruby-git/ruby-git/issues/1923) [#1924](https://github.com/ruby-git/ruby-git/issues/1924)
21
+
22
+ ## [5.6.1](https://github.com/ruby-git/ruby-git/compare/v5.6.0...v5.6.1) (2026-09-16)
23
+
24
+
25
+ ### Other Changes
26
+
27
+ * **errors:** Document that filesystem and gzip errors can escape unconverted ([0b171e4](https://github.com/ruby-git/ruby-git/commit/0b171e42713a884354a84138696102f8e3cd83e5)), closes [#1809](https://github.com/ruby-git/ruby-git/issues/1809)
28
+ * **remote:** Correct the argument forms in the Git::Remote and Git::Branch entries ([cea622a](https://github.com/ruby-git/ruby-git/commit/cea622a14cce54a90c2203953a457b13b298aa22)), closes [#1852](https://github.com/ruby-git/ruby-git/issues/1852)
29
+ * **tag:** Note that tag_create raises UnexpectedResultError in v6.0.0 ([050aa44](https://github.com/ruby-git/ruby-git/commit/050aa443136156d7ecab47ad6fb44f436d9c2b7f)), closes [#1856](https://github.com/ruby-git/ruby-git/issues/1856)
30
+ * **worktree:** Look the new worktree up with File.identical? in the v5.x note ([0c941ec](https://github.com/ruby-git/ruby-git/commit/0c941ec34204ef5c3aeb6cf1de9e61f33212a0d9))
31
+ * **worktree:** Look the new worktree up with File.identical? in the YARD note ([8eb10ec](https://github.com/ruby-git/ruby-git/commit/8eb10eccb50ff14911e09033cfeec33666ce5c6a)), closes [#1845](https://github.com/ruby-git/ruby-git/issues/1845)
32
+ * **worktree:** Note that worktree_add returns Git::WorktreeInfo in v6.0.0 ([24af07e](https://github.com/ruby-git/ruby-git/commit/24af07e24199303727d823804063732fcaa98c98)), closes [#1845](https://github.com/ruby-git/ruby-git/issues/1845)
33
+
8
34
  ## [5.6.0](https://github.com/ruby-git/ruby-git/compare/v5.5.0...v5.6.0) (2026-09-12)
9
35
 
10
36
 
data/README.md CHANGED
@@ -201,11 +201,41 @@ the full API of its result.
201
201
 
202
202
  ## Errors raised by this gem
203
203
 
204
- The git gem raises only `ArgumentError` or errors that subclass `Git::Error`. It
205
- does not explicitly raise any other types of errors.
206
-
207
- Rescue `Git::Error` to catch any runtime error raised by this gem, unless you need
208
- more specific error handling.
204
+ Errors the git gem raises deliberately are either `ArgumentError` or a subclass of
205
+ `Git::Error`, with one exception: with the `raise` behavior described under
206
+ [Deprecations](#deprecations), a deprecated call raises
207
+ `ActiveSupport::DeprecationException`, which is intentionally not a `Git::Error` so a
208
+ broad rescue cannot hide a deprecation your code opted to treat as fatal. The errors
209
+ described below come from Ruby's standard library and are not converted.
210
+
211
+ The gem's own filesystem operations, such as reading a `.git` pointer file,
212
+ creating a temporary file, or changing directory, do not convert operating system
213
+ errors. These can be raised as a bare `SystemCallError` (for example `Errno::ENOENT`
214
+ or `Errno::EACCES`) rather than `Git::Error`. Gzip compression in `archive` can
215
+ likewise raise a `Zlib::Error`. Rescue `SystemCallError` and `Zlib::Error` alongside
216
+ `Git::Error` if your code needs to handle them.
217
+
218
+ The affected methods are `Git.open` when the `.git` file is a gitdir pointer or the
219
+ path is relative, `Git.init`, `Git.bare`, and `Git.clone` when the path is relative,
220
+ `Git.export`, and these `Git::Repository` methods: `#chdir`, `#with_index`,
221
+ `#with_working`, `#with_temp_index`, `#with_temp_working`, `#set_index`,
222
+ `#set_working`, `#cat_file_contents` in block form, `#each_conflict`, `#conflicts`,
223
+ `#archive` (including the gzip step), `#repo_size`, and `#tag_sha` when it reads a
224
+ loose ref.
225
+
226
+ Any method that captures git output can also raise
227
+ `Encoding::ConverterNotFoundError` when the output contains a line whose detected
228
+ encoding, such as UTF-7, has no Ruby converter.
229
+
230
+ Starting with v6.0.0, the filesystem and gzip errors are raised as `Git::Error`
231
+ with the original error available through `cause`, except that `#tag_sha` falls
232
+ back to `git show-ref` instead of raising. Lines with no Ruby converter are
233
+ scrubbed instead of raising.
234
+
235
+ Rescue `Git::Error` to catch the runtime errors this gem raises itself, and add
236
+ `SystemCallError`, `Zlib::Error`, and `Encoding::ConverterNotFoundError` where the
237
+ paragraphs above say they can escape. Rescue a more specific subclass when you need
238
+ finer-grained handling.
209
239
 
210
240
  ```ruby
211
241
  begin
data/UPGRADING.md CHANGED
@@ -17,6 +17,7 @@ to update your code when upgrading from the preceding major version.
17
17
  - [Deprecated methods](#deprecated-methods)
18
18
  - [Facade method renames](#facade-method-renames)
19
19
  - [`Git::Repository` method renames](#gitrepository-method-renames)
20
+ - [`Git::Repository` alias renames](#gitrepository-alias-renames)
20
21
  - [`Git::Repository` option renames](#gitrepository-option-renames)
21
22
  - [v4.x-style configuration methods](#v4x-style-configuration-methods)
22
23
  - [`Git` module mixin deprecations](#git-module-mixin-deprecations)
@@ -395,6 +396,28 @@ replacement returns, except `branches_all`.
395
396
  | `g.is_branch?(name)` | `g.branch?(name)` |
396
397
  | `g.branches_all` | `g.branch_list` — returns `Array<Git::BranchInfo>`; see the return shape change above |
397
398
 
399
+ #### `Git::Repository` alias renames
400
+
401
+ Eight `Git::Repository` methods have a second, older name carried over from v4.x.
402
+ Releases before v5.7.0 kept the older names as aliases with no warning. From
403
+ v5.7.0 on, each old name emits a deprecation warning. Each old name takes the
404
+ same arguments and returns exactly what its replacement returns.
405
+
406
+ > **`diff_name_status`:** a `:path` option emits its own deprecation warning
407
+ > after the method-name warning. Pass `:path_limiter` instead, as described
408
+ > under [`Git::Repository` option renames](#gitrepository-option-renames) below.
409
+
410
+ | Deprecated call (works in v5.x, removed in v6.0.0) | Replacement |
411
+ |-----------------------------------------------------|-------------|
412
+ | `g.object_contents(object)` | `g.cat_file_contents(object)` |
413
+ | `g.object_size(object)` | `g.cat_file_size(object)` |
414
+ | `g.object_type(object)` | `g.cat_file_type(object)` |
415
+ | `g.commit_data(object)` | `g.cat_file_commit(object)` |
416
+ | `g.tag_data(object)` | `g.cat_file_tag(object)` |
417
+ | `g.revparse(objectish)` | `g.rev_parse(objectish)` |
418
+ | `g.namerev(commit_ish)` | `g.name_rev(commit_ish)` |
419
+ | `g.diff_name_status(from, to, opts)` | `g.diff_path_status(from, to, opts)` |
420
+
398
421
  #### `Git::Repository` option renames
399
422
 
400
423
  Five methods accept a v4.x option or positional argument under its old name.
@@ -637,7 +660,8 @@ with N remotes produces N + 1 warnings per call.
637
660
  > the last one configured, so use `r.url.last` to reproduce that exact value.
638
661
  > Likewise, `Git::Remote#fetch_opts` returned only the last configured fetch
639
662
  > refspec, while `fetch` holds all of them. Operations that lived on
640
- > `Git::Remote` are called on the repository with the remote name instead.
663
+ > `Git::Remote` are called on the repository instead; the table below shows
664
+ > the argument each one takes.
641
665
  >
642
666
  > **Order change:** `remotes` lists remotes in the order `git remote` prints
643
667
  > them, while `remote_list` keeps the order in which remotes first appear in the
@@ -656,8 +680,8 @@ with N remotes produces N + 1 warnings per call.
656
680
  | `remote.fetch(opts)` | `g.fetch(remote.name, opts)` — same options hash |
657
681
  | `remote.merge` | `g.merge("#{remote.name}/#{g.current_branch}")` |
658
682
  | `remote.merge(branch)` | `g.merge("#{remote.name}/#{branch}")` |
659
- | `remote.branch` | `g.branch_list("#{remote.name}/#{g.current_branch}").first` — returns a `Git::BranchInfo` |
660
- | `remote.branch(name)` | `g.branch_list("#{remote.name}/#{name}").first` — returns a `Git::BranchInfo` |
683
+ | `remote.branch` | `g.branch_list("#{remote.name}/#{g.current_branch}").find(&:remote?)` — returns a `Git::BranchInfo` |
684
+ | `remote.branch(name)` | `g.branch_list("#{remote.name}/#{name}").find(&:remote?)` — returns a `Git::BranchInfo` |
661
685
  | `remote.remove` | `g.remote_remove(remote.name)` |
662
686
 
663
687
  #### `Git::Remote` deprecated
@@ -665,13 +689,13 @@ with N remotes produces N + 1 warnings per call.
665
689
  `Git::Remote`, `Git::Repository#remote`, and `Git::Repository#config_remote` are
666
690
  deprecated and are removed in v6.0.0. Read a remote's configuration through
667
691
  `Git::Repository#remote_list`, which returns one `Git::RemoteInfo` value object per
668
- remote, and call the repository-level operations (`fetch`, `merge`, `branch_list`,
669
- `remote_remove`) with the remote name. Return values are unchanged. Constructing a
670
- `Git::Remote` directly emits one deprecation warning, and so does calling
671
- `g.config_remote`. Calling `g.remote` emits two: one for `Git::Repository#remote`
672
- and one for the `Git::Remote` it constructs. Likewise `g.remotes` emits one warning
673
- for itself plus one per `Git::Remote` it returns (N + 1 for N remotes). The extra
674
- warnings from `g.remote` and `g.remotes` are expected, not a bug.
692
+ remote; the table below shows the replacement for each operation. Return values
693
+ are unchanged. Constructing a `Git::Remote` directly emits one deprecation warning,
694
+ and so does calling `g.config_remote`. Calling `g.remote` emits two: one for
695
+ `Git::Repository#remote` and one for the `Git::Remote` it constructs. Likewise
696
+ `g.remotes` emits one warning for itself plus one per `Git::Remote` it returns
697
+ (N + 1 for N remotes). The extra warnings from `g.remote` and `g.remotes` are
698
+ expected, not a bug.
675
699
 
676
700
  > **Return type changes:** `Git::RemoteInfo#url` and `Git::RemoteInfo#fetch` are
677
701
  > frozen `Array<String>` because a remote may carry more than one URL or fetch
@@ -686,8 +710,9 @@ warnings from `g.remote` and `g.remotes` are expected, not a bug.
686
710
  > Code that reads custom keys should filter `g.config_list` instead (see the
687
711
  > table); that yields the same `Hash{String => String}` as `config_remote`.
688
712
  > `Git::Remote#branch` returned a `Git::Branch`. Its replacement,
689
- > `g.branch_list("#{name}/#{branch}").first`, returns a `Git::BranchInfo` value
690
- > object, or `nil` when the remote-tracking branch does not exist.
713
+ > `g.branch_list("#{name}/#{branch}").find(&:remote?)`, returns a
714
+ > `Git::BranchInfo` value object, or `nil` when the remote-tracking branch does
715
+ > not exist.
691
716
 
692
717
  In the table, `name` is the remote name (`g.remote` defaults it to `'origin'`).
693
718
 
@@ -704,8 +729,8 @@ In the table, `name` is the remote name (`g.remote` defaults it to `'origin'`).
704
729
  | `remote.fetch(opts)` | `g.fetch(name, opts)` — same option keys |
705
730
  | `remote.merge` | `g.merge("#{name}/#{g.current_branch}")` |
706
731
  | `remote.merge(branch)` | `g.merge("#{name}/#{branch}")` |
707
- | `remote.branch` | `g.branch_list("#{name}/#{g.current_branch}").first` — returns a `Git::BranchInfo` |
708
- | `remote.branch(branch)` | `g.branch_list("#{name}/#{branch}").first` — returns a `Git::BranchInfo` |
732
+ | `remote.branch` | `g.branch_list("#{name}/#{g.current_branch}").find(&:remote?)` — returns a `Git::BranchInfo` |
733
+ | `remote.branch(branch)` | `g.branch_list("#{name}/#{branch}").find(&:remote?)` — returns a `Git::BranchInfo` |
709
734
  | `remote.remove` | `g.remote_remove(name)` |
710
735
 
711
736
  #### `Git::Commands::CatFile::Raw` `allow_unknown_type` option deprecated
@@ -735,10 +760,12 @@ that constructs the command class directly is affected.
735
760
  data through `Git::Repository#branch_list`, which returns one `Git::BranchInfo`
736
761
  value object per local and remote-tracking branch, and call the repository-level
737
762
  operations (`checkout`, `branch_new`, `branch_delete`, `merge`, `merge_into`,
738
- `in_branch`, and so on) with the branch name. Calling `g.branch` or `g.branches`,
739
- constructing a `Git::Branches`, and calling any operation on a `Git::Branch` each
740
- emit a deprecation warning; their return values are unchanged. The `full`,
741
- `name`, `remote`, `to_s`, and `to_a` readers on `Git::Branch` do not warn.
763
+ `in_branch`, and so on) with the branch name. For a remote-tracking branch the
764
+ argument differs by operation; the table below shows the form each one takes.
765
+ Calling `g.branch` or `g.branches`, constructing a `Git::Branches`, and calling
766
+ any operation on a `Git::Branch` each emit a deprecation warning; their return
767
+ values are unchanged. The `full`, `name`, `remote`, `to_s`, and `to_a` readers
768
+ on `Git::Branch` do not warn.
742
769
 
743
770
  > **Return shape change:** `Git::Branch` exposes `full` (`main` or
744
771
  > `remotes/origin/main`), `name`, and `remote` (a `Git::Remote`, or `nil`).
@@ -863,6 +890,13 @@ warn.
863
890
  > **Missing tags:** `g.tag(name)` raises `Git::UnexpectedResultError` when no tag
864
891
  > has that name. `g.tag_list(name).first` returns `nil`.
865
892
  >
893
+ > **`tag_create` when the new tag is missing in v6.0.0:** on v5.x, `g.tag_create`
894
+ > returns `nil` when the tag it has just created is missing from the tag list
895
+ > (for example, another process deleted it before the lookup). In v6.0.0 it
896
+ > raises `Git::UnexpectedResultError` instead, so its return value is always a
897
+ > `Git::TagInfo`. A `nil` check on the result keeps working today and becomes
898
+ > unreachable in v6.0.0.
899
+ >
866
900
  > **Deleting through `tag_add`:** `g.tag_add(name, d: true)`, which was already
867
901
  > deprecated, deletes the tag and emits a second warning pointing at
868
902
  > `g.tag_delete`. `g.tag_create` rejects `:d` and `:delete` with `ArgumentError`.
@@ -1009,7 +1043,7 @@ and are removed in v6.0.0. Read worktree data through
1009
1043
  object per worktree, and call the repository-level operations (`worktree_add`,
1010
1044
  `worktree_remove`, `worktree_move`, `worktree_lock`, `worktree_unlock`,
1011
1045
  `worktree_repair`, and `worktree_prune`) with the worktree path or its
1012
- `Git::WorktreeInfo`. Return values are unchanged. Calling `g.worktree`,
1046
+ `Git::WorktreeInfo`. Return values are unchanged on v5.x. Calling `g.worktree`,
1013
1047
  `g.worktrees`, or `g.worktrees_all`, constructing a `Git::Worktrees`, and calling
1014
1048
  `gcommit`, `add`, or `remove` on a `Git::Worktree` each emit a deprecation
1015
1049
  warning; the `dir`, `full`, `to_s`, and `to_a` readers on `Git::Worktree` do not.
@@ -1035,6 +1069,14 @@ it constructs, and `g.worktree(dir).add` emits one for `g.worktree` and one for
1035
1069
  > **`full` and `to_s`:** `Git::Worktree#full` and `#to_s` append the commitish
1036
1070
  > given at construction to the path, so entries from `g.worktrees` read
1037
1071
  > `"/path/to/wt <sha>"`. `Git::WorktreeInfo#to_s` is the path alone.
1072
+ >
1073
+ > **`worktree_add` return type in v6.0.0:** on v5.x, `worktree_add` returns the
1074
+ > `git worktree add` output (`"HEAD is now at …"`). In v6.0.0 it returns the new
1075
+ > `Git::WorktreeInfo` instead. To get the entry today, look it up after the add:
1076
+ > `g.worktree_list.find { |w| File.identical?(w.path, dir) }`. Compare with
1077
+ > `File.identical?`, not string equality: git stores worktree paths with
1078
+ > symlinks resolved, so `/tmp/...` on macOS is listed as `/private/tmp/...`,
1079
+ > and on case-insensitive filesystems the listed casing may differ from `dir`.
1038
1080
 
1039
1081
  In the table, `dir` is the worktree path, `wt` is a `Git::Worktree`, and `info`
1040
1082
  is the `Git::WorktreeInfo` that replaces it.
@@ -77,7 +77,7 @@ module Git
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.diff_name_status(@from, @to, path_limiter: @path_limiter).to_h
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/errors.rb CHANGED
@@ -5,8 +5,20 @@ module Git
5
5
 
6
6
  # Base class for all custom git module errors
7
7
  #
8
- # The git gem will only raise an `ArgumentError` or an error that is a subclass of
9
- # `Git::Error`. It does not explicitly raise any other types of errors.
8
+ # Errors the git gem raises deliberately are either `ArgumentError` or a subclass
9
+ # of `Git::Error`. The exceptions described below come from Ruby's standard
10
+ # library and are not converted.
11
+ #
12
+ # The gem's own filesystem operations, such as reading a `.git` pointer file,
13
+ # creating a temporary file, or changing directory, do not convert operating
14
+ # system errors. These can be raised as a bare `SystemCallError` (for example
15
+ # `Errno::ENOENT` or `Errno::EACCES`) rather than `Git::Error`. Gzip compression
16
+ # in `archive` can likewise raise a `Zlib::Error`. Rescue `SystemCallError` and
17
+ # `Zlib::Error` alongside `Git::Error` if your code needs to handle them. Any
18
+ # method that captures git output can also raise
19
+ # `Encoding::ConverterNotFoundError` when a line's detected encoding has no Ruby
20
+ # converter. See the "Errors raised by this gem" section of the README for the
21
+ # affected methods.
10
22
  #
11
23
  # It is recommended to rescue `Git::Error` to catch any runtime error raised by
12
24
  # this gem unless you need more specific error handling.
@@ -373,14 +373,42 @@ module Git
373
373
  Git::DiffPathStatus.new(Private.extract_name_status_from_raw(result.stdout))
374
374
  end
375
375
 
376
- # Alias for {#diff_path_status}; provided for backward compatibility
376
+ # Reports each changed path with its status (deprecated name for {#diff_path_status})
377
+ #
378
+ # @example Report path statuses between HEAD and the working tree
379
+ # repo.diff_name_status.to_h #=> { "lib/foo.rb" => "M" }
380
+ #
381
+ # @param from [String, nil] the first commit or object to compare
382
+ #
383
+ # @param to [String, nil] the second commit or object to compare
384
+ #
385
+ # @param opts [Hash] the options accepted by {#diff_path_status}
386
+ #
387
+ # @option opts [String, Pathname, Array<String, Pathname>, nil] :path_limiter (nil)
388
+ # limit the status report to the given path(s)
389
+ #
390
+ # @option opts [String, Pathname, Array<String, Pathname>, nil] :path (nil)
391
+ # **deprecated** — use `:path_limiter` instead
377
392
  #
378
393
  # @return [Git::DiffPathStatus] the name-status report for the comparison
379
394
  #
380
- # @deprecated Use {#diff_path_status} instead
395
+ # @raise [ArgumentError] if unsupported options are provided
396
+ #
397
+ # @raise [ArgumentError] if `from` is `nil` but `to` is not OR if `from` or `to` starts with `"-"`
398
+ #
399
+ # @raise [Git::FailedError] if git exits outside the allowed range (exit code > 2)
400
+ #
401
+ # @deprecated Use {#diff_path_status} instead. Will be removed in v6.0.0.
381
402
  #
382
403
  # @see #diff_path_status
383
- alias diff_name_status diff_path_status
404
+ #
405
+ def diff_name_status(from = 'HEAD', to = nil, opts = {})
406
+ Git::Deprecation.warn(
407
+ 'Git::Repository#diff_name_status is deprecated and will be removed in v6.0.0. ' \
408
+ 'Use Git::Repository#diff_path_status instead.'
409
+ )
410
+ diff_path_status(from, to, opts)
411
+ end
384
412
 
385
413
  # Compares the index and the working directory
386
414
  #
@@ -89,17 +89,57 @@ module Git
89
89
  end
90
90
  end
91
91
 
92
- # Alias for {#cat_file_contents}; retained for backward compatibility
92
+ # Alias for {#cat_file_contents}; kept as a legacy name and not scheduled
93
+ # for removal
93
94
  #
94
95
  # @see #cat_file_contents
95
96
  alias cat_file cat_file_contents
96
97
 
97
- # Alias for {#cat_file_contents}
98
+ # Returns the raw contents of a git object (deprecated name for {#cat_file_contents})
98
99
  #
99
- # @deprecated Use {#cat_file_contents} instead
100
+ # @overload object_contents(object)
101
+ # Returns the object's raw content as a string
102
+ #
103
+ # @example Read a blob's contents
104
+ # repo.object_contents('HEAD:README.md') #=> "# My Project\n"
105
+ #
106
+ # @param object [String] the object name (SHA, ref, `HEAD`, treeish path, etc.)
107
+ #
108
+ # @return [String] the raw content of the object
109
+ #
110
+ # @overload object_contents(object, &block)
111
+ # Streams the object's raw content to a temporary file and yields it
112
+ #
113
+ # @example Read a large blob without buffering it in memory
114
+ # repo.object_contents('HEAD:large_file.bin') { |f| process(f) }
115
+ #
116
+ # @param object [String] the object name (SHA, ref, `HEAD`, treeish path, etc.)
117
+ #
118
+ # @yield [file] the temporary file containing the streamed content,
119
+ # positioned at the start
120
+ #
121
+ # @yieldparam file [File] readable `IO` object positioned at the beginning
122
+ # of the content
123
+ #
124
+ # @yieldreturn [Object] the value to return from this method
125
+ #
126
+ # @return [Object] the value returned by the block
127
+ #
128
+ # @raise [ArgumentError] if `object` starts with a hyphen
129
+ #
130
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
131
+ #
132
+ # @deprecated Use {#cat_file_contents} instead. Will be removed in v6.0.0.
100
133
  #
101
134
  # @see #cat_file_contents
102
- alias object_contents cat_file_contents
135
+ #
136
+ def object_contents(object, &)
137
+ Git::Deprecation.warn(
138
+ 'Git::Repository#object_contents is deprecated and will be removed in v6.0.0. ' \
139
+ 'Use Git::Repository#cat_file_contents instead.'
140
+ )
141
+ cat_file_contents(object, &)
142
+ end
103
143
 
104
144
  # Returns the size of a git object in bytes
105
145
  #
@@ -125,12 +165,30 @@ module Git
125
165
  Git::Commands::CatFile::Raw.new(@execution_context).call(object, s: true).stdout.chomp.to_i
126
166
  end
127
167
 
128
- # Alias for {#cat_file_size}
168
+ # Returns the size of a git object in bytes (deprecated name for {#cat_file_size})
169
+ #
170
+ # @example Get the size of a commit object
171
+ # repo.object_size('HEAD') #=> 265
172
+ #
173
+ # @param object [String] the object name (SHA, ref, `HEAD`, treeish path, etc.)
174
+ #
175
+ # @return [Integer] the size of the object in bytes
176
+ #
177
+ # @raise [ArgumentError] if `object` starts with a hyphen
178
+ #
179
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
129
180
  #
130
- # @deprecated Use {#cat_file_size} instead
181
+ # @deprecated Use {#cat_file_size} instead. Will be removed in v6.0.0.
131
182
  #
132
183
  # @see #cat_file_size
133
- alias object_size cat_file_size
184
+ #
185
+ def object_size(object)
186
+ Git::Deprecation.warn(
187
+ 'Git::Repository#object_size is deprecated and will be removed in v6.0.0. ' \
188
+ 'Use Git::Repository#cat_file_size instead.'
189
+ )
190
+ cat_file_size(object)
191
+ end
134
192
 
135
193
  # Returns the type of a git object
136
194
  #
@@ -157,12 +215,30 @@ module Git
157
215
  Git::Commands::CatFile::Raw.new(@execution_context).call(object, t: true).stdout.chomp
158
216
  end
159
217
 
160
- # Alias for {#cat_file_type}
218
+ # Returns the type of a git object (deprecated name for {#cat_file_type})
219
+ #
220
+ # @example Get the type of HEAD
221
+ # repo.object_type('HEAD') #=> "commit"
222
+ #
223
+ # @param object [String] the object name (SHA, ref, `HEAD`, treeish path, etc.)
224
+ #
225
+ # @return [String] the object type: `"blob"`, `"tree"`, `"commit"`, or `"tag"`
226
+ #
227
+ # @raise [ArgumentError] if `object` starts with a hyphen
228
+ #
229
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
161
230
  #
162
- # @deprecated Use {#cat_file_type} instead
231
+ # @deprecated Use {#cat_file_type} instead. Will be removed in v6.0.0.
163
232
  #
164
233
  # @see #cat_file_type
165
- alias object_type cat_file_type
234
+ #
235
+ def object_type(object)
236
+ Git::Deprecation.warn(
237
+ 'Git::Repository#object_type is deprecated and will be removed in v6.0.0. ' \
238
+ 'Use Git::Repository#cat_file_type instead.'
239
+ )
240
+ cat_file_type(object)
241
+ end
166
242
 
167
243
  # Returns parsed commit data for the given git object
168
244
  #
@@ -200,12 +276,28 @@ module Git
200
276
  Git::Parsers::CatFile.parse_commit(result.stdout.split("\n"), object)
201
277
  end
202
278
 
203
- # Alias for {#cat_file_commit}
279
+ # Returns parsed commit data for a git object (deprecated name for {#cat_file_commit})
280
+ #
281
+ # @example Get commit data for HEAD
282
+ # repo.commit_data('HEAD')
283
+ #
284
+ # @param object [String] the commit name (SHA, ref, `HEAD`, etc.)
204
285
  #
205
- # @deprecated Use {#cat_file_commit} instead
286
+ # @return [Hash] the parsed commit data; see {#cat_file_commit} for the keys
287
+ #
288
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
289
+ #
290
+ # @deprecated Use {#cat_file_commit} instead. Will be removed in v6.0.0.
206
291
  #
207
292
  # @see #cat_file_commit
208
- alias commit_data cat_file_commit
293
+ #
294
+ def commit_data(object)
295
+ Git::Deprecation.warn(
296
+ 'Git::Repository#commit_data is deprecated and will be removed in v6.0.0. ' \
297
+ 'Use Git::Repository#cat_file_commit instead.'
298
+ )
299
+ cat_file_commit(object)
300
+ end
209
301
 
210
302
  # Returns parsed tag data for the given annotated tag object
211
303
  #
@@ -256,12 +348,30 @@ module Git
256
348
  Git::Parsers::CatFile.parse_tag(tdata, object)
257
349
  end
258
350
 
259
- # Alias for {#cat_file_tag}
351
+ # Returns parsed tag data for an annotated tag (deprecated name for {#cat_file_tag})
352
+ #
353
+ # @example Get tag data for an annotated tag
354
+ # repo.tag_data('v1.0.0')
355
+ #
356
+ # @param object [String] the tag name or SHA of the annotated tag object
260
357
  #
261
- # @deprecated Use {#cat_file_tag} instead
358
+ # @return [Hash] the parsed tag data; see {#cat_file_tag} for the keys
359
+ #
360
+ # @raise [ArgumentError] if `object` starts with a hyphen
361
+ #
362
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
363
+ #
364
+ # @deprecated Use {#cat_file_tag} instead. Will be removed in v6.0.0.
262
365
  #
263
366
  # @see #cat_file_tag
264
- alias tag_data cat_file_tag
367
+ #
368
+ def tag_data(object)
369
+ Git::Deprecation.warn(
370
+ 'Git::Repository#tag_data is deprecated and will be removed in v6.0.0. ' \
371
+ 'Use Git::Repository#cat_file_tag instead.'
372
+ )
373
+ cat_file_tag(object)
374
+ end
265
375
 
266
376
  # Resolve a revision specifier to its full object ID
267
377
  #
@@ -292,7 +402,29 @@ module Git
292
402
  Git::Commands::RevParse.new(@execution_context).call(objectish, '--', revs_only: true).stdout
293
403
  end
294
404
 
295
- alias revparse rev_parse
405
+ # Resolves a revision specifier to its full object ID (deprecated name for {#rev_parse})
406
+ #
407
+ # @example Resolve HEAD to its SHA
408
+ # repo.revparse('HEAD') #=> "9b9b31e704c0b85ffdd8d2af2ded85170a5af87d"
409
+ #
410
+ # @param objectish [String] the revision specifier to resolve (branch name,
411
+ # tag, abbreviated SHA, refspec, etc.)
412
+ #
413
+ # @return [String] the full object ID of the resolved object
414
+ #
415
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
416
+ #
417
+ # @deprecated Use {#rev_parse} instead. Will be removed in v6.0.0.
418
+ #
419
+ # @see #rev_parse
420
+ #
421
+ def revparse(objectish)
422
+ Git::Deprecation.warn(
423
+ 'Git::Repository#revparse is deprecated and will be removed in v6.0.0. ' \
424
+ 'Use Git::Repository#rev_parse instead.'
425
+ )
426
+ rev_parse(objectish)
427
+ end
296
428
 
297
429
  # Returns the SHA of a named tag
298
430
  #
@@ -395,12 +527,30 @@ module Git
395
527
  Git::Commands::NameRev.new(@execution_context).call(commit_ish).stdout.split[1]
396
528
  end
397
529
 
398
- # Alias for {#name_rev}
530
+ # Finds a symbolic name for a commit (deprecated name for {#name_rev})
531
+ #
532
+ # @example Name the current commit
533
+ # repo.namerev('HEAD') #=> "main"
534
+ #
535
+ # @param commit_ish [String] the commit to name (SHA, ref, `HEAD`, etc.)
536
+ #
537
+ # @return [String, nil] the symbolic name, or `nil` if git finds none
399
538
  #
400
- # @deprecated Use {#name_rev} instead
539
+ # @raise [ArgumentError] if commit_ish starts with a hyphen
540
+ #
541
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
542
+ #
543
+ # @deprecated Use {#name_rev} instead. Will be removed in v6.0.0.
401
544
  #
402
545
  # @see #name_rev
403
- alias namerev name_rev
546
+ #
547
+ def namerev(commit_ish)
548
+ Git::Deprecation.warn(
549
+ 'Git::Repository#namerev is deprecated and will be removed in v6.0.0. ' \
550
+ 'Use Git::Repository#name_rev instead.'
551
+ )
552
+ name_rev(commit_ish)
553
+ end
404
554
 
405
555
  # Option keys accepted by {#ls_tree}
406
556
  LS_TREE_ALLOWED_OPTS = %i[recursive path].freeze
@@ -928,7 +1078,9 @@ module Git
928
1078
  # @option options [Boolean, nil] :create_reflog (nil) create a reflog for
929
1079
  # the tag
930
1080
  #
931
- # @return [Git::TagInfo] the newly created tag
1081
+ # @return [Git::TagInfo, nil] the newly created tag, or `nil` when the tag
1082
+ # is missing from the tag list after the create (for example, another
1083
+ # process deleted it before the lookup)
932
1084
  #
933
1085
  # @overload tag_create(name, target, options = {})
934
1086
  #
@@ -945,7 +1097,9 @@ module Git
945
1097
  # @param options [Hash] options for creating the tag (same keys as the
946
1098
  # first overload)
947
1099
  #
948
- # @return [Git::TagInfo] the newly created tag
1100
+ # @return [Git::TagInfo, nil] the newly created tag, or `nil` when the tag
1101
+ # is missing from the tag list after the create (for example, another
1102
+ # process deleted it before the lookup)
949
1103
  #
950
1104
  # @raise [ArgumentError] if unsupported options are provided, including the
951
1105
  # `:d` and `:delete` keys that {#tag_add} accepts; use {#tag_delete} to
@@ -960,6 +1114,12 @@ module Git
960
1114
  #
961
1115
  # @raise [Git::FailedError] if git exits with a non-zero exit status
962
1116
  #
1117
+ # @note In v6.0.0 this method raises {Git::UnexpectedResultError} instead of
1118
+ # returning `nil` when the tag it has just created is missing from the tag
1119
+ # list, so its return value is always a {Git::TagInfo}. Code that checks
1120
+ # the result for `nil` today can be left as is; the check becomes
1121
+ # unreachable in v6.0.0.
1122
+ #
963
1123
  # @see https://git-scm.com/docs/git-tag git-tag
964
1124
  #
965
1125
  def tag_create(name, *args)
@@ -99,6 +99,14 @@ module Git
99
99
  #
100
100
  # @raise [Git::FailedError] if git exits with a non-zero exit status
101
101
  #
102
+ # @note In v6.0.0 this method returns the new {Git::WorktreeInfo} instead of
103
+ # the command output. To get the entry today, look it up after the add:
104
+ # `worktree_list.find { |w| File.identical?(w.path, dir) }`.
105
+ # Compare with `File.identical?`, not string equality: git stores
106
+ # worktree paths with symlinks resolved, so `/tmp/...` on macOS is
107
+ # listed as `/private/tmp/...`, and on case-insensitive filesystems the
108
+ # listed casing may differ from `dir`.
109
+ #
102
110
  # @see https://git-scm.com/docs/git-worktree git-worktree documentation
103
111
  #
104
112
  def worktree_add(dir, commitish = nil)
data/lib/git/version.rb CHANGED
@@ -4,7 +4,7 @@ module Git
4
4
  # The current gem version
5
5
  #
6
6
  # @return [String] the current gem version
7
- VERSION = '5.6.0'
7
+ VERSION = '5.7.1'
8
8
 
9
9
  # Represents a git version with major, minor, and patch components
10
10
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0
4
+ version: 5.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon and others
@@ -548,8 +548,8 @@ licenses:
548
548
  metadata:
549
549
  homepage_uri: http://github.com/ruby-git/ruby-git
550
550
  source_code_uri: http://github.com/ruby-git/ruby-git
551
- changelog_uri: https://rubydoc.info/gems/git/5.6.0/file/CHANGELOG.md
552
- documentation_uri: https://rubydoc.info/gems/git/5.6.0
551
+ changelog_uri: https://rubydoc.info/gems/git/5.7.1/file/CHANGELOG.md
552
+ documentation_uri: https://rubydoc.info/gems/git/5.7.1
553
553
  rubygems_mfa_required: 'true'
554
554
  rdoc_options: []
555
555
  require_paths:
@@ -566,7 +566,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
566
566
  version: '0'
567
567
  requirements:
568
568
  - git 2.28.0 or greater
569
- rubygems_version: 4.0.16
569
+ rubygems_version: 4.0.20
570
570
  specification_version: 4
571
571
  summary: An API to create, read, and manipulate Git repositories
572
572
  test_files: []