git 1.10.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of git might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7d02f0f135a2a2f9e4f8d661bc4c5d4323af8b46a527581c0f47ff17df88019
4
- data.tar.gz: c45684c1b8f6af0c5a44a90c0e8918860653a6abb4a6464d11faff90278ef7c7
3
+ metadata.gz: 564087b850fc095e75b62f5fd231d27e7dc145b7839c795d8c84355cb0df0c67
4
+ data.tar.gz: 0d377c66918e25e2a52f1155db445657452be662553756c3e08cb5d66db29d2d
5
5
  SHA512:
6
- metadata.gz: 5bd13aa06dcdb48d0f47ac72d82608120a73b9fb83db278070715d9ce98023e18e75f61c5c42ea13fc24a8f125bde989e8afbc0460c94e1a6eb5c4cd658f7639
7
- data.tar.gz: 5c9a4e9d8734a23162e9c858246ac705ac3413db73f8e728845b7ae62aec7b6096f2b06ddcdc195c57efe052058e26c5b9340f1d9dbdc972bf8f68f303c7eba9
6
+ metadata.gz: 0e6bc7af5d099a33e79afabc655d62faa5e7ce7bcface1843f35a50fbafe2d02a26065b56d5cf2ec26fd7602363a232543ae8a5584952004d8253771a2753fdc
7
+ data.tar.gz: 732a2e8bbb690279caccc65dcedce95cb378d3554886574fbd71985b09dd77f74d3c82e5f0a71d5af19bddf943dd41b6b5a86be2e847205a26ff1db0ecaa2f1a
@@ -12,7 +12,7 @@ jobs:
12
12
  strategy:
13
13
  fail-fast: false
14
14
  matrix:
15
- ruby: [2.3, 2.7]
15
+ ruby: [2.3, 2.7, 3.0]
16
16
  operating-system: [ubuntu-latest]
17
17
  include:
18
18
  - ruby: head
data/CHANGELOG.md CHANGED
@@ -5,6 +5,25 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## v1.11.0
9
+
10
+ * 292087e Supress unneeded test output (#570)
11
+ * 19dfe5e Add support for fetch options "--force/-f" and "--prune-tags/-P". (#563)
12
+ * 018d919 Fix bug when grepping lines that contain numbers surrounded by colons (#566)
13
+ * c04d16e remove from maintainer (#567)
14
+ * 291ca09 Address command line injection in Git::Lib#fetch
15
+ * 521b8e7 Release v1.10.2 (#561)
16
+
17
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.11.0
18
+
19
+ ## v1.10.2
20
+
21
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.2
22
+
23
+ ## 1.10.1
24
+
25
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.1
26
+
8
27
  ## 1.10.0
9
28
 
10
29
  See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.0
@@ -0,0 +1,12 @@
1
+ FROM rust
2
+
3
+ # Build the docker image (from this project's root directory):
4
+ # docker build --file Dockerfile.changelog-rs --tag changelog-rs .
5
+ #
6
+ # Use this image to output a changelog (from this project's root directory):
7
+ # docker run --rm --volume "$PWD:/worktree" changelog-rs v1.9.1 v1.10.0
8
+
9
+ RUN cargo install changelog-rs
10
+ WORKDIR /worktree
11
+
12
+ ENTRYPOINT ["/usr/local/cargo/bin/changelog-rs", "/worktree"]
data/MAINTAINERS.md CHANGED
@@ -10,5 +10,4 @@ When making changes in this repository, one of the maintainers below must review
10
10
  ### Maintainers
11
11
 
12
12
  * [Per Lundberg](https://github.com/perlun)
13
- * [Vern Burton](https://github.com/tarcinil)
14
13
  * [James Couball](https://github.com/jcouball)
data/RELEASING.md CHANGED
@@ -6,9 +6,11 @@
6
6
  # How to release a new git.gem
7
7
 
8
8
  Releasing a new version of the `git` gem requires these steps:
9
- * [Prepare the release](#prepare-the-release)
10
- * [Create a GitHub release](#create-a-github-release)
11
- * [Build and release the gem](#build-and-release-the-gem)
9
+
10
+ - [How to release a new git.gem](#how-to-release-a-new-gitgem)
11
+ - [Prepare the release](#prepare-the-release)
12
+ - [Create a GitHub release](#create-a-github-release)
13
+ - [Build and release the gem](#build-and-release-the-gem)
12
14
 
13
15
  These instructions use an example where the current release version is `1.5.0`
14
16
  and the new release version to be created is `1.6.0.pre1`.
@@ -18,45 +20,49 @@ and the new release version to be created is `1.6.0.pre1`.
18
20
  From a fork of ruby-git, create a PR containing changes to (1) bump the
19
21
  version number, (2) update the CHANGELOG.md, and (3) tag the release.
20
22
 
21
- * Bump the version number in lib/git/version.rb following [Semantic Versioning](https://semver.org)
22
- guidelines
23
- * Add a link in CHANGELOG.md to the release tag which will be created later
24
- in this guide
25
- * Create a new tag using [git-extras](https://github.com/tj/git-extras/blob/master/Commands.md#git-release)
26
- `git release` command
27
- * For example: `git release v1.6.0.pre1`
28
- * These should be the only changes in the PR
29
- * An example of these changes for `v1.6.0.pre1` can be found in [PR #435](https://github.com/ruby-git/ruby-git/pull/435)
30
- * Get the PR reviewed, approved and merged to master.
23
+ - Bump the version number in lib/git/version.rb following [Semantic Versioning](https://semver.org)
24
+ guidelines
25
+ - Add a link in CHANGELOG.md to the release tag which will be created later
26
+ in this guide
27
+ - Create a new tag using [git-extras](https://github.com/tj/git-extras/blob/master/Commands.md#git-release)
28
+ `git release` command
29
+ - For example: `git release v1.6.0.pre1`
30
+ - These should be the only changes in the PR
31
+ - An example of these changes for `v1.6.0.pre1` can be found in [PR #435](https://github.com/ruby-git/ruby-git/pull/435)
32
+ - Get the PR reviewed, approved and merged to master.
31
33
 
32
34
  ## Create a GitHub release
33
35
 
34
36
  On [the ruby-git releases page](https://github.com/ruby-git/ruby-git/releases),
35
37
  select `Draft a new release`
36
38
 
37
- * Select the tag corresponding to the version being released `v1.6.0.pre1`
38
- * The Target should be `master`
39
- * For the release description, use the output of [changelog-rs](https://github.com/perlun/changelog-rs)
40
- * Since the release has not been created yet, you will need to supply
41
- `changeling-rs` with the current release tag and the tag the new release
42
- is being created from
43
- * For example: `changelog-rs . v1.5.0 v1.6.0.pre1`
44
- * Copy the output, omitting the tag header `## v1.6.0.pre1` and paste into
45
- the release description
46
- * The release description can be edited later if needed
47
- * Select the appropriate value for `This is a pre-release`
48
- * Since `v1.6.0.pre1` is a pre-release, check `This is a pre-release`
39
+ - Select the tag corresponding to the version being released `v1.6.0.pre1`
40
+ - The Target should be `master`
41
+ - For the release description, use the output of [changelog-rs](https://github.com/perlun/changelog-rs)
42
+ - A Docker image is provided in [Dockerfile.changelog-rs](https://github.com/ruby-git/ruby-git/blob/master/Dockerfile.changelog-rs)
43
+ so you don't have to install changelog-rs or the Rust tool chain. To build the
44
+ Docker image, run this command from this project's root directory:
45
+ - `docker build --file Dockerfile.changelog-rs --tag changelog-rs .`
46
+ - To run the changelog-rs command using this image, run the following command
47
+ from this project's root directory (replace the tag names appropriate for the
48
+ current release):
49
+ - `docker run --rm --volume "$PWD:/worktree" changelog-rs v1.5.0 v1.6.0.pre1`
50
+ - Copy the output, omitting the tag header `## v1.6.0.pre1` and paste into
51
+ the release description
52
+ - The release description can be edited later if needed
53
+ - Select the appropriate value for `This is a pre-release`
54
+ - Since `v1.6.0.pre1` is a pre-release, check `This is a pre-release`
49
55
 
50
56
  ## Build and release the gem
51
57
 
52
58
  Clone [ruby-git/ruby-git](https://github.com/ruby-git/ruby-git) directly (not a
53
59
  fork) and ensure your local working copy is on the master branch
54
60
 
55
- * Verify that you are not on a fork with the command `git remote -v`
56
- * Verify that the version number is correct by running `rake -T` and inspecting
57
- the output for the `release[remote]` task
61
+ - Verify that you are not on a fork with the command `git remote -v`
62
+ - Verify that the version number is correct by running `rake -T` and inspecting
63
+ the output for the `release[remote]` task
58
64
 
59
65
  Build the git gem and push it to rubygems.org with the command `rake release`
60
66
 
61
- * Ensure that your `gem sources list` includes `https://rubygems.org` (in my
62
- case, I usually have my work’s internal gem repository listed)
67
+ - Ensure that your `gem sources list` includes `https://rubygems.org` (in my
68
+ case, I usually have my work’s internal gem repository listed)
data/git.gemspec CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
 
29
29
  s.add_runtime_dependency 'rchardet', '~> 1.8'
30
30
 
31
+ s.add_development_dependency 'bump', '~> 0.10'
31
32
  s.add_development_dependency 'minitar', '~> 0.9'
32
33
  s.add_development_dependency 'rake', '~> 13.0'
33
34
  s.add_development_dependency 'test-unit', '~> 3.3'
@@ -41,6 +42,6 @@ Gem::Specification.new do |s|
41
42
  # Specify which files should be added to the gem when it is released.
42
43
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
43
44
  s.files = Dir.chdir(File.expand_path(__dir__)) do
44
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(tests|spec|features)/}) }
45
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(tests|spec|features|bin)/}) }
45
46
  end
46
47
  end
data/lib/git/base.rb CHANGED
@@ -36,7 +36,7 @@ module Git
36
36
 
37
37
  init_options = {
38
38
  :bare => options[:bare],
39
- :initial_branch => options[:initial_branch],
39
+ :initial_branch => options[:initial_branch]
40
40
  }
41
41
 
42
42
  directory = options[:bare] ? options[:repository] : options[:working_directory]
data/lib/git/diff.rb CHANGED
@@ -129,8 +129,8 @@ module Git
129
129
  final = {}
130
130
  current_file = nil
131
131
  @full_diff.split("\n").each do |line|
132
- if m = /^diff --git a\/(.*?) b\/(.*?)/.match(line)
133
- current_file = m[1]
132
+ if m = %r{\Adiff --git ("?)a/(.+?)\1 ("?)b/(.+?)\3\z}.match(line)
133
+ current_file = Git::EscapedPath.new(m[2]).unescape
134
134
  final[current_file] = defaults.merge({:patch => line, :path => current_file})
135
135
  else
136
136
  if m = /^index ([0-9a-f]{4,40})\.\.([0-9a-f]{4,40})( ......)*/.match(line)
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rchardet'
4
+
5
+ module Git
6
+ # Method that can be used to detect and normalize string encoding
7
+ module EncodingUtils
8
+ def self.default_encoding
9
+ __ENCODING__.name
10
+ end
11
+
12
+ def self.best_guess_encoding
13
+ # Encoding::ASCII_8BIT.name
14
+ Encoding::UTF_8.name
15
+ end
16
+
17
+ def self.detected_encoding(str)
18
+ CharDet.detect(str)['encoding'] || best_guess_encoding
19
+ end
20
+
21
+ def self.encoding_options
22
+ { invalid: :replace, undef: :replace }
23
+ end
24
+
25
+ def self.normalize_encoding(str)
26
+ return str if str.valid_encoding? && str.encoding.name == default_encoding
27
+
28
+ return str.encode(default_encoding, str.encoding, **encoding_options) if str.valid_encoding?
29
+
30
+ str.encode(default_encoding, detected_encoding(str), **encoding_options)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Git
4
+ # Represents an escaped Git path string
5
+ #
6
+ # Git commands that output paths (e.g. ls-files, diff), will escape usual
7
+ # characters in the path with backslashes in the same way C escapes control
8
+ # characters (e.g. \t for TAB, \n for LF, \\ for backslash) or bytes with values
9
+ # larger than 0x80 (e.g. octal \302\265 for "micro" in UTF-8).
10
+ #
11
+ # @example
12
+ # Git::GitPath.new('\302\265').unescape # => "µ"
13
+ #
14
+ class EscapedPath
15
+ UNESCAPES = {
16
+ 'a' => 0x07,
17
+ 'b' => 0x08,
18
+ 't' => 0x09,
19
+ 'n' => 0x0a,
20
+ 'v' => 0x0b,
21
+ 'f' => 0x0c,
22
+ 'r' => 0x0d,
23
+ 'e' => 0x1b,
24
+ '\\' => 0x5c,
25
+ '"' => 0x22,
26
+ "'" => 0x27
27
+ }.freeze
28
+
29
+ attr_reader :path
30
+
31
+ def initialize(path)
32
+ @path = path
33
+ end
34
+
35
+ # Convert an escaped path to an unescaped path
36
+ def unescape
37
+ bytes = escaped_path_to_bytes(path)
38
+ str = bytes.pack('C*')
39
+ str.force_encoding(Encoding::UTF_8)
40
+ end
41
+
42
+ private
43
+
44
+ def extract_octal(path, index)
45
+ [path[index + 1..index + 4].to_i(8), 4]
46
+ end
47
+
48
+ def extract_escape(path, index)
49
+ [UNESCAPES[path[index + 1]], 2]
50
+ end
51
+
52
+ def extract_single_char(path, index)
53
+ [path[index].ord, 1]
54
+ end
55
+
56
+ def next_byte(path, index)
57
+ if path[index] == '\\' && path[index + 1] >= '0' && path[index + 1] <= '7'
58
+ extract_octal(path, index)
59
+ elsif path[index] == '\\' && UNESCAPES.include?(path[index + 1])
60
+ extract_escape(path, index)
61
+ else
62
+ extract_single_char(path, index)
63
+ end
64
+ end
65
+
66
+ def escaped_path_to_bytes(path)
67
+ index = 0
68
+ [].tap do |bytes|
69
+ while index < path.length
70
+ byte, chars_used = next_byte(path, index)
71
+ bytes << byte
72
+ index += chars_used
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
data/lib/git/lib.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'rchardet'
2
1
  require 'tempfile'
3
2
  require 'zlib'
4
3
 
@@ -420,7 +419,7 @@ module Git
420
419
 
421
420
  hsh = {}
422
421
  command_lines('grep', grep_opts).each do |line|
423
- if m = /(.*)\:(\d+)\:(.*)/.match(line)
422
+ if m = /(.*?)\:(\d+)\:(.*)/.match(line)
424
423
  hsh[m[1]] ||= []
425
424
  hsh[m[1]] << [m[2].to_i, m[3]]
426
425
  end
@@ -876,14 +875,17 @@ module Git
876
875
  command('tag', arr_opts)
877
876
  end
878
877
 
879
-
880
878
  def fetch(remote, opts)
881
- arr_opts = [remote]
882
- arr_opts << opts[:ref] if opts[:ref]
879
+ arr_opts = []
883
880
  arr_opts << '--tags' if opts[:t] || opts[:tags]
884
881
  arr_opts << '--prune' if opts[:p] || opts[:prune]
882
+ arr_opts << '--prune-tags' if opts[:P] || opts[:'prune-tags']
883
+ arr_opts << '--force' if opts[:f] || opts[:force]
885
884
  arr_opts << '--unshallow' if opts[:unshallow]
886
885
  arr_opts << '--depth' << opts[:depth] if opts[:depth]
886
+ arr_opts << '--'
887
+ arr_opts << remote
888
+ arr_opts << opts[:ref] if opts[:ref]
887
889
 
888
890
  command('fetch', arr_opts)
889
891
  end
@@ -1085,7 +1087,8 @@ module Git
1085
1087
  global_opts = []
1086
1088
  global_opts << "--git-dir=#{@git_dir}" if !@git_dir.nil?
1087
1089
  global_opts << "--work-tree=#{@git_work_dir}" if !@git_work_dir.nil?
1088
- global_opts << ["-c", "color.ui=false"]
1090
+ global_opts << %w[-c core.quotePath=true]
1091
+ global_opts << %w[-c color.ui=false]
1089
1092
 
1090
1093
  opts = [opts].flatten.map {|s| escape(s) }.join(' ')
1091
1094
 
@@ -1176,35 +1179,10 @@ module Git
1176
1179
  arr_opts
1177
1180
  end
1178
1181
 
1179
- def default_encoding
1180
- __ENCODING__.name
1181
- end
1182
-
1183
- def best_guess_encoding
1184
- # Encoding::ASCII_8BIT.name
1185
- Encoding::UTF_8.name
1186
- end
1187
-
1188
- def detected_encoding(str)
1189
- CharDet.detect(str)['encoding'] || best_guess_encoding
1190
- end
1191
-
1192
- def encoding_options
1193
- { invalid: :replace, undef: :replace }
1194
- end
1195
-
1196
- def normalize_encoding(str)
1197
- return str if str.valid_encoding? && str.encoding.name == default_encoding
1198
-
1199
- return str.encode(default_encoding, str.encoding, **encoding_options) if str.valid_encoding?
1200
-
1201
- str.encode(default_encoding, detected_encoding(str), **encoding_options)
1202
- end
1203
-
1204
1182
  def run_command(git_cmd, &block)
1205
1183
  return IO.popen(git_cmd, &block) if block_given?
1206
1184
 
1207
- `#{git_cmd}`.lines.map { |l| normalize_encoding(l) }.join
1185
+ `#{git_cmd}`.lines.map { |l| Git::EncodingUtils.normalize_encoding(l) }.join
1208
1186
  end
1209
1187
 
1210
1188
  def escape(s)
@@ -1216,8 +1194,9 @@ module Git
1216
1194
  end
1217
1195
 
1218
1196
  def escape_for_windows(s)
1219
- # Windows does not need single quote escaping inside double quotes
1220
- %Q{"#{s}"}
1197
+ # Escape existing double quotes in s and then wrap the result with double quotes
1198
+ escaped_string = s.to_s.gsub('"','\\"')
1199
+ %Q{"#{escaped_string}"}
1221
1200
  end
1222
1201
 
1223
1202
  def windows_platform?
@@ -1225,6 +1204,5 @@ module Git
1225
1204
  win_platform_regex = /mingw|mswin/
1226
1205
  RUBY_PLATFORM =~ win_platform_regex || RUBY_DESCRIPTION =~ win_platform_regex
1227
1206
  end
1228
-
1229
1207
  end
1230
1208
  end
data/lib/git/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  # The current gem version
3
3
  # @return [String] the current gem version.
4
- VERSION='1.10.0'
4
+ VERSION='1.11.0'
5
5
  end
data/lib/git.rb CHANGED
@@ -9,6 +9,8 @@ require 'git/branch'
9
9
  require 'git/branches'
10
10
  require 'git/config'
11
11
  require 'git/diff'
12
+ require 'git/encoding_utils'
13
+ require 'git/escaped_path'
12
14
  require 'git/index'
13
15
  require 'git/lib'
14
16
  require 'git/log'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon and others
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-20 00:00:00.000000000 Z
11
+ date: 2022-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rchardet
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bump
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.10'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: minitar
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -125,6 +139,7 @@ files:
125
139
  - ".yardopts"
126
140
  - CHANGELOG.md
127
141
  - CONTRIBUTING.md
142
+ - Dockerfile.changelog-rs
128
143
  - Gemfile
129
144
  - ISSUE_TEMPLATE.md
130
145
  - LICENSE
@@ -142,6 +157,8 @@ files:
142
157
  - lib/git/branches.rb
143
158
  - lib/git/config.rb
144
159
  - lib/git/diff.rb
160
+ - lib/git/encoding_utils.rb
161
+ - lib/git/escaped_path.rb
145
162
  - lib/git/index.rb
146
163
  - lib/git/lib.rb
147
164
  - lib/git/log.rb