rugged 0.21.4 → 0.22.0b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -5
- data/ext/rugged/extconf.rb +9 -9
- data/ext/rugged/rugged.c +4 -2
- data/ext/rugged/rugged.h +3 -7
- data/ext/rugged/rugged_blob.c +57 -0
- data/ext/rugged/rugged_cred.c +23 -0
- data/ext/rugged/rugged_index.c +6 -2
- data/ext/rugged/rugged_remote.c +65 -52
- data/ext/rugged/rugged_remote_collection.c +59 -10
- data/ext/rugged/rugged_repo.c +345 -11
- data/ext/rugged/rugged_revwalk.c +10 -0
- data/ext/rugged/rugged_submodule.c +1042 -0
- data/ext/rugged/rugged_submodule_collection.c +236 -0
- data/ext/rugged/rugged_tag_collection.c +70 -2
- data/ext/rugged/rugged_tree.c +29 -10
- data/lib/rugged.rb +3 -0
- data/lib/rugged/attributes.rb +41 -0
- data/lib/rugged/blob.rb +28 -0
- data/lib/rugged/diff.rb +0 -1
- data/lib/rugged/diff/line.rb +1 -3
- data/lib/rugged/patch.rb +12 -2
- data/lib/rugged/repository.rb +7 -0
- data/lib/rugged/submodule_collection.rb +48 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +27 -3
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +324 -0
- data/vendor/libgit2/deps/http-parser/http_parser.h +2 -0
- data/vendor/libgit2/deps/zlib/adler32.c +39 -29
- data/vendor/libgit2/deps/zlib/crc32.c +33 -50
- data/vendor/libgit2/deps/zlib/crc32.h +1 -1
- data/vendor/libgit2/deps/zlib/deflate.c +198 -65
- data/vendor/libgit2/deps/zlib/deflate.h +8 -4
- data/vendor/libgit2/deps/zlib/infback.c +640 -0
- data/vendor/libgit2/deps/zlib/inffast.c +3 -3
- data/vendor/libgit2/deps/zlib/inffixed.h +3 -3
- data/vendor/libgit2/deps/zlib/inflate.c +84 -52
- data/vendor/libgit2/deps/zlib/inftrees.c +15 -39
- data/vendor/libgit2/deps/zlib/trees.c +18 -36
- data/vendor/libgit2/deps/zlib/zconf.h +4 -0
- data/vendor/libgit2/deps/zlib/zlib.h +250 -95
- data/vendor/libgit2/deps/zlib/zutil.c +13 -10
- data/vendor/libgit2/deps/zlib/zutil.h +41 -62
- data/vendor/libgit2/include/git2.h +4 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +99 -0
- data/vendor/libgit2/include/git2/attr.h +16 -13
- data/vendor/libgit2/include/git2/branch.h +11 -0
- data/vendor/libgit2/include/git2/buffer.h +16 -0
- data/vendor/libgit2/include/git2/checkout.h +12 -12
- data/vendor/libgit2/include/git2/cherrypick.h +15 -15
- data/vendor/libgit2/include/git2/clone.h +77 -69
- data/vendor/libgit2/include/git2/common.h +13 -1
- data/vendor/libgit2/include/git2/config.h +0 -14
- data/vendor/libgit2/include/git2/describe.h +162 -0
- data/vendor/libgit2/include/git2/diff.h +13 -8
- data/vendor/libgit2/include/git2/errors.h +5 -0
- data/vendor/libgit2/include/git2/global.h +38 -0
- data/vendor/libgit2/include/git2/merge.h +38 -64
- data/vendor/libgit2/include/git2/net.h +2 -2
- data/vendor/libgit2/include/git2/notes.h +17 -0
- data/vendor/libgit2/include/git2/oid.h +8 -4
- data/vendor/libgit2/include/git2/oidarray.h +40 -0
- data/vendor/libgit2/include/git2/rebase.h +261 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/remote.h +25 -47
- data/vendor/libgit2/include/git2/repository.h +4 -1
- data/vendor/libgit2/include/git2/reset.h +10 -1
- data/vendor/libgit2/include/git2/revert.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +28 -23
- data/vendor/libgit2/include/git2/status.h +19 -15
- data/vendor/libgit2/include/git2/submodule.h +18 -0
- data/vendor/libgit2/include/git2/sys/config.h +0 -1
- data/vendor/libgit2/{src → include/git2/sys}/hashsig.h +11 -7
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +13 -0
- data/vendor/libgit2/include/git2/sys/refs.h +0 -11
- data/vendor/libgit2/include/git2/sys/repository.h +13 -0
- data/vendor/libgit2/include/git2/sys/transport.h +352 -0
- data/vendor/libgit2/include/git2/threads.h +10 -20
- data/vendor/libgit2/include/git2/transaction.h +111 -0
- data/vendor/libgit2/include/git2/transport.h +79 -313
- data/vendor/libgit2/include/git2/tree.h +4 -2
- data/vendor/libgit2/include/git2/types.h +77 -8
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/annotated_commit.c +121 -0
- data/vendor/libgit2/src/annotated_commit.h +22 -0
- data/vendor/libgit2/src/attr.c +8 -4
- data/vendor/libgit2/src/attr_file.c +24 -2
- data/vendor/libgit2/src/blame.c +0 -1
- data/vendor/libgit2/src/branch.c +32 -3
- data/vendor/libgit2/src/buf_text.c +9 -5
- data/vendor/libgit2/src/buf_text.h +3 -2
- data/vendor/libgit2/src/buffer.c +67 -10
- data/vendor/libgit2/src/buffer.h +4 -2
- data/vendor/libgit2/src/cache.c +9 -9
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +2 -0
- data/vendor/libgit2/src/checkout.c +263 -82
- data/vendor/libgit2/src/checkout.h +1 -0
- data/vendor/libgit2/src/cherrypick.c +41 -44
- data/vendor/libgit2/src/clone.c +96 -58
- data/vendor/libgit2/src/commit.c +5 -31
- data/vendor/libgit2/src/commit_list.h +3 -1
- data/vendor/libgit2/src/config.c +0 -17
- data/vendor/libgit2/src/config_cache.c +0 -2
- data/vendor/libgit2/src/config_file.c +12 -15
- data/vendor/libgit2/src/crlf.c +2 -1
- data/vendor/libgit2/src/describe.c +886 -0
- data/vendor/libgit2/src/diff.c +29 -3
- data/vendor/libgit2/src/diff_file.c +1 -0
- data/vendor/libgit2/src/diff_patch.c +2 -3
- data/vendor/libgit2/src/diff_print.c +11 -9
- data/vendor/libgit2/src/diff_tform.c +4 -4
- data/vendor/libgit2/src/errors.c +9 -7
- data/vendor/libgit2/src/fetch.c +6 -6
- data/vendor/libgit2/src/fetchhead.h +2 -4
- data/vendor/libgit2/src/filebuf.c +0 -2
- data/vendor/libgit2/src/filebuf.h +2 -3
- data/vendor/libgit2/src/fileops.c +9 -7
- data/vendor/libgit2/src/global.c +44 -35
- data/vendor/libgit2/src/global.h +2 -0
- data/vendor/libgit2/src/graph.c +2 -2
- data/vendor/libgit2/src/hash.h +3 -1
- data/vendor/libgit2/src/hash/hash_common_crypto.h +44 -0
- data/vendor/libgit2/src/hash/hash_win32.c +1 -1
- data/vendor/libgit2/src/hashsig.c +1 -1
- data/vendor/libgit2/src/ignore.c +5 -88
- data/vendor/libgit2/src/index.c +70 -57
- data/vendor/libgit2/src/index.h +1 -0
- data/vendor/libgit2/src/indexer.c +16 -5
- data/vendor/libgit2/src/iterator.c +70 -1
- data/vendor/libgit2/src/iterator.h +5 -1
- data/vendor/libgit2/src/map.h +0 -1
- data/vendor/libgit2/src/merge.c +203 -327
- data/vendor/libgit2/src/merge.h +3 -13
- data/vendor/libgit2/src/mwindow.c +119 -8
- data/vendor/libgit2/src/mwindow.h +9 -1
- data/vendor/libgit2/src/netops.c +7 -8
- data/vendor/libgit2/src/netops.h +6 -16
- data/vendor/libgit2/src/notes.c +31 -4
- data/vendor/libgit2/src/notes.h +3 -0
- data/vendor/libgit2/src/odb.c +23 -1
- data/vendor/libgit2/src/odb_loose.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +6 -3
- data/vendor/libgit2/src/oid.c +9 -1
- data/vendor/libgit2/src/oid.h +11 -0
- data/vendor/libgit2/src/oidarray.c +21 -0
- data/vendor/libgit2/src/oidarray.h +18 -0
- data/vendor/libgit2/src/oidmap.h +16 -0
- data/vendor/libgit2/src/pack.c +20 -7
- data/vendor/libgit2/src/pack.h +3 -0
- data/vendor/libgit2/src/path.c +120 -293
- data/vendor/libgit2/src/path.h +21 -44
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/pool.c +5 -11
- data/vendor/libgit2/src/pool.h +0 -2
- data/vendor/libgit2/src/posix.c +6 -6
- data/vendor/libgit2/src/posix.h +48 -28
- data/vendor/libgit2/src/push.c +19 -48
- data/vendor/libgit2/src/push.h +2 -4
- data/vendor/libgit2/src/rebase.c +1125 -0
- data/vendor/libgit2/src/refdb.c +19 -0
- data/vendor/libgit2/src/refdb.h +2 -1
- data/vendor/libgit2/src/refdb_fs.c +101 -29
- data/vendor/libgit2/src/reflog.c +1 -1
- data/vendor/libgit2/src/refs.c +38 -3
- data/vendor/libgit2/src/refs.h +13 -2
- data/vendor/libgit2/src/refspec.c +20 -2
- data/vendor/libgit2/src/remote.c +288 -154
- data/vendor/libgit2/src/remote.h +5 -1
- data/vendor/libgit2/src/repository.c +75 -36
- data/vendor/libgit2/src/repository.h +3 -25
- data/vendor/libgit2/src/reset.c +5 -1
- data/vendor/libgit2/src/revert.c +4 -6
- data/vendor/libgit2/src/revparse.c +15 -18
- data/vendor/libgit2/src/revwalk.c +96 -22
- data/vendor/libgit2/src/revwalk.h +5 -4
- data/vendor/libgit2/src/settings.c +22 -0
- data/vendor/libgit2/src/signature.c +37 -2
- data/vendor/libgit2/src/signature.h +3 -0
- data/vendor/libgit2/src/stash.c +17 -12
- data/vendor/libgit2/src/status.c +13 -3
- data/vendor/libgit2/src/strnlen.h +2 -1
- data/vendor/libgit2/src/submodule.c +75 -35
- data/vendor/libgit2/src/thread-utils.h +4 -9
- data/vendor/libgit2/src/trace.h +9 -1
- data/vendor/libgit2/src/transaction.c +352 -0
- data/vendor/libgit2/src/transport.c +91 -97
- data/vendor/libgit2/src/transports/auth.c +71 -0
- data/vendor/libgit2/src/transports/auth.h +63 -0
- data/vendor/libgit2/src/transports/auth_negotiate.c +275 -0
- data/vendor/libgit2/src/transports/auth_negotiate.h +27 -0
- data/vendor/libgit2/src/transports/cred.c +58 -0
- data/vendor/libgit2/src/transports/cred.h +14 -0
- data/vendor/libgit2/src/transports/cred_helpers.c +3 -0
- data/vendor/libgit2/src/transports/git.c +1 -0
- data/vendor/libgit2/src/transports/http.c +208 -82
- data/vendor/libgit2/src/transports/local.c +2 -2
- data/vendor/libgit2/src/transports/smart.c +2 -0
- data/vendor/libgit2/src/transports/smart.h +2 -0
- data/vendor/libgit2/src/transports/smart_protocol.c +10 -10
- data/vendor/libgit2/src/transports/ssh.c +243 -57
- data/vendor/libgit2/src/transports/winhttp.c +139 -35
- data/vendor/libgit2/src/tree-cache.c +118 -31
- data/vendor/libgit2/src/tree-cache.h +12 -7
- data/vendor/libgit2/src/tree.c +83 -64
- data/vendor/libgit2/src/tree.h +2 -3
- data/vendor/libgit2/src/unix/map.c +8 -2
- data/vendor/libgit2/src/unix/posix.h +23 -9
- data/vendor/libgit2/src/unix/realpath.c +8 -7
- data/vendor/libgit2/src/userdiff.h +3 -3
- data/vendor/libgit2/src/util.c +2 -92
- data/vendor/libgit2/src/util.h +3 -15
- data/vendor/libgit2/src/win32/findfile.c +0 -1
- data/vendor/libgit2/src/win32/map.c +3 -2
- data/vendor/libgit2/src/win32/mingw-compat.h +5 -12
- data/vendor/libgit2/src/win32/msvc-compat.h +3 -32
- data/vendor/libgit2/src/win32/posix.h +20 -32
- data/vendor/libgit2/src/win32/posix_w32.c +103 -31
- data/vendor/libgit2/src/win32/utf-conv.c +6 -36
- data/vendor/libgit2/src/win32/utf-conv.h +39 -0
- data/vendor/libgit2/src/win32/w32_util.h +0 -1
- metadata +32 -7
- data/vendor/libgit2/src/win32/path_w32.c +0 -305
- data/vendor/libgit2/src/win32/path_w32.h +0 -82
data/vendor/libgit2/src/global.h
CHANGED
@@ -7,12 +7,14 @@
|
|
7
7
|
#ifndef INCLUDE_global_h__
|
8
8
|
#define INCLUDE_global_h__
|
9
9
|
|
10
|
+
#include "common.h"
|
10
11
|
#include "mwindow.h"
|
11
12
|
#include "hash.h"
|
12
13
|
|
13
14
|
typedef struct {
|
14
15
|
git_error *last_error;
|
15
16
|
git_error error_t;
|
17
|
+
char oid_fmt[GIT_OID_HEXSZ+1];
|
16
18
|
} git_global_st;
|
17
19
|
|
18
20
|
#ifdef GIT_SSL
|
data/vendor/libgit2/src/graph.c
CHANGED
@@ -124,9 +124,9 @@ static int ahead_behind(git_commit_list_node *one, git_commit_list_node *two,
|
|
124
124
|
(commit->flags & (PARENT1 | PARENT2)) == (PARENT1 | PARENT2))
|
125
125
|
continue;
|
126
126
|
else if (commit->flags & PARENT1)
|
127
|
-
(*behind)++;
|
128
|
-
else if (commit->flags & PARENT2)
|
129
127
|
(*ahead)++;
|
128
|
+
else if (commit->flags & PARENT2)
|
129
|
+
(*behind)++;
|
130
130
|
|
131
131
|
for (i = 0; i < commit->out_degree; i++) {
|
132
132
|
git_commit_list_node *p = commit->parents[i];
|
data/vendor/libgit2/src/hash.h
CHANGED
@@ -16,7 +16,9 @@ int git_hash_global_init(void);
|
|
16
16
|
int git_hash_ctx_init(git_hash_ctx *ctx);
|
17
17
|
void git_hash_ctx_cleanup(git_hash_ctx *ctx);
|
18
18
|
|
19
|
-
#if defined(
|
19
|
+
#if defined(GIT_COMMON_CRYPTO)
|
20
|
+
# include "hash/hash_common_crypto.h"
|
21
|
+
#elif defined(OPENSSL_SHA1)
|
20
22
|
# include "hash/hash_openssl.h"
|
21
23
|
#elif defined(WIN32_SHA1)
|
22
24
|
# include "hash/hash_win32.h"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef INCLUDE_hash_common_crypto_h__
|
9
|
+
#define INCLUDE_hash_common_crypto_h__
|
10
|
+
|
11
|
+
#include "hash.h"
|
12
|
+
|
13
|
+
#include <CommonCrypto/CommonDigest.h>
|
14
|
+
|
15
|
+
struct git_hash_ctx {
|
16
|
+
CC_SHA1_CTX c;
|
17
|
+
};
|
18
|
+
|
19
|
+
#define git_hash_global_init() 0
|
20
|
+
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
|
21
|
+
#define git_hash_ctx_cleanup(ctx)
|
22
|
+
|
23
|
+
GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx)
|
24
|
+
{
|
25
|
+
assert(ctx);
|
26
|
+
CC_SHA1_Init(&ctx->c);
|
27
|
+
return 0;
|
28
|
+
}
|
29
|
+
|
30
|
+
GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
|
31
|
+
{
|
32
|
+
assert(ctx);
|
33
|
+
CC_SHA1_Update(&ctx->c, data, len);
|
34
|
+
return 0;
|
35
|
+
}
|
36
|
+
|
37
|
+
GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx)
|
38
|
+
{
|
39
|
+
assert(ctx);
|
40
|
+
CC_SHA1_Final(out->id, &ctx->c);
|
41
|
+
return 0;
|
42
|
+
}
|
43
|
+
|
44
|
+
#endif /* INCLUDE_hash_common_crypto_h__ */
|
@@ -236,7 +236,7 @@ int git_hash_ctx_init(git_hash_ctx *ctx)
|
|
236
236
|
|
237
237
|
/*
|
238
238
|
* When compiled with GIT_THREADS, the global hash_prov data is
|
239
|
-
* initialized with
|
239
|
+
* initialized with git_libgit2_init. Otherwise, it must be initialized
|
240
240
|
* at first use.
|
241
241
|
*/
|
242
242
|
if (hash_prov.type == INVALID && (error = git_hash_global_init()) < 0)
|
data/vendor/libgit2/src/ignore.c
CHANGED
@@ -4,87 +4,11 @@
|
|
4
4
|
#include "attrcache.h"
|
5
5
|
#include "path.h"
|
6
6
|
#include "config.h"
|
7
|
-
#include "fnmatch.h"
|
8
7
|
|
9
8
|
#define GIT_IGNORE_INTERNAL "[internal]exclude"
|
10
9
|
|
11
10
|
#define GIT_IGNORE_DEFAULT_RULES ".\n..\n.git\n"
|
12
11
|
|
13
|
-
/**
|
14
|
-
* A negative ignore can only unignore a file which is given explicitly before, thus
|
15
|
-
*
|
16
|
-
* foo
|
17
|
-
* !foo/bar
|
18
|
-
*
|
19
|
-
* does not unignore 'foo/bar' as it's not in the list. However
|
20
|
-
*
|
21
|
-
* foo/<star>
|
22
|
-
* !foo/bar
|
23
|
-
*
|
24
|
-
* does unignore 'foo/bar', as it is contained within the 'foo/<star>' rule.
|
25
|
-
*/
|
26
|
-
static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match)
|
27
|
-
{
|
28
|
-
int error = 0;
|
29
|
-
size_t i;
|
30
|
-
git_attr_fnmatch *rule;
|
31
|
-
char *path;
|
32
|
-
git_buf buf = GIT_BUF_INIT;
|
33
|
-
|
34
|
-
/* path of the file relative to the workdir, so we match the rules in subdirs */
|
35
|
-
if (match->containing_dir) {
|
36
|
-
git_buf_puts(&buf, match->containing_dir);
|
37
|
-
}
|
38
|
-
if (git_buf_puts(&buf, match->pattern) < 0)
|
39
|
-
return -1;
|
40
|
-
|
41
|
-
path = git_buf_detach(&buf);
|
42
|
-
|
43
|
-
git_vector_foreach(rules, i, rule) {
|
44
|
-
/* no chance of matching w/o a wilcard */
|
45
|
-
if (!(rule->flags & GIT_ATTR_FNMATCH_HASWILD))
|
46
|
-
continue;
|
47
|
-
|
48
|
-
/*
|
49
|
-
* If we're dealing with a directory (which we know via the
|
50
|
-
* strchr() check) we want to use 'dirname/<star>' as the
|
51
|
-
* pattern so p_fnmatch() honours FNM_PATHNAME
|
52
|
-
*/
|
53
|
-
git_buf_clear(&buf);
|
54
|
-
if (rule->containing_dir) {
|
55
|
-
git_buf_puts(&buf, rule->containing_dir);
|
56
|
-
}
|
57
|
-
if (!strchr(rule->pattern, '*'))
|
58
|
-
error = git_buf_printf(&buf, "%s/*", rule->pattern);
|
59
|
-
else
|
60
|
-
error = git_buf_puts(&buf, rule->pattern);
|
61
|
-
|
62
|
-
if (error < 0)
|
63
|
-
goto out;
|
64
|
-
|
65
|
-
|
66
|
-
if ((error = p_fnmatch(git_buf_cstr(&buf), path, FNM_PATHNAME)) < 0) {
|
67
|
-
giterr_set(GITERR_INVALID, "error matching pattern");
|
68
|
-
goto out;
|
69
|
-
}
|
70
|
-
|
71
|
-
/* if we found a match, we want to keep this rule */
|
72
|
-
if (error != FNM_NOMATCH) {
|
73
|
-
*out = 1;
|
74
|
-
error = 0;
|
75
|
-
goto out;
|
76
|
-
}
|
77
|
-
}
|
78
|
-
|
79
|
-
*out = 0;
|
80
|
-
error = 0;
|
81
|
-
|
82
|
-
out:
|
83
|
-
git__free(path);
|
84
|
-
git_buf_free(&buf);
|
85
|
-
return error;
|
86
|
-
}
|
87
|
-
|
88
12
|
static int parse_ignore_file(
|
89
13
|
git_repository *repo, git_attr_file *attrs, const char *data)
|
90
14
|
{
|
@@ -108,8 +32,6 @@ static int parse_ignore_file(
|
|
108
32
|
}
|
109
33
|
|
110
34
|
while (!error && *scan) {
|
111
|
-
int valid_rule = 1;
|
112
|
-
|
113
35
|
if (!match && !(match = git__calloc(1, sizeof(*match)))) {
|
114
36
|
error = -1;
|
115
37
|
break;
|
@@ -126,16 +48,11 @@ static int parse_ignore_file(
|
|
126
48
|
match->flags |= GIT_ATTR_FNMATCH_ICASE;
|
127
49
|
|
128
50
|
scan = git__next_line(scan);
|
129
|
-
|
130
|
-
/* if a negative match doesn't actually do anything, throw it away */
|
131
|
-
if (match->flags & GIT_ATTR_FNMATCH_NEGATIVE)
|
132
|
-
error = does_negate_rule(&valid_rule, &attrs->rules, match);
|
133
|
-
|
134
|
-
if (!error && valid_rule)
|
135
|
-
error = git_vector_insert(&attrs->rules, match);
|
51
|
+
error = git_vector_insert(&attrs->rules, match);
|
136
52
|
}
|
137
53
|
|
138
|
-
if (error != 0
|
54
|
+
if (error != 0) {
|
55
|
+
git__free(match->pattern);
|
139
56
|
match->pattern = NULL;
|
140
57
|
|
141
58
|
if (error == GIT_ENOTFOUND)
|
@@ -174,11 +91,11 @@ static int push_ignore_file(
|
|
174
91
|
return error;
|
175
92
|
}
|
176
93
|
|
177
|
-
static int push_one_ignore(void *payload,
|
94
|
+
static int push_one_ignore(void *payload, const char *path)
|
178
95
|
{
|
179
96
|
git_ignores *ign = payload;
|
180
97
|
ign->depth++;
|
181
|
-
return push_ignore_file(ign, &ign->ign_path, path
|
98
|
+
return push_ignore_file(ign, &ign->ign_path, path, GIT_IGNORE_FILE);
|
182
99
|
}
|
183
100
|
|
184
101
|
static int get_internal_ignores(git_attr_file **out, git_repository *repo)
|
data/vendor/libgit2/src/index.c
CHANGED
@@ -405,6 +405,8 @@ int git_index_open(git_index **index_out, const char *index_path)
|
|
405
405
|
return -1;
|
406
406
|
}
|
407
407
|
|
408
|
+
git_pool_init(&index->tree_pool, 1, 0);
|
409
|
+
|
408
410
|
if (index_path != NULL) {
|
409
411
|
index->index_file_path = git__strdup(index_path);
|
410
412
|
if (!index->index_file_path)
|
@@ -435,6 +437,7 @@ int git_index_open(git_index **index_out, const char *index_path)
|
|
435
437
|
return 0;
|
436
438
|
|
437
439
|
fail:
|
440
|
+
git_pool_clear(&index->tree_pool);
|
438
441
|
git_index_free(index);
|
439
442
|
return error;
|
440
443
|
}
|
@@ -517,8 +520,8 @@ int git_index_clear(git_index *index)
|
|
517
520
|
|
518
521
|
assert(index);
|
519
522
|
|
520
|
-
git_tree_cache_free(index->tree);
|
521
523
|
index->tree = NULL;
|
524
|
+
git_pool_clear(&index->tree_pool);
|
522
525
|
|
523
526
|
if (git_mutex_lock(&index->lock) < 0) {
|
524
527
|
giterr_set(GITERR_OS, "Failed to lock index");
|
@@ -621,6 +624,9 @@ int git_index_read(git_index *index, int force)
|
|
621
624
|
if (error < 0)
|
622
625
|
return error;
|
623
626
|
|
627
|
+
index->tree = NULL;
|
628
|
+
git_pool_clear(&index->tree_pool);
|
629
|
+
|
624
630
|
error = git_index_clear(index);
|
625
631
|
|
626
632
|
if (!error)
|
@@ -756,35 +762,23 @@ void git_index_entry__init_from_stat(
|
|
756
762
|
entry->file_size = st->st_size;
|
757
763
|
}
|
758
764
|
|
759
|
-
static
|
760
|
-
git_index_entry **out,
|
761
|
-
git_repository *repo,
|
762
|
-
const char *path)
|
765
|
+
static git_index_entry *index_entry_alloc(const char *path)
|
763
766
|
{
|
764
767
|
size_t pathlen = strlen(path);
|
765
|
-
struct entry_internal *entry
|
766
|
-
|
767
|
-
if (!
|
768
|
-
|
769
|
-
giterr_set(GITERR_INDEX, "Invalid path: '%s'", path);
|
770
|
-
return -1;
|
771
|
-
}
|
772
|
-
|
773
|
-
entry = git__calloc(sizeof(struct entry_internal) + pathlen + 1, 1);
|
774
|
-
GITERR_CHECK_ALLOC(entry);
|
768
|
+
struct entry_internal *entry =
|
769
|
+
git__calloc(sizeof(struct entry_internal) + pathlen + 1, 1);
|
770
|
+
if (!entry)
|
771
|
+
return NULL;
|
775
772
|
|
776
773
|
entry->pathlen = pathlen;
|
777
774
|
memcpy(entry->path, path, pathlen);
|
778
775
|
entry->entry.path = entry->path;
|
779
776
|
|
780
|
-
|
781
|
-
return 0;
|
777
|
+
return (git_index_entry *)entry;
|
782
778
|
}
|
783
779
|
|
784
780
|
static int index_entry_init(
|
785
|
-
git_index_entry **entry_out,
|
786
|
-
git_index *index,
|
787
|
-
const char *rel_path)
|
781
|
+
git_index_entry **entry_out, git_index *index, const char *rel_path)
|
788
782
|
{
|
789
783
|
int error = 0;
|
790
784
|
git_index_entry *entry = NULL;
|
@@ -796,17 +790,14 @@ static int index_entry_init(
|
|
796
790
|
"Could not initialize index entry. "
|
797
791
|
"Index is not backed up by an existing repository.");
|
798
792
|
|
799
|
-
if (index_entry_create(&entry, INDEX_OWNER(index), rel_path) < 0)
|
800
|
-
return -1;
|
801
|
-
|
802
793
|
/* write the blob to disk and get the oid and stat info */
|
803
794
|
error = git_blob__create_from_paths(
|
804
795
|
&oid, &st, INDEX_OWNER(index), NULL, rel_path, 0, true);
|
805
|
-
|
806
|
-
if (error < 0) {
|
807
|
-
index_entry_free(entry);
|
796
|
+
if (error < 0)
|
808
797
|
return error;
|
809
|
-
|
798
|
+
|
799
|
+
entry = index_entry_alloc(rel_path);
|
800
|
+
GITERR_CHECK_ALLOC(entry);
|
810
801
|
|
811
802
|
entry->id = oid;
|
812
803
|
git_index_entry__init_from_stat(entry, &st, !index->distrust_filemode);
|
@@ -862,10 +853,7 @@ static void index_entry_cpy(git_index_entry *tgt, const git_index_entry *src)
|
|
862
853
|
tgt->path = tgt_path; /* reset to existing path data */
|
863
854
|
}
|
864
855
|
|
865
|
-
static int index_entry_dup(
|
866
|
-
git_index_entry **out,
|
867
|
-
git_repository *repo,
|
868
|
-
const git_index_entry *src)
|
856
|
+
static int index_entry_dup(git_index_entry **out, const git_index_entry *src)
|
869
857
|
{
|
870
858
|
git_index_entry *entry;
|
871
859
|
|
@@ -874,11 +862,11 @@ static int index_entry_dup(
|
|
874
862
|
return 0;
|
875
863
|
}
|
876
864
|
|
877
|
-
|
878
|
-
|
865
|
+
*out = entry = index_entry_alloc(src->path);
|
866
|
+
GITERR_CHECK_ALLOC(entry);
|
879
867
|
|
880
868
|
index_entry_cpy(entry, src);
|
881
|
-
|
869
|
+
|
882
870
|
return 0;
|
883
871
|
}
|
884
872
|
|
@@ -1143,7 +1131,7 @@ int git_index_add(git_index *index, const git_index_entry *source_entry)
|
|
1143
1131
|
return -1;
|
1144
1132
|
}
|
1145
1133
|
|
1146
|
-
if ((ret = index_entry_dup(&entry,
|
1134
|
+
if ((ret = index_entry_dup(&entry, source_entry)) < 0 ||
|
1147
1135
|
(ret = index_insert(index, &entry, 1)) < 0)
|
1148
1136
|
return ret;
|
1149
1137
|
|
@@ -1263,9 +1251,9 @@ int git_index_conflict_add(git_index *index,
|
|
1263
1251
|
|
1264
1252
|
assert (index);
|
1265
1253
|
|
1266
|
-
if ((ret = index_entry_dup(&entries[0],
|
1267
|
-
(ret = index_entry_dup(&entries[1],
|
1268
|
-
(ret = index_entry_dup(&entries[2],
|
1254
|
+
if ((ret = index_entry_dup(&entries[0], ancestor_entry)) < 0 ||
|
1255
|
+
(ret = index_entry_dup(&entries[1], our_entry)) < 0 ||
|
1256
|
+
(ret = index_entry_dup(&entries[2], their_entry)) < 0)
|
1269
1257
|
goto on_error;
|
1270
1258
|
|
1271
1259
|
for (i = 0; i < 3; i++) {
|
@@ -1782,10 +1770,7 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
|
|
1782
1770
|
}
|
1783
1771
|
|
1784
1772
|
static size_t read_entry(
|
1785
|
-
git_index_entry **out,
|
1786
|
-
git_index *index,
|
1787
|
-
const void *buffer,
|
1788
|
-
size_t buffer_size)
|
1773
|
+
git_index_entry **out, const void *buffer, size_t buffer_size)
|
1789
1774
|
{
|
1790
1775
|
size_t path_length, entry_size;
|
1791
1776
|
const char *path_ptr;
|
@@ -1849,7 +1834,7 @@ static size_t read_entry(
|
|
1849
1834
|
|
1850
1835
|
entry.path = (char *)path_ptr;
|
1851
1836
|
|
1852
|
-
if (index_entry_dup(out,
|
1837
|
+
if (index_entry_dup(out, &entry) < 0)
|
1853
1838
|
return 0;
|
1854
1839
|
|
1855
1840
|
return entry_size;
|
@@ -1892,7 +1877,7 @@ static size_t read_extension(git_index *index, const char *buffer, size_t buffer
|
|
1892
1877
|
if (dest.signature[0] >= 'A' && dest.signature[0] <= 'Z') {
|
1893
1878
|
/* tree cache */
|
1894
1879
|
if (memcmp(dest.signature, INDEX_EXT_TREECACHE_SIG, 4) == 0) {
|
1895
|
-
if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size) < 0)
|
1880
|
+
if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size, &index->tree_pool) < 0)
|
1896
1881
|
return 0;
|
1897
1882
|
} else if (memcmp(dest.signature, INDEX_EXT_UNMERGED_SIG, 4) == 0) {
|
1898
1883
|
if (read_reuc(index, buffer + 8, dest.extension_size) < 0)
|
@@ -1950,7 +1935,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
1950
1935
|
/* Parse all the entries */
|
1951
1936
|
for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) {
|
1952
1937
|
git_index_entry *entry;
|
1953
|
-
size_t entry_size = read_entry(&entry,
|
1938
|
+
size_t entry_size = read_entry(&entry, buffer, buffer_size);
|
1954
1939
|
|
1955
1940
|
/* 0 bytes read means an object corruption */
|
1956
1941
|
if (entry_size == 0) {
|
@@ -2129,16 +2114,13 @@ static int write_entries(git_index *index, git_filebuf *file)
|
|
2129
2114
|
static int write_extension(git_filebuf *file, struct index_extension *header, git_buf *data)
|
2130
2115
|
{
|
2131
2116
|
struct index_extension ondisk;
|
2132
|
-
int error = 0;
|
2133
2117
|
|
2134
2118
|
memset(&ondisk, 0x0, sizeof(struct index_extension));
|
2135
2119
|
memcpy(&ondisk, header, 4);
|
2136
2120
|
ondisk.extension_size = htonl(header->extension_size);
|
2137
2121
|
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
return error;
|
2122
|
+
git_filebuf_write(file, &ondisk, sizeof(struct index_extension));
|
2123
|
+
return git_filebuf_write(file, data->ptr, data->size);
|
2142
2124
|
}
|
2143
2125
|
|
2144
2126
|
static int create_name_extension_data(git_buf *name_buf, git_index_name_entry *conflict_name)
|
@@ -2244,6 +2226,29 @@ done:
|
|
2244
2226
|
return error;
|
2245
2227
|
}
|
2246
2228
|
|
2229
|
+
static int write_tree_extension(git_index *index, git_filebuf *file)
|
2230
|
+
{
|
2231
|
+
struct index_extension extension;
|
2232
|
+
git_buf buf = GIT_BUF_INIT;
|
2233
|
+
int error;
|
2234
|
+
|
2235
|
+
if (index->tree == NULL)
|
2236
|
+
return 0;
|
2237
|
+
|
2238
|
+
if ((error = git_tree_cache_write(&buf, index->tree)) < 0)
|
2239
|
+
return error;
|
2240
|
+
|
2241
|
+
memset(&extension, 0x0, sizeof(struct index_extension));
|
2242
|
+
memcpy(&extension.signature, INDEX_EXT_TREECACHE_SIG, 4);
|
2243
|
+
extension.extension_size = (uint32_t)buf.size;
|
2244
|
+
|
2245
|
+
error = write_extension(file, &extension, &buf);
|
2246
|
+
|
2247
|
+
git_buf_free(&buf);
|
2248
|
+
|
2249
|
+
return error;
|
2250
|
+
}
|
2251
|
+
|
2247
2252
|
static int write_index(git_index *index, git_filebuf *file)
|
2248
2253
|
{
|
2249
2254
|
git_oid hash_final;
|
@@ -2266,7 +2271,9 @@ static int write_index(git_index *index, git_filebuf *file)
|
|
2266
2271
|
if (write_entries(index, file) < 0)
|
2267
2272
|
return -1;
|
2268
2273
|
|
2269
|
-
/*
|
2274
|
+
/* write the tree cache extension */
|
2275
|
+
if (index->tree != NULL && write_tree_extension(index, file) < 0)
|
2276
|
+
return -1;
|
2270
2277
|
|
2271
2278
|
/* write the rename conflict extension */
|
2272
2279
|
if (index->names.length > 0 && write_name_extension(index, file) < 0)
|
@@ -2289,10 +2296,10 @@ int git_index_entry_stage(const git_index_entry *entry)
|
|
2289
2296
|
}
|
2290
2297
|
|
2291
2298
|
typedef struct read_tree_data {
|
2292
|
-
git_index *index;
|
2293
2299
|
git_vector *old_entries;
|
2294
2300
|
git_vector *new_entries;
|
2295
2301
|
git_vector_cmp entry_cmp;
|
2302
|
+
git_tree_cache *tree;
|
2296
2303
|
} read_tree_data;
|
2297
2304
|
|
2298
2305
|
static int read_tree_cb(
|
@@ -2309,8 +2316,8 @@ static int read_tree_cb(
|
|
2309
2316
|
if (git_buf_joinpath(&path, root, tentry->filename) < 0)
|
2310
2317
|
return -1;
|
2311
2318
|
|
2312
|
-
|
2313
|
-
|
2319
|
+
entry = index_entry_alloc(path.ptr);
|
2320
|
+
GITERR_CHECK_ALLOC(entry);
|
2314
2321
|
|
2315
2322
|
entry->mode = tentry->attr;
|
2316
2323
|
entry->id = tentry->oid;
|
@@ -2350,11 +2357,13 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
2350
2357
|
|
2351
2358
|
git_vector_set_cmp(&entries, index->entries._cmp); /* match sort */
|
2352
2359
|
|
2353
|
-
data.index = index;
|
2354
2360
|
data.old_entries = &index->entries;
|
2355
2361
|
data.new_entries = &entries;
|
2356
2362
|
data.entry_cmp = index->entries_search;
|
2357
2363
|
|
2364
|
+
index->tree = NULL;
|
2365
|
+
git_pool_clear(&index->tree_pool);
|
2366
|
+
|
2358
2367
|
if (index_sort_if_needed(index, true) < 0)
|
2359
2368
|
return -1;
|
2360
2369
|
|
@@ -2375,6 +2384,10 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
2375
2384
|
}
|
2376
2385
|
|
2377
2386
|
git_vector_free(&entries);
|
2387
|
+
if (error < 0)
|
2388
|
+
return error;
|
2389
|
+
|
2390
|
+
error = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool);
|
2378
2391
|
|
2379
2392
|
return error;
|
2380
2393
|
}
|
@@ -2428,7 +2441,7 @@ int git_index_add_all(
|
|
2428
2441
|
goto cleanup;
|
2429
2442
|
|
2430
2443
|
if ((error = git_iterator_for_workdir(
|
2431
|
-
&wditer, repo, 0, ps.prefix, ps.prefix)) < 0)
|
2444
|
+
&wditer, repo, NULL, NULL, 0, ps.prefix, ps.prefix)) < 0)
|
2432
2445
|
goto cleanup;
|
2433
2446
|
|
2434
2447
|
while (!(error = git_iterator_advance(&wd, wditer))) {
|
@@ -2463,7 +2476,7 @@ int git_index_add_all(
|
|
2463
2476
|
break;
|
2464
2477
|
|
2465
2478
|
/* make the new entry to insert */
|
2466
|
-
if ((error = index_entry_dup(&entry,
|
2479
|
+
if ((error = index_entry_dup(&entry, wd)) < 0)
|
2467
2480
|
break;
|
2468
2481
|
|
2469
2482
|
entry->id = blobid;
|