rugged 0.21.0 → 0.21.1b0
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 +8 -8
- data/ext/rugged/rugged.h +1 -1
- data/ext/rugged/rugged_cred.c +23 -0
- data/ext/rugged/rugged_index.c +5 -1
- data/ext/rugged/rugged_remote.c +68 -0
- data/ext/rugged/rugged_repo.c +287 -5
- data/ext/rugged/rugged_tag_collection.c +70 -2
- data/ext/rugged/rugged_tree.c +29 -10
- data/lib/rugged.rb +1 -0
- data/lib/rugged/attributes.rb +41 -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/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +11 -0
- 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/attr.h +16 -13
- 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/diff.h +7 -0
- data/vendor/libgit2/include/git2/errors.h +1 -0
- data/vendor/libgit2/include/git2/merge.h +16 -0
- data/vendor/libgit2/include/git2/oid.h +8 -4
- data/vendor/libgit2/include/git2/oidarray.h +40 -0
- data/vendor/libgit2/include/git2/remote.h +5 -24
- data/vendor/libgit2/include/git2/repository.h +4 -1
- data/vendor/libgit2/include/git2/reset.h +4 -0
- data/vendor/libgit2/include/git2/status.h +17 -14
- data/vendor/libgit2/include/git2/submodule.h +18 -0
- data/vendor/libgit2/include/git2/sys/transport.h +354 -0
- data/vendor/libgit2/include/git2/transport.h +34 -327
- data/vendor/libgit2/include/git2/types.h +16 -6
- data/vendor/libgit2/src/array.h +1 -1
- data/vendor/libgit2/src/attr_file.c +14 -1
- data/vendor/libgit2/src/blame.c +0 -1
- 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/checkout.c +118 -23
- data/vendor/libgit2/src/cherrypick.c +41 -44
- data/vendor/libgit2/src/clone.c +94 -56
- data/vendor/libgit2/src/config_file.c +4 -4
- data/vendor/libgit2/src/diff.c +21 -0
- data/vendor/libgit2/src/diff_file.c +1 -0
- data/vendor/libgit2/src/diff_print.c +11 -9
- data/vendor/libgit2/src/diff_tform.c +3 -1
- data/vendor/libgit2/src/errors.c +9 -7
- data/vendor/libgit2/src/fileops.c +5 -3
- data/vendor/libgit2/src/global.c +9 -1
- data/vendor/libgit2/src/global.h +1 -0
- data/vendor/libgit2/src/graph.c +2 -2
- data/vendor/libgit2/src/indexer.c +6 -1
- data/vendor/libgit2/src/merge.c +98 -144
- data/vendor/libgit2/src/merge.h +1 -1
- data/vendor/libgit2/src/netops.c +4 -0
- data/vendor/libgit2/src/oid.c +8 -0
- 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/pack.c +1 -4
- data/vendor/libgit2/src/path.c +93 -33
- data/vendor/libgit2/src/path.h +21 -0
- data/vendor/libgit2/src/pool.c +1 -1
- data/vendor/libgit2/src/posix.h +46 -28
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +54 -18
- data/vendor/libgit2/src/remote.c +31 -8
- data/vendor/libgit2/src/remote.h +3 -0
- data/vendor/libgit2/src/repository.c +27 -11
- data/vendor/libgit2/src/revert.c +4 -6
- data/vendor/libgit2/src/revparse.c +15 -18
- data/vendor/libgit2/src/revwalk.c +0 -3
- data/vendor/libgit2/src/signature.c +2 -2
- data/vendor/libgit2/src/stash.c +2 -1
- data/vendor/libgit2/src/status.c +11 -2
- data/vendor/libgit2/src/strnlen.h +2 -1
- data/vendor/libgit2/src/submodule.c +73 -33
- data/vendor/libgit2/src/thread-utils.h +0 -7
- data/vendor/libgit2/src/trace.h +9 -1
- data/vendor/libgit2/src/transport.c +93 -90
- 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 +168 -76
- data/vendor/libgit2/src/transports/smart.h +1 -0
- data/vendor/libgit2/src/transports/smart_protocol.c +4 -2
- data/vendor/libgit2/src/transports/ssh.c +214 -38
- data/vendor/libgit2/src/transports/winhttp.c +26 -6
- data/vendor/libgit2/src/unix/posix.h +23 -9
- data/vendor/libgit2/src/unix/realpath.c +8 -7
- data/vendor/libgit2/src/util.c +2 -1
- data/vendor/libgit2/src/util.h +3 -3
- 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 -31
- data/vendor/libgit2/src/win32/posix_w32.c +33 -4
- metadata +81 -69
@@ -378,6 +378,18 @@ bool git_attr_fnmatch__match(
|
|
378
378
|
return (matchval != FNM_NOMATCH);
|
379
379
|
}
|
380
380
|
|
381
|
+
/* if path is a directory prefix of a negated pattern, then match */
|
382
|
+
if ((match->flags & GIT_ATTR_FNMATCH_NEGATIVE) && path->is_dir) {
|
383
|
+
size_t pathlen = strlen(path->path);
|
384
|
+
bool prefixed = (pathlen <= match->length) &&
|
385
|
+
((match->flags & GIT_ATTR_FNMATCH_ICASE) ?
|
386
|
+
!strncasecmp(match->pattern, path->path, pathlen) :
|
387
|
+
!strncmp(match->pattern, path->path, pathlen));
|
388
|
+
|
389
|
+
if (prefixed && git_path_at_end_of_segment(&match->pattern[pathlen]))
|
390
|
+
return true;
|
391
|
+
}
|
392
|
+
|
381
393
|
return (p_fnmatch(match->pattern, filename, flags) != FNM_NOMATCH);
|
382
394
|
}
|
383
395
|
|
@@ -522,7 +534,8 @@ int git_attr_fnmatch__parse(
|
|
522
534
|
}
|
523
535
|
|
524
536
|
if (*pattern == '!' && (spec->flags & GIT_ATTR_FNMATCH_ALLOWNEG) != 0) {
|
525
|
-
spec->flags = spec->flags |
|
537
|
+
spec->flags = spec->flags |
|
538
|
+
GIT_ATTR_FNMATCH_NEGATIVE | GIT_ATTR_FNMATCH_LEADINGDIR;
|
526
539
|
pattern++;
|
527
540
|
}
|
528
541
|
|
data/vendor/libgit2/src/blame.c
CHANGED
data/vendor/libgit2/src/buffer.c
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
#include "buffer.h"
|
8
8
|
#include "posix.h"
|
9
9
|
#include "git2/buffer.h"
|
10
|
+
#include "buf_text.h"
|
10
11
|
#include <ctype.h>
|
11
12
|
|
12
13
|
/* Used as default value for git_buf->ptr so that people can always
|
@@ -141,6 +142,16 @@ int git_buf_set(git_buf *buf, const void *data, size_t len)
|
|
141
142
|
return 0;
|
142
143
|
}
|
143
144
|
|
145
|
+
int git_buf_is_binary(const git_buf *buf)
|
146
|
+
{
|
147
|
+
return git_buf_text_is_binary(buf);
|
148
|
+
}
|
149
|
+
|
150
|
+
int git_buf_contains_nul(const git_buf *buf)
|
151
|
+
{
|
152
|
+
return git_buf_text_contains_nul(buf);
|
153
|
+
}
|
154
|
+
|
144
155
|
int git_buf_sets(git_buf *buf, const char *string)
|
145
156
|
{
|
146
157
|
return git_buf_set(buf, string, string ? strlen(string) : 0);
|
@@ -178,10 +189,10 @@ int git_buf_puts(git_buf *buf, const char *string)
|
|
178
189
|
return git_buf_put(buf, string, strlen(string));
|
179
190
|
}
|
180
191
|
|
181
|
-
static const char
|
192
|
+
static const char base64_encode[] =
|
182
193
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
183
194
|
|
184
|
-
int
|
195
|
+
int git_buf_encode_base64(git_buf *buf, const char *data, size_t len)
|
185
196
|
{
|
186
197
|
size_t extra = len % 3;
|
187
198
|
uint8_t *write, a, b, c;
|
@@ -196,19 +207,19 @@ int git_buf_put_base64(git_buf *buf, const char *data, size_t len)
|
|
196
207
|
b = *read++;
|
197
208
|
c = *read++;
|
198
209
|
|
199
|
-
*write++ =
|
200
|
-
*write++ =
|
201
|
-
*write++ =
|
202
|
-
*write++ =
|
210
|
+
*write++ = base64_encode[a >> 2];
|
211
|
+
*write++ = base64_encode[(a & 0x03) << 4 | b >> 4];
|
212
|
+
*write++ = base64_encode[(b & 0x0f) << 2 | c >> 6];
|
213
|
+
*write++ = base64_encode[c & 0x3f];
|
203
214
|
}
|
204
215
|
|
205
216
|
if (extra > 0) {
|
206
217
|
a = *read++;
|
207
218
|
b = (extra > 1) ? *read++ : 0;
|
208
219
|
|
209
|
-
*write++ =
|
210
|
-
*write++ =
|
211
|
-
*write++ = (extra > 1) ?
|
220
|
+
*write++ = base64_encode[a >> 2];
|
221
|
+
*write++ = base64_encode[(a & 0x03) << 4 | b >> 4];
|
222
|
+
*write++ = (extra > 1) ? base64_encode[(b & 0x0f) << 2] : '=';
|
212
223
|
*write++ = '=';
|
213
224
|
}
|
214
225
|
|
@@ -218,10 +229,56 @@ int git_buf_put_base64(git_buf *buf, const char *data, size_t len)
|
|
218
229
|
return 0;
|
219
230
|
}
|
220
231
|
|
232
|
+
/* The inverse of base64_encode, offset by '+' == 43. */
|
233
|
+
static const int8_t base64_decode[] = {
|
234
|
+
62,
|
235
|
+
-1, -1, -1,
|
236
|
+
63,
|
237
|
+
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
|
238
|
+
-1, -1, -1, 0, -1, -1, -1,
|
239
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
|
240
|
+
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
|
241
|
+
-1, -1, -1, -1, -1, -1,
|
242
|
+
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
|
243
|
+
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
|
244
|
+
};
|
245
|
+
|
246
|
+
#define BASE64_DECODE_VALUE(c) (((c) < 43 || (c) > 122) ? -1 : base64_decode[c - 43])
|
247
|
+
|
248
|
+
int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len)
|
249
|
+
{
|
250
|
+
size_t i;
|
251
|
+
int8_t a, b, c, d;
|
252
|
+
size_t orig_size = buf->size;
|
253
|
+
|
254
|
+
assert(len % 4 == 0);
|
255
|
+
ENSURE_SIZE(buf, buf->size + (len / 4 * 3) + 1);
|
256
|
+
|
257
|
+
for (i = 0; i < len; i += 4) {
|
258
|
+
if ((a = BASE64_DECODE_VALUE(base64[i])) < 0 ||
|
259
|
+
(b = BASE64_DECODE_VALUE(base64[i+1])) < 0 ||
|
260
|
+
(c = BASE64_DECODE_VALUE(base64[i+2])) < 0 ||
|
261
|
+
(d = BASE64_DECODE_VALUE(base64[i+3])) < 0) {
|
262
|
+
buf->size = orig_size;
|
263
|
+
buf->ptr[buf->size] = '\0';
|
264
|
+
|
265
|
+
giterr_set(GITERR_INVALID, "Invalid base64 input");
|
266
|
+
return -1;
|
267
|
+
}
|
268
|
+
|
269
|
+
buf->ptr[buf->size++] = ((a << 2) | (b & 0x30) >> 4);
|
270
|
+
buf->ptr[buf->size++] = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2);
|
271
|
+
buf->ptr[buf->size++] = (c & 0x03) << 6 | (d & 0x3f);
|
272
|
+
}
|
273
|
+
|
274
|
+
buf->ptr[buf->size] = '\0';
|
275
|
+
return 0;
|
276
|
+
}
|
277
|
+
|
221
278
|
static const char b85str[] =
|
222
279
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~";
|
223
280
|
|
224
|
-
int
|
281
|
+
int git_buf_encode_base85(git_buf *buf, const char *data, size_t len)
|
225
282
|
{
|
226
283
|
ENSURE_SIZE(buf, buf->size + (5 * ((len / 4) + !!(len % 4))) + 1);
|
227
284
|
|
data/vendor/libgit2/src/buffer.h
CHANGED
@@ -156,10 +156,12 @@ void git_buf_rtrim(git_buf *buf);
|
|
156
156
|
int git_buf_cmp(const git_buf *a, const git_buf *b);
|
157
157
|
|
158
158
|
/* Write data as base64 encoded in buffer */
|
159
|
-
int
|
159
|
+
int git_buf_encode_base64(git_buf *buf, const char *data, size_t len);
|
160
|
+
/* Decode the given bas64 and write the result to the buffer */
|
161
|
+
int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len);
|
160
162
|
|
161
163
|
/* Write data as "base85" encoded in buffer */
|
162
|
-
int
|
164
|
+
int git_buf_encode_base85(git_buf *buf, const char *data, size_t len);
|
163
165
|
|
164
166
|
/*
|
165
167
|
* Insert, remove or replace a portion of the buffer.
|
data/vendor/libgit2/src/cache.c
CHANGED
@@ -68,8 +68,8 @@ int git_cache_init(git_cache *cache)
|
|
68
68
|
{
|
69
69
|
memset(cache, 0, sizeof(*cache));
|
70
70
|
cache->map = git_oidmap_alloc();
|
71
|
-
if (
|
72
|
-
giterr_set(GITERR_OS, "Failed to initialize cache
|
71
|
+
if (git_rwlock_init(&cache->lock)) {
|
72
|
+
giterr_set(GITERR_OS, "Failed to initialize cache rwlock");
|
73
73
|
return -1;
|
74
74
|
}
|
75
75
|
return 0;
|
@@ -94,19 +94,19 @@ static void clear_cache(git_cache *cache)
|
|
94
94
|
|
95
95
|
void git_cache_clear(git_cache *cache)
|
96
96
|
{
|
97
|
-
if (
|
97
|
+
if (git_rwlock_wrlock(&cache->lock) < 0)
|
98
98
|
return;
|
99
99
|
|
100
100
|
clear_cache(cache);
|
101
101
|
|
102
|
-
|
102
|
+
git_rwlock_wrunlock(&cache->lock);
|
103
103
|
}
|
104
104
|
|
105
105
|
void git_cache_free(git_cache *cache)
|
106
106
|
{
|
107
107
|
git_cache_clear(cache);
|
108
108
|
git_oidmap_free(cache->map);
|
109
|
-
|
109
|
+
git_rwlock_free(&cache->lock);
|
110
110
|
git__memzero(cache, sizeof(*cache));
|
111
111
|
}
|
112
112
|
|
@@ -152,7 +152,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
|
|
152
152
|
khiter_t pos;
|
153
153
|
git_cached_obj *entry = NULL;
|
154
154
|
|
155
|
-
if (!git_cache__enabled ||
|
155
|
+
if (!git_cache__enabled || git_rwlock_rdlock(&cache->lock) < 0)
|
156
156
|
return NULL;
|
157
157
|
|
158
158
|
pos = kh_get(oid, cache->map, oid);
|
@@ -166,7 +166,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
|
|
166
166
|
}
|
167
167
|
}
|
168
168
|
|
169
|
-
|
169
|
+
git_rwlock_rdunlock(&cache->lock);
|
170
170
|
|
171
171
|
return entry;
|
172
172
|
}
|
@@ -185,7 +185,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
|
|
185
185
|
if (!cache_should_store(entry->type, entry->size))
|
186
186
|
return entry;
|
187
187
|
|
188
|
-
if (
|
188
|
+
if (git_rwlock_wrlock(&cache->lock) < 0)
|
189
189
|
return entry;
|
190
190
|
|
191
191
|
/* soften the load on the cache */
|
@@ -227,7 +227,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
|
|
227
227
|
}
|
228
228
|
}
|
229
229
|
|
230
|
-
|
230
|
+
git_rwlock_wrunlock(&cache->lock);
|
231
231
|
return entry;
|
232
232
|
}
|
233
233
|
|
data/vendor/libgit2/src/cache.h
CHANGED
@@ -46,6 +46,7 @@ enum {
|
|
46
46
|
|
47
47
|
typedef struct {
|
48
48
|
git_repository *repo;
|
49
|
+
git_iterator *target;
|
49
50
|
git_diff *diff;
|
50
51
|
git_checkout_options opts;
|
51
52
|
bool opts_free_baseline;
|
@@ -54,6 +55,8 @@ typedef struct {
|
|
54
55
|
git_pool pool;
|
55
56
|
git_vector removes;
|
56
57
|
git_vector conflicts;
|
58
|
+
git_vector *reuc;
|
59
|
+
git_vector *names;
|
57
60
|
git_buf path;
|
58
61
|
size_t workdir_len;
|
59
62
|
git_buf tmp;
|
@@ -116,6 +119,7 @@ static int checkout_notify(
|
|
116
119
|
case GIT_DELTA_ADDED:
|
117
120
|
case GIT_DELTA_IGNORED:
|
118
121
|
case GIT_DELTA_UNTRACKED:
|
122
|
+
case GIT_DELTA_UNREADABLE:
|
119
123
|
target = &delta->new_file;
|
120
124
|
break;
|
121
125
|
case GIT_DELTA_DELETED:
|
@@ -138,6 +142,7 @@ static int checkout_notify(
|
|
138
142
|
static bool checkout_is_workdir_modified(
|
139
143
|
checkout_data *data,
|
140
144
|
const git_diff_file *baseitem,
|
145
|
+
const git_diff_file *newitem,
|
141
146
|
const git_index_entry *wditem)
|
142
147
|
{
|
143
148
|
git_oid oid;
|
@@ -169,13 +174,16 @@ static bool checkout_is_workdir_modified(
|
|
169
174
|
|
170
175
|
/* Look at the cache to decide if the workdir is modified. If not,
|
171
176
|
* we can simply compare the oid in the cache to the baseitem instead
|
172
|
-
* of hashing the file.
|
177
|
+
* of hashing the file. If so, we allow the checkout to proceed if the
|
178
|
+
* oid is identical (ie, the staged item is what we're trying to check
|
179
|
+
* out.)
|
173
180
|
*/
|
174
181
|
if ((ie = git_index_get_bypath(data->index, wditem->path, 0)) != NULL) {
|
175
182
|
if (wditem->mtime.seconds == ie->mtime.seconds &&
|
176
183
|
wditem->mtime.nanoseconds == ie->mtime.nanoseconds &&
|
177
184
|
wditem->file_size == ie->file_size)
|
178
|
-
return (git_oid__cmp(&baseitem->id, &ie->id) != 0
|
185
|
+
return (git_oid__cmp(&baseitem->id, &ie->id) != 0 &&
|
186
|
+
git_oid_cmp(&newitem->id, &ie->id) != 0);
|
179
187
|
}
|
180
188
|
|
181
189
|
/* depending on where base is coming from, we may or may not know
|
@@ -401,7 +409,7 @@ static int checkout_action_with_wd(
|
|
401
409
|
|
402
410
|
switch (delta->status) {
|
403
411
|
case GIT_DELTA_UNMODIFIED: /* case 14/15 or 33 */
|
404
|
-
if (checkout_is_workdir_modified(data, &delta->old_file, wd)) {
|
412
|
+
if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) {
|
405
413
|
GITERR_CHECK_ERROR(
|
406
414
|
checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd) );
|
407
415
|
*action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, NONE);
|
@@ -414,13 +422,13 @@ static int checkout_action_with_wd(
|
|
414
422
|
*action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
|
415
423
|
break;
|
416
424
|
case GIT_DELTA_DELETED: /* case 9 or 10 (or 26 but not really) */
|
417
|
-
if (checkout_is_workdir_modified(data, &delta->old_file, wd))
|
425
|
+
if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
|
418
426
|
*action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
|
419
427
|
else
|
420
428
|
*action = CHECKOUT_ACTION_IF(SAFE, REMOVE, NONE);
|
421
429
|
break;
|
422
430
|
case GIT_DELTA_MODIFIED: /* case 16, 17, 18 (or 36 but not really) */
|
423
|
-
if (checkout_is_workdir_modified(data, &delta->old_file, wd))
|
431
|
+
if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
|
424
432
|
*action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
|
425
433
|
else
|
426
434
|
*action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
|
@@ -443,7 +451,7 @@ static int checkout_action_with_wd(
|
|
443
451
|
} else
|
444
452
|
*action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT);
|
445
453
|
}
|
446
|
-
else if (checkout_is_workdir_modified(data, &delta->old_file, wd))
|
454
|
+
else if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
|
447
455
|
*action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT);
|
448
456
|
else
|
449
457
|
*action = CHECKOUT_ACTION_IF(SAFE, REMOVE_AND_UPDATE, NONE);
|
@@ -788,11 +796,16 @@ done:
|
|
788
796
|
static int checkout_conflicts_load(checkout_data *data, git_iterator *workdir, git_vector *pathspec)
|
789
797
|
{
|
790
798
|
git_index_conflict_iterator *iterator = NULL;
|
799
|
+
git_index *index;
|
791
800
|
const git_index_entry *ancestor, *ours, *theirs;
|
792
801
|
checkout_conflictdata *conflict;
|
793
802
|
int error = 0;
|
794
803
|
|
795
|
-
|
804
|
+
/* Only write conficts from sources that have them: indexes. */
|
805
|
+
if ((index = git_iterator_get_index(data->target)) == NULL)
|
806
|
+
return 0;
|
807
|
+
|
808
|
+
if ((error = git_index_conflict_iterator_new(&iterator, index)) < 0)
|
796
809
|
goto done;
|
797
810
|
|
798
811
|
data->conflicts._cmp = checkout_conflictdata_cmp;
|
@@ -819,6 +832,10 @@ static int checkout_conflicts_load(checkout_data *data, git_iterator *workdir, g
|
|
819
832
|
git_vector_insert(&data->conflicts, conflict);
|
820
833
|
}
|
821
834
|
|
835
|
+
/* Collect the REUC and NAME entries */
|
836
|
+
data->reuc = &index->reuc;
|
837
|
+
data->names = &index->names;
|
838
|
+
|
822
839
|
if (error == GIT_ITEROVER)
|
823
840
|
error = 0;
|
824
841
|
|
@@ -957,16 +974,20 @@ done:
|
|
957
974
|
static int checkout_conflicts_coalesce_renames(
|
958
975
|
checkout_data *data)
|
959
976
|
{
|
977
|
+
git_index *index;
|
960
978
|
const git_index_name_entry *name_entry;
|
961
979
|
checkout_conflictdata *ancestor_conflict, *our_conflict, *their_conflict;
|
962
980
|
size_t i, names;
|
963
981
|
int error = 0;
|
964
982
|
|
983
|
+
if ((index = git_iterator_get_index(data->target)) == NULL)
|
984
|
+
return 0;
|
985
|
+
|
965
986
|
/* Juggle entries based on renames */
|
966
|
-
names = git_index_name_entrycount(
|
987
|
+
names = git_index_name_entrycount(index);
|
967
988
|
|
968
989
|
for (i = 0; i < names; i++) {
|
969
|
-
name_entry = git_index_name_get_byindex(
|
990
|
+
name_entry = git_index_name_get_byindex(index, i);
|
970
991
|
|
971
992
|
if ((error = checkout_conflicts_load_byname_entry(
|
972
993
|
&ancestor_conflict, &our_conflict, &their_conflict,
|
@@ -1010,13 +1031,17 @@ done:
|
|
1010
1031
|
static int checkout_conflicts_mark_directoryfile(
|
1011
1032
|
checkout_data *data)
|
1012
1033
|
{
|
1034
|
+
git_index *index;
|
1013
1035
|
checkout_conflictdata *conflict;
|
1014
1036
|
const git_index_entry *entry;
|
1015
1037
|
size_t i, j, len;
|
1016
1038
|
const char *path;
|
1017
1039
|
int prefixed, error = 0;
|
1018
1040
|
|
1019
|
-
|
1041
|
+
if ((index = git_iterator_get_index(data->target)) == NULL)
|
1042
|
+
return 0;
|
1043
|
+
|
1044
|
+
len = git_index_entrycount(index);
|
1020
1045
|
|
1021
1046
|
/* Find d/f conflicts */
|
1022
1047
|
git_vector_foreach(&data->conflicts, i, conflict) {
|
@@ -1027,7 +1052,7 @@ static int checkout_conflicts_mark_directoryfile(
|
|
1027
1052
|
path = conflict->ours ?
|
1028
1053
|
conflict->ours->path : conflict->theirs->path;
|
1029
1054
|
|
1030
|
-
if ((error = git_index_find(&j,
|
1055
|
+
if ((error = git_index_find(&j, index, path)) < 0) {
|
1031
1056
|
if (error == GIT_ENOTFOUND)
|
1032
1057
|
giterr_set(GITERR_INDEX,
|
1033
1058
|
"Index inconsistency, could not find entry for expected conflict '%s'", path);
|
@@ -1036,7 +1061,7 @@ static int checkout_conflicts_mark_directoryfile(
|
|
1036
1061
|
}
|
1037
1062
|
|
1038
1063
|
for (; j < len; j++) {
|
1039
|
-
if ((entry = git_index_get_byindex(
|
1064
|
+
if ((entry = git_index_get_byindex(index, j)) == NULL) {
|
1040
1065
|
giterr_set(GITERR_INDEX,
|
1041
1066
|
"Index inconsistency, truncated index while loading expected conflict '%s'", path);
|
1042
1067
|
error = -1;
|
@@ -1802,6 +1827,24 @@ done:
|
|
1802
1827
|
return error;
|
1803
1828
|
}
|
1804
1829
|
|
1830
|
+
static int checkout_conflict_update_index(
|
1831
|
+
checkout_data *data,
|
1832
|
+
checkout_conflictdata *conflict)
|
1833
|
+
{
|
1834
|
+
int error = 0;
|
1835
|
+
|
1836
|
+
if (conflict->ancestor)
|
1837
|
+
error = git_index_add(data->index, conflict->ancestor);
|
1838
|
+
|
1839
|
+
if (!error && conflict->ours)
|
1840
|
+
error = git_index_add(data->index, conflict->ours);
|
1841
|
+
|
1842
|
+
if (!error && conflict->theirs)
|
1843
|
+
error = git_index_add(data->index, conflict->theirs);
|
1844
|
+
|
1845
|
+
return error;
|
1846
|
+
}
|
1847
|
+
|
1805
1848
|
static int checkout_create_conflicts(checkout_data *data)
|
1806
1849
|
{
|
1807
1850
|
checkout_conflictdata *conflict;
|
@@ -1864,6 +1907,12 @@ static int checkout_create_conflicts(checkout_data *data)
|
|
1864
1907
|
else if (!error)
|
1865
1908
|
error = checkout_write_merge(data, conflict);
|
1866
1909
|
|
1910
|
+
/* Update the index extensions (REUC and NAME) if we're checking
|
1911
|
+
* out a different index. (Otherwise just leave them there.)
|
1912
|
+
*/
|
1913
|
+
if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
|
1914
|
+
error = checkout_conflict_update_index(data, conflict);
|
1915
|
+
|
1867
1916
|
if (error)
|
1868
1917
|
break;
|
1869
1918
|
|
@@ -1876,6 +1925,37 @@ static int checkout_create_conflicts(checkout_data *data)
|
|
1876
1925
|
return error;
|
1877
1926
|
}
|
1878
1927
|
|
1928
|
+
static int checkout_extensions_update_index(checkout_data *data)
|
1929
|
+
{
|
1930
|
+
const git_index_reuc_entry *reuc_entry;
|
1931
|
+
const git_index_name_entry *name_entry;
|
1932
|
+
size_t i;
|
1933
|
+
int error = 0;
|
1934
|
+
|
1935
|
+
if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0)
|
1936
|
+
return 0;
|
1937
|
+
|
1938
|
+
if (data->reuc) {
|
1939
|
+
git_vector_foreach(data->reuc, i, reuc_entry) {
|
1940
|
+
if ((error = git_index_reuc_add(data->index, reuc_entry->path,
|
1941
|
+
reuc_entry->mode[0], &reuc_entry->oid[0],
|
1942
|
+
reuc_entry->mode[1], &reuc_entry->oid[1],
|
1943
|
+
reuc_entry->mode[2], &reuc_entry->oid[2])) < 0)
|
1944
|
+
goto done;
|
1945
|
+
}
|
1946
|
+
}
|
1947
|
+
|
1948
|
+
if (data->names) {
|
1949
|
+
git_vector_foreach(data->names, i, name_entry) {
|
1950
|
+
if ((error = git_index_name_add(data->index, name_entry->ancestor,
|
1951
|
+
name_entry->ours, name_entry->theirs)) < 0)
|
1952
|
+
goto done;
|
1953
|
+
}
|
1954
|
+
}
|
1955
|
+
|
1956
|
+
done:
|
1957
|
+
return error;
|
1958
|
+
}
|
1879
1959
|
|
1880
1960
|
static void checkout_data_clear(checkout_data *data)
|
1881
1961
|
{
|
@@ -1919,6 +1999,7 @@ static int checkout_data_init(
|
|
1919
1999
|
return error;
|
1920
2000
|
|
1921
2001
|
data->repo = repo;
|
2002
|
+
data->target = target;
|
1922
2003
|
|
1923
2004
|
GITERR_CHECK_VERSION(
|
1924
2005
|
proposed, GIT_CHECKOUT_OPTIONS_VERSION, "git_checkout_options");
|
@@ -1943,15 +2024,15 @@ static int checkout_data_init(
|
|
1943
2024
|
(error = git_config_refresh(cfg)) < 0)
|
1944
2025
|
goto cleanup;
|
1945
2026
|
|
1946
|
-
/*
|
1947
|
-
*
|
2027
|
+
/* Get the repository index and reload it (unless we're checking
|
2028
|
+
* out the index; then it has the changes we're trying to check
|
2029
|
+
* out and those should not be overwritten.)
|
1948
2030
|
*/
|
1949
|
-
if ((data->index
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
if ((error =
|
1954
|
-
(error = git_index_read(data->index, true)) < 0)
|
2031
|
+
if ((error = git_repository_index(&data->index, data->repo)) < 0)
|
2032
|
+
goto cleanup;
|
2033
|
+
|
2034
|
+
if (data->index != git_iterator_get_index(target)) {
|
2035
|
+
if ((error = git_index_read(data->index, true)) < 0)
|
1955
2036
|
goto cleanup;
|
1956
2037
|
|
1957
2038
|
/* cannot checkout if unresolved conflicts exist */
|
@@ -1963,7 +2044,7 @@ static int checkout_data_init(
|
|
1963
2044
|
goto cleanup;
|
1964
2045
|
}
|
1965
2046
|
|
1966
|
-
/* clean conflict data
|
2047
|
+
/* clean conflict data in the current index */
|
1967
2048
|
git_index_name_clear(data->index);
|
1968
2049
|
git_index_reuc_clear(data->index);
|
1969
2050
|
}
|
@@ -2063,6 +2144,7 @@ int git_checkout_iterator(
|
|
2063
2144
|
|
2064
2145
|
diff_opts.flags =
|
2065
2146
|
GIT_DIFF_INCLUDE_UNMODIFIED |
|
2147
|
+
GIT_DIFF_INCLUDE_UNREADABLE |
|
2066
2148
|
GIT_DIFF_INCLUDE_UNTRACKED |
|
2067
2149
|
GIT_DIFF_RECURSE_UNTRACKED_DIRS | /* needed to match baseline */
|
2068
2150
|
GIT_DIFF_INCLUDE_IGNORED |
|
@@ -2132,6 +2214,10 @@ int git_checkout_iterator(
|
|
2132
2214
|
(error = checkout_create_conflicts(&data)) < 0)
|
2133
2215
|
goto cleanup;
|
2134
2216
|
|
2217
|
+
if (data.index != git_iterator_get_index(target) &&
|
2218
|
+
(error = checkout_extensions_update_index(&data)) < 0)
|
2219
|
+
goto cleanup;
|
2220
|
+
|
2135
2221
|
assert(data.completed_steps == data.total_steps);
|
2136
2222
|
|
2137
2223
|
cleanup:
|
@@ -2154,7 +2240,7 @@ int git_checkout_index(
|
|
2154
2240
|
git_index *index,
|
2155
2241
|
const git_checkout_options *opts)
|
2156
2242
|
{
|
2157
|
-
int error;
|
2243
|
+
int error, owned = 0;
|
2158
2244
|
git_iterator *index_i;
|
2159
2245
|
|
2160
2246
|
if (!index && !repo) {
|
@@ -2162,10 +2248,16 @@ int git_checkout_index(
|
|
2162
2248
|
"Must provide either repository or index to checkout");
|
2163
2249
|
return -1;
|
2164
2250
|
}
|
2165
|
-
|
2251
|
+
|
2252
|
+
if (index && repo &&
|
2253
|
+
git_index_owner(index) &&
|
2254
|
+
git_index_owner(index) != repo) {
|
2166
2255
|
giterr_set(GITERR_CHECKOUT,
|
2167
2256
|
"Index to checkout does not match repository");
|
2168
2257
|
return -1;
|
2258
|
+
} else if(index && repo && !git_index_owner(index)) {
|
2259
|
+
GIT_REFCOUNT_OWN(index, repo);
|
2260
|
+
owned = 1;
|
2169
2261
|
}
|
2170
2262
|
|
2171
2263
|
if (!repo)
|
@@ -2178,6 +2270,9 @@ int git_checkout_index(
|
|
2178
2270
|
if (!(error = git_iterator_for_index(&index_i, index, 0, NULL, NULL)))
|
2179
2271
|
error = git_checkout_iterator(index_i, opts);
|
2180
2272
|
|
2273
|
+
if (owned)
|
2274
|
+
GIT_REFCOUNT_OWN(index, NULL);
|
2275
|
+
|
2181
2276
|
git_iterator_free(index_i);
|
2182
2277
|
git_index_free(index);
|
2183
2278
|
|