rugged 0.26.0b3 → 0.26.0b4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/ext/rugged/extconf.rb +10 -7
- data/ext/rugged/rugged.c +4 -6
- data/ext/rugged/rugged_repo.c +1 -1
- data/ext/rugged/rugged_revwalk.c +4 -4
- data/ext/rugged/rugged_tree.c +2 -2
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +13 -6
- data/vendor/libgit2/COPYING +33 -0
- data/vendor/libgit2/include/git2/branch.h +12 -0
- data/vendor/libgit2/include/git2/commit.h +6 -3
- data/vendor/libgit2/include/git2/common.h +11 -0
- data/vendor/libgit2/include/git2/errors.h +2 -0
- data/vendor/libgit2/include/git2/index.h +7 -6
- data/vendor/libgit2/include/git2/repository.h +91 -0
- data/vendor/libgit2/include/git2/stash.h +2 -2
- data/vendor/libgit2/include/git2/types.h +3 -0
- data/vendor/libgit2/include/git2/worktree.h +161 -0
- data/vendor/libgit2/src/attr.c +24 -16
- data/vendor/libgit2/src/attr_file.h +1 -1
- data/vendor/libgit2/src/attrcache.c +11 -10
- data/vendor/libgit2/src/attrcache.h +1 -4
- data/vendor/libgit2/src/blob.c +2 -2
- data/vendor/libgit2/src/branch.c +63 -0
- data/vendor/libgit2/src/buffer.h +2 -1
- data/vendor/libgit2/src/cache.c +21 -25
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/checkout.c +0 -2
- data/vendor/libgit2/src/cherrypick.c +2 -2
- data/vendor/libgit2/src/clone.c +2 -3
- data/vendor/libgit2/src/commit.c +8 -4
- data/vendor/libgit2/src/config_file.c +1 -3
- data/vendor/libgit2/src/describe.c +1 -3
- data/vendor/libgit2/src/diff_driver.c +2 -4
- data/vendor/libgit2/src/fetchhead.c +2 -2
- data/vendor/libgit2/src/fileops.c +1 -3
- data/vendor/libgit2/src/hash.h +5 -3
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +57 -0
- data/vendor/libgit2/src/hash/sha1dc/sha1.c +1149 -0
- data/vendor/libgit2/src/hash/sha1dc/sha1.h +94 -0
- data/vendor/libgit2/src/hash/sha1dc/ubc_check.c +361 -0
- data/vendor/libgit2/src/hash/sha1dc/ubc_check.h +35 -0
- data/vendor/libgit2/src/idxmap.c +133 -0
- data/vendor/libgit2/src/idxmap.h +22 -60
- data/vendor/libgit2/src/ignore.c +7 -1
- data/vendor/libgit2/src/ignore.h +1 -1
- data/vendor/libgit2/src/index.c +11 -14
- data/vendor/libgit2/src/indexer.c +8 -11
- data/vendor/libgit2/src/merge.c +5 -5
- data/vendor/libgit2/src/mwindow.c +1 -3
- data/vendor/libgit2/src/odb.c +3 -3
- data/vendor/libgit2/src/odb.h +3 -0
- data/vendor/libgit2/src/odb_mempack.c +11 -18
- data/vendor/libgit2/src/offmap.c +83 -0
- data/vendor/libgit2/src/offmap.h +14 -34
- data/vendor/libgit2/src/oidmap.c +105 -0
- data/vendor/libgit2/src/oidmap.h +19 -22
- data/vendor/libgit2/src/pack-objects.c +10 -13
- data/vendor/libgit2/src/pack.c +17 -26
- data/vendor/libgit2/src/path.c +45 -24
- data/vendor/libgit2/src/rebase.c +3 -3
- data/vendor/libgit2/src/refdb_fs.c +81 -46
- data/vendor/libgit2/src/refs.c +13 -3
- data/vendor/libgit2/src/remote.c +6 -2
- data/vendor/libgit2/src/repository.c +318 -46
- data/vendor/libgit2/src/repository.h +5 -2
- data/vendor/libgit2/src/revert.c +2 -2
- data/vendor/libgit2/src/revwalk.c +6 -8
- data/vendor/libgit2/src/settings.c +5 -0
- data/vendor/libgit2/src/sortedcache.c +3 -5
- data/vendor/libgit2/src/strmap.c +95 -0
- data/vendor/libgit2/src/strmap.h +17 -37
- data/vendor/libgit2/src/submodule.c +12 -8
- data/vendor/libgit2/src/thread-utils.h +6 -0
- data/vendor/libgit2/src/transaction.c +5 -17
- data/vendor/libgit2/src/transports/local.c +2 -1
- data/vendor/libgit2/src/transports/smart.h +2 -0
- data/vendor/libgit2/src/transports/smart_protocol.c +3 -1
- data/vendor/libgit2/src/tree.c +2 -4
- data/vendor/libgit2/src/unix/posix.h +1 -1
- data/vendor/libgit2/src/worktree.c +432 -0
- data/vendor/libgit2/src/worktree.h +35 -0
- metadata +13 -2
data/vendor/libgit2/src/pack.c
CHANGED
@@ -16,9 +16,6 @@
|
|
16
16
|
|
17
17
|
#include <zlib.h>
|
18
18
|
|
19
|
-
GIT__USE_OFFMAP
|
20
|
-
GIT__USE_OIDMAP
|
21
|
-
|
22
19
|
static int packfile_open(struct git_pack_file *p);
|
23
20
|
static git_off_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n);
|
24
21
|
static int packfile_unpack_compressed(
|
@@ -78,13 +75,12 @@ static void free_cache_object(void *o)
|
|
78
75
|
|
79
76
|
static void cache_free(git_pack_cache *cache)
|
80
77
|
{
|
81
|
-
|
78
|
+
git_pack_cache_entry *entry;
|
82
79
|
|
83
80
|
if (cache->entries) {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
}
|
81
|
+
git_offmap_foreach_value(cache->entries, entry, {
|
82
|
+
free_cache_object(entry);
|
83
|
+
});
|
88
84
|
|
89
85
|
git_offmap_free(cache->entries);
|
90
86
|
cache->entries = NULL;
|
@@ -118,9 +114,9 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
|
|
118
114
|
if (git_mutex_lock(&cache->lock) < 0)
|
119
115
|
return NULL;
|
120
116
|
|
121
|
-
k =
|
122
|
-
if (
|
123
|
-
entry =
|
117
|
+
k = git_offmap_lookup_index(cache->entries, offset);
|
118
|
+
if (git_offmap_valid_index(cache->entries, k)) { /* found it */
|
119
|
+
entry = git_offmap_value_at(cache->entries, k);
|
124
120
|
git_atomic_inc(&entry->refcount);
|
125
121
|
entry->last_usage = cache->use_ctr++;
|
126
122
|
}
|
@@ -132,21 +128,16 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
|
|
132
128
|
/* Run with the cache lock held */
|
133
129
|
static void free_lowest_entry(git_pack_cache *cache)
|
134
130
|
{
|
131
|
+
git_off_t offset;
|
135
132
|
git_pack_cache_entry *entry;
|
136
|
-
khiter_t k;
|
137
|
-
|
138
|
-
for (k = kh_begin(cache->entries); k != kh_end(cache->entries); k++) {
|
139
|
-
if (!kh_exist(cache->entries, k))
|
140
|
-
continue;
|
141
|
-
|
142
|
-
entry = kh_value(cache->entries, k);
|
143
133
|
|
134
|
+
git_offmap_foreach(cache->entries, offset, entry, {
|
144
135
|
if (entry && entry->refcount.val == 0) {
|
145
136
|
cache->memory_used -= entry->raw.len;
|
146
|
-
|
137
|
+
git_offmap_delete(cache->entries, offset);
|
147
138
|
free_cache_object(entry);
|
148
139
|
}
|
149
|
-
}
|
140
|
+
});
|
150
141
|
}
|
151
142
|
|
152
143
|
static int cache_add(
|
@@ -170,14 +161,14 @@ static int cache_add(
|
|
170
161
|
return -1;
|
171
162
|
}
|
172
163
|
/* Add it to the cache if nobody else has */
|
173
|
-
exists =
|
164
|
+
exists = git_offmap_exists(cache->entries, offset);
|
174
165
|
if (!exists) {
|
175
166
|
while (cache->memory_used + base->len > cache->memory_limit)
|
176
167
|
free_lowest_entry(cache);
|
177
168
|
|
178
|
-
k =
|
169
|
+
k = git_offmap_put(cache->entries, offset, &error);
|
179
170
|
assert(error != 0);
|
180
|
-
|
171
|
+
git_offmap_set_value_at(cache->entries, k, entry);
|
181
172
|
cache->memory_used += entry->raw.len;
|
182
173
|
|
183
174
|
*cached_out = entry;
|
@@ -962,10 +953,10 @@ git_off_t get_delta_base(
|
|
962
953
|
git_oid oid;
|
963
954
|
|
964
955
|
git_oid_fromraw(&oid, base_info);
|
965
|
-
k =
|
966
|
-
if (
|
956
|
+
k = git_oidmap_lookup_index(p->idx_cache, &oid);
|
957
|
+
if (git_oidmap_valid_index(p->idx_cache, k)) {
|
967
958
|
*curpos += 20;
|
968
|
-
return ((struct git_pack_entry *)
|
959
|
+
return ((struct git_pack_entry *)git_oidmap_value_at(p->idx_cache, k))->offset;
|
969
960
|
} else {
|
970
961
|
/* If we're building an index, don't try to find the pack
|
971
962
|
* entry; we just haven't seen it yet. We'll make
|
data/vendor/libgit2/src/path.c
CHANGED
@@ -110,6 +110,34 @@ Exit:
|
|
110
110
|
return result;
|
111
111
|
}
|
112
112
|
|
113
|
+
/*
|
114
|
+
* Determine if the path is a Windows prefix and, if so, returns
|
115
|
+
* its actual lentgh. If it is not a prefix, returns -1.
|
116
|
+
*/
|
117
|
+
static int win32_prefix_length(const char *path, int len)
|
118
|
+
{
|
119
|
+
#ifndef GIT_WIN32
|
120
|
+
GIT_UNUSED(path);
|
121
|
+
GIT_UNUSED(len);
|
122
|
+
#else
|
123
|
+
/*
|
124
|
+
* Mimic unix behavior where '/.git' returns '/': 'C:/.git' will return
|
125
|
+
* 'C:/' here
|
126
|
+
*/
|
127
|
+
if (len == 2 && LOOKS_LIKE_DRIVE_PREFIX(path))
|
128
|
+
return 2;
|
129
|
+
|
130
|
+
/*
|
131
|
+
* Similarly checks if we're dealing with a network computer name
|
132
|
+
* '//computername/.git' will return '//computername/'
|
133
|
+
*/
|
134
|
+
if (looks_like_network_computer_name(path, len))
|
135
|
+
return len;
|
136
|
+
#endif
|
137
|
+
|
138
|
+
return -1;
|
139
|
+
}
|
140
|
+
|
113
141
|
/*
|
114
142
|
* Based on the Android implementation, BSD licensed.
|
115
143
|
* Check http://android.git.kernel.org/
|
@@ -117,7 +145,7 @@ Exit:
|
|
117
145
|
int git_path_dirname_r(git_buf *buffer, const char *path)
|
118
146
|
{
|
119
147
|
const char *endp;
|
120
|
-
int
|
148
|
+
int is_prefix = 0, len;
|
121
149
|
|
122
150
|
/* Empty or NULL string gets treated as "." */
|
123
151
|
if (path == NULL || *path == '\0') {
|
@@ -131,6 +159,11 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
|
|
131
159
|
while (endp > path && *endp == '/')
|
132
160
|
endp--;
|
133
161
|
|
162
|
+
if ((len = win32_prefix_length(path, endp - path + 1)) > 0) {
|
163
|
+
is_prefix = 1;
|
164
|
+
goto Exit;
|
165
|
+
}
|
166
|
+
|
134
167
|
/* Find the start of the dir */
|
135
168
|
while (endp > path && *endp != '/')
|
136
169
|
endp--;
|
@@ -146,35 +179,23 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
|
|
146
179
|
endp--;
|
147
180
|
} while (endp > path && *endp == '/');
|
148
181
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
#ifdef GIT_WIN32
|
153
|
-
/* Mimic unix behavior where '/.git' returns '/': 'C:/.git' will return
|
154
|
-
'C:/' here */
|
155
|
-
|
156
|
-
if (len == 2 && LOOKS_LIKE_DRIVE_PREFIX(path)) {
|
157
|
-
len = 3;
|
182
|
+
if ((len = win32_prefix_length(path, endp - path + 1)) > 0) {
|
183
|
+
is_prefix = 1;
|
158
184
|
goto Exit;
|
159
185
|
}
|
160
186
|
|
161
|
-
/*
|
162
|
-
|
163
|
-
|
164
|
-
if (looks_like_network_computer_name(path, len)) {
|
165
|
-
len++;
|
166
|
-
goto Exit;
|
167
|
-
}
|
168
|
-
|
169
|
-
#endif
|
187
|
+
/* Cast is safe because max path < max int */
|
188
|
+
len = (int)(endp - path + 1);
|
170
189
|
|
171
190
|
Exit:
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
191
|
+
if (buffer) {
|
192
|
+
if (git_buf_set(buffer, path, len) < 0)
|
193
|
+
return -1;
|
194
|
+
if (is_prefix && git_buf_putc(buffer, '/') < 0)
|
195
|
+
return -1;
|
196
|
+
}
|
176
197
|
|
177
|
-
return
|
198
|
+
return len;
|
178
199
|
}
|
179
200
|
|
180
201
|
|
data/vendor/libgit2/src/rebase.c
CHANGED
@@ -92,7 +92,7 @@ static int rebase_state_type(
|
|
92
92
|
git_buf path = GIT_BUF_INIT;
|
93
93
|
git_rebase_type_t type = GIT_REBASE_TYPE_NONE;
|
94
94
|
|
95
|
-
if (git_buf_joinpath(&path, repo->
|
95
|
+
if (git_buf_joinpath(&path, repo->gitdir, REBASE_APPLY_DIR) < 0)
|
96
96
|
return -1;
|
97
97
|
|
98
98
|
if (git_path_isdir(git_buf_cstr(&path))) {
|
@@ -101,7 +101,7 @@ static int rebase_state_type(
|
|
101
101
|
}
|
102
102
|
|
103
103
|
git_buf_clear(&path);
|
104
|
-
if (git_buf_joinpath(&path, repo->
|
104
|
+
if (git_buf_joinpath(&path, repo->gitdir, REBASE_MERGE_DIR) < 0)
|
105
105
|
return -1;
|
106
106
|
|
107
107
|
if (git_path_isdir(git_buf_cstr(&path))) {
|
@@ -624,7 +624,7 @@ static int rebase_init_merge(
|
|
624
624
|
|
625
625
|
GIT_UNUSED(upstream);
|
626
626
|
|
627
|
-
if ((error = git_buf_joinpath(&state_path, repo->
|
627
|
+
if ((error = git_buf_joinpath(&state_path, repo->gitdir, REBASE_MERGE_DIR)) < 0)
|
628
628
|
goto done;
|
629
629
|
|
630
630
|
rebase->state_path = git_buf_detach(&state_path);
|
@@ -26,8 +26,6 @@
|
|
26
26
|
#include <git2/sys/refs.h>
|
27
27
|
#include <git2/sys/reflog.h>
|
28
28
|
|
29
|
-
GIT__USE_STRMAP
|
30
|
-
|
31
29
|
#define DEFAULT_NESTING_LEVEL 5
|
32
30
|
#define MAX_NESTING_LEVEL 10
|
33
31
|
|
@@ -55,7 +53,10 @@ typedef struct refdb_fs_backend {
|
|
55
53
|
git_refdb_backend parent;
|
56
54
|
|
57
55
|
git_repository *repo;
|
58
|
-
|
56
|
+
/* path to git directory */
|
57
|
+
char *gitpath;
|
58
|
+
/* path to common objects' directory */
|
59
|
+
char *commonpath;
|
59
60
|
|
60
61
|
git_sortedcache *refcache;
|
61
62
|
int peeling_mode;
|
@@ -77,7 +78,7 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
77
78
|
git_buf packedrefs = GIT_BUF_INIT;
|
78
79
|
char *scan, *eof, *eol;
|
79
80
|
|
80
|
-
if (!backend->
|
81
|
+
if (!backend->gitpath)
|
81
82
|
return 0;
|
82
83
|
|
83
84
|
error = git_sortedcache_lockandload(backend->refcache, &packedrefs);
|
@@ -238,7 +239,7 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
|
|
238
239
|
/* if we fail to load the loose reference, assume someone changed
|
239
240
|
* the filesystem under us and skip it...
|
240
241
|
*/
|
241
|
-
if (loose_readbuffer(&ref_file, backend->
|
242
|
+
if (loose_readbuffer(&ref_file, backend->gitpath, name) < 0) {
|
242
243
|
giterr_clear();
|
243
244
|
goto done;
|
244
245
|
}
|
@@ -287,7 +288,7 @@ static int _dirent_loose_load(void *payload, git_buf *full_path)
|
|
287
288
|
return error;
|
288
289
|
}
|
289
290
|
|
290
|
-
file_path = full_path->ptr + strlen(backend->
|
291
|
+
file_path = full_path->ptr + strlen(backend->gitpath);
|
291
292
|
|
292
293
|
return loose_lookup_to_packfile(backend, file_path);
|
293
294
|
}
|
@@ -303,7 +304,7 @@ static int packed_loadloose(refdb_fs_backend *backend)
|
|
303
304
|
int error;
|
304
305
|
git_buf refs_path = GIT_BUF_INIT;
|
305
306
|
|
306
|
-
if (git_buf_joinpath(&refs_path, backend->
|
307
|
+
if (git_buf_joinpath(&refs_path, backend->gitpath, GIT_REFS_DIR) < 0)
|
307
308
|
return -1;
|
308
309
|
|
309
310
|
/*
|
@@ -331,7 +332,7 @@ static int refdb_fs_backend__exists(
|
|
331
332
|
assert(backend);
|
332
333
|
|
333
334
|
if ((error = packed_reload(backend)) < 0 ||
|
334
|
-
(error = git_buf_joinpath(&ref_path, backend->
|
335
|
+
(error = git_buf_joinpath(&ref_path, backend->gitpath, ref_name)) < 0)
|
335
336
|
return error;
|
336
337
|
|
337
338
|
*exists = git_path_isfile(ref_path.ptr) ||
|
@@ -362,6 +363,19 @@ static const char *loose_parse_symbolic(git_buf *file_content)
|
|
362
363
|
return refname_start;
|
363
364
|
}
|
364
365
|
|
366
|
+
/*
|
367
|
+
* Returns whether a reference is stored per worktree or not.
|
368
|
+
* Per-worktree references are:
|
369
|
+
*
|
370
|
+
* - all pseudorefs, e.g. HEAD and MERGE_HEAD
|
371
|
+
* - all references stored inside of "refs/bisect/"
|
372
|
+
*/
|
373
|
+
static bool is_per_worktree_ref(const char *ref_name)
|
374
|
+
{
|
375
|
+
return git__prefixcmp(ref_name, "refs/") != 0 ||
|
376
|
+
git__prefixcmp(ref_name, "refs/bisect/") == 0;
|
377
|
+
}
|
378
|
+
|
365
379
|
static int loose_lookup(
|
366
380
|
git_reference **out,
|
367
381
|
refdb_fs_backend *backend,
|
@@ -369,11 +383,17 @@ static int loose_lookup(
|
|
369
383
|
{
|
370
384
|
git_buf ref_file = GIT_BUF_INIT;
|
371
385
|
int error = 0;
|
386
|
+
const char *ref_dir;
|
372
387
|
|
373
388
|
if (out)
|
374
389
|
*out = NULL;
|
375
390
|
|
376
|
-
if ((
|
391
|
+
if (is_per_worktree_ref(ref_name))
|
392
|
+
ref_dir = backend->gitpath;
|
393
|
+
else
|
394
|
+
ref_dir = backend->commonpath;
|
395
|
+
|
396
|
+
if ((error = loose_readbuffer(&ref_file, ref_dir, ref_name)) < 0)
|
377
397
|
/* cannot read loose ref file - gah */;
|
378
398
|
else if (git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF) == 0) {
|
379
399
|
const char *target;
|
@@ -484,12 +504,12 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
|
|
484
504
|
git_iterator_options fsit_opts = GIT_ITERATOR_OPTIONS_INIT;
|
485
505
|
const git_index_entry *entry = NULL;
|
486
506
|
|
487
|
-
if (!backend->
|
507
|
+
if (!backend->commonpath) /* do nothing if no commonpath for loose refs */
|
488
508
|
return 0;
|
489
509
|
|
490
510
|
fsit_opts.flags = backend->iterator_flags;
|
491
511
|
|
492
|
-
if ((error = git_buf_printf(&path, "%s/refs", backend->
|
512
|
+
if ((error = git_buf_printf(&path, "%s/refs", backend->commonpath)) < 0 ||
|
493
513
|
(error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
|
494
514
|
git_buf_free(&path);
|
495
515
|
return error;
|
@@ -729,10 +749,10 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
|
|
729
749
|
/* Remove a possibly existing empty directory hierarchy
|
730
750
|
* which name would collide with the reference name
|
731
751
|
*/
|
732
|
-
if ((error = git_futils_rmdir_r(name, backend->
|
752
|
+
if ((error = git_futils_rmdir_r(name, backend->gitpath, GIT_RMDIR_SKIP_NONEMPTY)) < 0)
|
733
753
|
return error;
|
734
754
|
|
735
|
-
if (git_buf_joinpath(&ref_path, backend->
|
755
|
+
if (git_buf_joinpath(&ref_path, backend->gitpath, name) < 0)
|
736
756
|
return -1;
|
737
757
|
|
738
758
|
error = git_filebuf_open(file, ref_path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE);
|
@@ -1283,7 +1303,7 @@ static int refdb_fs_backend__delete_tail(
|
|
1283
1303
|
}
|
1284
1304
|
|
1285
1305
|
/* If a loose reference exists, remove it from the filesystem */
|
1286
|
-
if (git_buf_joinpath(&loose_path, backend->
|
1306
|
+
if (git_buf_joinpath(&loose_path, backend->gitpath, ref_name) < 0)
|
1287
1307
|
return -1;
|
1288
1308
|
|
1289
1309
|
|
@@ -1408,28 +1428,30 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
|
|
1408
1428
|
assert(backend);
|
1409
1429
|
|
1410
1430
|
git_sortedcache_free(backend->refcache);
|
1411
|
-
git__free(backend->
|
1431
|
+
git__free(backend->gitpath);
|
1432
|
+
git__free(backend->commonpath);
|
1412
1433
|
git__free(backend);
|
1413
1434
|
}
|
1414
1435
|
|
1415
|
-
static
|
1436
|
+
static char *setup_namespace(git_repository *repo, const char *in)
|
1416
1437
|
{
|
1417
|
-
|
1438
|
+
git_buf path = GIT_BUF_INIT;
|
1439
|
+
char *parts, *start, *end, *out = NULL;
|
1418
1440
|
|
1419
|
-
|
1420
|
-
|
1421
|
-
return 0;
|
1441
|
+
if (!in)
|
1442
|
+
goto done;
|
1422
1443
|
|
1423
|
-
|
1424
|
-
git_buf_puts(path, repo->path_repository);
|
1444
|
+
git_buf_puts(&path, in);
|
1425
1445
|
|
1426
1446
|
/* if the repo is not namespaced, nothing else to do */
|
1427
|
-
if (repo->namespace == NULL)
|
1428
|
-
|
1447
|
+
if (repo->namespace == NULL) {
|
1448
|
+
out = git_buf_detach(&path);
|
1449
|
+
goto done;
|
1450
|
+
}
|
1429
1451
|
|
1430
1452
|
parts = end = git__strdup(repo->namespace);
|
1431
1453
|
if (parts == NULL)
|
1432
|
-
|
1454
|
+
goto done;
|
1433
1455
|
|
1434
1456
|
/*
|
1435
1457
|
* From `man gitnamespaces`:
|
@@ -1437,21 +1459,24 @@ static int setup_namespace(git_buf *path, git_repository *repo)
|
|
1437
1459
|
* of namespaces; for example, GIT_NAMESPACE=foo/bar will store
|
1438
1460
|
* refs under refs/namespaces/foo/refs/namespaces/bar/
|
1439
1461
|
*/
|
1440
|
-
while ((start = git__strsep(&end, "/")) != NULL)
|
1441
|
-
git_buf_printf(path, "refs/namespaces/%s/", start);
|
1442
|
-
}
|
1462
|
+
while ((start = git__strsep(&end, "/")) != NULL)
|
1463
|
+
git_buf_printf(&path, "refs/namespaces/%s/", start);
|
1443
1464
|
|
1444
|
-
git_buf_printf(path, "refs/namespaces/%s/refs", end);
|
1465
|
+
git_buf_printf(&path, "refs/namespaces/%s/refs", end);
|
1445
1466
|
git__free(parts);
|
1446
1467
|
|
1447
1468
|
/* Make sure that the folder with the namespace exists */
|
1448
|
-
if (git_futils_mkdir_relative(git_buf_cstr(path),
|
1449
|
-
|
1450
|
-
|
1469
|
+
if (git_futils_mkdir_relative(git_buf_cstr(&path), in, 0777,
|
1470
|
+
GIT_MKDIR_PATH, NULL) < 0)
|
1471
|
+
goto done;
|
1451
1472
|
|
1452
|
-
/* Return root of the namespaced
|
1453
|
-
git_buf_rtruncate_at_char(path, '/');
|
1454
|
-
|
1473
|
+
/* Return root of the namespaced gitpath, i.e. without the trailing '/refs' */
|
1474
|
+
git_buf_rtruncate_at_char(&path, '/');
|
1475
|
+
out = git_buf_detach(&path);
|
1476
|
+
|
1477
|
+
done:
|
1478
|
+
git_buf_free(&path);
|
1479
|
+
return out;
|
1455
1480
|
}
|
1456
1481
|
|
1457
1482
|
static int reflog_alloc(git_reflog **reflog, const char *name)
|
@@ -1562,7 +1587,7 @@ static int create_new_reflog_file(const char *filepath)
|
|
1562
1587
|
|
1563
1588
|
GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name)
|
1564
1589
|
{
|
1565
|
-
return git_buf_join3(path, '/', repo->
|
1590
|
+
return git_buf_join3(path, '/', repo->commondir, GIT_REFLOG_DIR, name);
|
1566
1591
|
}
|
1567
1592
|
|
1568
1593
|
static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *name)
|
@@ -1857,7 +1882,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
|
|
1857
1882
|
&normalized, new_name, GIT_REF_FORMAT_ALLOW_ONELEVEL)) < 0)
|
1858
1883
|
return error;
|
1859
1884
|
|
1860
|
-
if (git_buf_joinpath(&temp_path, repo->
|
1885
|
+
if (git_buf_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
|
1861
1886
|
return -1;
|
1862
1887
|
|
1863
1888
|
if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), old_name) < 0)
|
@@ -1948,7 +1973,7 @@ int git_refdb_backend_fs(
|
|
1948
1973
|
git_repository *repository)
|
1949
1974
|
{
|
1950
1975
|
int t = 0;
|
1951
|
-
git_buf
|
1976
|
+
git_buf gitpath = GIT_BUF_INIT;
|
1952
1977
|
refdb_fs_backend *backend;
|
1953
1978
|
|
1954
1979
|
backend = git__calloc(1, sizeof(refdb_fs_backend));
|
@@ -1956,18 +1981,27 @@ int git_refdb_backend_fs(
|
|
1956
1981
|
|
1957
1982
|
backend->repo = repository;
|
1958
1983
|
|
1959
|
-
if (
|
1960
|
-
|
1984
|
+
if (repository->gitdir) {
|
1985
|
+
backend->gitpath = setup_namespace(repository, repository->gitdir);
|
1961
1986
|
|
1962
|
-
|
1987
|
+
if (backend->gitpath == NULL)
|
1988
|
+
goto fail;
|
1989
|
+
}
|
1990
|
+
|
1991
|
+
if (repository->commondir) {
|
1992
|
+
backend->commonpath = setup_namespace(repository, repository->commondir);
|
1993
|
+
|
1994
|
+
if (backend->commonpath == NULL)
|
1995
|
+
goto fail;
|
1996
|
+
}
|
1963
1997
|
|
1964
|
-
if (git_buf_joinpath(&
|
1998
|
+
if (git_buf_joinpath(&gitpath, backend->commonpath, GIT_PACKEDREFS_FILE) < 0 ||
|
1965
1999
|
git_sortedcache_new(
|
1966
2000
|
&backend->refcache, offsetof(struct packref, name),
|
1967
|
-
NULL, NULL, packref_cmp, git_buf_cstr(&
|
2001
|
+
NULL, NULL, packref_cmp, git_buf_cstr(&gitpath)) < 0)
|
1968
2002
|
goto fail;
|
1969
2003
|
|
1970
|
-
git_buf_free(&
|
2004
|
+
git_buf_free(&gitpath);
|
1971
2005
|
|
1972
2006
|
if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_IGNORECASE) && t) {
|
1973
2007
|
backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE;
|
@@ -1999,8 +2033,9 @@ int git_refdb_backend_fs(
|
|
1999
2033
|
return 0;
|
2000
2034
|
|
2001
2035
|
fail:
|
2002
|
-
git_buf_free(&
|
2003
|
-
git__free(backend->
|
2036
|
+
git_buf_free(&gitpath);
|
2037
|
+
git__free(backend->gitpath);
|
2038
|
+
git__free(backend->commonpath);
|
2004
2039
|
git__free(backend);
|
2005
2040
|
return -1;
|
2006
2041
|
}
|