jit 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3456259298664412f5d90d68ba0a102320bd6b59a9ace12b3817b76cdd553a89
4
- data.tar.gz: 57d5cec5ebd3150ccc5abd83a458d60ed59cc1065b0a0dc8a6fd4df40153ea53
3
+ metadata.gz: a23448f0810b2084307896eb1e1406b86b24c04c579a47d685da99d71ca35a3a
4
+ data.tar.gz: f36e92883aeb81d4ab383e47d74047b9c508c0f8b83db2e630749cf32967230a
5
5
  SHA512:
6
- metadata.gz: bca4b9acaec9bc125b22adbcfe0179794a0f2f27e196c70be266cb1081296bda1a18c740e274cb17fa1f676499cd1d2bdd4187cfa751f8a380ffabdc7d529a50
7
- data.tar.gz: 074d431d5f9a5b1b66e1fcb72223aa92a457fdd08be43d6f3361b7ecf2c3184fb1b3c13dd0437960b0763e604a673fb7114aaff140a613c0574808113f57fb89
6
+ metadata.gz: 7ea0e84691e98799b8cdd265aad34829580bfe248c934ddbc6ff24bb5c008029d07a1935471b05abec87d0568e0cc6a562279285157fc794f420a9847dd09eb7
7
+ data.tar.gz: 1e1b050921161d866dd2e0f42a57a6b7b0b432f930c86eae29f77d608fad121fb4851f4a07d11dff0c76d8b98402261750347907255123b00102238478f2859a
data/lib/command/diff.rb CHANGED
@@ -27,6 +27,8 @@ module Command
27
27
 
28
28
  if @options[:cached]
29
29
  diff_head_index
30
+ elsif @args.size == 2
31
+ diff_commits
30
32
  else
31
33
  diff_index_workspace
32
34
  end
@@ -36,6 +38,13 @@ module Command
36
38
 
37
39
  private
38
40
 
41
+ def diff_commits
42
+ return unless @options[:patch]
43
+
44
+ a, b = @args.map { |rev| Revision.new(repo, rev).resolve }
45
+ print_commit_diff(a, b)
46
+ end
47
+
39
48
  def diff_head_index
40
49
  return unless @options[:patch]
41
50
 
@@ -85,17 +94,12 @@ module Command
85
94
 
86
95
  def from_head(path)
87
96
  entry = @status.head_tree.fetch(path)
88
- blob = repo.database.load(entry.oid)
89
-
90
- Target.new(path, entry.oid, entry.mode.to_s(8), blob.data)
97
+ from_entry(path, entry)
91
98
  end
92
99
 
93
100
  def from_index(path, stage = 0)
94
101
  entry = repo.index.entry_for_path(path, stage)
95
- return nil unless entry
96
-
97
- blob = repo.database.load(entry.oid)
98
- Target.new(path, entry.oid, entry.mode.to_s(8), blob.data)
102
+ entry ? from_entry(path, entry) : nil
99
103
  end
100
104
 
101
105
  def from_file(path)
@@ -106,9 +110,5 @@ module Command
106
110
  Target.new(path, oid, mode.to_s(8), blob.data)
107
111
  end
108
112
 
109
- def from_nothing(path)
110
- Target.new(path, NULL_OID, nil, "")
111
- end
112
-
113
113
  end
114
114
  end
data/lib/command/log.rb CHANGED
@@ -145,15 +145,8 @@ module Command
145
145
  return unless @options[:patch]
146
146
  return show_merge_patch(commit) if commit.merge?
147
147
 
148
- diff = @rev_list.tree_diff(commit.parent, commit.oid)
149
- paths = diff.keys.sort_by(&:to_s)
150
-
151
148
  blank_line
152
-
153
- paths.each do |path|
154
- old_item, new_item = diff[path]
155
- print_diff(from_diff_item(path, old_item), from_diff_item(path, new_item))
156
- end
149
+ print_commit_diff(commit.parent, commit.oid, @rev_list)
157
150
  end
158
151
 
159
152
  def show_merge_patch(commit)
@@ -168,21 +161,12 @@ module Command
168
161
  blank_line
169
162
 
170
163
  paths.each do |path|
171
- parents = diffs.map { |diff| from_diff_item(path, diff[path][0]) }
172
- child = from_diff_item(path, diffs.first[path][1])
164
+ parents = diffs.map { |diff| from_entry(path, diff[path][0]) }
165
+ child = from_entry(path, diffs.first[path][1])
173
166
 
174
167
  print_combined_diff(parents, child)
175
168
  end
176
169
  end
177
170
 
178
- def from_diff_item(path, item)
179
- if item
180
- blob = repo.database.load(item.oid)
181
- Target.new(path, item.oid, item.mode.to_s(8), blob.data)
182
- else
183
- Target.new(path, NULL_OID, nil, "")
184
- end
185
- end
186
-
187
171
  end
188
172
  end
@@ -64,6 +64,9 @@ module Command
64
64
  end
65
65
 
66
66
  def validate_update(ref, old_oid, new_oid)
67
+ raise "funny refname" unless Revision.valid_ref?(ref)
68
+ raise "missing necessary objects" if new_oid and not repo.database.has?(new_oid)
69
+
67
70
  if repo.config.get(["receive", "denyDeletes"])
68
71
  raise "deletion prohibited" unless new_oid
69
72
  end
@@ -28,6 +28,17 @@ module Command
28
28
 
29
29
  private
30
30
 
31
+ def from_entry(path, entry)
32
+ return from_nothing(path) unless entry
33
+
34
+ blob = repo.database.load(entry.oid)
35
+ Target.new(path, entry.oid, entry.mode.to_s(8), blob.data)
36
+ end
37
+
38
+ def from_nothing(path)
39
+ Target.new(path, NULL_OID, nil, "")
40
+ end
41
+
31
42
  def diff_fmt(name, text)
32
43
  key = ["color", "diff", name]
33
44
  style = repo.config.get(key)&.split(/ +/) || DIFF_FORMATS.fetch(name)
@@ -43,6 +54,17 @@ module Command
43
54
  repo.database.short_oid(oid)
44
55
  end
45
56
 
57
+ def print_commit_diff(a, b, differ = nil)
58
+ differ ||= repo.database
59
+ diff = differ.tree_diff(a, b)
60
+ paths = diff.keys.sort_by(&:to_s)
61
+
62
+ paths.each do |path|
63
+ old_entry, new_entry = diff[path]
64
+ print_diff(from_entry(path, old_entry), from_entry(path, new_entry))
65
+ end
66
+ end
67
+
46
68
  def print_diff(a, b)
47
69
  return if a.oid == b.oid and a.mode == b.mode
48
70
 
@@ -17,6 +17,7 @@ module Command
17
17
  processor = factory.new(repo.database, reader, stream, progress)
18
18
 
19
19
  processor.process_pack
20
+ repo.database.reload
20
21
  end
21
22
 
22
23
  def select_processor_class(reader, unpack_limit)
data/lib/database.rb CHANGED
@@ -24,7 +24,7 @@ class Database
24
24
 
25
25
  extend Forwardable
26
26
  def_delegators :@backend, :has?, :load_info, :load_raw,
27
- :prefix_match, :pack_path
27
+ :prefix_match, :pack_path, :reload
28
28
 
29
29
  def initialize(pathname)
30
30
  @objects = {}
@@ -12,7 +12,12 @@ class Database
12
12
  def initialize(pathname)
13
13
  @pathname = pathname
14
14
  @loose = Loose.new(pathname)
15
- @stores = [@loose] + packed
15
+
16
+ reload
17
+ end
18
+
19
+ def reload
20
+ @stores = [@loose] + packed
16
21
  end
17
22
 
18
23
  def pack_path
@@ -1,8 +1,5 @@
1
1
  require "forwardable"
2
-
3
- require_relative "../pack/expander"
4
- require_relative "../pack/index"
5
- require_relative "../pack/reader"
2
+ require_relative "../pack"
6
3
 
7
4
  class Database
8
5
  class Packed
data/lib/pack.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require_relative "./pack/reader"
2
+ require_relative "./pack/index"
2
3
  require_relative "./pack/writer"
3
4
  require_relative "./pack/stream"
4
5
  require_relative "./pack/indexer"
@@ -23,9 +23,9 @@ module Pack
23
23
  def build_deltas
24
24
  @progress&.start("Compressing objects", @objects.size)
25
25
 
26
- @objects.sort! { |a, b| b.sort_key <=> a.sort_key }
26
+ @objects.sort_by!(&:sort_key)
27
27
 
28
- @objects.each do |entry|
28
+ @objects.reverse_each do |entry|
29
29
  build_delta(entry)
30
30
  @progress&.tick
31
31
  end
data/lib/pack/index.rb CHANGED
@@ -44,7 +44,7 @@ module Pack
44
44
  loop do
45
45
  oid = @input.read(20).unpack("H40").first
46
46
  return oids unless oid.start_with?(name)
47
- oids << oid
47
+ oids.push(oid)
48
48
  end
49
49
  end
50
50
 
data/lib/refs.rb CHANGED
@@ -160,7 +160,8 @@ class Refs
160
160
  path.dirname.ascend.any? { |parent| parent == dir }
161
161
  end
162
162
 
163
- path.relative_path_from(prefix).to_s
163
+ path = path.relative_path_from(prefix) if prefix
164
+ path.to_s
164
165
  end
165
166
 
166
167
  def long_name(ref)
data/lib/revision.rb CHANGED
@@ -33,6 +33,7 @@ class Revision
33
33
  ^\.
34
34
  | \/\.
35
35
  | \.\.
36
+ | ^\/
36
37
  | \/$
37
38
  | \.lock$
38
39
  | @\{
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Coglan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-10 00:00:00.000000000 Z
11
+ date: 2021-06-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description:
14
14
  email: jcoglan@gmail.com
15
15
  executables:
16
16
  - jit
@@ -115,7 +115,7 @@ homepage: https://shop.jcoglan.com/building-git/
115
115
  licenses:
116
116
  - GPL-3.0
117
117
  metadata: {}
118
- post_install_message:
118
+ post_install_message:
119
119
  rdoc_options: []
120
120
  require_paths:
121
121
  - lib
@@ -130,8 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubygems_version: 3.1.2
134
- signing_key:
133
+ rubygems_version: 3.1.6
134
+ signing_key:
135
135
  specification_version: 4
136
136
  summary: The information manager from London
137
137
  test_files: []