rugged 0.17.0.b6 → 0.17.0.b7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/Rakefile +3 -1
- data/ext/rugged/rugged.c +30 -0
- data/ext/rugged/rugged.h +9 -0
- data/ext/rugged/rugged_branch.c +306 -0
- data/ext/rugged/rugged_config.c +16 -13
- data/ext/rugged/rugged_index.c +25 -0
- data/ext/rugged/rugged_object.c +6 -2
- data/ext/rugged/rugged_reference.c +11 -18
- data/ext/rugged/rugged_revwalk.c +1 -1
- data/lib/rugged.rb +1 -0
- data/lib/rugged/branch.rb +28 -0
- data/lib/rugged/commit.rb +5 -5
- data/lib/rugged/repository.rb +32 -7
- data/lib/rugged/tag.rb +5 -1
- data/lib/rugged/version.rb +1 -1
- data/test/branch_test.rb +227 -0
- data/test/config_test.rb +1 -1
- data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
- data/test/index_test.rb +31 -0
- data/test/index_test.rb~ +218 -0
- data/test/lib_test.rb +22 -0
- data/test/reference_test.rb +5 -3
- data/vendor/libgit2/Makefile.embed +1 -1
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/include/git2/branch.h +17 -13
- data/vendor/libgit2/include/git2/checkout.h +83 -22
- data/vendor/libgit2/include/git2/clone.h +6 -3
- data/vendor/libgit2/include/git2/common.h +1 -8
- data/vendor/libgit2/include/git2/config.h +185 -26
- data/vendor/libgit2/include/git2/diff.h +229 -17
- data/vendor/libgit2/include/git2/errors.h +39 -1
- data/vendor/libgit2/include/git2/ignore.h +6 -3
- data/vendor/libgit2/include/git2/indexer.h +1 -0
- data/vendor/libgit2/include/git2/merge.h +1 -1
- data/vendor/libgit2/include/git2/object.h +7 -4
- data/vendor/libgit2/include/git2/odb.h +4 -2
- data/vendor/libgit2/include/git2/odb_backend.h +6 -0
- data/vendor/libgit2/include/git2/oid.h +2 -0
- data/vendor/libgit2/include/git2/pack.h +89 -0
- data/vendor/libgit2/include/git2/refs.h +88 -0
- data/vendor/libgit2/include/git2/refspec.h +0 -8
- data/vendor/libgit2/include/git2/remote.h +34 -1
- data/vendor/libgit2/include/git2/repository.h +238 -6
- data/vendor/libgit2/include/git2/reset.h +4 -1
- data/vendor/libgit2/include/git2/revwalk.h +1 -1
- data/vendor/libgit2/include/git2/status.h +19 -14
- data/vendor/libgit2/include/git2/strarray.h +54 -0
- data/vendor/libgit2/include/git2/submodule.h +451 -45
- data/vendor/libgit2/include/git2/tag.h +16 -0
- data/vendor/libgit2/include/git2/tree.h +2 -2
- data/vendor/libgit2/include/git2/types.h +4 -0
- data/vendor/libgit2/src/amiga/map.c +4 -7
- data/vendor/libgit2/src/attr.c +21 -13
- data/vendor/libgit2/src/attr.h +3 -1
- data/vendor/libgit2/src/attr_file.c +14 -14
- data/vendor/libgit2/src/attr_file.h +6 -5
- data/vendor/libgit2/src/blob.c +22 -12
- data/vendor/libgit2/src/branch.c +62 -66
- data/vendor/libgit2/src/buffer.c +63 -14
- data/vendor/libgit2/src/buffer.h +4 -0
- data/vendor/libgit2/src/cache.c +5 -4
- data/vendor/libgit2/src/checkout.c +381 -159
- data/vendor/libgit2/src/clone.c +221 -94
- data/vendor/libgit2/src/common.h +13 -3
- data/vendor/libgit2/src/compress.c +53 -0
- data/vendor/libgit2/src/compress.h +16 -0
- data/vendor/libgit2/src/config.c +380 -175
- data/vendor/libgit2/src/config.h +2 -5
- data/vendor/libgit2/src/config_file.c +63 -46
- data/vendor/libgit2/src/config_file.h +16 -4
- data/vendor/libgit2/src/crlf.c +4 -3
- data/vendor/libgit2/src/delta.c +491 -0
- data/vendor/libgit2/src/delta.h +112 -0
- data/vendor/libgit2/src/diff.c +310 -67
- data/vendor/libgit2/src/diff.h +10 -1
- data/vendor/libgit2/src/diff_output.c +1030 -337
- data/vendor/libgit2/src/diff_output.h +86 -0
- data/vendor/libgit2/src/errors.c +10 -1
- data/vendor/libgit2/src/fetch.c +108 -24
- data/vendor/libgit2/src/filebuf.c +8 -2
- data/vendor/libgit2/src/fileops.c +342 -177
- data/vendor/libgit2/src/fileops.h +84 -7
- data/vendor/libgit2/src/filter.c +0 -35
- data/vendor/libgit2/src/filter.h +0 -12
- data/vendor/libgit2/src/{compat/fnmatch.c → fnmatch.c} +16 -4
- data/vendor/libgit2/src/{compat/fnmatch.h → fnmatch.h} +4 -3
- data/vendor/libgit2/src/global.c +4 -0
- data/vendor/libgit2/src/ignore.c +122 -23
- data/vendor/libgit2/src/ignore.h +1 -0
- data/vendor/libgit2/src/index.c +56 -10
- data/vendor/libgit2/src/index.h +2 -0
- data/vendor/libgit2/src/indexer.c +8 -9
- data/vendor/libgit2/src/iterator.c +244 -31
- data/vendor/libgit2/src/iterator.h +30 -1
- data/vendor/libgit2/src/message.c +1 -1
- data/vendor/libgit2/src/netops.c +44 -4
- data/vendor/libgit2/src/object.c +80 -69
- data/vendor/libgit2/src/object.h +39 -0
- data/vendor/libgit2/src/odb.c +79 -15
- data/vendor/libgit2/src/odb.h +20 -5
- data/vendor/libgit2/src/odb_pack.c +65 -33
- data/vendor/libgit2/src/oid.c +0 -3
- data/vendor/libgit2/src/pack-objects.c +1315 -0
- data/vendor/libgit2/src/pack-objects.h +87 -0
- data/vendor/libgit2/src/pack.c +36 -12
- data/vendor/libgit2/src/pack.h +1 -0
- data/vendor/libgit2/src/path.c +42 -9
- data/vendor/libgit2/src/path.h +14 -0
- data/vendor/libgit2/src/pkt.c +52 -2
- data/vendor/libgit2/src/pkt.h +10 -0
- data/vendor/libgit2/src/pool.h +11 -0
- data/vendor/libgit2/src/posix.h +8 -0
- data/vendor/libgit2/src/protocol.c +24 -2
- data/vendor/libgit2/src/protocol.h +4 -0
- data/vendor/libgit2/src/reflog.c +1 -1
- data/vendor/libgit2/src/refs.c +292 -124
- data/vendor/libgit2/src/refs.h +4 -2
- data/vendor/libgit2/src/refspec.c +117 -19
- data/vendor/libgit2/src/refspec.h +19 -0
- data/vendor/libgit2/src/remote.c +152 -48
- data/vendor/libgit2/src/remote.h +4 -1
- data/vendor/libgit2/src/repo_template.h +58 -0
- data/vendor/libgit2/src/repository.c +594 -179
- data/vendor/libgit2/src/repository.h +23 -22
- data/vendor/libgit2/src/reset.c +71 -29
- data/vendor/libgit2/src/revparse.c +26 -17
- data/vendor/libgit2/src/revwalk.c +36 -19
- data/vendor/libgit2/src/sha1.h +7 -0
- data/vendor/libgit2/src/{sha1.c → sha1/sha1.c} +0 -0
- data/vendor/libgit2/src/signature.c +12 -10
- data/vendor/libgit2/src/status.c +52 -6
- data/vendor/libgit2/src/submodule.c +1363 -255
- data/vendor/libgit2/src/submodule.h +102 -0
- data/vendor/libgit2/src/tag.c +42 -26
- data/vendor/libgit2/src/thread-utils.h +7 -7
- data/vendor/libgit2/src/transport.h +15 -1
- data/vendor/libgit2/src/transports/git.c +1 -1
- data/vendor/libgit2/src/transports/http.c +197 -36
- data/vendor/libgit2/src/tree.c +3 -3
- data/vendor/libgit2/src/unix/map.c +2 -0
- data/vendor/libgit2/src/unix/posix.h +1 -8
- data/vendor/libgit2/src/util.c +6 -1
- data/vendor/libgit2/src/util.h +7 -0
- data/vendor/libgit2/src/vector.c +16 -0
- data/vendor/libgit2/src/vector.h +1 -0
- data/vendor/libgit2/src/win32/dir.c +8 -21
- data/vendor/libgit2/src/win32/findfile.c +149 -0
- data/vendor/libgit2/src/win32/findfile.h +23 -0
- data/vendor/libgit2/src/win32/posix.h +3 -7
- data/vendor/libgit2/src/win32/posix_w32.c +44 -102
- data/vendor/libgit2/src/win32/pthread.c +68 -0
- data/vendor/libgit2/src/win32/pthread.h +7 -0
- data/vendor/libgit2/src/win32/utf-conv.c +60 -71
- data/vendor/libgit2/src/win32/utf-conv.h +4 -3
- metadata +70 -71
- data/vendor/libgit2/include/git2/windows.h +0 -59
data/test/config_test.rb
CHANGED
data/test/index_test.rb
CHANGED
@@ -184,3 +184,34 @@ context "Rugged::Index with working directory" do
|
|
184
184
|
assert_equal e[:mode], 33199
|
185
185
|
end
|
186
186
|
end
|
187
|
+
|
188
|
+
|
189
|
+
context "Rugged::Index with Rugged::Repository" do
|
190
|
+
setup do
|
191
|
+
@path = temp_repo("testrepo.git")
|
192
|
+
@repo = Rugged::Repository.new(@path)
|
193
|
+
@index = @repo.index
|
194
|
+
end
|
195
|
+
|
196
|
+
test "idempotent read_tree/write_tree" do
|
197
|
+
head_sha = Rugged::Reference.lookup(@repo,'HEAD').resolve.target
|
198
|
+
tree = @repo.lookup(head_sha).tree
|
199
|
+
@index.read_tree(tree)
|
200
|
+
|
201
|
+
index_tree_sha = @index.write_tree
|
202
|
+
index_tree = @repo.lookup(index_tree_sha)
|
203
|
+
assert_equal tree.oid, index_tree.oid
|
204
|
+
end
|
205
|
+
|
206
|
+
|
207
|
+
test "build tree from index on non-HEAD branch" do
|
208
|
+
head_sha = Rugged::Reference.lookup(@repo,'refs/remotes/origin/packed').resolve.target
|
209
|
+
tree = @repo.lookup(head_sha).tree
|
210
|
+
@index.read_tree(tree)
|
211
|
+
@index.remove('second.txt')
|
212
|
+
|
213
|
+
new_tree_sha = @index.write_tree
|
214
|
+
assert head_sha != new_tree_sha
|
215
|
+
assert_nil @repo.lookup(new_tree_sha)['second.txt']
|
216
|
+
end
|
217
|
+
end
|
data/test/index_test.rb~
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require 'base64'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
def new_index_entry
|
7
|
+
now = Time.now
|
8
|
+
{
|
9
|
+
:path => "new_path",
|
10
|
+
:oid => "d385f264afb75a56a5bec74243be9b367ba4ca08",
|
11
|
+
:mtime => now,
|
12
|
+
:ctime => now,
|
13
|
+
:file_size => 1000,
|
14
|
+
:dev => 234881027,
|
15
|
+
:ino => 88888,
|
16
|
+
:mode => 33199,
|
17
|
+
:uid => 502,
|
18
|
+
:gid => 502,
|
19
|
+
:stage => 3,
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
context "Rugged::Index reading stuff" do
|
24
|
+
setup do
|
25
|
+
path = File.dirname(__FILE__) + '/fixtures/testrepo.git/index'
|
26
|
+
@index = Rugged::Index.new(path)
|
27
|
+
end
|
28
|
+
|
29
|
+
test "can iterate through the index" do
|
30
|
+
enum = @index.each
|
31
|
+
assert enum.kind_of? Enumerable
|
32
|
+
|
33
|
+
i = 0
|
34
|
+
@index.each { |e| i += 1 }
|
35
|
+
assert_equal @index.count, i
|
36
|
+
end
|
37
|
+
|
38
|
+
test "can count index entries" do
|
39
|
+
assert_equal 2, @index.count
|
40
|
+
end
|
41
|
+
|
42
|
+
test "can clear the in-memory index" do
|
43
|
+
@index.clear
|
44
|
+
assert_equal 0, @index.count
|
45
|
+
end
|
46
|
+
|
47
|
+
test "can remove entries from the index" do
|
48
|
+
@index.remove 0
|
49
|
+
assert_equal 1, @index.count
|
50
|
+
end
|
51
|
+
|
52
|
+
test "can get all data from an entry" do
|
53
|
+
e = @index.get_entry(0)
|
54
|
+
assert_equal 'README', e[:path]
|
55
|
+
assert_equal '1385f264afb75a56a5bec74243be9b367ba4ca08', e[:oid]
|
56
|
+
assert_equal 1273360380, e[:mtime].to_i
|
57
|
+
assert_equal 1273360380, e[:ctime].to_i
|
58
|
+
assert_equal 4, e[:file_size]
|
59
|
+
assert_equal 234881026, e[:dev]
|
60
|
+
assert_equal 6674088, e[:ino]
|
61
|
+
assert_equal 33188, e[:mode]
|
62
|
+
assert_equal 501, e[:uid]
|
63
|
+
assert_equal 0, e[:gid]
|
64
|
+
assert_equal false, e[:valid]
|
65
|
+
assert_equal 0, e[:stage]
|
66
|
+
|
67
|
+
e = @index.get_entry(1)
|
68
|
+
assert_equal 'new.txt', e[:path]
|
69
|
+
assert_equal 'fa49b077972391ad58037050f2a75f74e3671e92', e[:oid]
|
70
|
+
end
|
71
|
+
|
72
|
+
test "can iterate over the entries" do
|
73
|
+
itr_test = @index.sort { |a, b| a[:oid] <=> b[:oid] }.map { |e| e[:path] }.join(':')
|
74
|
+
assert_equal "README:new.txt", itr_test
|
75
|
+
end
|
76
|
+
|
77
|
+
test "can update entries" do
|
78
|
+
now = Time.at Time.now.to_i
|
79
|
+
e = @index.get_entry(0)
|
80
|
+
|
81
|
+
e[:oid] = "12ea3153a78002a988bb92f4123e7e831fd1138a"
|
82
|
+
e[:mtime] = now
|
83
|
+
e[:ctime] = now
|
84
|
+
e[:file_size] = 1000
|
85
|
+
e[:dev] = 234881027
|
86
|
+
e[:ino] = 88888
|
87
|
+
e[:mode] = 33199
|
88
|
+
e[:uid] = 502
|
89
|
+
e[:gid] = 502
|
90
|
+
e[:stage] = 3
|
91
|
+
|
92
|
+
@index.add(e)
|
93
|
+
new_e = @index[e[:path]]
|
94
|
+
|
95
|
+
# git only sets executable bit based on owner
|
96
|
+
e[:mode] = 33188
|
97
|
+
assert_equal e, new_e
|
98
|
+
end
|
99
|
+
|
100
|
+
test "can add new entries" do
|
101
|
+
e = new_index_entry
|
102
|
+
@index << e
|
103
|
+
assert_equal 3, @index.count
|
104
|
+
itr_test = @index.sort { |a, b| a[:oid] <=> b[:oid] }.map { |x| x[:path] }.join(':')
|
105
|
+
assert_equal "README:new_path:new.txt", itr_test
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "Rugged::Index writing stuff" do
|
110
|
+
setup do
|
111
|
+
path = File.dirname(__FILE__) + '/fixtures/testrepo.git/index'
|
112
|
+
@tmppath = Tempfile.new('index').path
|
113
|
+
FileUtils.copy(path, @tmppath)
|
114
|
+
@index = Rugged::Index.new(@tmppath)
|
115
|
+
end
|
116
|
+
|
117
|
+
test "add raises if it gets something weird" do
|
118
|
+
assert_raise TypeError do
|
119
|
+
@index.add(21)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
test "can write a new index" do
|
124
|
+
e = new_index_entry
|
125
|
+
@index << e
|
126
|
+
|
127
|
+
e[:path] = "else.txt"
|
128
|
+
@index << e
|
129
|
+
|
130
|
+
@index.write
|
131
|
+
|
132
|
+
index2 = Rugged::Index.new(@tmppath)
|
133
|
+
|
134
|
+
itr_test = index2.sort { |a, b| a[:oid] <=> b[:oid] }.map { |x| x[:path] }.join(':')
|
135
|
+
assert_equal "README:else.txt:new_path:new.txt", itr_test
|
136
|
+
assert_equal 4, index2.count
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context "Rugged::Index with working directory" do
|
141
|
+
setup do
|
142
|
+
@tmppath = Dir.mktmpdir
|
143
|
+
@repo = Rugged::Repository.init_at(@tmppath, false)
|
144
|
+
@index = @repo.index
|
145
|
+
end
|
146
|
+
|
147
|
+
teardown do
|
148
|
+
FileUtils.remove_entry_secure(@tmppath)
|
149
|
+
end
|
150
|
+
|
151
|
+
test "can add from a path" do
|
152
|
+
File.open(File.join(@tmppath, 'test.txt'), 'w') do |f|
|
153
|
+
f.puts "test content"
|
154
|
+
end
|
155
|
+
@index.add('test.txt')
|
156
|
+
@index.write
|
157
|
+
|
158
|
+
index2 = Rugged::Index.new(@tmppath + '/.git/index')
|
159
|
+
assert_equal index2.get_entry(0)[:path], 'test.txt'
|
160
|
+
end
|
161
|
+
|
162
|
+
test "can reload the index" do
|
163
|
+
File.open(File.join(@tmppath, 'test.txt'), 'w') do |f|
|
164
|
+
f.puts "test content"
|
165
|
+
end
|
166
|
+
@index.add('test.txt', 2)
|
167
|
+
@index.write
|
168
|
+
|
169
|
+
sleep(1) # we need this sleep to sync at the FS level
|
170
|
+
# most FSs have 1s granularity on mtimes
|
171
|
+
|
172
|
+
rindex = Rugged::Index.new(File.join(@tmppath, '/.git/index'))
|
173
|
+
e = rindex['test.txt']
|
174
|
+
assert_equal 2, e[:stage]
|
175
|
+
|
176
|
+
rindex << new_index_entry
|
177
|
+
rindex.write
|
178
|
+
|
179
|
+
assert_equal 1, @index.count
|
180
|
+
@index.reload
|
181
|
+
assert_equal 2, @index.count
|
182
|
+
|
183
|
+
e = @index['new_path']
|
184
|
+
assert_equal e[:mode], 33199
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
context "Rugged::Index with Rugged::Repository" do
|
190
|
+
setup do
|
191
|
+
@path = temp_repo("testrepo.git")
|
192
|
+
@repo = Rugged::Repository.new(@path)
|
193
|
+
@index = @repo.index
|
194
|
+
end
|
195
|
+
|
196
|
+
test "idempotent read_tree/write_tree" do
|
197
|
+
head_sha = Rugged::Reference.lookup(@repo,'HEAD').resolve.target
|
198
|
+
tree = @repo.lookup(head_sha).tree
|
199
|
+
@index.read_tree(tree)
|
200
|
+
|
201
|
+
index_tree_sha = @index.write_tree
|
202
|
+
index_tree = @repo.lookup(index_tree_sha)
|
203
|
+
assert_equal tree.oid, index_tree.oid
|
204
|
+
end
|
205
|
+
|
206
|
+
|
207
|
+
test "build tree from index on non-HEAD branch" do
|
208
|
+
head_sha = Rugged::Reference.lookup(@repo,'refs/remotes/origin/packed').resolve.target
|
209
|
+
tree = @repo.lookup(head_sha).tree
|
210
|
+
@index.read_tree(tree)
|
211
|
+
@index.remove('second.txt')
|
212
|
+
|
213
|
+
new_tree_sha = @index.write_tree
|
214
|
+
assert head_sha != new_tree_sha
|
215
|
+
pp @repo.lookup(new_tree_sha)
|
216
|
+
assert_nil @repo.lookup(new_tree_sha)['second.txt']
|
217
|
+
end
|
218
|
+
end
|
data/test/lib_test.rb
CHANGED
@@ -37,4 +37,26 @@ context "Rugged::Lib stuff" do
|
|
37
37
|
hex2 = raw.unpack("H*")[0]
|
38
38
|
assert_equal hex1, hex2
|
39
39
|
end
|
40
|
+
|
41
|
+
test "prettifies commit messages properly" do
|
42
|
+
message = <<-MESSAGE
|
43
|
+
Testing this whole prettify business
|
44
|
+
|
45
|
+
with newlines and stuff
|
46
|
+
# take out this line haha
|
47
|
+
# and this one
|
48
|
+
|
49
|
+
not this one
|
50
|
+
MESSAGE
|
51
|
+
|
52
|
+
clean_message = <<-MESSAGE
|
53
|
+
Testing this whole prettify business
|
54
|
+
|
55
|
+
with newlines and stuff
|
56
|
+
|
57
|
+
not this one
|
58
|
+
MESSAGE
|
59
|
+
|
60
|
+
assert_equal clean_message, Rugged::prettify_message(message, true)
|
61
|
+
end
|
40
62
|
end
|
data/test/reference_test.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
require File.expand_path "../test_helper", __FILE__
|
3
3
|
|
4
4
|
context "Rugged::Reference stuff" do
|
5
|
+
UNICODE_REF_NAME = "A\314\212ngstro\314\210m"
|
6
|
+
|
5
7
|
setup do
|
6
8
|
@path = File.dirname(__FILE__) + '/fixtures/testrepo.git'
|
7
9
|
@repo = Rugged::Repository.new(@path)
|
@@ -9,7 +11,7 @@ context "Rugged::Reference stuff" do
|
|
9
11
|
|
10
12
|
teardown do
|
11
13
|
FileUtils.remove_entry_secure(@path + '/refs/heads/unit_test', true)
|
12
|
-
FileUtils.remove_entry_secure(@path +
|
14
|
+
FileUtils.remove_entry_secure(@path + "/refs/heads/#{UNICODE_REF_NAME}", true)
|
13
15
|
end
|
14
16
|
|
15
17
|
test "can list references" do
|
@@ -18,9 +20,9 @@ context "Rugged::Reference stuff" do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
test "can list references with non 7-bit ASCII characters" do
|
21
|
-
Rugged::Reference.create(@repo, "refs/heads
|
23
|
+
Rugged::Reference.create(@repo, "refs/heads/#{UNICODE_REF_NAME}", "refs/heads/master")
|
22
24
|
refs = @repo.refs.map { |r| r.name.gsub("refs/", '') }.sort.join(':')
|
23
|
-
assert_equal "heads/master:heads/packed:
|
25
|
+
assert_equal "heads/#{UNICODE_REF_NAME}:heads/master:heads/packed:tags/v0.9:tags/v1.0", refs
|
24
26
|
end
|
25
27
|
|
26
28
|
test "can list filtered references from regex" do
|
@@ -15,7 +15,7 @@ INCLUDES= -I. -Isrc -Iinclude -Ideps/http-parser -Ideps/zlib
|
|
15
15
|
DEFINES= $(INCLUDES) -DNO_VIZ -DSTDC -DNO_GZIP -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $(EXTRA_DEFINES)
|
16
16
|
CFLAGS= -g $(DEFINES) -Wall -Wextra -O2 $(EXTRA_CFLAGS)
|
17
17
|
|
18
|
-
SRCS = $(wildcard src/*.c) $(wildcard src/transports/*.c) $(wildcard src/xdiff/*.c) $(wildcard deps/http-parser/*.c) $(wildcard deps/zlib/*.c)
|
18
|
+
SRCS = $(wildcard src/*.c) $(wildcard src/transports/*.c) $(wildcard src/xdiff/*.c) $(wildcard deps/http-parser/*.c) $(wildcard deps/zlib/*.c) $(wildcard src/sha1/*.c)
|
19
19
|
|
20
20
|
ifeq ($(PLATFORM),Msys)
|
21
21
|
SRCS += $(wildcard src/win32/*.c) $(wildcard src/compat/*.c) deps/regex/regex.c
|
@@ -8,6 +8,7 @@
|
|
8
8
|
#define INCLUDE_git_branch_h__
|
9
9
|
|
10
10
|
#include "common.h"
|
11
|
+
#include "oid.h"
|
11
12
|
#include "types.h"
|
12
13
|
|
13
14
|
/**
|
@@ -55,21 +56,13 @@ GIT_EXTERN(int) git_branch_create(
|
|
55
56
|
/**
|
56
57
|
* Delete an existing branch reference.
|
57
58
|
*
|
58
|
-
*
|
59
|
+
* If the branch is successfully deleted, the passed reference
|
60
|
+
* object will be freed and invalidated.
|
59
61
|
*
|
60
|
-
* @param
|
61
|
-
*
|
62
|
-
*
|
63
|
-
* @param branch_type Type of the considered branch. This should
|
64
|
-
* be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE.
|
65
|
-
*
|
66
|
-
* @return 0 on success, GIT_ENOTFOUND if the branch
|
67
|
-
* doesn't exist or an error code.
|
62
|
+
* @param branch A valid reference representing a branch
|
63
|
+
* @return 0 on success, or an error code.
|
68
64
|
*/
|
69
|
-
GIT_EXTERN(int) git_branch_delete(
|
70
|
-
git_repository *repo,
|
71
|
-
const char *branch_name,
|
72
|
-
git_branch_t branch_type);
|
65
|
+
GIT_EXTERN(int) git_branch_delete(git_reference *branch);
|
73
66
|
|
74
67
|
/**
|
75
68
|
* Loop over all the branches and issue a callback for each one.
|
@@ -155,6 +148,17 @@ GIT_EXTERN(int) git_branch_tracking(
|
|
155
148
|
git_reference **tracking_out,
|
156
149
|
git_reference *branch);
|
157
150
|
|
151
|
+
/**
|
152
|
+
* Determine if the current local branch is pointed at by HEAD.
|
153
|
+
*
|
154
|
+
* @param branch Current underlying reference of the branch.
|
155
|
+
*
|
156
|
+
* @return 1 if HEAD points at the branch, 0 if it isn't,
|
157
|
+
* error code otherwise.
|
158
|
+
*/
|
159
|
+
GIT_EXTERN(int) git_branch_is_head(
|
160
|
+
git_reference *branch);
|
161
|
+
|
158
162
|
/** @} */
|
159
163
|
GIT_END_DECL
|
160
164
|
#endif
|
@@ -10,7 +10,7 @@
|
|
10
10
|
#include "common.h"
|
11
11
|
#include "types.h"
|
12
12
|
#include "indexer.h"
|
13
|
-
|
13
|
+
#include "strarray.h"
|
14
14
|
|
15
15
|
/**
|
16
16
|
* @file git2/checkout.h
|
@@ -21,45 +21,106 @@
|
|
21
21
|
*/
|
22
22
|
GIT_BEGIN_DECL
|
23
23
|
|
24
|
+
/**
|
25
|
+
* Checkout behavior flags
|
26
|
+
*
|
27
|
+
* These flags control what checkout does with files. Pass in a
|
28
|
+
* combination of these values OR'ed together.
|
29
|
+
*/
|
30
|
+
typedef enum {
|
31
|
+
/** Checkout does not update any files in the working directory. */
|
32
|
+
GIT_CHECKOUT_DEFAULT = (1 << 0),
|
33
|
+
|
34
|
+
/** When a file exists and is modified, replace it with new version. */
|
35
|
+
GIT_CHECKOUT_OVERWRITE_MODIFIED = (1 << 1),
|
36
|
+
|
37
|
+
/** When a file does not exist in the working directory, create it. */
|
38
|
+
GIT_CHECKOUT_CREATE_MISSING = (1 << 2),
|
24
39
|
|
25
|
-
|
26
|
-
|
40
|
+
/** If an untracked file in found in the working dir, delete it. */
|
41
|
+
GIT_CHECKOUT_REMOVE_UNTRACKED = (1 << 3),
|
42
|
+
} git_checkout_strategy_t;
|
27
43
|
|
28
|
-
|
44
|
+
/**
|
45
|
+
* Checkout options structure
|
46
|
+
*
|
47
|
+
* Use zeros to indicate default settings.
|
48
|
+
*/
|
29
49
|
typedef struct git_checkout_opts {
|
30
|
-
int
|
31
|
-
int disable_filters;
|
32
|
-
int dir_mode;
|
33
|
-
int file_mode;
|
34
|
-
int file_open_flags;
|
50
|
+
unsigned int checkout_strategy; /** default: GIT_CHECKOUT_DEFAULT */
|
51
|
+
int disable_filters; /** don't apply filters like CRLF conversion */
|
52
|
+
int dir_mode; /** default is 0755 */
|
53
|
+
int file_mode; /** default is 0644 or 0755 as dictated by blob */
|
54
|
+
int file_open_flags; /** default is O_CREAT | O_TRUNC | O_WRONLY */
|
55
|
+
|
56
|
+
/** Optional callback to notify the consumer of files that
|
57
|
+
* haven't be checked out because a modified version of them
|
58
|
+
* exist in the working directory.
|
59
|
+
*
|
60
|
+
* When provided, this callback will be invoked when the flag
|
61
|
+
* GIT_CHECKOUT_OVERWRITE_MODIFIED isn't part of the checkout strategy.
|
62
|
+
*/
|
63
|
+
int (* skipped_notify_cb)(
|
64
|
+
const char *skipped_file,
|
65
|
+
const git_oid *blob_oid,
|
66
|
+
int file_mode,
|
67
|
+
void *payload);
|
68
|
+
|
69
|
+
void *notify_payload;
|
70
|
+
|
71
|
+
/** When not NULL, array of fnmatch patterns specifying
|
72
|
+
* which paths should be taken into account
|
73
|
+
*/
|
74
|
+
git_strarray paths;
|
35
75
|
} git_checkout_opts;
|
36
76
|
|
37
77
|
/**
|
38
|
-
* Updates files in the working tree to match the
|
78
|
+
* Updates files in the index and the working tree to match the content of the
|
79
|
+
* commit pointed at by HEAD.
|
39
80
|
*
|
40
81
|
* @param repo repository to check out (must be non-bare)
|
41
82
|
* @param opts specifies checkout options (may be NULL)
|
42
83
|
* @param stats structure through which progress information is reported
|
43
|
-
* @return 0 on success,
|
84
|
+
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing
|
85
|
+
* branch, GIT_ERROR otherwise (use giterr_last for information
|
86
|
+
* about the error)
|
44
87
|
*/
|
45
|
-
GIT_EXTERN(int) git_checkout_head(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
88
|
+
GIT_EXTERN(int) git_checkout_head(
|
89
|
+
git_repository *repo,
|
90
|
+
git_checkout_opts *opts,
|
91
|
+
git_indexer_stats *stats);
|
50
92
|
|
51
93
|
/**
|
52
|
-
* Updates files in the working tree to match
|
94
|
+
* Updates files in the working tree to match the content of the index.
|
53
95
|
*
|
54
|
-
* @param
|
96
|
+
* @param repo repository to check out (must be non-bare)
|
55
97
|
* @param opts specifies checkout options (may be NULL)
|
56
98
|
* @param stats structure through which progress information is reported
|
57
|
-
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
|
99
|
+
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
|
100
|
+
* about the error)
|
58
101
|
*/
|
59
|
-
GIT_EXTERN(int)
|
60
|
-
|
61
|
-
|
102
|
+
GIT_EXTERN(int) git_checkout_index(
|
103
|
+
git_repository *repo,
|
104
|
+
git_checkout_opts *opts,
|
105
|
+
git_indexer_stats *stats);
|
62
106
|
|
107
|
+
/**
|
108
|
+
* Updates files in the index and working tree to match the content of the
|
109
|
+
* tree pointed at by the treeish.
|
110
|
+
*
|
111
|
+
* @param repo repository to check out (must be non-bare)
|
112
|
+
* @param treeish a commit, tag or tree which content will be used to update
|
113
|
+
* the working directory
|
114
|
+
* @param opts specifies checkout options (may be NULL)
|
115
|
+
* @param stats structure through which progress information is reported
|
116
|
+
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
|
117
|
+
* about the error)
|
118
|
+
*/
|
119
|
+
GIT_EXTERN(int) git_checkout_tree(
|
120
|
+
git_repository *repo,
|
121
|
+
git_object *treeish,
|
122
|
+
git_checkout_opts *opts,
|
123
|
+
git_indexer_stats *stats);
|
63
124
|
|
64
125
|
/** @} */
|
65
126
|
GIT_END_DECL
|