git 1.10.0 → 1.10.1

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: 6dd58567bba3a5effab0e3d3f565f5b3891dcf056ef4df11c1521037bbe9f489
4
+ data.tar.gz: a1f8f9968a3927ce99f393805c34b0ca23941c37f27607d296eaecba9dc0f872
5
5
  SHA512:
6
- metadata.gz: 5bd13aa06dcdb48d0f47ac72d82608120a73b9fb83db278070715d9ce98023e18e75f61c5c42ea13fc24a8f125bde989e8afbc0460c94e1a6eb5c4cd658f7639
7
- data.tar.gz: 5c9a4e9d8734a23162e9c858246ac705ac3413db73f8e728845b7ae62aec7b6096f2b06ddcdc195c57efe052058e26c5b9340f1d9dbdc972bf8f68f303c7eba9
6
+ metadata.gz: b1231323bde0b63677f46945800dc950a004cd854bee8c1d5a6711c8709c3dd87fb0c187f54c39c94ae07f92674f27a94b23fe3200a1799992f272c0bd84d315
7
+ data.tar.gz: 8d89a33a9cbee9357f9a4ffb568ec38506749aa81b931f9b2e862af0420c549c1738fde90e48eede6650c3202d31b9463e852eea5b358020b5561e5a60e12ef3
@@ -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,10 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## 1.10.1
9
+
10
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.1
11
+
8
12
  ## 1.10.0
9
13
 
10
14
  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/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/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
 
@@ -1085,7 +1084,8 @@ module Git
1085
1084
  global_opts = []
1086
1085
  global_opts << "--git-dir=#{@git_dir}" if !@git_dir.nil?
1087
1086
  global_opts << "--work-tree=#{@git_work_dir}" if !@git_work_dir.nil?
1088
- global_opts << ["-c", "color.ui=false"]
1087
+ global_opts << %w[-c core.quotePath=true]
1088
+ global_opts << %w[-c color.ui=false]
1089
1089
 
1090
1090
  opts = [opts].flatten.map {|s| escape(s) }.join(' ')
1091
1091
 
@@ -1176,35 +1176,10 @@ module Git
1176
1176
  arr_opts
1177
1177
  end
1178
1178
 
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
1179
  def run_command(git_cmd, &block)
1205
1180
  return IO.popen(git_cmd, &block) if block_given?
1206
1181
 
1207
- `#{git_cmd}`.lines.map { |l| normalize_encoding(l) }.join
1182
+ `#{git_cmd}`.lines.map { |l| Git::EncodingUtils.normalize_encoding(l) }.join
1208
1183
  end
1209
1184
 
1210
1185
  def escape(s)
@@ -1216,8 +1191,9 @@ module Git
1216
1191
  end
1217
1192
 
1218
1193
  def escape_for_windows(s)
1219
- # Windows does not need single quote escaping inside double quotes
1220
- %Q{"#{s}"}
1194
+ # Escape existing double quotes in s and then wrap the result with double quotes
1195
+ escaped_string = s.to_s.gsub('"','\\"')
1196
+ %Q{"#{escaped_string}"}
1221
1197
  end
1222
1198
 
1223
1199
  def windows_platform?
@@ -1225,6 +1201,5 @@ module Git
1225
1201
  win_platform_regex = /mingw|mswin/
1226
1202
  RUBY_PLATFORM =~ win_platform_regex || RUBY_DESCRIPTION =~ win_platform_regex
1227
1203
  end
1228
-
1229
1204
  end
1230
1205
  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.10.1'
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.10.1
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-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rchardet
@@ -125,6 +125,7 @@ files:
125
125
  - ".yardopts"
126
126
  - CHANGELOG.md
127
127
  - CONTRIBUTING.md
128
+ - Dockerfile.changelog-rs
128
129
  - Gemfile
129
130
  - ISSUE_TEMPLATE.md
130
131
  - LICENSE
@@ -142,6 +143,8 @@ files:
142
143
  - lib/git/branches.rb
143
144
  - lib/git/config.rb
144
145
  - lib/git/diff.rb
146
+ - lib/git/encoding_utils.rb
147
+ - lib/git/escaped_path.rb
145
148
  - lib/git/index.rb
146
149
  - lib/git/lib.rb
147
150
  - lib/git/log.rb