rugged 1.5.0.1 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +2 -2
- data/ext/rugged/rugged_allocator.c +0 -54
- data/ext/rugged/rugged_blame.c +2 -0
- data/ext/rugged/rugged_blob.c +3 -0
- data/ext/rugged/rugged_commit.c +1 -0
- data/ext/rugged/rugged_config.c +2 -0
- data/ext/rugged/rugged_diff.c +1 -0
- data/ext/rugged/rugged_index.c +2 -0
- data/ext/rugged/rugged_patch.c +1 -0
- data/ext/rugged/rugged_rebase.c +1 -0
- data/ext/rugged/rugged_reference.c +1 -0
- data/ext/rugged/rugged_remote.c +1 -0
- data/ext/rugged/rugged_repo.c +5 -2
- data/ext/rugged/rugged_revwalk.c +5 -1
- data/ext/rugged/rugged_submodule.c +1 -0
- data/ext/rugged/rugged_tag.c +1 -0
- data/ext/rugged/rugged_tree.c +4 -0
- data/lib/rugged/index.rb +1 -1
- data/lib/rugged/tree.rb +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +7 -8
- data/vendor/libgit2/COPYING +30 -0
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
- data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +3 -3
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +21 -2
- data/vendor/libgit2/cmake/SelectHashes.cmake +4 -0
- data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/pcre/LICENCE +5 -5
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
- data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +24 -22
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
- data/vendor/libgit2/include/git2/common.h +38 -6
- data/vendor/libgit2/include/git2/deprecated.h +6 -0
- data/vendor/libgit2/include/git2/diff.h +42 -4
- data/vendor/libgit2/include/git2/errors.h +4 -2
- data/vendor/libgit2/include/git2/experimental.h +20 -0
- data/vendor/libgit2/include/git2/index.h +9 -0
- data/vendor/libgit2/include/git2/indexer.h +29 -0
- data/vendor/libgit2/include/git2/object.h +28 -2
- data/vendor/libgit2/include/git2/odb.h +58 -7
- data/vendor/libgit2/include/git2/odb_backend.h +106 -18
- data/vendor/libgit2/include/git2/oid.h +116 -16
- data/vendor/libgit2/include/git2/remote.h +18 -0
- data/vendor/libgit2/include/git2/repository.h +32 -3
- data/vendor/libgit2/include/git2/stash.h +60 -6
- data/vendor/libgit2/include/git2/strarray.h +0 -13
- data/vendor/libgit2/include/git2/sys/alloc.h +0 -34
- data/vendor/libgit2/include/git2/sys/commit_graph.h +12 -2
- data/vendor/libgit2/include/git2/sys/midx.h +5 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/sys/stream.h +16 -2
- data/vendor/libgit2/include/git2/sys/transport.h +32 -2
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +3 -1
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +34 -17
- data/vendor/libgit2/src/cli/CMakeLists.txt +5 -2
- data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
- data/vendor/libgit2/src/cli/cmd_hash_object.c +27 -8
- data/vendor/libgit2/src/cli/opt.c +1 -1
- data/vendor/libgit2/src/cli/progress.c +9 -8
- data/vendor/libgit2/src/cli/progress.h +4 -4
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +25 -34
- data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
- data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
- data/vendor/libgit2/src/libgit2/apply.c +4 -3
- data/vendor/libgit2/src/libgit2/attr_file.c +1 -1
- data/vendor/libgit2/src/libgit2/attrcache.c +1 -1
- data/vendor/libgit2/src/libgit2/blame.c +23 -14
- data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
- data/vendor/libgit2/src/libgit2/blob.c +4 -2
- data/vendor/libgit2/src/libgit2/blob.h +2 -2
- data/vendor/libgit2/src/libgit2/branch.c +2 -2
- data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
- data/vendor/libgit2/src/libgit2/clone.c +34 -3
- data/vendor/libgit2/src/libgit2/commit.c +78 -21
- data/vendor/libgit2/src/libgit2/commit.h +25 -7
- data/vendor/libgit2/src/libgit2/commit_graph.c +129 -47
- data/vendor/libgit2/src/libgit2/commit_graph.h +23 -4
- data/vendor/libgit2/src/libgit2/commit_list.c +16 -5
- data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
- data/vendor/libgit2/src/libgit2/config.c +6 -3
- data/vendor/libgit2/src/libgit2/config_file.c +16 -10
- data/vendor/libgit2/src/libgit2/describe.c +11 -8
- data/vendor/libgit2/src/libgit2/diff.c +19 -6
- data/vendor/libgit2/src/libgit2/diff.h +6 -6
- data/vendor/libgit2/src/libgit2/diff_file.c +16 -7
- data/vendor/libgit2/src/libgit2/diff_generate.c +37 -11
- data/vendor/libgit2/src/libgit2/diff_parse.c +20 -4
- data/vendor/libgit2/src/libgit2/diff_print.c +26 -7
- data/vendor/libgit2/src/libgit2/diff_tform.c +4 -0
- data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/libgit2/email.c +4 -3
- data/vendor/libgit2/src/libgit2/errors.c +73 -18
- data/vendor/libgit2/src/libgit2/experimental.h.in +13 -0
- data/vendor/libgit2/src/libgit2/fetch.c +38 -13
- data/vendor/libgit2/src/libgit2/fetch.h +0 -2
- data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
- data/vendor/libgit2/src/libgit2/grafts.c +272 -0
- data/vendor/libgit2/src/libgit2/grafts.h +36 -0
- data/vendor/libgit2/src/libgit2/ident.c +3 -3
- data/vendor/libgit2/src/libgit2/index.c +327 -123
- data/vendor/libgit2/src/libgit2/index.h +14 -1
- data/vendor/libgit2/src/libgit2/indexer.c +116 -46
- data/vendor/libgit2/src/libgit2/iterator.c +21 -4
- data/vendor/libgit2/src/libgit2/iterator.h +3 -0
- data/vendor/libgit2/src/libgit2/libgit2.c +58 -0
- data/vendor/libgit2/src/libgit2/merge.c +14 -9
- data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
- data/vendor/libgit2/src/libgit2/midx.c +68 -38
- data/vendor/libgit2/src/libgit2/midx.h +13 -3
- data/vendor/libgit2/src/libgit2/mwindow.c +5 -2
- data/vendor/libgit2/src/libgit2/mwindow.h +4 -1
- data/vendor/libgit2/src/libgit2/notes.c +9 -8
- data/vendor/libgit2/src/libgit2/object.c +118 -29
- data/vendor/libgit2/src/libgit2/object.h +17 -2
- data/vendor/libgit2/src/libgit2/odb.c +224 -55
- data/vendor/libgit2/src/libgit2/odb.h +43 -4
- data/vendor/libgit2/src/libgit2/odb_loose.c +128 -70
- data/vendor/libgit2/src/libgit2/odb_pack.c +111 -46
- data/vendor/libgit2/src/libgit2/oid.c +141 -77
- data/vendor/libgit2/src/libgit2/oid.h +183 -9
- data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
- data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
- data/vendor/libgit2/src/libgit2/pack-objects.c +31 -13
- data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
- data/vendor/libgit2/src/libgit2/pack.c +93 -70
- data/vendor/libgit2/src/libgit2/pack.h +29 -15
- data/vendor/libgit2/src/libgit2/parse.c +8 -4
- data/vendor/libgit2/src/libgit2/parse.h +1 -1
- data/vendor/libgit2/src/libgit2/patch.h +7 -1
- data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
- data/vendor/libgit2/src/libgit2/patch_parse.c +16 -8
- data/vendor/libgit2/src/libgit2/push.c +13 -3
- data/vendor/libgit2/src/libgit2/reader.c +1 -1
- data/vendor/libgit2/src/libgit2/rebase.c +72 -83
- data/vendor/libgit2/src/libgit2/refdb_fs.c +92 -52
- data/vendor/libgit2/src/libgit2/reflog.c +7 -5
- data/vendor/libgit2/src/libgit2/reflog.h +1 -2
- data/vendor/libgit2/src/libgit2/refs.c +9 -0
- data/vendor/libgit2/src/libgit2/remote.c +47 -37
- data/vendor/libgit2/src/libgit2/remote.h +41 -0
- data/vendor/libgit2/src/libgit2/repository.c +784 -329
- data/vendor/libgit2/src/libgit2/repository.h +26 -2
- data/vendor/libgit2/src/libgit2/reset.c +2 -2
- data/vendor/libgit2/src/libgit2/revert.c +8 -11
- data/vendor/libgit2/src/libgit2/revparse.c +23 -7
- data/vendor/libgit2/src/libgit2/revwalk.c +31 -5
- data/vendor/libgit2/src/libgit2/stash.c +209 -33
- data/vendor/libgit2/src/libgit2/strarray.c +1 -0
- data/vendor/libgit2/src/libgit2/strarray.h +25 -0
- data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
- data/vendor/libgit2/src/libgit2/streams/openssl.c +9 -17
- data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +7 -3
- data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
- data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
- data/vendor/libgit2/src/libgit2/streams/socket.c +240 -51
- data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
- data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
- data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
- data/vendor/libgit2/src/libgit2/submodule.c +6 -2
- data/vendor/libgit2/src/libgit2/submodule.h +3 -3
- data/vendor/libgit2/src/libgit2/sysdir.c +294 -7
- data/vendor/libgit2/src/libgit2/sysdir.h +41 -9
- data/vendor/libgit2/src/libgit2/tag.c +29 -10
- data/vendor/libgit2/src/libgit2/tag.h +2 -2
- data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
- data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
- data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
- data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
- data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
- data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
- data/vendor/libgit2/src/libgit2/transports/http.c +15 -9
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +14 -0
- data/vendor/libgit2/src/libgit2/transports/httpclient.h +10 -0
- data/vendor/libgit2/src/libgit2/transports/local.c +27 -4
- data/vendor/libgit2/src/libgit2/transports/smart.c +68 -27
- data/vendor/libgit2/src/libgit2/transports/smart.h +33 -9
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +281 -49
- data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +192 -55
- data/vendor/libgit2/src/libgit2/transports/ssh.c +334 -102
- data/vendor/libgit2/src/libgit2/transports/winhttp.c +22 -18
- data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
- data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
- data/vendor/libgit2/src/libgit2/tree.c +23 -17
- data/vendor/libgit2/src/libgit2/tree.h +2 -2
- data/vendor/libgit2/src/libgit2/worktree.c +30 -10
- data/vendor/libgit2/src/util/CMakeLists.txt +6 -1
- data/vendor/libgit2/src/util/alloc.c +65 -6
- data/vendor/libgit2/src/util/alloc.h +34 -9
- data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
- data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
- data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
- data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
- data/vendor/libgit2/src/util/array.h +6 -1
- data/vendor/libgit2/src/util/cc-compat.h +2 -0
- data/vendor/libgit2/src/util/filebuf.c +6 -1
- data/vendor/libgit2/src/util/filebuf.h +19 -6
- data/vendor/libgit2/src/util/fs_path.c +2 -2
- data/vendor/libgit2/src/util/futils.c +8 -8
- data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +9 -3
- data/vendor/libgit2/src/util/git2_util.h +2 -2
- data/vendor/libgit2/src/util/hash/openssl.c +4 -3
- data/vendor/libgit2/src/util/hash/rfc6234/sha.h +0 -112
- data/vendor/libgit2/src/util/hash.h +13 -0
- data/vendor/libgit2/src/util/net.c +492 -87
- data/vendor/libgit2/src/util/net.h +32 -0
- data/vendor/libgit2/src/util/posix.c +54 -0
- data/vendor/libgit2/src/util/posix.h +24 -0
- data/vendor/libgit2/src/util/rand.c +10 -4
- data/vendor/libgit2/src/util/regexp.c +3 -3
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/util/thread.h +20 -19
- data/vendor/libgit2/src/util/util.c +15 -10
- data/vendor/libgit2/src/util/util.h +25 -16
- data/vendor/libgit2/src/util/win32/error.c +1 -1
- data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
- data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
- data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
- data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
- data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
- metadata +34 -26
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
- data/vendor/libgit2/src/libgit2/netops.c +0 -124
- data/vendor/libgit2/src/libgit2/netops.h +0 -68
- data/vendor/libgit2/src/util/win32/findfile.c +0 -286
- data/vendor/libgit2/src/util/win32/findfile.h +0 -22
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -138,19 +138,22 @@ static int commit_graph_parse_oid_lookup(
|
|
138
138
|
struct git_commit_graph_chunk *chunk_oid_lookup)
|
139
139
|
{
|
140
140
|
uint32_t i;
|
141
|
-
unsigned char *oid, *prev_oid, zero_oid[
|
141
|
+
unsigned char *oid, *prev_oid, zero_oid[GIT_OID_MAX_SIZE] = {0};
|
142
|
+
size_t oid_size;
|
143
|
+
|
144
|
+
oid_size = git_oid_size(file->oid_type);
|
142
145
|
|
143
146
|
if (chunk_oid_lookup->offset == 0)
|
144
147
|
return commit_graph_error("missing OID Lookup chunk");
|
145
148
|
if (chunk_oid_lookup->length == 0)
|
146
149
|
return commit_graph_error("empty OID Lookup chunk");
|
147
|
-
if (chunk_oid_lookup->length != file->num_commits *
|
150
|
+
if (chunk_oid_lookup->length != file->num_commits * oid_size)
|
148
151
|
return commit_graph_error("OID Lookup chunk has wrong length");
|
149
152
|
|
150
153
|
file->oid_lookup = oid = (unsigned char *)(data + chunk_oid_lookup->offset);
|
151
154
|
prev_oid = zero_oid;
|
152
|
-
for (i = 0; i < file->num_commits; ++i, oid +=
|
153
|
-
if (git_oid_raw_cmp(prev_oid, oid) >= 0)
|
155
|
+
for (i = 0; i < file->num_commits; ++i, oid += oid_size) {
|
156
|
+
if (git_oid_raw_cmp(prev_oid, oid, oid_size) >= 0)
|
154
157
|
return commit_graph_error("OID Lookup index is non-monotonic");
|
155
158
|
prev_oid = oid;
|
156
159
|
}
|
@@ -163,11 +166,13 @@ static int commit_graph_parse_commit_data(
|
|
163
166
|
const unsigned char *data,
|
164
167
|
struct git_commit_graph_chunk *chunk_commit_data)
|
165
168
|
{
|
169
|
+
size_t oid_size = git_oid_size(file->oid_type);
|
170
|
+
|
166
171
|
if (chunk_commit_data->offset == 0)
|
167
172
|
return commit_graph_error("missing Commit Data chunk");
|
168
173
|
if (chunk_commit_data->length == 0)
|
169
174
|
return commit_graph_error("empty Commit Data chunk");
|
170
|
-
if (chunk_commit_data->length != file->num_commits * (
|
175
|
+
if (chunk_commit_data->length != file->num_commits * (oid_size + 16))
|
171
176
|
return commit_graph_error("Commit Data chunk has wrong length");
|
172
177
|
|
173
178
|
file->commit_data = data + chunk_commit_data->offset;
|
@@ -200,8 +205,7 @@ int git_commit_graph_file_parse(
|
|
200
205
|
const unsigned char *chunk_hdr;
|
201
206
|
struct git_commit_graph_chunk *last_chunk;
|
202
207
|
uint32_t i;
|
203
|
-
|
204
|
-
unsigned char checksum[GIT_HASH_SHA1_SIZE];
|
208
|
+
uint64_t last_chunk_offset, chunk_offset, trailer_offset;
|
205
209
|
size_t checksum_size;
|
206
210
|
int error;
|
207
211
|
struct git_commit_graph_chunk chunk_oid_fanout = {0}, chunk_oid_lookup = {0},
|
@@ -210,7 +214,9 @@ int git_commit_graph_file_parse(
|
|
210
214
|
|
211
215
|
GIT_ASSERT_ARG(file);
|
212
216
|
|
213
|
-
|
217
|
+
checksum_size = git_oid_size(file->oid_type);
|
218
|
+
|
219
|
+
if (size < sizeof(struct git_commit_graph_header) + checksum_size)
|
214
220
|
return commit_graph_error("commit-graph is too short");
|
215
221
|
|
216
222
|
hdr = ((struct git_commit_graph_header *)data);
|
@@ -227,23 +233,17 @@ int git_commit_graph_file_parse(
|
|
227
233
|
* headers, and a special zero chunk.
|
228
234
|
*/
|
229
235
|
last_chunk_offset = sizeof(struct git_commit_graph_header) + (1 + hdr->chunks) * 12;
|
230
|
-
trailer_offset = size -
|
231
|
-
checksum_size = GIT_HASH_SHA1_SIZE;
|
236
|
+
trailer_offset = size - checksum_size;
|
232
237
|
|
233
238
|
if (trailer_offset < last_chunk_offset)
|
234
239
|
return commit_graph_error("wrong commit-graph size");
|
235
240
|
memcpy(file->checksum, (data + trailer_offset), checksum_size);
|
236
241
|
|
237
|
-
if (git_hash_buf(checksum, data, (size_t)trailer_offset, GIT_HASH_ALGORITHM_SHA1) < 0)
|
238
|
-
return commit_graph_error("could not calculate signature");
|
239
|
-
if (memcmp(checksum, file->checksum, checksum_size) != 0)
|
240
|
-
return commit_graph_error("index signature mismatch");
|
241
|
-
|
242
242
|
chunk_hdr = data + sizeof(struct git_commit_graph_header);
|
243
243
|
last_chunk = NULL;
|
244
244
|
for (i = 0; i < hdr->chunks; ++i, chunk_hdr += 12) {
|
245
|
-
chunk_offset = ((
|
246
|
-
| ((
|
245
|
+
chunk_offset = ((uint64_t)ntohl(*((uint32_t *)(chunk_hdr + 4)))) << 32
|
246
|
+
| ((uint64_t)ntohl(*((uint32_t *)(chunk_hdr + 8))));
|
247
247
|
if (chunk_offset < last_chunk_offset)
|
248
248
|
return commit_graph_error("chunks are non-monotonic");
|
249
249
|
if (chunk_offset >= trailer_offset)
|
@@ -301,25 +301,35 @@ int git_commit_graph_file_parse(
|
|
301
301
|
return 0;
|
302
302
|
}
|
303
303
|
|
304
|
-
int git_commit_graph_new(
|
304
|
+
int git_commit_graph_new(
|
305
|
+
git_commit_graph **cgraph_out,
|
306
|
+
const char *objects_dir,
|
307
|
+
bool open_file,
|
308
|
+
git_oid_t oid_type)
|
305
309
|
{
|
306
310
|
git_commit_graph *cgraph = NULL;
|
307
311
|
int error = 0;
|
308
312
|
|
309
313
|
GIT_ASSERT_ARG(cgraph_out);
|
310
314
|
GIT_ASSERT_ARG(objects_dir);
|
315
|
+
GIT_ASSERT_ARG(oid_type);
|
311
316
|
|
312
317
|
cgraph = git__calloc(1, sizeof(git_commit_graph));
|
313
318
|
GIT_ERROR_CHECK_ALLOC(cgraph);
|
314
319
|
|
320
|
+
cgraph->oid_type = oid_type;
|
321
|
+
|
315
322
|
error = git_str_joinpath(&cgraph->filename, objects_dir, "info/commit-graph");
|
316
323
|
if (error < 0)
|
317
324
|
goto error;
|
318
325
|
|
319
326
|
if (open_file) {
|
320
|
-
error = git_commit_graph_file_open(&cgraph->file,
|
327
|
+
error = git_commit_graph_file_open(&cgraph->file,
|
328
|
+
git_str_cstr(&cgraph->filename), oid_type);
|
329
|
+
|
321
330
|
if (error < 0)
|
322
331
|
goto error;
|
332
|
+
|
323
333
|
cgraph->checked = 1;
|
324
334
|
}
|
325
335
|
|
@@ -331,12 +341,52 @@ error:
|
|
331
341
|
return error;
|
332
342
|
}
|
333
343
|
|
334
|
-
int
|
344
|
+
int git_commit_graph_validate(git_commit_graph *cgraph) {
|
345
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
346
|
+
git_hash_algorithm_t checksum_type;
|
347
|
+
size_t checksum_size, trailer_offset;
|
348
|
+
|
349
|
+
checksum_type = git_oid_algorithm(cgraph->oid_type);
|
350
|
+
checksum_size = git_hash_size(checksum_type);
|
351
|
+
trailer_offset = cgraph->file->graph_map.len - checksum_size;
|
352
|
+
|
353
|
+
if (cgraph->file->graph_map.len < checksum_size)
|
354
|
+
return commit_graph_error("map length too small");
|
355
|
+
|
356
|
+
if (git_hash_buf(checksum, cgraph->file->graph_map.data, trailer_offset, checksum_type) < 0)
|
357
|
+
return commit_graph_error("could not calculate signature");
|
358
|
+
if (memcmp(checksum, cgraph->file->checksum, checksum_size) != 0)
|
359
|
+
return commit_graph_error("index signature mismatch");
|
360
|
+
|
361
|
+
return 0;
|
362
|
+
}
|
363
|
+
|
364
|
+
int git_commit_graph_open(
|
365
|
+
git_commit_graph **cgraph_out,
|
366
|
+
const char *objects_dir
|
367
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
368
|
+
, git_oid_t oid_type
|
369
|
+
#endif
|
370
|
+
)
|
335
371
|
{
|
336
|
-
|
372
|
+
#ifndef GIT_EXPERIMENTAL_SHA256
|
373
|
+
git_oid_t oid_type = GIT_OID_SHA1;
|
374
|
+
#endif
|
375
|
+
int error;
|
376
|
+
|
377
|
+
error = git_commit_graph_new(cgraph_out, objects_dir, true,
|
378
|
+
oid_type);
|
379
|
+
|
380
|
+
if (!error)
|
381
|
+
return git_commit_graph_validate(*cgraph_out);
|
382
|
+
|
383
|
+
return error;
|
337
384
|
}
|
338
385
|
|
339
|
-
int git_commit_graph_file_open(
|
386
|
+
int git_commit_graph_file_open(
|
387
|
+
git_commit_graph_file **file_out,
|
388
|
+
const char *path,
|
389
|
+
git_oid_t oid_type)
|
340
390
|
{
|
341
391
|
git_commit_graph_file *file;
|
342
392
|
git_file fd = -1;
|
@@ -365,6 +415,8 @@ int git_commit_graph_file_open(git_commit_graph_file **file_out, const char *pat
|
|
365
415
|
file = git__calloc(1, sizeof(git_commit_graph_file));
|
366
416
|
GIT_ERROR_CHECK_ALLOC(file);
|
367
417
|
|
418
|
+
file->oid_type = oid_type;
|
419
|
+
|
368
420
|
error = git_futils_mmap_ro(&file->graph_map, fd, 0, cgraph_size);
|
369
421
|
p_close(fd);
|
370
422
|
if (error < 0) {
|
@@ -381,7 +433,9 @@ int git_commit_graph_file_open(git_commit_graph_file **file_out, const char *pat
|
|
381
433
|
return 0;
|
382
434
|
}
|
383
435
|
|
384
|
-
int git_commit_graph_get_file(
|
436
|
+
int git_commit_graph_get_file(
|
437
|
+
git_commit_graph_file **file_out,
|
438
|
+
git_commit_graph *cgraph)
|
385
439
|
{
|
386
440
|
if (!cgraph->checked) {
|
387
441
|
int error = 0;
|
@@ -391,7 +445,8 @@ int git_commit_graph_get_file(git_commit_graph_file **file_out, git_commit_graph
|
|
391
445
|
cgraph->checked = 1;
|
392
446
|
|
393
447
|
/* Best effort */
|
394
|
-
error = git_commit_graph_file_open(&result,
|
448
|
+
error = git_commit_graph_file_open(&result,
|
449
|
+
git_str_cstr(&cgraph->filename), cgraph->oid_type);
|
395
450
|
|
396
451
|
if (error < 0)
|
397
452
|
return error;
|
@@ -427,6 +482,7 @@ static int git_commit_graph_entry_get_byindex(
|
|
427
482
|
size_t pos)
|
428
483
|
{
|
429
484
|
const unsigned char *commit_data;
|
485
|
+
size_t oid_size = git_oid_size(file->oid_type);
|
430
486
|
|
431
487
|
GIT_ASSERT_ARG(e);
|
432
488
|
GIT_ASSERT_ARG(file);
|
@@ -436,15 +492,15 @@ static int git_commit_graph_entry_get_byindex(
|
|
436
492
|
return GIT_ENOTFOUND;
|
437
493
|
}
|
438
494
|
|
439
|
-
commit_data = file->commit_data + pos * (
|
440
|
-
|
441
|
-
e->parent_indices[0] = ntohl(*((uint32_t *)(commit_data +
|
495
|
+
commit_data = file->commit_data + pos * (oid_size + 4 * sizeof(uint32_t));
|
496
|
+
git_oid__fromraw(&e->tree_oid, commit_data, file->oid_type);
|
497
|
+
e->parent_indices[0] = ntohl(*((uint32_t *)(commit_data + oid_size)));
|
442
498
|
e->parent_indices[1] = ntohl(
|
443
|
-
*((uint32_t *)(commit_data +
|
499
|
+
*((uint32_t *)(commit_data + oid_size + sizeof(uint32_t))));
|
444
500
|
e->parent_count = (e->parent_indices[0] != GIT_COMMIT_GRAPH_MISSING_PARENT)
|
445
501
|
+ (e->parent_indices[1] != GIT_COMMIT_GRAPH_MISSING_PARENT);
|
446
|
-
e->generation = ntohl(*((uint32_t *)(commit_data +
|
447
|
-
e->commit_time = ntohl(*((uint32_t *)(commit_data +
|
502
|
+
e->generation = ntohl(*((uint32_t *)(commit_data + oid_size + 2 * sizeof(uint32_t))));
|
503
|
+
e->commit_time = ntohl(*((uint32_t *)(commit_data + oid_size + 3 * sizeof(uint32_t))));
|
448
504
|
|
449
505
|
e->commit_time |= (e->generation & UINT64_C(0x3)) << UINT64_C(32);
|
450
506
|
e->generation >>= 2u;
|
@@ -471,7 +527,7 @@ static int git_commit_graph_entry_get_byindex(
|
|
471
527
|
}
|
472
528
|
}
|
473
529
|
|
474
|
-
|
530
|
+
git_oid__fromraw(&e->sha1, &file->oid_lookup[pos * oid_size], file->oid_type);
|
475
531
|
return 0;
|
476
532
|
}
|
477
533
|
|
@@ -480,8 +536,8 @@ bool git_commit_graph_file_needs_refresh(const git_commit_graph_file *file, cons
|
|
480
536
|
git_file fd = -1;
|
481
537
|
struct stat st;
|
482
538
|
ssize_t bytes_read;
|
483
|
-
unsigned char checksum[
|
484
|
-
size_t checksum_size =
|
539
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
540
|
+
size_t checksum_size = git_oid_size(file->oid_type);
|
485
541
|
|
486
542
|
/* TODO: properly open the file without access time using O_NOATIME */
|
487
543
|
fd = git_futils_open_ro(path);
|
@@ -516,35 +572,40 @@ int git_commit_graph_entry_find(
|
|
516
572
|
int pos, found = 0;
|
517
573
|
uint32_t hi, lo;
|
518
574
|
const unsigned char *current = NULL;
|
575
|
+
size_t oid_size, oid_hexsize;
|
519
576
|
|
520
577
|
GIT_ASSERT_ARG(e);
|
521
578
|
GIT_ASSERT_ARG(file);
|
522
579
|
GIT_ASSERT_ARG(short_oid);
|
523
580
|
|
581
|
+
oid_size = git_oid_size(file->oid_type);
|
582
|
+
oid_hexsize = git_oid_hexsize(file->oid_type);
|
583
|
+
|
524
584
|
hi = ntohl(file->oid_fanout[(int)short_oid->id[0]]);
|
525
585
|
lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(file->oid_fanout[(int)short_oid->id[0] - 1]));
|
526
586
|
|
527
|
-
pos =
|
587
|
+
pos = git_pack__lookup_id(file->oid_lookup, oid_size, lo, hi,
|
588
|
+
short_oid->id, file->oid_type);
|
528
589
|
|
529
590
|
if (pos >= 0) {
|
530
591
|
/* An object matching exactly the oid was found */
|
531
592
|
found = 1;
|
532
|
-
current = file->oid_lookup + (pos *
|
593
|
+
current = file->oid_lookup + (pos * oid_size);
|
533
594
|
} else {
|
534
595
|
/* No object was found */
|
535
596
|
/* pos refers to the object with the "closest" oid to short_oid */
|
536
597
|
pos = -1 - pos;
|
537
598
|
if (pos < (int)file->num_commits) {
|
538
|
-
current = file->oid_lookup + (pos *
|
599
|
+
current = file->oid_lookup + (pos * oid_size);
|
539
600
|
|
540
601
|
if (!git_oid_raw_ncmp(short_oid->id, current, len))
|
541
602
|
found = 1;
|
542
603
|
}
|
543
604
|
}
|
544
605
|
|
545
|
-
if (found && len !=
|
606
|
+
if (found && len != oid_hexsize && pos + 1 < (int)file->num_commits) {
|
546
607
|
/* Check for ambiguousity */
|
547
|
-
const unsigned char *next = current +
|
608
|
+
const unsigned char *next = current + oid_size;
|
548
609
|
|
549
610
|
if (!git_oid_raw_ncmp(short_oid->id, next, len))
|
550
611
|
found = 2;
|
@@ -623,11 +684,27 @@ static int packed_commit__cmp(const void *a_, const void *b_)
|
|
623
684
|
return git_oid_cmp(&a->sha1, &b->sha1);
|
624
685
|
}
|
625
686
|
|
626
|
-
int git_commit_graph_writer_new(
|
687
|
+
int git_commit_graph_writer_new(
|
688
|
+
git_commit_graph_writer **out,
|
689
|
+
const char *objects_info_dir
|
690
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
691
|
+
, git_oid_t oid_type
|
692
|
+
#endif
|
693
|
+
)
|
627
694
|
{
|
628
|
-
git_commit_graph_writer *w
|
695
|
+
git_commit_graph_writer *w;
|
696
|
+
|
697
|
+
#ifndef GIT_EXPERIMENTAL_SHA256
|
698
|
+
git_oid_t oid_type = GIT_OID_SHA1;
|
699
|
+
#endif
|
700
|
+
|
701
|
+
GIT_ASSERT_ARG(out && objects_info_dir && oid_type);
|
702
|
+
|
703
|
+
w = git__calloc(1, sizeof(git_commit_graph_writer));
|
629
704
|
GIT_ERROR_CHECK_ALLOC(w);
|
630
705
|
|
706
|
+
w->oid_type = oid_type;
|
707
|
+
|
631
708
|
if (git_str_sets(&w->objects_info_dir, objects_info_dir) < 0) {
|
632
709
|
git__free(w);
|
633
710
|
return -1;
|
@@ -712,7 +789,8 @@ int git_commit_graph_writer_add_index_file(
|
|
712
789
|
if (error < 0)
|
713
790
|
goto cleanup;
|
714
791
|
|
715
|
-
|
792
|
+
/* TODO: SHA256 */
|
793
|
+
error = git_mwindow_get_pack(&p, idx_path, 0);
|
716
794
|
if (error < 0)
|
717
795
|
goto cleanup;
|
718
796
|
|
@@ -978,8 +1056,9 @@ static int commit_graph_write(
|
|
978
1056
|
off64_t offset;
|
979
1057
|
git_str oid_lookup = GIT_STR_INIT, commit_data = GIT_STR_INIT,
|
980
1058
|
extra_edge_list = GIT_STR_INIT;
|
981
|
-
unsigned char checksum[
|
982
|
-
|
1059
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
1060
|
+
git_hash_algorithm_t checksum_type;
|
1061
|
+
size_t checksum_size, oid_size;
|
983
1062
|
git_hash_ctx ctx;
|
984
1063
|
struct commit_graph_write_hash_context hash_cb_data = {0};
|
985
1064
|
|
@@ -992,8 +1071,11 @@ static int commit_graph_write(
|
|
992
1071
|
hash_cb_data.cb_data = cb_data;
|
993
1072
|
hash_cb_data.ctx = &ctx;
|
994
1073
|
|
995
|
-
|
996
|
-
|
1074
|
+
oid_size = git_oid_size(w->oid_type);
|
1075
|
+
checksum_type = git_oid_algorithm(w->oid_type);
|
1076
|
+
checksum_size = git_hash_size(checksum_type);
|
1077
|
+
|
1078
|
+
error = git_hash_ctx_init(&ctx, checksum_type);
|
997
1079
|
if (error < 0)
|
998
1080
|
return error;
|
999
1081
|
cb_data = &hash_cb_data;
|
@@ -1020,7 +1102,7 @@ static int commit_graph_write(
|
|
1020
1102
|
git_vector_foreach (&w->commits, i, packed_commit) {
|
1021
1103
|
error = git_str_put(&oid_lookup,
|
1022
1104
|
(const char *)&packed_commit->sha1.id,
|
1023
|
-
|
1105
|
+
oid_size);
|
1024
1106
|
|
1025
1107
|
if (error < 0)
|
1026
1108
|
goto cleanup;
|
@@ -1037,7 +1119,7 @@ static int commit_graph_write(
|
|
1037
1119
|
|
1038
1120
|
error = git_str_put(&commit_data,
|
1039
1121
|
(const char *)&packed_commit->tree_oid.id,
|
1040
|
-
|
1122
|
+
oid_size);
|
1041
1123
|
|
1042
1124
|
if (error < 0)
|
1043
1125
|
goto cleanup;
|
@@ -30,6 +30,9 @@
|
|
30
30
|
typedef struct git_commit_graph_file {
|
31
31
|
git_map graph_map;
|
32
32
|
|
33
|
+
/* The type of object IDs in the commit graph file. */
|
34
|
+
git_oid_t oid_type;
|
35
|
+
|
33
36
|
/* The OID Fanout table. */
|
34
37
|
const uint32_t *oid_fanout;
|
35
38
|
/* The total number of commits in the graph. */
|
@@ -84,10 +87,10 @@ typedef struct git_commit_graph_entry {
|
|
84
87
|
/* The index within the Extra Edge List of any parent after the first two. */
|
85
88
|
size_t extra_parents_index;
|
86
89
|
|
87
|
-
/* The
|
90
|
+
/* The object ID of the root tree of the commit. */
|
88
91
|
git_oid tree_oid;
|
89
92
|
|
90
|
-
/* The
|
93
|
+
/* The object ID hash of the requested commit. */
|
91
94
|
git_oid sha1;
|
92
95
|
} git_commit_graph_entry;
|
93
96
|
|
@@ -99,15 +102,28 @@ struct git_commit_graph {
|
|
99
102
|
/* The underlying commit-graph file. */
|
100
103
|
git_commit_graph_file *file;
|
101
104
|
|
105
|
+
/* The object ID types in the commit graph. */
|
106
|
+
git_oid_t oid_type;
|
107
|
+
|
102
108
|
/* Whether the commit-graph file was already checked for validity. */
|
103
109
|
bool checked;
|
104
110
|
};
|
105
111
|
|
106
112
|
/** Create a new commit-graph, optionally opening the underlying file. */
|
107
|
-
int git_commit_graph_new(
|
113
|
+
int git_commit_graph_new(
|
114
|
+
git_commit_graph **cgraph_out,
|
115
|
+
const char *objects_dir,
|
116
|
+
bool open_file,
|
117
|
+
git_oid_t oid_type);
|
118
|
+
|
119
|
+
/** Validate the checksum of a commit graph */
|
120
|
+
int git_commit_graph_validate(git_commit_graph *cgraph);
|
108
121
|
|
109
122
|
/** Open and validate a commit-graph file. */
|
110
|
-
int git_commit_graph_file_open(
|
123
|
+
int git_commit_graph_file_open(
|
124
|
+
git_commit_graph_file **file_out,
|
125
|
+
const char *path,
|
126
|
+
git_oid_t oid_type);
|
111
127
|
|
112
128
|
/*
|
113
129
|
* Attempt to get the git_commit_graph's commit-graph file. This object is
|
@@ -131,6 +147,9 @@ struct git_commit_graph_writer {
|
|
131
147
|
*/
|
132
148
|
git_str objects_info_dir;
|
133
149
|
|
150
|
+
/* The object ID type of the commit graph. */
|
151
|
+
git_oid_t oid_type;
|
152
|
+
|
134
153
|
/* The list of packed commits. */
|
135
154
|
git_vector commits;
|
136
155
|
};
|
@@ -43,13 +43,18 @@ int git_commit_list_time_cmp(const void *a, const void *b)
|
|
43
43
|
return 0;
|
44
44
|
}
|
45
45
|
|
46
|
-
git_commit_list *
|
47
|
-
{
|
46
|
+
git_commit_list *git_commit_list_create(git_commit_list_node *item, git_commit_list *next) {
|
48
47
|
git_commit_list *new_list = git__malloc(sizeof(git_commit_list));
|
49
48
|
if (new_list != NULL) {
|
50
49
|
new_list->item = item;
|
51
|
-
new_list->next =
|
50
|
+
new_list->next = next;
|
52
51
|
}
|
52
|
+
return new_list;
|
53
|
+
}
|
54
|
+
|
55
|
+
git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p)
|
56
|
+
{
|
57
|
+
git_commit_list *new_list = git_commit_list_create(item, *list_p);
|
53
58
|
*list_p = new_list;
|
54
59
|
return new_list;
|
55
60
|
}
|
@@ -124,13 +129,17 @@ static int commit_quick_parse(
|
|
124
129
|
{
|
125
130
|
git_oid *parent_oid;
|
126
131
|
git_commit *commit;
|
132
|
+
git_commit__parse_options parse_opts = {
|
133
|
+
walk->repo->oid_type,
|
134
|
+
GIT_COMMIT_PARSE_QUICK
|
135
|
+
};
|
127
136
|
size_t i;
|
128
137
|
|
129
138
|
commit = git__calloc(1, sizeof(*commit));
|
130
139
|
GIT_ERROR_CHECK_ALLOC(commit);
|
131
140
|
commit->object.repo = walk->repo;
|
132
141
|
|
133
|
-
if (git_commit__parse_ext(commit, obj,
|
142
|
+
if (git_commit__parse_ext(commit, obj, &parse_opts) < 0) {
|
134
143
|
git__free(commit);
|
135
144
|
return -1;
|
136
145
|
}
|
@@ -172,7 +181,9 @@ int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit)
|
|
172
181
|
if (cgraph_file) {
|
173
182
|
git_commit_graph_entry e;
|
174
183
|
|
175
|
-
error = git_commit_graph_entry_find(&e, cgraph_file,
|
184
|
+
error = git_commit_graph_entry_find(&e, cgraph_file,
|
185
|
+
&commit->oid, git_oid_size(walk->repo->oid_type));
|
186
|
+
|
176
187
|
if (error == 0 && git__is_uint16(e.parent_count)) {
|
177
188
|
size_t i;
|
178
189
|
commit->generation = (uint32_t)e.generation;
|
@@ -49,6 +49,7 @@ git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk);
|
|
49
49
|
int git_commit_list_generation_cmp(const void *a, const void *b);
|
50
50
|
int git_commit_list_time_cmp(const void *a, const void *b);
|
51
51
|
void git_commit_list_free(git_commit_list **list_p);
|
52
|
+
git_commit_list *git_commit_list_create(git_commit_list_node *item, git_commit_list *next);
|
52
53
|
git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p);
|
53
54
|
git_commit_list *git_commit_list_insert_by_date(git_commit_list_node *item, git_commit_list **list_p);
|
54
55
|
int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit);
|
@@ -860,7 +860,7 @@ static int git_config__parse_path(git_str *out, const char *value)
|
|
860
860
|
return -1;
|
861
861
|
}
|
862
862
|
|
863
|
-
return
|
863
|
+
return git_sysdir_expand_homedir_file(out, value[1] ? &value[2] : NULL);
|
864
864
|
}
|
865
865
|
|
866
866
|
return git_str_sets(out, value);
|
@@ -1174,9 +1174,12 @@ int git_config__find_programdata(git_str *path)
|
|
1174
1174
|
GIT_FS_PATH_OWNER_CURRENT_USER |
|
1175
1175
|
GIT_FS_PATH_OWNER_ADMINISTRATOR;
|
1176
1176
|
bool is_safe;
|
1177
|
+
int error;
|
1178
|
+
|
1179
|
+
if ((error = git_sysdir_find_programdata_file(path, GIT_CONFIG_FILENAME_PROGRAMDATA)) < 0)
|
1180
|
+
return error;
|
1177
1181
|
|
1178
|
-
if (
|
1179
|
-
git_fs_path_owner_is(&is_safe, path->ptr, owner_level) < 0)
|
1182
|
+
if (git_fs_path_owner_is(&is_safe, path->ptr, owner_level) < 0)
|
1180
1183
|
return -1;
|
1181
1184
|
|
1182
1185
|
if (!is_safe) {
|
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
typedef struct config_file {
|
28
28
|
git_futils_filestamp stamp;
|
29
|
-
unsigned char checksum[
|
29
|
+
unsigned char checksum[GIT_HASH_SHA256_SIZE];
|
30
30
|
char *path;
|
31
31
|
git_array_t(struct config_file) includes;
|
32
32
|
} config_file;
|
@@ -133,7 +133,7 @@ static int config_file_is_modified(int *modified, config_file *file)
|
|
133
133
|
{
|
134
134
|
config_file *include;
|
135
135
|
git_str buf = GIT_STR_INIT;
|
136
|
-
unsigned char checksum[
|
136
|
+
unsigned char checksum[GIT_HASH_SHA256_SIZE];
|
137
137
|
uint32_t i;
|
138
138
|
int error = 0;
|
139
139
|
|
@@ -145,10 +145,10 @@ static int config_file_is_modified(int *modified, config_file *file)
|
|
145
145
|
if ((error = git_futils_readbuffer(&buf, file->path)) < 0)
|
146
146
|
goto out;
|
147
147
|
|
148
|
-
if ((error = git_hash_buf(checksum, buf.ptr, buf.size,
|
148
|
+
if ((error = git_hash_buf(checksum, buf.ptr, buf.size, GIT_HASH_ALGORITHM_SHA256)) < 0)
|
149
149
|
goto out;
|
150
150
|
|
151
|
-
if (memcmp(checksum, file->checksum,
|
151
|
+
if (memcmp(checksum, file->checksum, GIT_HASH_SHA256_SIZE) != 0) {
|
152
152
|
*modified = 1;
|
153
153
|
goto out;
|
154
154
|
}
|
@@ -528,7 +528,7 @@ static int included_path(git_str *out, const char *dir, const char *path)
|
|
528
528
|
{
|
529
529
|
/* From the user's home */
|
530
530
|
if (path[0] == '~' && path[1] == '/')
|
531
|
-
return
|
531
|
+
return git_sysdir_expand_homedir_file(out, &path[1]);
|
532
532
|
|
533
533
|
return git_fs_path_join_unrooted(out, path, dir, NULL);
|
534
534
|
}
|
@@ -616,7 +616,7 @@ static int do_match_gitdir(
|
|
616
616
|
git_fs_path_dirname_r(&pattern, cfg_file);
|
617
617
|
git_str_joinpath(&pattern, pattern.ptr, condition + 2);
|
618
618
|
} else if (condition[0] == '~' && git_fs_path_is_dirsep(condition[1]))
|
619
|
-
|
619
|
+
git_sysdir_expand_homedir_file(&pattern, condition + 1);
|
620
620
|
else if (!git_fs_path_is_absolute(condition))
|
621
621
|
git_str_joinpath(&pattern, "**", condition);
|
622
622
|
else
|
@@ -881,7 +881,7 @@ static int config_file_read(
|
|
881
881
|
goto out;
|
882
882
|
|
883
883
|
git_futils_filestamp_set_from_stat(&file->stamp, &st);
|
884
|
-
if ((error = git_hash_buf(file->checksum, contents.ptr, contents.size,
|
884
|
+
if ((error = git_hash_buf(file->checksum, contents.ptr, contents.size, GIT_HASH_ALGORITHM_SHA256)) < 0)
|
885
885
|
goto out;
|
886
886
|
|
887
887
|
if ((error = config_file_read_buffer(entries, repo, file, level, depth,
|
@@ -1116,7 +1116,12 @@ static int write_on_eof(
|
|
1116
1116
|
/*
|
1117
1117
|
* This is pretty much the parsing, except we write out anything we don't have
|
1118
1118
|
*/
|
1119
|
-
static int config_file_write(
|
1119
|
+
static int config_file_write(
|
1120
|
+
config_file_backend *cfg,
|
1121
|
+
const char *orig_key,
|
1122
|
+
const char *key,
|
1123
|
+
const git_regexp *preg,
|
1124
|
+
const char *value)
|
1120
1125
|
|
1121
1126
|
{
|
1122
1127
|
char *orig_section = NULL, *section = NULL, *orig_name, *name, *ldot;
|
@@ -1131,8 +1136,9 @@ static int config_file_write(config_file_backend *cfg, const char *orig_key, con
|
|
1131
1136
|
if (cfg->locked) {
|
1132
1137
|
error = git_str_puts(&contents, git_str_cstr(&cfg->locked_content) == NULL ? "" : git_str_cstr(&cfg->locked_content));
|
1133
1138
|
} else {
|
1134
|
-
if ((error = git_filebuf_open(&file, cfg->file.path,
|
1135
|
-
|
1139
|
+
if ((error = git_filebuf_open(&file, cfg->file.path,
|
1140
|
+
GIT_FILEBUF_HASH_SHA256,
|
1141
|
+
GIT_CONFIG_FILE_MODE)) < 0)
|
1136
1142
|
goto done;
|
1137
1143
|
|
1138
1144
|
/* We need to read in our own config file */
|