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
@@ -17,9 +17,9 @@
|
|
17
17
|
#include "git2/commit.h"
|
18
18
|
#include "git2/sys/commit.h"
|
19
19
|
|
20
|
-
#define
|
20
|
+
#define GIT_CHERRYPICK_FILE_MODE 0666
|
21
21
|
|
22
|
-
static int
|
22
|
+
static int write_cherrypick_head(
|
23
23
|
git_repository *repo,
|
24
24
|
const char *commit_oidstr)
|
25
25
|
{
|
@@ -27,8 +27,8 @@ static int write_cherry_pick_head(
|
|
27
27
|
git_buf file_path = GIT_BUF_INIT;
|
28
28
|
int error = 0;
|
29
29
|
|
30
|
-
if ((error = git_buf_joinpath(&file_path, repo->path_repository,
|
31
|
-
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE,
|
30
|
+
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_CHERRYPICK_HEAD_FILE)) >= 0 &&
|
31
|
+
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) >= 0 &&
|
32
32
|
(error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0)
|
33
33
|
error = git_filebuf_commit(&file);
|
34
34
|
|
@@ -49,7 +49,7 @@ static int write_merge_msg(
|
|
49
49
|
int error = 0;
|
50
50
|
|
51
51
|
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 ||
|
52
|
-
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE,
|
52
|
+
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) < 0 ||
|
53
53
|
(error = git_filebuf_printf(&file, "%s", commit_msg)) < 0)
|
54
54
|
goto cleanup;
|
55
55
|
|
@@ -64,10 +64,10 @@ cleanup:
|
|
64
64
|
return error;
|
65
65
|
}
|
66
66
|
|
67
|
-
static int
|
67
|
+
static int cherrypick_normalize_opts(
|
68
68
|
git_repository *repo,
|
69
|
-
|
70
|
-
const
|
69
|
+
git_cherrypick_options *opts,
|
70
|
+
const git_cherrypick_options *given,
|
71
71
|
const char *their_label)
|
72
72
|
{
|
73
73
|
int error = 0;
|
@@ -77,10 +77,10 @@ static int cherry_pick_normalize_opts(
|
|
77
77
|
GIT_UNUSED(repo);
|
78
78
|
|
79
79
|
if (given != NULL)
|
80
|
-
memcpy(opts, given, sizeof(
|
80
|
+
memcpy(opts, given, sizeof(git_cherrypick_options));
|
81
81
|
else {
|
82
|
-
|
83
|
-
memcpy(opts, &default_opts, sizeof(
|
82
|
+
git_cherrypick_options default_opts = GIT_CHERRYPICK_OPTIONS_INIT;
|
83
|
+
memcpy(opts, &default_opts, sizeof(git_cherrypick_options));
|
84
84
|
}
|
85
85
|
|
86
86
|
if (!opts->checkout_opts.checkout_strategy)
|
@@ -95,14 +95,14 @@ static int cherry_pick_normalize_opts(
|
|
95
95
|
return error;
|
96
96
|
}
|
97
97
|
|
98
|
-
static int
|
98
|
+
static int cherrypick_state_cleanup(git_repository *repo)
|
99
99
|
{
|
100
|
-
const char *state_files[] = {
|
100
|
+
const char *state_files[] = { GIT_CHERRYPICK_HEAD_FILE, GIT_MERGE_MSG_FILE };
|
101
101
|
|
102
102
|
return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files));
|
103
103
|
}
|
104
104
|
|
105
|
-
static int
|
105
|
+
static int cherrypick_seterr(git_commit *commit, const char *fmt)
|
106
106
|
{
|
107
107
|
char commit_oidstr[GIT_OID_HEXSZ + 1];
|
108
108
|
|
@@ -112,71 +112,71 @@ static int cherry_pick_seterr(git_commit *commit, const char *fmt)
|
|
112
112
|
return -1;
|
113
113
|
}
|
114
114
|
|
115
|
-
int
|
115
|
+
int git_cherrypick_commit(
|
116
116
|
git_index **out,
|
117
117
|
git_repository *repo,
|
118
|
-
git_commit *
|
118
|
+
git_commit *cherrypick_commit,
|
119
119
|
git_commit *our_commit,
|
120
120
|
unsigned int mainline,
|
121
121
|
const git_merge_options *merge_opts)
|
122
122
|
{
|
123
123
|
git_commit *parent_commit = NULL;
|
124
|
-
git_tree *parent_tree = NULL, *our_tree = NULL, *
|
124
|
+
git_tree *parent_tree = NULL, *our_tree = NULL, *cherrypick_tree = NULL;
|
125
125
|
int parent = 0, error = 0;
|
126
126
|
|
127
|
-
assert(out && repo &&
|
127
|
+
assert(out && repo && cherrypick_commit && our_commit);
|
128
128
|
|
129
|
-
if (git_commit_parentcount(
|
129
|
+
if (git_commit_parentcount(cherrypick_commit) > 1) {
|
130
130
|
if (!mainline)
|
131
|
-
return
|
131
|
+
return cherrypick_seterr(cherrypick_commit,
|
132
132
|
"Mainline branch is not specified but %s is a merge commit");
|
133
133
|
|
134
134
|
parent = mainline;
|
135
135
|
} else {
|
136
136
|
if (mainline)
|
137
|
-
return
|
137
|
+
return cherrypick_seterr(cherrypick_commit,
|
138
138
|
"Mainline branch specified but %s is not a merge commit");
|
139
139
|
|
140
|
-
parent = git_commit_parentcount(
|
140
|
+
parent = git_commit_parentcount(cherrypick_commit);
|
141
141
|
}
|
142
142
|
|
143
143
|
if (parent &&
|
144
|
-
((error = git_commit_parent(&parent_commit,
|
144
|
+
((error = git_commit_parent(&parent_commit, cherrypick_commit, (parent - 1))) < 0 ||
|
145
145
|
(error = git_commit_tree(&parent_tree, parent_commit)) < 0))
|
146
146
|
goto done;
|
147
147
|
|
148
|
-
if ((error = git_commit_tree(&
|
148
|
+
if ((error = git_commit_tree(&cherrypick_tree, cherrypick_commit)) < 0 ||
|
149
149
|
(error = git_commit_tree(&our_tree, our_commit)) < 0)
|
150
150
|
goto done;
|
151
151
|
|
152
|
-
error = git_merge_trees(out, repo, parent_tree, our_tree,
|
152
|
+
error = git_merge_trees(out, repo, parent_tree, our_tree, cherrypick_tree, merge_opts);
|
153
153
|
|
154
154
|
done:
|
155
155
|
git_tree_free(parent_tree);
|
156
156
|
git_tree_free(our_tree);
|
157
|
-
git_tree_free(
|
157
|
+
git_tree_free(cherrypick_tree);
|
158
158
|
git_commit_free(parent_commit);
|
159
159
|
|
160
160
|
return error;
|
161
161
|
}
|
162
162
|
|
163
|
-
int
|
163
|
+
int git_cherrypick(
|
164
164
|
git_repository *repo,
|
165
165
|
git_commit *commit,
|
166
|
-
const
|
166
|
+
const git_cherrypick_options *given_opts)
|
167
167
|
{
|
168
|
-
|
168
|
+
git_cherrypick_options opts;
|
169
169
|
git_reference *our_ref = NULL;
|
170
170
|
git_commit *our_commit = NULL;
|
171
171
|
char commit_oidstr[GIT_OID_HEXSZ + 1];
|
172
172
|
const char *commit_msg, *commit_summary;
|
173
173
|
git_buf their_label = GIT_BUF_INIT;
|
174
|
-
git_index *index_new = NULL
|
174
|
+
git_index *index_new = NULL;
|
175
175
|
int error = 0;
|
176
176
|
|
177
177
|
assert(repo && commit);
|
178
178
|
|
179
|
-
GITERR_CHECK_VERSION(given_opts,
|
179
|
+
GITERR_CHECK_VERSION(given_opts, GIT_CHERRYPICK_OPTIONS_VERSION, "git_cherrypick_options");
|
180
180
|
|
181
181
|
if ((error = git_repository__ensure_not_bare(repo, "cherry-pick")) < 0)
|
182
182
|
return error;
|
@@ -191,25 +191,22 @@ int git_cherry_pick(
|
|
191
191
|
|
192
192
|
if ((error = write_merge_msg(repo, commit_msg)) < 0 ||
|
193
193
|
(error = git_buf_printf(&their_label, "%.7s... %s", commit_oidstr, commit_summary)) < 0 ||
|
194
|
-
(error =
|
195
|
-
(error =
|
194
|
+
(error = cherrypick_normalize_opts(repo, &opts, given_opts, git_buf_cstr(&their_label))) < 0 ||
|
195
|
+
(error = write_cherrypick_head(repo, commit_oidstr)) < 0 ||
|
196
196
|
(error = git_repository_head(&our_ref, repo)) < 0 ||
|
197
197
|
(error = git_reference_peel((git_object **)&our_commit, our_ref, GIT_OBJ_COMMIT)) < 0 ||
|
198
|
-
(error =
|
199
|
-
(error =
|
200
|
-
(error =
|
201
|
-
(error =
|
202
|
-
(error = git_checkout_index(repo, index_repo, &opts.checkout_opts)) < 0)
|
198
|
+
(error = git_cherrypick_commit(&index_new, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 ||
|
199
|
+
(error = git_merge__check_result(repo, index_new)) < 0 ||
|
200
|
+
(error = git_merge__append_conflicts_to_merge_msg(repo, index_new)) < 0 ||
|
201
|
+
(error = git_checkout_index(repo, index_new, &opts.checkout_opts)) < 0)
|
203
202
|
goto on_error;
|
204
|
-
|
205
203
|
goto done;
|
206
204
|
|
207
205
|
on_error:
|
208
|
-
|
206
|
+
cherrypick_state_cleanup(repo);
|
209
207
|
|
210
208
|
done:
|
211
209
|
git_index_free(index_new);
|
212
|
-
git_index_free(index_repo);
|
213
210
|
git_commit_free(our_commit);
|
214
211
|
git_reference_free(our_ref);
|
215
212
|
git_buf_free(&their_label);
|
@@ -217,10 +214,10 @@ done:
|
|
217
214
|
return error;
|
218
215
|
}
|
219
216
|
|
220
|
-
int
|
221
|
-
|
217
|
+
int git_cherrypick_init_options(
|
218
|
+
git_cherrypick_options *opts, unsigned int version)
|
222
219
|
{
|
223
220
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
224
|
-
opts, version,
|
221
|
+
opts, version, git_cherrypick_options, GIT_CHERRYPICK_OPTIONS_INIT);
|
225
222
|
return 0;
|
226
223
|
}
|
data/vendor/libgit2/src/clone.c
CHANGED
@@ -24,6 +24,8 @@
|
|
24
24
|
#include "repository.h"
|
25
25
|
#include "odb.h"
|
26
26
|
|
27
|
+
static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link, const git_signature *signature);
|
28
|
+
|
27
29
|
static int create_branch(
|
28
30
|
git_reference **branch,
|
29
31
|
git_repository *repo,
|
@@ -142,9 +144,9 @@ static int update_head_to_remote(
|
|
142
144
|
const git_signature *signature,
|
143
145
|
const char *reflog_message)
|
144
146
|
{
|
145
|
-
int error = 0
|
147
|
+
int error = 0;
|
146
148
|
size_t refs_len;
|
147
|
-
git_refspec
|
149
|
+
git_refspec *refspec;
|
148
150
|
const git_remote_head *remote_head, **refs;
|
149
151
|
const git_oid *remote_head_id;
|
150
152
|
git_buf remote_master_name = GIT_BUF_INIT;
|
@@ -153,28 +155,30 @@ static int update_head_to_remote(
|
|
153
155
|
if ((error = git_remote_ls(&refs, &refs_len, remote)) < 0)
|
154
156
|
return error;
|
155
157
|
|
156
|
-
/*
|
157
|
-
if (refs_len == 0)
|
158
|
+
/* We cloned an empty repository or one with an unborn HEAD */
|
159
|
+
if (refs_len == 0 || strcmp(refs[0]->name, GIT_HEAD_FILE))
|
158
160
|
return setup_tracking_config(
|
159
161
|
repo, "master", GIT_REMOTE_ORIGIN, GIT_REFS_HEADS_MASTER_FILE);
|
160
162
|
|
161
|
-
|
162
|
-
if (error == GIT_ENOTFOUND) {
|
163
|
-
git_buf_puts(&branch, GIT_REFS_HEADS_MASTER_FILE);
|
164
|
-
} else {
|
165
|
-
found_branch = 1;
|
166
|
-
}
|
167
|
-
|
168
|
-
/* Get the remote's HEAD. This is always the first ref in the list. */
|
163
|
+
/* We know we have HEAD, let's see where it points */
|
169
164
|
remote_head = refs[0];
|
170
165
|
assert(remote_head);
|
171
166
|
|
172
167
|
remote_head_id = &remote_head->oid;
|
168
|
+
|
169
|
+
error = git_remote_default_branch(&branch, remote);
|
170
|
+
if (error == GIT_ENOTFOUND) {
|
171
|
+
error = git_repository_set_head_detached(
|
172
|
+
repo, remote_head_id, signature, reflog_message);
|
173
|
+
goto cleanup;
|
174
|
+
}
|
175
|
+
|
173
176
|
refspec = git_remote__matching_refspec(remote, git_buf_cstr(&branch));
|
174
177
|
|
175
178
|
if (refspec == NULL) {
|
176
|
-
|
177
|
-
|
179
|
+
giterr_set(GITERR_NET, "the remote's default branch does not fit the refspec configuration");
|
180
|
+
error = GIT_EINVALIDSPEC;
|
181
|
+
goto cleanup;
|
178
182
|
}
|
179
183
|
|
180
184
|
/* Determine the remote tracking reference name from the local master */
|
@@ -182,21 +186,18 @@ static int update_head_to_remote(
|
|
182
186
|
&remote_master_name,
|
183
187
|
refspec,
|
184
188
|
git_buf_cstr(&branch))) < 0)
|
185
|
-
|
189
|
+
goto cleanup;
|
186
190
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
signature, reflog_message);
|
193
|
-
} else {
|
194
|
-
error = git_repository_set_head_detached(
|
195
|
-
repo, remote_head_id, signature, reflog_message);
|
196
|
-
}
|
191
|
+
error = update_head_to_new_branch(
|
192
|
+
repo,
|
193
|
+
remote_head_id,
|
194
|
+
git_buf_cstr(&branch),
|
195
|
+
signature, reflog_message);
|
197
196
|
|
197
|
+
cleanup:
|
198
198
|
git_buf_free(&remote_master_name);
|
199
199
|
git_buf_free(&branch);
|
200
|
+
|
200
201
|
return error;
|
201
202
|
}
|
202
203
|
|
@@ -229,6 +230,29 @@ cleanup:
|
|
229
230
|
return retcode;
|
230
231
|
}
|
231
232
|
|
233
|
+
static int default_repository_create(git_repository **out, const char *path, int bare, void *payload)
|
234
|
+
{
|
235
|
+
GIT_UNUSED(payload);
|
236
|
+
|
237
|
+
return git_repository_init(out, path, bare);
|
238
|
+
}
|
239
|
+
|
240
|
+
static int default_remote_create(
|
241
|
+
git_remote **out,
|
242
|
+
git_repository *repo,
|
243
|
+
const char *name,
|
244
|
+
const char *url,
|
245
|
+
void *payload)
|
246
|
+
{
|
247
|
+
int error;
|
248
|
+
git_remote_callbacks *callbacks = payload;
|
249
|
+
|
250
|
+
if ((error = git_remote_create(out, repo, name, url)) < 0)
|
251
|
+
return error;
|
252
|
+
|
253
|
+
return git_remote_set_callbacks(*out, callbacks);
|
254
|
+
}
|
255
|
+
|
232
256
|
/*
|
233
257
|
* submodules?
|
234
258
|
*/
|
@@ -241,8 +265,9 @@ static int create_and_configure_origin(
|
|
241
265
|
{
|
242
266
|
int error;
|
243
267
|
git_remote *origin = NULL;
|
244
|
-
const char *name;
|
245
268
|
char buf[GIT_PATH_MAX];
|
269
|
+
git_remote_create_cb remote_create = options->remote_cb;
|
270
|
+
void *payload = options->remote_cb_payload;
|
246
271
|
|
247
272
|
/* If the path exists and is a dir, the url should be the absolute path */
|
248
273
|
if (git_path_root(url) < 0 && git_path_exists(url) && git_path_isdir(url)) {
|
@@ -252,14 +277,12 @@ static int create_and_configure_origin(
|
|
252
277
|
url = buf;
|
253
278
|
}
|
254
279
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
if (options->ignore_cert_errors)
|
260
|
-
git_remote_check_cert(origin, 0);
|
280
|
+
if (!remote_create) {
|
281
|
+
remote_create = default_remote_create;
|
282
|
+
payload = (void *)&options->remote_callbacks;
|
283
|
+
}
|
261
284
|
|
262
|
-
if ((error =
|
285
|
+
if ((error = remote_create(&origin, repo, "origin", url, payload)) < 0)
|
263
286
|
goto on_error;
|
264
287
|
|
265
288
|
if ((error = git_remote_save(origin)) < 0)
|
@@ -307,7 +330,7 @@ static int checkout_branch(git_repository *repo, git_remote *remote, const git_c
|
|
307
330
|
return error;
|
308
331
|
}
|
309
332
|
|
310
|
-
int
|
333
|
+
static int clone_into(git_repository *repo, git_remote *_remote, const git_checkout_options *co_opts, const char *branch, const git_signature *signature)
|
311
334
|
{
|
312
335
|
int error;
|
313
336
|
git_buf reflog_message = GIT_BUF_INIT;
|
@@ -335,7 +358,7 @@ int git_clone_into(git_repository *repo, git_remote *_remote, const git_checkout
|
|
335
358
|
git_remote_set_update_fetchhead(remote, 0);
|
336
359
|
git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
|
337
360
|
|
338
|
-
if ((error = git_remote_fetch(remote, signature, git_buf_cstr(&reflog_message))) != 0)
|
361
|
+
if ((error = git_remote_fetch(remote, NULL, signature, git_buf_cstr(&reflog_message))) != 0)
|
339
362
|
goto cleanup;
|
340
363
|
|
341
364
|
error = checkout_branch(repo, remote, co_opts, branch, signature, git_buf_cstr(&reflog_message));
|
@@ -347,27 +370,30 @@ cleanup:
|
|
347
370
|
return error;
|
348
371
|
}
|
349
372
|
|
350
|
-
int git_clone__should_clone_local(const char *
|
373
|
+
int git_clone__should_clone_local(const char *url_or_path, git_clone_local_t local)
|
351
374
|
{
|
352
|
-
|
353
|
-
|
375
|
+
git_buf fromurl = GIT_BUF_INIT;
|
376
|
+
const char *path = url_or_path;
|
377
|
+
bool is_url, is_local;
|
354
378
|
|
355
379
|
if (local == GIT_CLONE_NO_LOCAL)
|
356
|
-
return
|
380
|
+
return 0;
|
357
381
|
|
358
|
-
is_url =
|
359
|
-
|
360
|
-
|
361
|
-
|
382
|
+
if ((is_url = git_path_is_local_file_url(url_or_path)) != 0) {
|
383
|
+
if (git_path_fromurl(&fromurl, url_or_path) < 0) {
|
384
|
+
is_local = -1;
|
385
|
+
goto done;
|
386
|
+
}
|
362
387
|
|
363
|
-
|
364
|
-
|
365
|
-
path = url + strlen("file://");
|
388
|
+
path = fromurl.ptr;
|
389
|
+
}
|
366
390
|
|
367
|
-
|
368
|
-
|
391
|
+
is_local = (!is_url || local != GIT_CLONE_LOCAL_AUTO) &&
|
392
|
+
git_path_isdir(path);
|
369
393
|
|
370
|
-
|
394
|
+
done:
|
395
|
+
git_buf_free(&fromurl);
|
396
|
+
return is_local;
|
371
397
|
}
|
372
398
|
|
373
399
|
int git_clone(
|
@@ -381,6 +407,7 @@ int git_clone(
|
|
381
407
|
git_remote *origin;
|
382
408
|
git_clone_options options = GIT_CLONE_OPTIONS_INIT;
|
383
409
|
uint32_t rmdir_flags = GIT_RMDIR_REMOVE_FILES;
|
410
|
+
git_repository_create_cb repository_cb;
|
384
411
|
|
385
412
|
assert(out && url && local_path);
|
386
413
|
|
@@ -400,20 +427,28 @@ int git_clone(
|
|
400
427
|
if (git_path_exists(local_path))
|
401
428
|
rmdir_flags |= GIT_RMDIR_SKIP_ROOT;
|
402
429
|
|
403
|
-
if (
|
430
|
+
if (options.repository_cb)
|
431
|
+
repository_cb = options.repository_cb;
|
432
|
+
else
|
433
|
+
repository_cb = default_repository_create;
|
434
|
+
|
435
|
+
if ((error = repository_cb(&repo, local_path, options.bare, options.repository_cb_payload)) < 0)
|
404
436
|
return error;
|
405
437
|
|
406
438
|
if (!(error = create_and_configure_origin(&origin, repo, url, &options))) {
|
407
|
-
|
408
|
-
|
409
|
-
|
439
|
+
int clone_local = git_clone__should_clone_local(url, options.local);
|
440
|
+
int link = options.local != GIT_CLONE_LOCAL_NO_LINKS;
|
441
|
+
|
442
|
+
if (clone_local == 1)
|
443
|
+
error = clone_local_into(
|
410
444
|
repo, origin, &options.checkout_opts,
|
411
445
|
options.checkout_branch, link, options.signature);
|
412
|
-
|
413
|
-
error =
|
446
|
+
else if (clone_local == 0)
|
447
|
+
error = clone_into(
|
414
448
|
repo, origin, &options.checkout_opts,
|
415
449
|
options.checkout_branch, options.signature);
|
416
|
-
|
450
|
+
else
|
451
|
+
error = -1;
|
417
452
|
|
418
453
|
git_remote_free(origin);
|
419
454
|
}
|
@@ -452,6 +487,9 @@ static const char *repository_base(git_repository *repo)
|
|
452
487
|
static bool can_link(const char *src, const char *dst, int link)
|
453
488
|
{
|
454
489
|
#ifdef GIT_WIN32
|
490
|
+
GIT_UNUSED(src);
|
491
|
+
GIT_UNUSED(dst);
|
492
|
+
GIT_UNUSED(link);
|
455
493
|
return false;
|
456
494
|
#else
|
457
495
|
|
@@ -470,7 +508,7 @@ static bool can_link(const char *src, const char *dst, int link)
|
|
470
508
|
#endif
|
471
509
|
}
|
472
510
|
|
473
|
-
int
|
511
|
+
static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link, const git_signature *signature)
|
474
512
|
{
|
475
513
|
int error, flags;
|
476
514
|
git_repository *src;
|
@@ -515,7 +553,7 @@ int git_clone_local_into(git_repository *repo, git_remote *remote, const git_che
|
|
515
553
|
|
516
554
|
git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
|
517
555
|
|
518
|
-
if ((error = git_remote_fetch(remote, signature, git_buf_cstr(&reflog_message))) != 0)
|
556
|
+
if ((error = git_remote_fetch(remote, NULL, signature, git_buf_cstr(&reflog_message))) != 0)
|
519
557
|
goto cleanup;
|
520
558
|
|
521
559
|
error = checkout_branch(repo, remote, co_opts, branch, signature, git_buf_cstr(&reflog_message));
|