rugged 0.27.7 → 0.27.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +6 -2
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +29 -0
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +96 -0
- data/vendor/libgit2/cmake/Modules/FindIconv.cmake +11 -6
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -2
- data/vendor/libgit2/include/git2.h +0 -1
- data/vendor/libgit2/include/git2/attr.h +7 -18
- data/vendor/libgit2/include/git2/blame.h +22 -39
- data/vendor/libgit2/include/git2/blob.h +1 -1
- data/vendor/libgit2/include/git2/branch.h +1 -1
- data/vendor/libgit2/include/git2/buffer.h +2 -14
- data/vendor/libgit2/include/git2/checkout.h +12 -13
- data/vendor/libgit2/include/git2/cherrypick.h +4 -6
- data/vendor/libgit2/include/git2/clone.h +6 -8
- data/vendor/libgit2/include/git2/commit.h +0 -28
- data/vendor/libgit2/include/git2/common.h +0 -27
- data/vendor/libgit2/include/git2/config.h +0 -1
- data/vendor/libgit2/include/git2/describe.h +7 -30
- data/vendor/libgit2/include/git2/diff.h +22 -32
- data/vendor/libgit2/include/git2/errors.h +0 -1
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/merge.h +8 -10
- data/vendor/libgit2/include/git2/proxy.h +5 -9
- data/vendor/libgit2/include/git2/rebase.h +4 -7
- data/vendor/libgit2/include/git2/refs.h +1 -1
- data/vendor/libgit2/include/git2/refspec.h +0 -17
- data/vendor/libgit2/include/git2/remote.h +10 -12
- data/vendor/libgit2/include/git2/repository.h +5 -7
- data/vendor/libgit2/include/git2/revert.h +3 -5
- data/vendor/libgit2/include/git2/stash.h +8 -11
- data/vendor/libgit2/include/git2/status.h +3 -7
- data/vendor/libgit2/include/git2/submodule.h +7 -8
- data/vendor/libgit2/include/git2/sys/index.h +0 -3
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +1 -6
- data/vendor/libgit2/include/git2/transaction.h +0 -1
- data/vendor/libgit2/include/git2/types.h +5 -8
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/include/git2/worktree.h +11 -46
- data/vendor/libgit2/src/CMakeLists.txt +28 -91
- data/vendor/libgit2/src/annotated_commit.c +4 -4
- data/vendor/libgit2/src/apply.c +6 -5
- data/vendor/libgit2/src/attr.c +4 -4
- data/vendor/libgit2/src/attr_file.c +5 -5
- data/vendor/libgit2/src/attrcache.c +2 -2
- data/vendor/libgit2/src/blame.c +4 -11
- data/vendor/libgit2/src/blame.h +0 -1
- data/vendor/libgit2/src/blame_git.c +5 -8
- data/vendor/libgit2/src/blob.c +5 -5
- data/vendor/libgit2/src/branch.c +20 -20
- data/vendor/libgit2/src/buffer.c +4 -9
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/checkout.c +24 -33
- data/vendor/libgit2/src/cherrypick.c +3 -3
- data/vendor/libgit2/src/clone.c +13 -13
- data/vendor/libgit2/src/commit.c +5 -18
- data/vendor/libgit2/src/commit_list.c +9 -3
- data/vendor/libgit2/src/common.h +1 -3
- data/vendor/libgit2/src/config.c +15 -6
- data/vendor/libgit2/src/config_file.c +249 -193
- data/vendor/libgit2/src/config_parse.c +66 -89
- data/vendor/libgit2/src/config_parse.h +2 -2
- data/vendor/libgit2/src/crlf.c +3 -9
- data/vendor/libgit2/src/diff.c +2 -2
- data/vendor/libgit2/src/diff_driver.c +3 -3
- data/vendor/libgit2/src/diff_file.c +3 -3
- data/vendor/libgit2/src/diff_generate.c +3 -4
- data/vendor/libgit2/src/diff_print.c +8 -8
- data/vendor/libgit2/src/diff_tform.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.c +0 -12
- data/vendor/libgit2/src/features.h.in +0 -2
- data/vendor/libgit2/src/fetch.c +2 -2
- data/vendor/libgit2/src/fetchhead.c +5 -5
- data/vendor/libgit2/src/filebuf.c +4 -4
- data/vendor/libgit2/src/fileops.c +10 -10
- data/vendor/libgit2/src/filter.c +9 -3
- data/vendor/libgit2/src/global.c +12 -17
- data/vendor/libgit2/src/hash.h +0 -2
- data/vendor/libgit2/src/ignore.c +5 -5
- data/vendor/libgit2/src/index.c +40 -80
- data/vendor/libgit2/src/index.h +0 -10
- data/vendor/libgit2/src/indexer.c +9 -9
- data/vendor/libgit2/src/iterator.c +8 -8
- data/vendor/libgit2/src/khash.h +1 -3
- data/vendor/libgit2/src/merge.c +7 -7
- data/vendor/libgit2/src/netops.c +5 -5
- data/vendor/libgit2/src/notes.c +2 -2
- data/vendor/libgit2/src/odb.c +9 -9
- data/vendor/libgit2/src/odb_loose.c +22 -18
- data/vendor/libgit2/src/odb_pack.c +3 -3
- data/vendor/libgit2/src/pack-objects.c +3 -3
- data/vendor/libgit2/src/pack.c +5 -5
- data/vendor/libgit2/src/pack.h +1 -1
- data/vendor/libgit2/src/parse.c +7 -4
- data/vendor/libgit2/src/patch.c +1 -1
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +4 -24
- data/vendor/libgit2/src/path.c +140 -39
- data/vendor/libgit2/src/path.h +84 -2
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/push.c +2 -2
- data/vendor/libgit2/src/rebase.c +23 -20
- data/vendor/libgit2/src/refdb_fs.c +34 -65
- data/vendor/libgit2/src/refs.c +16 -13
- data/vendor/libgit2/src/refspec.c +5 -30
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +43 -43
- data/vendor/libgit2/src/repository.c +56 -56
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/revert.c +3 -3
- data/vendor/libgit2/src/revparse.c +7 -6
- data/vendor/libgit2/src/revwalk.c +20 -48
- data/vendor/libgit2/src/revwalk.h +1 -2
- data/vendor/libgit2/src/settings.c +1 -25
- data/vendor/libgit2/src/signature.c +4 -2
- data/vendor/libgit2/src/stash.c +34 -80
- data/vendor/libgit2/src/status.c +1 -1
- data/vendor/libgit2/src/streams/curl.c +1 -1
- data/vendor/libgit2/src/streams/openssl.c +34 -132
- data/vendor/libgit2/src/streams/openssl.h +107 -0
- data/vendor/libgit2/src/streams/tls.c +0 -3
- data/vendor/libgit2/src/submodule.c +83 -118
- data/vendor/libgit2/src/sysdir.c +4 -4
- data/vendor/libgit2/src/tag.c +12 -12
- data/vendor/libgit2/src/trace.h +1 -1
- data/vendor/libgit2/src/trailer.c +6 -6
- data/vendor/libgit2/src/transport.c +2 -2
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +2 -2
- data/vendor/libgit2/src/transports/git.c +1 -1
- data/vendor/libgit2/src/transports/http.c +15 -12
- data/vendor/libgit2/src/transports/local.c +7 -7
- data/vendor/libgit2/src/transports/smart.c +15 -20
- data/vendor/libgit2/src/transports/smart.h +5 -5
- data/vendor/libgit2/src/transports/smart_pkt.c +131 -123
- data/vendor/libgit2/src/transports/smart_protocol.c +38 -48
- data/vendor/libgit2/src/transports/ssh.c +1 -1
- data/vendor/libgit2/src/transports/winhttp.c +26 -21
- data/vendor/libgit2/src/tree-cache.c +2 -2
- data/vendor/libgit2/src/tree.c +69 -23
- data/vendor/libgit2/src/tree.h +12 -0
- data/vendor/libgit2/src/util.c +99 -52
- data/vendor/libgit2/src/util.h +138 -14
- data/vendor/libgit2/src/vector.c +13 -8
- data/vendor/libgit2/src/win32/findfile.c +2 -2
- data/vendor/libgit2/src/win32/posix_w32.c +1 -1
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -94
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +75 -28
- data/vendor/libgit2/src/worktree.c +44 -65
- data/vendor/libgit2/src/worktree.h +0 -2
- data/vendor/libgit2/src/xdiff/xdiffi.c +1 -3
- metadata +5 -17
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +0 -93
- data/vendor/libgit2/include/git2/mailmap.h +0 -115
- data/vendor/libgit2/include/git2/sys/alloc.h +0 -101
- data/vendor/libgit2/include/git2/sys/path.h +0 -55
- data/vendor/libgit2/src/alloc.c +0 -47
- data/vendor/libgit2/src/alloc.h +0 -40
- data/vendor/libgit2/src/hash/hash_mbedtls.c +0 -38
- data/vendor/libgit2/src/hash/hash_mbedtls.h +0 -20
- data/vendor/libgit2/src/mailmap.c +0 -485
- data/vendor/libgit2/src/mailmap.h +0 -35
- data/vendor/libgit2/src/stdalloc.c +0 -120
- data/vendor/libgit2/src/stdalloc.h +0 -17
- data/vendor/libgit2/src/streams/mbedtls.c +0 -463
- data/vendor/libgit2/src/streams/mbedtls.h +0 -20
@@ -158,7 +158,7 @@ static int win32_find_existing_dirs(
|
|
158
158
|
}
|
159
159
|
}
|
160
160
|
|
161
|
-
|
161
|
+
git_buf_free(&buf);
|
162
162
|
|
163
163
|
return (git_buf_oom(out) ? -1 : 0);
|
164
164
|
}
|
@@ -185,7 +185,7 @@ int git_win32__find_system_dirs(git_buf *out, const wchar_t *subdir)
|
|
185
185
|
&buf, HKEY_LOCAL_MACHINE, REG_MSYSGIT_INSTALL, subdir) && buf.size)
|
186
186
|
git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr);
|
187
187
|
|
188
|
-
|
188
|
+
git_buf_free(&buf);
|
189
189
|
|
190
190
|
return (git_buf_oom(out) ? -1 : 0);
|
191
191
|
}
|
@@ -832,7 +832,7 @@ int p_mkstemp(char *tmp_path)
|
|
832
832
|
return -1;
|
833
833
|
#endif
|
834
834
|
|
835
|
-
return p_open(tmp_path, O_RDWR | O_CREAT | O_EXCL, 0744);
|
835
|
+
return p_open(tmp_path, O_RDWR | O_CREAT | O_EXCL, 0744); //-V536
|
836
836
|
}
|
837
837
|
|
838
838
|
int p_access(const char* path, mode_t mode)
|
@@ -71,99 +71,6 @@ static bool g_limit_reached = false; /* had allocs after we filled row table */
|
|
71
71
|
static unsigned int g_checkpoint_id = 0; /* to better label leak checkpoints */
|
72
72
|
static bool g_transient_leaks_since_mark = false; /* payload for hook */
|
73
73
|
|
74
|
-
static void *crtdbg__malloc(size_t len, const char *file, int line)
|
75
|
-
{
|
76
|
-
void *ptr = _malloc_dbg(len, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
77
|
-
if (!ptr) giterr_set_oom();
|
78
|
-
return ptr;
|
79
|
-
}
|
80
|
-
|
81
|
-
static void *crtdbg__calloc(size_t nelem, size_t elsize, const char *file, int line)
|
82
|
-
{
|
83
|
-
void *ptr = _calloc_dbg(nelem, elsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
84
|
-
if (!ptr) giterr_set_oom();
|
85
|
-
return ptr;
|
86
|
-
}
|
87
|
-
|
88
|
-
static char *crtdbg__strdup(const char *str, const char *file, int line)
|
89
|
-
{
|
90
|
-
char *ptr = _strdup_dbg(str, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
91
|
-
if (!ptr) giterr_set_oom();
|
92
|
-
return ptr;
|
93
|
-
}
|
94
|
-
|
95
|
-
static char *crtdbg__strndup(const char *str, size_t n, const char *file, int line)
|
96
|
-
{
|
97
|
-
size_t length = 0, alloclength;
|
98
|
-
char *ptr;
|
99
|
-
|
100
|
-
length = p_strnlen(str, n);
|
101
|
-
|
102
|
-
if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) ||
|
103
|
-
!(ptr = crtdbg__malloc(alloclength, file, line)))
|
104
|
-
return NULL;
|
105
|
-
|
106
|
-
if (length)
|
107
|
-
memcpy(ptr, str, length);
|
108
|
-
|
109
|
-
ptr[length] = '\0';
|
110
|
-
|
111
|
-
return ptr;
|
112
|
-
}
|
113
|
-
|
114
|
-
static char *crtdbg__substrdup(const char *start, size_t n, const char *file, int line)
|
115
|
-
{
|
116
|
-
char *ptr;
|
117
|
-
size_t alloclen;
|
118
|
-
|
119
|
-
if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) ||
|
120
|
-
!(ptr = crtdbg__malloc(alloclen, file, line)))
|
121
|
-
return NULL;
|
122
|
-
|
123
|
-
memcpy(ptr, start, n);
|
124
|
-
ptr[n] = '\0';
|
125
|
-
return ptr;
|
126
|
-
}
|
127
|
-
|
128
|
-
static void *crtdbg__realloc(void *ptr, size_t size, const char *file, int line)
|
129
|
-
{
|
130
|
-
void *new_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
131
|
-
if (!new_ptr) giterr_set_oom();
|
132
|
-
return new_ptr;
|
133
|
-
}
|
134
|
-
|
135
|
-
static void *crtdbg__reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
|
136
|
-
{
|
137
|
-
size_t newsize;
|
138
|
-
|
139
|
-
return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ?
|
140
|
-
NULL : _realloc_dbg(ptr, newsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
141
|
-
}
|
142
|
-
|
143
|
-
static void *crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, int line)
|
144
|
-
{
|
145
|
-
return crtdbg__reallocarray(NULL, nelem, elsize, file, line);
|
146
|
-
}
|
147
|
-
|
148
|
-
static void crtdbg__free(void *ptr)
|
149
|
-
{
|
150
|
-
free(ptr);
|
151
|
-
}
|
152
|
-
|
153
|
-
int git_win32_crtdbg_init_allocator(git_allocator *allocator)
|
154
|
-
{
|
155
|
-
allocator->gmalloc = crtdbg__malloc;
|
156
|
-
allocator->gcalloc = crtdbg__calloc;
|
157
|
-
allocator->gstrdup = crtdbg__strdup;
|
158
|
-
allocator->gstrndup = crtdbg__strndup;
|
159
|
-
allocator->gsubstrdup = crtdbg__substrdup;
|
160
|
-
allocator->grealloc = crtdbg__realloc;
|
161
|
-
allocator->greallocarray = crtdbg__reallocarray;
|
162
|
-
allocator->gmallocarray = crtdbg__mallocarray;
|
163
|
-
allocator->gfree = crtdbg__free;
|
164
|
-
return 0;
|
165
|
-
}
|
166
|
-
|
167
74
|
/**
|
168
75
|
* Compare function for bsearch on g_cs_index table.
|
169
76
|
*/
|
@@ -434,5 +341,4 @@ const char *git_win32__crtdbg_stacktrace(int skip, const char *file)
|
|
434
341
|
|
435
342
|
return result;
|
436
343
|
}
|
437
|
-
|
438
344
|
#endif
|
@@ -17,34 +17,6 @@
|
|
17
17
|
#include "git2/errors.h"
|
18
18
|
#include "strnlen.h"
|
19
19
|
|
20
|
-
/* MSVC CRTDBG memory leak reporting.
|
21
|
-
*
|
22
|
-
* We DO NOT use the "_CRTDBG_MAP_ALLOC" macro described in the MSVC
|
23
|
-
* documentation because all allocs/frees in libgit2 already go through
|
24
|
-
* the "git__" routines defined in this file. Simply using the normal
|
25
|
-
* reporting mechanism causes all leaks to be attributed to a routine
|
26
|
-
* here in util.h (ie, the actual call to calloc()) rather than the
|
27
|
-
* caller of git__calloc().
|
28
|
-
*
|
29
|
-
* Therefore, we declare a set of "git__crtdbg__" routines to replace
|
30
|
-
* the corresponding "git__" routines and re-define the "git__" symbols
|
31
|
-
* as macros. This allows us to get and report the file:line info of
|
32
|
-
* the real caller.
|
33
|
-
*
|
34
|
-
* We DO NOT replace the "git__free" routine because it needs to remain
|
35
|
-
* a function pointer because it is used as a function argument when
|
36
|
-
* setting up various structure "destructors".
|
37
|
-
*
|
38
|
-
* We also DO NOT use the "_CRTDBG_MAP_ALLOC" macro because it causes
|
39
|
-
* "free" to be remapped to "_free_dbg" and this causes problems for
|
40
|
-
* structures which define a field named "free".
|
41
|
-
*
|
42
|
-
* Finally, CRTDBG must be explicitly enabled and configured at program
|
43
|
-
* startup. See tests/main.c for an example.
|
44
|
-
*/
|
45
|
-
|
46
|
-
int git_win32_crtdbg_init_allocator(git_allocator *allocator);
|
47
|
-
|
48
20
|
/**
|
49
21
|
* Initialize our memory leak tracking and de-dup data structures.
|
50
22
|
* This should ONLY be called by git_libgit2_init().
|
@@ -125,5 +97,80 @@ GIT_EXTERN(int) git_win32__crtdbg_stacktrace__dump(
|
|
125
97
|
*/
|
126
98
|
const char *git_win32__crtdbg_stacktrace(int skip, const char *file);
|
127
99
|
|
100
|
+
GIT_INLINE(void *) git__crtdbg__malloc(size_t len, const char *file, int line)
|
101
|
+
{
|
102
|
+
void *ptr = _malloc_dbg(len, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
103
|
+
if (!ptr) giterr_set_oom();
|
104
|
+
return ptr;
|
105
|
+
}
|
106
|
+
|
107
|
+
GIT_INLINE(void *) git__crtdbg__calloc(size_t nelem, size_t elsize, const char *file, int line)
|
108
|
+
{
|
109
|
+
void *ptr = _calloc_dbg(nelem, elsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
110
|
+
if (!ptr) giterr_set_oom();
|
111
|
+
return ptr;
|
112
|
+
}
|
113
|
+
|
114
|
+
GIT_INLINE(char *) git__crtdbg__strdup(const char *str, const char *file, int line)
|
115
|
+
{
|
116
|
+
char *ptr = _strdup_dbg(str, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
117
|
+
if (!ptr) giterr_set_oom();
|
118
|
+
return ptr;
|
119
|
+
}
|
120
|
+
|
121
|
+
GIT_INLINE(char *) git__crtdbg__strndup(const char *str, size_t n, const char *file, int line)
|
122
|
+
{
|
123
|
+
size_t length = 0, alloclength;
|
124
|
+
char *ptr;
|
125
|
+
|
126
|
+
length = p_strnlen(str, n);
|
127
|
+
|
128
|
+
if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) ||
|
129
|
+
!(ptr = git__crtdbg__malloc(alloclength, file, line)))
|
130
|
+
return NULL;
|
131
|
+
|
132
|
+
if (length)
|
133
|
+
memcpy(ptr, str, length);
|
134
|
+
|
135
|
+
ptr[length] = '\0';
|
136
|
+
|
137
|
+
return ptr;
|
138
|
+
}
|
139
|
+
|
140
|
+
GIT_INLINE(char *) git__crtdbg__substrdup(const char *start, size_t n, const char *file, int line)
|
141
|
+
{
|
142
|
+
char *ptr;
|
143
|
+
size_t alloclen;
|
144
|
+
|
145
|
+
if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) ||
|
146
|
+
!(ptr = git__crtdbg__malloc(alloclen, file, line)))
|
147
|
+
return NULL;
|
148
|
+
|
149
|
+
memcpy(ptr, start, n);
|
150
|
+
ptr[n] = '\0';
|
151
|
+
return ptr;
|
152
|
+
}
|
153
|
+
|
154
|
+
GIT_INLINE(void *) git__crtdbg__realloc(void *ptr, size_t size, const char *file, int line)
|
155
|
+
{
|
156
|
+
void *new_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
157
|
+
if (!new_ptr) giterr_set_oom();
|
158
|
+
return new_ptr;
|
159
|
+
}
|
160
|
+
|
161
|
+
GIT_INLINE(void *) git__crtdbg__reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
|
162
|
+
{
|
163
|
+
size_t newsize;
|
164
|
+
|
165
|
+
return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ?
|
166
|
+
NULL : _realloc_dbg(ptr, newsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
167
|
+
}
|
168
|
+
|
169
|
+
GIT_INLINE(void *) git__crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, int line)
|
170
|
+
{
|
171
|
+
return git__crtdbg__reallocarray(NULL, nelem, elsize, file, line);
|
172
|
+
}
|
173
|
+
|
174
|
+
|
128
175
|
#endif
|
129
176
|
#endif
|
@@ -25,7 +25,7 @@ static bool is_worktree_dir(const char *dir)
|
|
25
25
|
&& git_path_contains_file(&buf, "gitdir")
|
26
26
|
&& git_path_contains_file(&buf, "HEAD");
|
27
27
|
|
28
|
-
|
28
|
+
git_buf_free(&buf);
|
29
29
|
return error;
|
30
30
|
}
|
31
31
|
|
@@ -64,7 +64,7 @@ int git_worktree_list(git_strarray *wts, git_repository *repo)
|
|
64
64
|
wts->strings = (char **)git_vector_detach(&wts->count, NULL, &worktrees);
|
65
65
|
|
66
66
|
exit:
|
67
|
-
|
67
|
+
git_buf_free(&path);
|
68
68
|
|
69
69
|
return error;
|
70
70
|
}
|
@@ -79,7 +79,7 @@ char *git_worktree__read_link(const char *base, const char *file)
|
|
79
79
|
goto err;
|
80
80
|
if (git_futils_readbuffer(&buf, path.ptr) < 0)
|
81
81
|
goto err;
|
82
|
-
|
82
|
+
git_buf_free(&path);
|
83
83
|
|
84
84
|
git_buf_rtrim(&buf);
|
85
85
|
|
@@ -90,13 +90,13 @@ char *git_worktree__read_link(const char *base, const char *file)
|
|
90
90
|
goto err;
|
91
91
|
if (git_path_apply_relative(&path, buf.ptr) < 0)
|
92
92
|
goto err;
|
93
|
-
|
93
|
+
git_buf_free(&buf);
|
94
94
|
|
95
95
|
return git_buf_detach(&path);
|
96
96
|
|
97
97
|
err:
|
98
|
-
|
99
|
-
|
98
|
+
git_buf_free(&buf);
|
99
|
+
git_buf_free(&path);
|
100
100
|
|
101
101
|
return NULL;
|
102
102
|
}
|
@@ -115,7 +115,7 @@ static int write_wtfile(const char *base, const char *file, const git_buf *buf)
|
|
115
115
|
goto out;
|
116
116
|
|
117
117
|
out:
|
118
|
-
|
118
|
+
git_buf_free(&path);
|
119
119
|
|
120
120
|
return err;
|
121
121
|
}
|
@@ -139,8 +139,7 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
|
|
139
139
|
if ((wt->name = git__strdup(name)) == NULL
|
140
140
|
|| (wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL
|
141
141
|
|| (wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL
|
142
|
-
|| (parent && (wt->parent_path = git__strdup(parent)) == NULL)
|
143
|
-
|| (wt->worktree_path = git_path_dirname(wt->gitlink_path)) == NULL) {
|
142
|
+
|| (parent && (wt->parent_path = git__strdup(parent)) == NULL)) {
|
144
143
|
error = -1;
|
145
144
|
goto out;
|
146
145
|
}
|
@@ -156,7 +155,7 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
|
|
156
155
|
out:
|
157
156
|
if (error)
|
158
157
|
git_worktree_free(wt);
|
159
|
-
|
158
|
+
git_buf_free(&gitdir);
|
160
159
|
|
161
160
|
return error;
|
162
161
|
}
|
@@ -178,7 +177,7 @@ int git_worktree_lookup(git_worktree **out, git_repository *repo, const char *na
|
|
178
177
|
goto out;
|
179
178
|
|
180
179
|
out:
|
181
|
-
|
180
|
+
git_buf_free(&path);
|
182
181
|
|
183
182
|
if (error)
|
184
183
|
git_worktree_free(wt);
|
@@ -213,7 +212,7 @@ int git_worktree_open_from_repository(git_worktree **out, git_repository *repo)
|
|
213
212
|
|
214
213
|
out:
|
215
214
|
git__free(name);
|
216
|
-
|
215
|
+
git_buf_free(&parent);
|
217
216
|
|
218
217
|
return error;
|
219
218
|
}
|
@@ -224,7 +223,6 @@ void git_worktree_free(git_worktree *wt)
|
|
224
223
|
return;
|
225
224
|
|
226
225
|
git__free(wt->commondir_path);
|
227
|
-
git__free(wt->worktree_path);
|
228
226
|
git__free(wt->gitlink_path);
|
229
227
|
git__free(wt->gitdir_path);
|
230
228
|
git__free(wt->parent_path);
|
@@ -234,30 +232,40 @@ void git_worktree_free(git_worktree *wt)
|
|
234
232
|
|
235
233
|
int git_worktree_validate(const git_worktree *wt)
|
236
234
|
{
|
235
|
+
git_buf buf = GIT_BUF_INIT;
|
236
|
+
int err = 0;
|
237
|
+
|
237
238
|
assert(wt);
|
238
239
|
|
239
|
-
|
240
|
+
git_buf_puts(&buf, wt->gitdir_path);
|
241
|
+
if (!is_worktree_dir(buf.ptr)) {
|
240
242
|
giterr_set(GITERR_WORKTREE,
|
241
243
|
"Worktree gitdir ('%s') is not valid",
|
242
244
|
wt->gitlink_path);
|
243
|
-
|
245
|
+
err = -1;
|
246
|
+
goto out;
|
244
247
|
}
|
245
248
|
|
246
|
-
if (
|
249
|
+
if (!git_path_exists(wt->parent_path)) {
|
247
250
|
giterr_set(GITERR_WORKTREE,
|
248
251
|
"Worktree parent directory ('%s') does not exist ",
|
249
252
|
wt->parent_path);
|
250
|
-
|
253
|
+
err = -2;
|
254
|
+
goto out;
|
251
255
|
}
|
252
256
|
|
253
257
|
if (!git_path_exists(wt->commondir_path)) {
|
254
258
|
giterr_set(GITERR_WORKTREE,
|
255
259
|
"Worktree common directory ('%s') does not exist ",
|
256
260
|
wt->commondir_path);
|
257
|
-
|
261
|
+
err = -3;
|
262
|
+
goto out;
|
258
263
|
}
|
259
264
|
|
260
|
-
|
265
|
+
out:
|
266
|
+
git_buf_free(&buf);
|
267
|
+
|
268
|
+
return err;
|
261
269
|
}
|
262
270
|
|
263
271
|
int git_worktree_add_init_options(git_worktree_add_options *opts,
|
@@ -340,30 +348,13 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
340
348
|
|| (err = write_wtfile(gitdir.ptr, "gitdir", &buf)) < 0)
|
341
349
|
goto out;
|
342
350
|
|
343
|
-
/*
|
344
|
-
if (
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
if (git_branch_is_checked_out(wtopts.ref)) {
|
352
|
-
giterr_set(GITERR_WORKTREE, "reference is already checked out");
|
353
|
-
err = -1;
|
354
|
-
goto out;
|
355
|
-
}
|
356
|
-
|
357
|
-
if ((err = git_reference_dup(&ref, wtopts.ref)) < 0)
|
358
|
-
goto out;
|
359
|
-
} else {
|
360
|
-
if ((err = git_repository_head(&head, repo)) < 0)
|
361
|
-
goto out;
|
362
|
-
if ((err = git_commit_lookup(&commit, repo, &head->target.oid)) < 0)
|
363
|
-
goto out;
|
364
|
-
if ((err = git_branch_create(&ref, repo, name, commit, false)) < 0)
|
365
|
-
goto out;
|
366
|
-
}
|
351
|
+
/* Create new branch */
|
352
|
+
if ((err = git_repository_head(&head, repo)) < 0)
|
353
|
+
goto out;
|
354
|
+
if ((err = git_commit_lookup(&commit, repo, &head->target.oid)) < 0)
|
355
|
+
goto out;
|
356
|
+
if ((err = git_branch_create(&ref, repo, name, commit, false)) < 0)
|
357
|
+
goto out;
|
367
358
|
|
368
359
|
/* Set worktree's HEAD */
|
369
360
|
if ((err = git_repository_create_head(gitdir.ptr, git_reference_name(ref))) < 0)
|
@@ -381,9 +372,9 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
381
372
|
goto out;
|
382
373
|
|
383
374
|
out:
|
384
|
-
|
385
|
-
|
386
|
-
|
375
|
+
git_buf_free(&gitdir);
|
376
|
+
git_buf_free(&wddir);
|
377
|
+
git_buf_free(&buf);
|
387
378
|
git_reference_free(ref);
|
388
379
|
git_reference_free(head);
|
389
380
|
git_commit_free(commit);
|
@@ -414,7 +405,7 @@ int git_worktree_lock(git_worktree *wt, const char *reason)
|
|
414
405
|
wt->locked = 1;
|
415
406
|
|
416
407
|
out:
|
417
|
-
|
408
|
+
git_buf_free(&path);
|
418
409
|
|
419
410
|
return err;
|
420
411
|
}
|
@@ -426,19 +417,19 @@ int git_worktree_unlock(git_worktree *wt)
|
|
426
417
|
assert(wt);
|
427
418
|
|
428
419
|
if (!git_worktree_is_locked(NULL, wt))
|
429
|
-
return
|
420
|
+
return 1;
|
430
421
|
|
431
422
|
if (git_buf_joinpath(&path, wt->gitdir_path, "locked") < 0)
|
432
423
|
return -1;
|
433
424
|
|
434
425
|
if (p_unlink(path.ptr) != 0) {
|
435
|
-
|
426
|
+
git_buf_free(&path);
|
436
427
|
return -1;
|
437
428
|
}
|
438
429
|
|
439
430
|
wt->locked = 0;
|
440
431
|
|
441
|
-
|
432
|
+
git_buf_free(&path);
|
442
433
|
|
443
434
|
return 0;
|
444
435
|
}
|
@@ -459,23 +450,11 @@ int git_worktree_is_locked(git_buf *reason, const git_worktree *wt)
|
|
459
450
|
git_futils_readbuffer(reason, path.ptr);
|
460
451
|
|
461
452
|
out:
|
462
|
-
|
453
|
+
git_buf_free(&path);
|
463
454
|
|
464
455
|
return ret;
|
465
456
|
}
|
466
457
|
|
467
|
-
const char *git_worktree_name(const git_worktree *wt)
|
468
|
-
{
|
469
|
-
assert(wt);
|
470
|
-
return wt->name;
|
471
|
-
}
|
472
|
-
|
473
|
-
const char *git_worktree_path(const git_worktree *wt)
|
474
|
-
{
|
475
|
-
assert(wt);
|
476
|
-
return wt->worktree_path;
|
477
|
-
}
|
478
|
-
|
479
458
|
int git_worktree_prune_init_options(
|
480
459
|
git_worktree_prune_options *opts,
|
481
460
|
unsigned int version)
|
@@ -504,7 +483,7 @@ int git_worktree_is_prunable(git_worktree *wt,
|
|
504
483
|
if (!reason.size)
|
505
484
|
git_buf_attach_notowned(&reason, "no reason given", 15);
|
506
485
|
giterr_set(GITERR_WORKTREE, "Not pruning locked working tree: '%s'", reason.ptr);
|
507
|
-
|
486
|
+
git_buf_free(&reason);
|
508
487
|
|
509
488
|
return 0;
|
510
489
|
}
|
@@ -572,7 +551,7 @@ int git_worktree_prune(git_worktree *wt,
|
|
572
551
|
goto out;
|
573
552
|
|
574
553
|
out:
|
575
|
-
|
554
|
+
git_buf_free(&path);
|
576
555
|
|
577
556
|
return err;
|
578
557
|
}
|