rugged 0.22.2 → 0.23.0b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/rugged.c +1 -2
- data/ext/rugged/rugged_branch_collection.c +6 -44
- data/ext/rugged/rugged_config.c +7 -3
- data/ext/rugged/rugged_diff_delta.c +1 -1
- data/ext/rugged/rugged_diff_line.c +1 -1
- data/ext/rugged/rugged_object.c +2 -2
- data/ext/rugged/rugged_reference_collection.c +12 -56
- data/ext/rugged/rugged_remote.c +4 -33
- data/ext/rugged/rugged_remote_collection.c +1 -1
- data/ext/rugged/rugged_repo.c +10 -36
- data/ext/rugged/rugged_settings.c +3 -3
- data/ext/rugged/rugged_tree.c +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +10 -3
- data/vendor/libgit2/COPYING +15 -21
- data/vendor/libgit2/include/git2/annotated_commit.h +20 -3
- data/vendor/libgit2/include/git2/branch.h +20 -16
- data/vendor/libgit2/include/git2/checkout.h +32 -18
- data/vendor/libgit2/include/git2/cherrypick.h +2 -2
- data/vendor/libgit2/include/git2/clone.h +4 -10
- data/vendor/libgit2/include/git2/config.h +66 -12
- data/vendor/libgit2/include/git2/describe.h +3 -2
- data/vendor/libgit2/include/git2/diff.h +3 -3
- data/vendor/libgit2/include/git2/errors.h +1 -0
- data/vendor/libgit2/include/git2/filter.h +21 -5
- data/vendor/libgit2/include/git2/index.h +32 -0
- data/vendor/libgit2/include/git2/merge.h +20 -3
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +13 -0
- data/vendor/libgit2/include/git2/patch.h +3 -6
- data/vendor/libgit2/include/git2/rebase.h +8 -12
- data/vendor/libgit2/include/git2/refs.h +19 -29
- data/vendor/libgit2/include/git2/remote.h +5 -11
- data/vendor/libgit2/include/git2/repository.h +44 -15
- data/vendor/libgit2/include/git2/reset.h +19 -10
- data/vendor/libgit2/include/git2/revert.h +2 -2
- data/vendor/libgit2/include/git2/submodule.h +3 -9
- data/vendor/libgit2/include/git2/sys/config.h +3 -1
- data/vendor/libgit2/include/git2/sys/filter.h +10 -2
- data/vendor/libgit2/include/git2/sys/hashsig.h +49 -22
- data/vendor/libgit2/include/git2/transport.h +1 -1
- data/vendor/libgit2/include/git2/types.h +10 -3
- data/vendor/libgit2/include/git2/version.h +3 -2
- data/vendor/libgit2/src/annotated_commit.c +28 -0
- data/vendor/libgit2/src/array.h +19 -8
- data/vendor/libgit2/src/attr.c +95 -35
- data/vendor/libgit2/src/attr_file.c +51 -17
- data/vendor/libgit2/src/attr_file.h +37 -10
- data/vendor/libgit2/src/attrcache.c +13 -7
- data/vendor/libgit2/src/attrcache.h +1 -0
- data/vendor/libgit2/src/blame.c +26 -2
- data/vendor/libgit2/src/blame_git.c +6 -2
- data/vendor/libgit2/src/blob.c +6 -8
- data/vendor/libgit2/src/branch.c +55 -43
- data/vendor/libgit2/src/buf_text.c +13 -6
- data/vendor/libgit2/src/buffer.c +110 -25
- data/vendor/libgit2/src/buffer.h +18 -0
- data/vendor/libgit2/src/checkout.c +164 -92
- data/vendor/libgit2/src/checkout.h +0 -7
- data/vendor/libgit2/src/cherrypick.c +13 -7
- data/vendor/libgit2/src/clone.c +23 -25
- data/vendor/libgit2/src/commit.c +3 -3
- data/vendor/libgit2/src/common.h +23 -1
- data/vendor/libgit2/src/config.c +137 -19
- data/vendor/libgit2/src/config.h +2 -2
- data/vendor/libgit2/src/config_cache.c +2 -1
- data/vendor/libgit2/src/config_file.c +39 -18
- data/vendor/libgit2/src/config_file.h +1 -1
- data/vendor/libgit2/src/crlf.c +1 -1
- data/vendor/libgit2/src/delta-apply.c +3 -2
- data/vendor/libgit2/src/delta.c +25 -6
- data/vendor/libgit2/src/describe.c +2 -0
- data/vendor/libgit2/src/diff.c +8 -5
- data/vendor/libgit2/src/diff_driver.c +39 -18
- data/vendor/libgit2/src/diff_file.c +1 -1
- data/vendor/libgit2/src/diff_patch.c +12 -6
- data/vendor/libgit2/src/diff_tform.c +21 -24
- data/vendor/libgit2/src/filebuf.c +14 -12
- data/vendor/libgit2/src/fileops.c +61 -18
- data/vendor/libgit2/src/fileops.h +11 -2
- data/vendor/libgit2/src/filter.c +351 -99
- data/vendor/libgit2/src/filter.h +17 -0
- data/vendor/libgit2/src/global.c +38 -9
- data/vendor/libgit2/src/hash/hash_generic.c +1 -1
- data/vendor/libgit2/src/hashsig.c +28 -16
- data/vendor/libgit2/src/ignore.c +2 -2
- data/vendor/libgit2/src/index.c +159 -42
- data/vendor/libgit2/src/index.h +29 -0
- data/vendor/libgit2/src/indexer.c +11 -2
- data/vendor/libgit2/src/integer.h +96 -0
- data/vendor/libgit2/src/iterator.c +5 -3
- data/vendor/libgit2/src/khash.h +41 -29
- data/vendor/libgit2/src/merge.c +48 -35
- data/vendor/libgit2/src/merge.h +0 -1
- data/vendor/libgit2/src/merge_file.c +13 -0
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/notes.c +1 -1
- data/vendor/libgit2/src/odb.c +13 -11
- data/vendor/libgit2/src/odb_loose.c +22 -10
- data/vendor/libgit2/src/odb_mempack.c +4 -2
- data/vendor/libgit2/src/offmap.h +3 -2
- data/vendor/libgit2/src/oid.c +1 -1
- data/vendor/libgit2/src/oidmap.h +2 -1
- data/vendor/libgit2/src/openssl_stream.c +6 -3
- data/vendor/libgit2/src/pack-objects.c +273 -12
- data/vendor/libgit2/src/pack-objects.h +10 -0
- data/vendor/libgit2/src/pack.c +17 -6
- data/vendor/libgit2/src/pack.h +1 -3
- data/vendor/libgit2/src/path.c +68 -38
- data/vendor/libgit2/src/pathspec.c +3 -0
- data/vendor/libgit2/src/pool.c +9 -8
- data/vendor/libgit2/src/posix.c +11 -1
- data/vendor/libgit2/src/push.c +15 -17
- data/vendor/libgit2/src/push.h +1 -6
- data/vendor/libgit2/src/rebase.c +77 -35
- data/vendor/libgit2/src/refdb_fs.c +2 -2
- data/vendor/libgit2/src/refs.c +107 -81
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +3 -0
- data/vendor/libgit2/src/remote.c +19 -21
- data/vendor/libgit2/src/repository.c +258 -67
- data/vendor/libgit2/src/repository.h +31 -16
- data/vendor/libgit2/src/reset.c +28 -12
- data/vendor/libgit2/src/revert.c +12 -7
- data/vendor/libgit2/src/revwalk.c +3 -5
- data/vendor/libgit2/src/revwalk.h +1 -1
- data/vendor/libgit2/src/sortedcache.c +5 -3
- data/vendor/libgit2/src/stash.c +3 -5
- data/vendor/libgit2/src/strmap.h +2 -1
- data/vendor/libgit2/src/submodule.c +5 -6
- data/vendor/libgit2/src/tag.c +7 -5
- data/vendor/libgit2/src/transaction.c +1 -1
- data/vendor/libgit2/src/transports/cred.c +5 -2
- data/vendor/libgit2/src/transports/git.c +2 -3
- data/vendor/libgit2/src/transports/local.c +15 -34
- data/vendor/libgit2/src/transports/smart.c +1 -1
- data/vendor/libgit2/src/transports/smart_pkt.c +58 -18
- data/vendor/libgit2/src/transports/smart_protocol.c +2 -2
- data/vendor/libgit2/src/transports/winhttp.c +2 -2
- data/vendor/libgit2/src/tree.c +7 -5
- data/vendor/libgit2/src/tsort.c +3 -1
- data/vendor/libgit2/src/util.c +25 -0
- data/vendor/libgit2/src/util.h +31 -27
- data/vendor/libgit2/src/vector.c +2 -7
- data/vendor/libgit2/src/win32/dir.c +5 -3
- data/vendor/libgit2/src/win32/git2.rc +8 -4
- data/vendor/libgit2/src/win32/mingw-compat.h +7 -0
- data/vendor/libgit2/src/win32/msvc-compat.h +3 -0
- data/vendor/libgit2/src/win32/posix.h +1 -3
- data/vendor/libgit2/src/win32/posix_w32.c +31 -7
- data/vendor/libgit2/src/win32/utf-conv.c +1 -3
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +5 -5
- data/vendor/libgit2/src/bswap.h +0 -97
@@ -38,11 +38,11 @@
|
|
38
38
|
GIT_ATTR_FNMATCH_ALLOWMACRO | GIT_ATTR_FNMATCH_NOLEADINGDIR)
|
39
39
|
|
40
40
|
typedef enum {
|
41
|
-
GIT_ATTR_FILE__IN_MEMORY
|
42
|
-
GIT_ATTR_FILE__FROM_FILE
|
43
|
-
GIT_ATTR_FILE__FROM_INDEX
|
41
|
+
GIT_ATTR_FILE__IN_MEMORY = 0,
|
42
|
+
GIT_ATTR_FILE__FROM_FILE = 1,
|
43
|
+
GIT_ATTR_FILE__FROM_INDEX = 2,
|
44
44
|
|
45
|
-
GIT_ATTR_FILE_NUM_SOURCES
|
45
|
+
GIT_ATTR_FILE_NUM_SOURCES = 3
|
46
46
|
} git_attr_file_source;
|
47
47
|
|
48
48
|
extern const char *git_attr__true;
|
@@ -84,6 +84,8 @@ typedef struct {
|
|
84
84
|
git_attr_file_source source;
|
85
85
|
git_vector rules; /* vector of <rule*> or <fnmatch*> */
|
86
86
|
git_pool pool;
|
87
|
+
unsigned int nonexistent:1;
|
88
|
+
int session_key;
|
87
89
|
union {
|
88
90
|
git_oid oid;
|
89
91
|
git_futils_filestamp stamp;
|
@@ -96,11 +98,6 @@ struct git_attr_file_entry {
|
|
96
98
|
char fullpath[GIT_FLEX_ARRAY];
|
97
99
|
};
|
98
100
|
|
99
|
-
typedef int (*git_attr_file_parser)(
|
100
|
-
git_repository *repo,
|
101
|
-
git_attr_file *file,
|
102
|
-
const char *data);
|
103
|
-
|
104
101
|
typedef struct {
|
105
102
|
git_buf full;
|
106
103
|
char *path;
|
@@ -108,6 +105,35 @@ typedef struct {
|
|
108
105
|
int is_dir;
|
109
106
|
} git_attr_path;
|
110
107
|
|
108
|
+
/* A git_attr_session can provide an "instance" of reading, to prevent cache
|
109
|
+
* invalidation during a single operation instance (like checkout).
|
110
|
+
*/
|
111
|
+
|
112
|
+
typedef struct {
|
113
|
+
int key;
|
114
|
+
unsigned int init_setup:1,
|
115
|
+
init_sysdir:1;
|
116
|
+
git_buf sysdir;
|
117
|
+
git_buf tmp;
|
118
|
+
} git_attr_session;
|
119
|
+
|
120
|
+
extern int git_attr_session__init(git_attr_session *attr_session, git_repository *repo);
|
121
|
+
extern void git_attr_session__free(git_attr_session *session);
|
122
|
+
|
123
|
+
extern int git_attr_get_many_with_session(
|
124
|
+
const char **values_out,
|
125
|
+
git_repository *repo,
|
126
|
+
git_attr_session *attr_session,
|
127
|
+
uint32_t flags,
|
128
|
+
const char *path,
|
129
|
+
size_t num_attr,
|
130
|
+
const char **names);
|
131
|
+
|
132
|
+
typedef int (*git_attr_file_parser)(
|
133
|
+
git_repository *repo,
|
134
|
+
git_attr_file *file,
|
135
|
+
const char *data);
|
136
|
+
|
111
137
|
/*
|
112
138
|
* git_attr_file API
|
113
139
|
*/
|
@@ -122,6 +148,7 @@ void git_attr_file__free(git_attr_file *file);
|
|
122
148
|
int git_attr_file__load(
|
123
149
|
git_attr_file **out,
|
124
150
|
git_repository *repo,
|
151
|
+
git_attr_session *attr_session,
|
125
152
|
git_attr_file_entry *ce,
|
126
153
|
git_attr_file_source source,
|
127
154
|
git_attr_file_parser parser);
|
@@ -130,7 +157,7 @@ int git_attr_file__load_standalone(
|
|
130
157
|
git_attr_file **out, const char *path);
|
131
158
|
|
132
159
|
int git_attr_file__out_of_date(
|
133
|
-
git_repository *repo, git_attr_file *file);
|
160
|
+
git_repository *repo, git_attr_session *session, git_attr_file *file);
|
134
161
|
|
135
162
|
int git_attr_file__parse_buffer(
|
136
163
|
git_repository *repo, git_attr_file *attrs, const char *data);
|
@@ -5,7 +5,7 @@
|
|
5
5
|
#include "sysdir.h"
|
6
6
|
#include "ignore.h"
|
7
7
|
|
8
|
-
GIT__USE_STRMAP
|
8
|
+
GIT__USE_STRMAP
|
9
9
|
|
10
10
|
GIT_INLINE(int) attr_cache_lock(git_attr_cache *cache)
|
11
11
|
{
|
@@ -149,6 +149,7 @@ static int attr_cache_lookup(
|
|
149
149
|
git_attr_file **out_file,
|
150
150
|
git_attr_file_entry **out_entry,
|
151
151
|
git_repository *repo,
|
152
|
+
git_attr_session *attr_session,
|
152
153
|
git_attr_file_source source,
|
153
154
|
const char *base,
|
154
155
|
const char *filename)
|
@@ -162,9 +163,12 @@ static int attr_cache_lookup(
|
|
162
163
|
|
163
164
|
/* join base and path as needed */
|
164
165
|
if (base != NULL && git_path_root(filename) < 0) {
|
165
|
-
|
166
|
+
git_buf *p = attr_session ? &attr_session->tmp : &path;
|
167
|
+
|
168
|
+
if (git_buf_joinpath(p, base, filename) < 0)
|
166
169
|
return -1;
|
167
|
-
|
170
|
+
|
171
|
+
filename = p->ptr;
|
168
172
|
}
|
169
173
|
|
170
174
|
relfile = filename;
|
@@ -196,6 +200,7 @@ cleanup:
|
|
196
200
|
int git_attr_cache__get(
|
197
201
|
git_attr_file **out,
|
198
202
|
git_repository *repo,
|
203
|
+
git_attr_session *attr_session,
|
199
204
|
git_attr_file_source source,
|
200
205
|
const char *base,
|
201
206
|
const char *filename,
|
@@ -207,12 +212,12 @@ int git_attr_cache__get(
|
|
207
212
|
git_attr_file *file = NULL, *updated = NULL;
|
208
213
|
|
209
214
|
if ((error = attr_cache_lookup(
|
210
|
-
&file, &entry, repo, source, base, filename)) < 0)
|
215
|
+
&file, &entry, repo, attr_session, source, base, filename)) < 0)
|
211
216
|
return error;
|
212
217
|
|
213
218
|
/* load file if we don't have one or if existing one is out of date */
|
214
|
-
if (!file || (error = git_attr_file__out_of_date(repo, file)) > 0)
|
215
|
-
error = git_attr_file__load(&updated, repo, entry, source, parser);
|
219
|
+
if (!file || (error = git_attr_file__out_of_date(repo, attr_session, file)) > 0)
|
220
|
+
error = git_attr_file__load(&updated, repo, attr_session, entry, source, parser);
|
216
221
|
|
217
222
|
/* if we loaded the file, insert into and/or update cache */
|
218
223
|
if (updated) {
|
@@ -271,7 +276,7 @@ static int attr_cache__lookup_path(
|
|
271
276
|
{
|
272
277
|
git_buf buf = GIT_BUF_INIT;
|
273
278
|
int error;
|
274
|
-
|
279
|
+
git_config_entry *entry = NULL;
|
275
280
|
|
276
281
|
*out = NULL;
|
277
282
|
|
@@ -291,6 +296,7 @@ static int attr_cache__lookup_path(
|
|
291
296
|
else if (!git_sysdir_find_xdg_file(&buf, fallback))
|
292
297
|
*out = git_buf_detach(&buf);
|
293
298
|
|
299
|
+
git_config_entry_free(entry);
|
294
300
|
git_buf_free(&buf);
|
295
301
|
|
296
302
|
return error;
|
data/vendor/libgit2/src/blame.c
CHANGED
@@ -76,6 +76,10 @@ static git_blame_hunk* dup_hunk(git_blame_hunk *hunk)
|
|
76
76
|
hunk->lines_in_hunk,
|
77
77
|
hunk->orig_start_line_number,
|
78
78
|
hunk->orig_path);
|
79
|
+
|
80
|
+
if (!newhunk)
|
81
|
+
return NULL;
|
82
|
+
|
79
83
|
git_oid_cpy(&newhunk->orig_commit_id, &hunk->orig_commit_id);
|
80
84
|
git_oid_cpy(&newhunk->final_commit_id, &hunk->final_commit_id);
|
81
85
|
newhunk->boundary = hunk->boundary;
|
@@ -221,6 +225,10 @@ static git_blame_hunk *split_hunk_in_vector(
|
|
221
225
|
new_line_count = hunk->lines_in_hunk - rel_line;
|
222
226
|
nh = new_hunk((uint16_t)(hunk->final_start_line_number+rel_line), (uint16_t)new_line_count,
|
223
227
|
(uint16_t)(hunk->orig_start_line_number+rel_line), hunk->orig_path);
|
228
|
+
|
229
|
+
if (!nh)
|
230
|
+
return NULL;
|
231
|
+
|
224
232
|
git_oid_cpy(&nh->final_commit_id, &hunk->final_commit_id);
|
225
233
|
git_oid_cpy(&nh->orig_commit_id, &hunk->orig_commit_id);
|
226
234
|
|
@@ -270,6 +278,10 @@ static git_blame_hunk* hunk_from_entry(git_blame__entry *e)
|
|
270
278
|
{
|
271
279
|
git_blame_hunk *h = new_hunk(
|
272
280
|
e->lno+1, e->num_lines, e->s_lno+1, e->suspect->path);
|
281
|
+
|
282
|
+
if (!h)
|
283
|
+
return NULL;
|
284
|
+
|
273
285
|
git_oid_cpy(&h->final_commit_id, git_commit_id(e->suspect->commit));
|
274
286
|
git_oid_cpy(&h->orig_commit_id, git_commit_id(e->suspect->commit));
|
275
287
|
git_signature_dup(&h->final_signature, git_commit_author(e->suspect->commit));
|
@@ -307,6 +319,8 @@ static int blame_internal(git_blame *blame)
|
|
307
319
|
blame->final_buf_size = git_blob_rawsize(blame->final_blob);
|
308
320
|
|
309
321
|
ent = git__calloc(1, sizeof(git_blame__entry));
|
322
|
+
GITERR_CHECK_ALLOC(ent);
|
323
|
+
|
310
324
|
ent->num_lines = index_blob_lines(blame);
|
311
325
|
ent->lno = blame->options.min_line - 1;
|
312
326
|
ent->num_lines = ent->num_lines - blame->options.min_line + 1;
|
@@ -322,8 +336,9 @@ static int blame_internal(git_blame *blame)
|
|
322
336
|
cleanup:
|
323
337
|
for (ent = blame->ent; ent; ) {
|
324
338
|
git_blame__entry *e = ent->next;
|
339
|
+
git_blame_hunk *h = hunk_from_entry(ent);
|
325
340
|
|
326
|
-
git_vector_insert(&blame->hunks,
|
341
|
+
git_vector_insert(&blame->hunks, h);
|
327
342
|
|
328
343
|
git_blame__free_entry(ent);
|
329
344
|
ent = e;
|
@@ -392,11 +407,14 @@ static int buffer_hunk_cb(
|
|
392
407
|
if (!blame->current_hunk) {
|
393
408
|
/* Line added at the end of the file */
|
394
409
|
blame->current_hunk = new_hunk(wedge_line, 0, wedge_line, blame->path);
|
410
|
+
GITERR_CHECK_ALLOC(blame->current_hunk);
|
411
|
+
|
395
412
|
git_vector_insert(&blame->hunks, blame->current_hunk);
|
396
413
|
} else if (!hunk_starts_at_or_after_line(blame->current_hunk, wedge_line)){
|
397
414
|
/* If this hunk doesn't start between existing hunks, split a hunk up so it does */
|
398
415
|
blame->current_hunk = split_hunk_in_vector(&blame->hunks, blame->current_hunk,
|
399
416
|
wedge_line - blame->current_hunk->orig_start_line_number, true);
|
417
|
+
GITERR_CHECK_ALLOC(blame->current_hunk);
|
400
418
|
}
|
401
419
|
|
402
420
|
return 0;
|
@@ -425,6 +443,8 @@ static int buffer_line_cb(
|
|
425
443
|
/* Create a new buffer-blame hunk with this line */
|
426
444
|
shift_hunks_by(&blame->hunks, blame->current_diff_line, 1);
|
427
445
|
blame->current_hunk = new_hunk((uint16_t)blame->current_diff_line, 1, 0, blame->path);
|
446
|
+
GITERR_CHECK_ALLOC(blame->current_hunk);
|
447
|
+
|
428
448
|
git_vector_insert_sorted(&blame->hunks, blame->current_hunk, NULL);
|
429
449
|
}
|
430
450
|
blame->current_diff_line++;
|
@@ -464,10 +484,14 @@ int git_blame_buffer(
|
|
464
484
|
assert(out && reference && buffer && buffer_len);
|
465
485
|
|
466
486
|
blame = git_blame__alloc(reference->repository, reference->options, reference->path);
|
487
|
+
GITERR_CHECK_ALLOC(blame);
|
467
488
|
|
468
489
|
/* Duplicate all of the hunk structures in the reference blame */
|
469
490
|
git_vector_foreach(&reference->hunks, i, hunk) {
|
470
|
-
|
491
|
+
git_blame_hunk *h = dup_hunk(hunk);
|
492
|
+
GITERR_CHECK_ALLOC(h);
|
493
|
+
|
494
|
+
git_vector_insert(&blame->hunks, h);
|
471
495
|
}
|
472
496
|
|
473
497
|
/* Diff to the reference blob */
|
@@ -35,11 +35,15 @@ static void origin_decref(git_blame__origin *o)
|
|
35
35
|
/* Given a commit and a path in it, create a new origin structure. */
|
36
36
|
static int make_origin(git_blame__origin **out, git_commit *commit, const char *path)
|
37
37
|
{
|
38
|
-
int error = 0;
|
39
38
|
git_blame__origin *o;
|
39
|
+
size_t path_len = strlen(path), alloc_len;
|
40
|
+
int error = 0;
|
40
41
|
|
41
|
-
|
42
|
+
GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*o), path_len);
|
43
|
+
GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1);
|
44
|
+
o = git__calloc(1, alloc_len);
|
42
45
|
GITERR_CHECK_ALLOC(o);
|
46
|
+
|
43
47
|
o->commit = commit;
|
44
48
|
o->refcnt = 1;
|
45
49
|
strcpy(o->path, path);
|
data/vendor/libgit2/src/blob.c
CHANGED
@@ -199,7 +199,7 @@ int git_blob__create_from_paths(
|
|
199
199
|
/* Load the filters for writing this file to the ODB */
|
200
200
|
error = git_filter_list_load(
|
201
201
|
&fl, repo, NULL, hint_path,
|
202
|
-
GIT_FILTER_TO_ODB,
|
202
|
+
GIT_FILTER_TO_ODB, GIT_FILTER_DEFAULT);
|
203
203
|
|
204
204
|
if (error < 0)
|
205
205
|
/* well, that didn't work */;
|
@@ -329,15 +329,13 @@ cleanup:
|
|
329
329
|
|
330
330
|
int git_blob_is_binary(const git_blob *blob)
|
331
331
|
{
|
332
|
-
git_buf content;
|
332
|
+
git_buf content = GIT_BUF_INIT;
|
333
333
|
|
334
334
|
assert(blob);
|
335
335
|
|
336
|
-
content
|
337
|
-
|
338
|
-
|
339
|
-
content.asize = 0;
|
340
|
-
|
336
|
+
git_buf_attach_notowned(&content, blob->odb_object->buffer,
|
337
|
+
min(blob->odb_object->cached.size,
|
338
|
+
GIT_FILTER_BYTES_TO_CHECK_NUL));
|
341
339
|
return git_buf_text_is_binary(&content);
|
342
340
|
}
|
343
341
|
|
@@ -359,7 +357,7 @@ int git_blob_filtered_content(
|
|
359
357
|
|
360
358
|
if (!(error = git_filter_list_load(
|
361
359
|
&fl, git_blob_owner(blob), blob, path,
|
362
|
-
GIT_FILTER_TO_WORKTREE,
|
360
|
+
GIT_FILTER_TO_WORKTREE, GIT_FILTER_DEFAULT))) {
|
363
361
|
|
364
362
|
error = git_filter_list_apply_to_blob(out, fl, blob);
|
365
363
|
|
data/vendor/libgit2/src/branch.c
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
#include "refspec.h"
|
13
13
|
#include "refs.h"
|
14
14
|
#include "remote.h"
|
15
|
+
#include "annotated_commit.h"
|
15
16
|
|
16
17
|
#include "git2/branch.h"
|
17
18
|
|
@@ -49,19 +50,18 @@ static int not_a_local_branch(const char *reference_name)
|
|
49
50
|
return -1;
|
50
51
|
}
|
51
52
|
|
52
|
-
int
|
53
|
+
static int create_branch(
|
53
54
|
git_reference **ref_out,
|
54
55
|
git_repository *repository,
|
55
56
|
const char *branch_name,
|
56
57
|
const git_commit *commit,
|
57
|
-
|
58
|
-
|
59
|
-
const char *log_message)
|
58
|
+
const char *from,
|
59
|
+
int force)
|
60
60
|
{
|
61
61
|
int is_head = 0;
|
62
62
|
git_reference *branch = NULL;
|
63
63
|
git_buf canonical_branch_name = GIT_BUF_INIT,
|
64
|
-
|
64
|
+
log_message = GIT_BUF_INIT;
|
65
65
|
int error = -1;
|
66
66
|
|
67
67
|
assert(branch_name && commit && ref_out);
|
@@ -84,26 +84,46 @@ int git_branch_create(
|
|
84
84
|
error = -1;
|
85
85
|
goto cleanup;
|
86
86
|
}
|
87
|
-
|
87
|
+
|
88
88
|
if (git_buf_joinpath(&canonical_branch_name, GIT_REFS_HEADS_DIR, branch_name) < 0)
|
89
89
|
goto cleanup;
|
90
90
|
|
91
|
-
if (
|
91
|
+
if (git_buf_printf(&log_message, "branch: Created from %s", from) < 0)
|
92
92
|
goto cleanup;
|
93
93
|
|
94
94
|
error = git_reference_create(&branch, repository,
|
95
|
-
git_buf_cstr(&canonical_branch_name), git_commit_id(commit), force,
|
96
|
-
git_buf_cstr(&
|
95
|
+
git_buf_cstr(&canonical_branch_name), git_commit_id(commit), force,
|
96
|
+
git_buf_cstr(&log_message));
|
97
97
|
|
98
98
|
if (!error)
|
99
99
|
*ref_out = branch;
|
100
100
|
|
101
101
|
cleanup:
|
102
102
|
git_buf_free(&canonical_branch_name);
|
103
|
-
git_buf_free(&
|
103
|
+
git_buf_free(&log_message);
|
104
104
|
return error;
|
105
105
|
}
|
106
106
|
|
107
|
+
int git_branch_create(
|
108
|
+
git_reference **ref_out,
|
109
|
+
git_repository *repository,
|
110
|
+
const char *branch_name,
|
111
|
+
const git_commit *commit,
|
112
|
+
int force)
|
113
|
+
{
|
114
|
+
return create_branch(ref_out, repository, branch_name, commit, git_oid_tostr_s(git_commit_id(commit)), force);
|
115
|
+
}
|
116
|
+
|
117
|
+
int git_branch_create_from_annotated(
|
118
|
+
git_reference **ref_out,
|
119
|
+
git_repository *repository,
|
120
|
+
const char *branch_name,
|
121
|
+
const git_annotated_commit *commit,
|
122
|
+
int force)
|
123
|
+
{
|
124
|
+
return create_branch(ref_out, repository, branch_name, commit->commit, commit->ref_name, force);
|
125
|
+
}
|
126
|
+
|
107
127
|
int git_branch_delete(git_reference *branch)
|
108
128
|
{
|
109
129
|
int is_head;
|
@@ -222,14 +242,12 @@ int git_branch_move(
|
|
222
242
|
git_reference **out,
|
223
243
|
git_reference *branch,
|
224
244
|
const char *new_branch_name,
|
225
|
-
int force
|
226
|
-
const git_signature *signature,
|
227
|
-
const char *log_message)
|
245
|
+
int force)
|
228
246
|
{
|
229
247
|
git_buf new_reference_name = GIT_BUF_INIT,
|
230
248
|
old_config_section = GIT_BUF_INIT,
|
231
249
|
new_config_section = GIT_BUF_INIT,
|
232
|
-
|
250
|
+
log_message = GIT_BUF_INIT;
|
233
251
|
int error;
|
234
252
|
|
235
253
|
assert(branch && new_branch_name);
|
@@ -240,20 +258,15 @@ int git_branch_move(
|
|
240
258
|
if ((error = git_buf_joinpath(&new_reference_name, GIT_REFS_HEADS_DIR, new_branch_name)) < 0)
|
241
259
|
goto done;
|
242
260
|
|
243
|
-
if (log_message
|
244
|
-
|
245
|
-
goto done;
|
246
|
-
} else {
|
247
|
-
if ((error = git_buf_printf(&log_message_buf, "Branch: renamed %s to %s",
|
248
|
-
git_reference_name(branch), git_buf_cstr(&new_reference_name))) < 0)
|
261
|
+
if ((error = git_buf_printf(&log_message, "branch: renamed %s to %s",
|
262
|
+
git_reference_name(branch), git_buf_cstr(&new_reference_name))) < 0)
|
249
263
|
goto done;
|
250
|
-
}
|
251
264
|
|
252
265
|
/* first update ref then config so failure won't trash config */
|
253
266
|
|
254
267
|
error = git_reference_rename(
|
255
268
|
out, branch, git_buf_cstr(&new_reference_name), force,
|
256
|
-
|
269
|
+
git_buf_cstr(&log_message));
|
257
270
|
if (error < 0)
|
258
271
|
goto done;
|
259
272
|
|
@@ -270,7 +283,7 @@ done:
|
|
270
283
|
git_buf_free(&new_reference_name);
|
271
284
|
git_buf_free(&old_config_section);
|
272
285
|
git_buf_free(&new_config_section);
|
273
|
-
git_buf_free(&
|
286
|
+
git_buf_free(&log_message);
|
274
287
|
|
275
288
|
return error;
|
276
289
|
}
|
@@ -310,7 +323,7 @@ int git_branch_name(
|
|
310
323
|
}
|
311
324
|
|
312
325
|
static int retrieve_upstream_configuration(
|
313
|
-
|
326
|
+
git_buf *out,
|
314
327
|
const git_config *config,
|
315
328
|
const char *canonical_branch_name,
|
316
329
|
const char *format)
|
@@ -322,7 +335,7 @@ static int retrieve_upstream_configuration(
|
|
322
335
|
canonical_branch_name + strlen(GIT_REFS_HEADS_DIR)) < 0)
|
323
336
|
return -1;
|
324
337
|
|
325
|
-
error =
|
338
|
+
error = git_config_get_string_buf(out, config, git_buf_cstr(&buf));
|
326
339
|
git_buf_free(&buf);
|
327
340
|
return error;
|
328
341
|
}
|
@@ -332,7 +345,8 @@ int git_branch_upstream_name(
|
|
332
345
|
git_repository *repo,
|
333
346
|
const char *refname)
|
334
347
|
{
|
335
|
-
|
348
|
+
git_buf remote_name = GIT_BUF_INIT;
|
349
|
+
git_buf merge_name = GIT_BUF_INIT;
|
336
350
|
git_buf buf = GIT_BUF_INIT;
|
337
351
|
int error = -1;
|
338
352
|
git_remote *remote = NULL;
|
@@ -357,27 +371,27 @@ int git_branch_upstream_name(
|
|
357
371
|
&merge_name, config, refname, "branch.%s.merge")) < 0)
|
358
372
|
goto cleanup;
|
359
373
|
|
360
|
-
if (
|
374
|
+
if (git_buf_len(&remote_name) == 0 || git_buf_len(&merge_name) == 0) {
|
361
375
|
giterr_set(GITERR_REFERENCE,
|
362
376
|
"branch '%s' does not have an upstream", refname);
|
363
377
|
error = GIT_ENOTFOUND;
|
364
378
|
goto cleanup;
|
365
379
|
}
|
366
380
|
|
367
|
-
if (strcmp(".", remote_name) != 0) {
|
368
|
-
if ((error = git_remote_lookup(&remote, repo, remote_name)) < 0)
|
381
|
+
if (strcmp(".", git_buf_cstr(&remote_name)) != 0) {
|
382
|
+
if ((error = git_remote_lookup(&remote, repo, git_buf_cstr(&remote_name))) < 0)
|
369
383
|
goto cleanup;
|
370
384
|
|
371
|
-
refspec = git_remote__matching_refspec(remote, merge_name);
|
385
|
+
refspec = git_remote__matching_refspec(remote, git_buf_cstr(&merge_name));
|
372
386
|
if (!refspec) {
|
373
387
|
error = GIT_ENOTFOUND;
|
374
388
|
goto cleanup;
|
375
389
|
}
|
376
390
|
|
377
|
-
if (git_refspec_transform(&buf, refspec, merge_name) < 0)
|
391
|
+
if (git_refspec_transform(&buf, refspec, git_buf_cstr(&merge_name)) < 0)
|
378
392
|
goto cleanup;
|
379
393
|
} else
|
380
|
-
if (
|
394
|
+
if (git_buf_set(&buf, git_buf_cstr(&merge_name), git_buf_len(&merge_name)) < 0)
|
381
395
|
goto cleanup;
|
382
396
|
|
383
397
|
error = git_buf_set(out, git_buf_cstr(&buf), git_buf_len(&buf));
|
@@ -385,6 +399,8 @@ int git_branch_upstream_name(
|
|
385
399
|
cleanup:
|
386
400
|
git_config_free(config);
|
387
401
|
git_remote_free(remote);
|
402
|
+
git_buf_free(&remote_name);
|
403
|
+
git_buf_free(&merge_name);
|
388
404
|
git_buf_free(&buf);
|
389
405
|
return error;
|
390
406
|
}
|
@@ -392,29 +408,25 @@ cleanup:
|
|
392
408
|
int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname)
|
393
409
|
{
|
394
410
|
int error;
|
395
|
-
const char *str;
|
396
411
|
git_config *cfg;
|
397
412
|
|
398
413
|
if (!git_reference__is_branch(refname))
|
399
414
|
return not_a_local_branch(refname);
|
400
415
|
|
401
|
-
|
402
|
-
if ((error = git_repository_config_snapshot(&cfg, repo)) < 0)
|
416
|
+
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
|
403
417
|
return error;
|
404
418
|
|
405
|
-
|
406
|
-
|
419
|
+
git_buf_sanitize(buf);
|
420
|
+
|
421
|
+
if ((error = retrieve_upstream_configuration(buf, cfg, refname, "branch.%s.remote")) < 0)
|
422
|
+
return error;
|
407
423
|
|
408
|
-
if (
|
424
|
+
if (git_buf_len(buf) == 0) {
|
409
425
|
giterr_set(GITERR_REFERENCE, "branch '%s' does not have an upstream remote", refname);
|
410
426
|
error = GIT_ENOTFOUND;
|
411
|
-
|
427
|
+
git_buf_clear(buf);
|
412
428
|
}
|
413
429
|
|
414
|
-
error = git_buf_puts(buf, str);
|
415
|
-
|
416
|
-
cleanup:
|
417
|
-
git_config_free(cfg);
|
418
430
|
return error;
|
419
431
|
}
|
420
432
|
|