rugged 0.21.1b2 → 0.21.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -12
- data/ext/rugged/extconf.rb +8 -8
- data/ext/rugged/rugged.h +1 -1
- data/ext/rugged/rugged_blob.c +0 -57
- data/ext/rugged/rugged_cred.c +0 -23
- data/ext/rugged/rugged_index.c +2 -6
- data/ext/rugged/rugged_remote.c +1 -69
- data/ext/rugged/rugged_repo.c +5 -287
- data/ext/rugged/rugged_tag_collection.c +2 -70
- data/ext/rugged/rugged_tree.c +10 -29
- data/lib/rugged.rb +0 -2
- data/lib/rugged/diff.rb +1 -0
- data/lib/rugged/diff/line.rb +3 -1
- data/lib/rugged/patch.rb +2 -12
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +0 -11
- data/vendor/libgit2/deps/http-parser/http_parser.h +0 -2
- data/vendor/libgit2/deps/zlib/adler32.c +29 -39
- data/vendor/libgit2/deps/zlib/crc32.c +50 -33
- data/vendor/libgit2/deps/zlib/crc32.h +1 -1
- data/vendor/libgit2/deps/zlib/deflate.c +65 -198
- data/vendor/libgit2/deps/zlib/deflate.h +4 -8
- 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 +52 -84
- data/vendor/libgit2/deps/zlib/inftrees.c +39 -15
- data/vendor/libgit2/deps/zlib/trees.c +36 -18
- data/vendor/libgit2/deps/zlib/zconf.h +0 -4
- data/vendor/libgit2/deps/zlib/zlib.h +95 -250
- data/vendor/libgit2/deps/zlib/zutil.c +10 -13
- data/vendor/libgit2/deps/zlib/zutil.h +62 -41
- data/vendor/libgit2/include/git2/attr.h +13 -16
- data/vendor/libgit2/include/git2/buffer.h +0 -16
- 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 +69 -77
- data/vendor/libgit2/include/git2/diff.h +0 -7
- data/vendor/libgit2/include/git2/errors.h +0 -2
- data/vendor/libgit2/include/git2/merge.h +0 -16
- data/vendor/libgit2/include/git2/oid.h +4 -8
- data/vendor/libgit2/include/git2/remote.h +32 -13
- data/vendor/libgit2/include/git2/repository.h +1 -4
- data/vendor/libgit2/include/git2/reset.h +0 -4
- data/vendor/libgit2/include/git2/revert.h +1 -1
- data/vendor/libgit2/include/git2/status.h +14 -17
- data/vendor/libgit2/include/git2/submodule.h +0 -18
- data/vendor/libgit2/include/git2/sys/repository.h +0 -13
- data/vendor/libgit2/include/git2/transport.h +313 -79
- data/vendor/libgit2/include/git2/tree.h +2 -4
- data/vendor/libgit2/include/git2/types.h +6 -54
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/attr.c +4 -8
- data/vendor/libgit2/src/attr_file.c +1 -14
- data/vendor/libgit2/src/blame.c +1 -0
- data/vendor/libgit2/src/buf_text.c +5 -9
- data/vendor/libgit2/src/buf_text.h +2 -3
- data/vendor/libgit2/src/buffer.c +10 -67
- data/vendor/libgit2/src/buffer.h +2 -4
- data/vendor/libgit2/src/cache.c +9 -9
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/checkout.c +44 -121
- data/vendor/libgit2/src/cherrypick.c +44 -41
- data/vendor/libgit2/src/clone.c +56 -94
- data/vendor/libgit2/src/config_file.c +7 -2
- data/vendor/libgit2/src/crlf.c +1 -2
- data/vendor/libgit2/src/diff.c +0 -21
- data/vendor/libgit2/src/diff_file.c +0 -1
- data/vendor/libgit2/src/diff_print.c +9 -11
- data/vendor/libgit2/src/diff_tform.c +2 -4
- data/vendor/libgit2/src/errors.c +7 -9
- data/vendor/libgit2/src/filebuf.c +2 -0
- data/vendor/libgit2/src/fileops.c +7 -9
- data/vendor/libgit2/src/filter.c +11 -2
- data/vendor/libgit2/src/global.c +20 -3
- data/vendor/libgit2/src/global.h +0 -2
- data/vendor/libgit2/src/graph.c +2 -2
- data/vendor/libgit2/src/hashsig.c +1 -1
- data/vendor/libgit2/{include/git2/sys → src}/hashsig.h +7 -11
- data/vendor/libgit2/src/ignore.c +2 -2
- data/vendor/libgit2/src/indexer.c +1 -13
- data/vendor/libgit2/src/merge.c +145 -99
- data/vendor/libgit2/src/merge.h +1 -1
- data/vendor/libgit2/src/mwindow.c +8 -117
- data/vendor/libgit2/src/mwindow.h +1 -9
- data/vendor/libgit2/src/netops.c +7 -6
- data/vendor/libgit2/src/netops.h +4 -0
- data/vendor/libgit2/src/odb_loose.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +3 -6
- data/vendor/libgit2/src/oid.c +0 -8
- data/vendor/libgit2/src/oid.h +0 -11
- data/vendor/libgit2/src/pack.c +6 -20
- data/vendor/libgit2/src/pack.h +0 -3
- data/vendor/libgit2/src/path.c +64 -134
- data/vendor/libgit2/src/path.h +1 -22
- data/vendor/libgit2/src/posix.h +28 -46
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +2 -14
- data/vendor/libgit2/src/remote.c +26 -29
- data/vendor/libgit2/src/remote.h +1 -3
- data/vendor/libgit2/src/repository.c +14 -54
- data/vendor/libgit2/src/revert.c +6 -4
- data/vendor/libgit2/src/revparse.c +18 -15
- data/vendor/libgit2/src/signature.c +2 -2
- data/vendor/libgit2/src/stash.c +1 -2
- data/vendor/libgit2/src/status.c +2 -11
- data/vendor/libgit2/src/strnlen.h +1 -2
- data/vendor/libgit2/src/submodule.c +33 -73
- data/vendor/libgit2/src/tag.c +3 -2
- data/vendor/libgit2/src/thread-utils.h +7 -0
- data/vendor/libgit2/src/trace.h +1 -9
- data/vendor/libgit2/src/transport.c +90 -93
- data/vendor/libgit2/src/transports/cred.c +0 -58
- data/vendor/libgit2/src/transports/cred_helpers.c +0 -3
- data/vendor/libgit2/src/transports/git.c +0 -1
- data/vendor/libgit2/src/transports/http.c +82 -205
- data/vendor/libgit2/src/transports/smart.c +0 -2
- data/vendor/libgit2/src/transports/smart.h +0 -2
- data/vendor/libgit2/src/transports/smart_protocol.c +5 -7
- data/vendor/libgit2/src/transports/ssh.c +35 -224
- data/vendor/libgit2/src/transports/winhttp.c +34 -140
- data/vendor/libgit2/src/tree.c +60 -64
- data/vendor/libgit2/src/tree.h +3 -2
- data/vendor/libgit2/src/unix/posix.h +9 -23
- data/vendor/libgit2/src/unix/realpath.c +7 -8
- data/vendor/libgit2/src/util.c +1 -2
- data/vendor/libgit2/src/util.h +3 -3
- data/vendor/libgit2/src/win32/mingw-compat.h +12 -5
- data/vendor/libgit2/src/win32/msvc-compat.h +32 -3
- data/vendor/libgit2/src/win32/posix.h +31 -20
- data/vendor/libgit2/src/win32/posix_w32.c +18 -62
- metadata +5 -18
- data/lib/rugged/attributes.rb +0 -41
- data/lib/rugged/blob.rb +0 -28
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +0 -324
- data/vendor/libgit2/deps/zlib/infback.c +0 -640
- data/vendor/libgit2/include/git2/oidarray.h +0 -40
- data/vendor/libgit2/include/git2/sys/transport.h +0 -352
- data/vendor/libgit2/src/oidarray.c +0 -21
- data/vendor/libgit2/src/oidarray.h +0 -18
- data/vendor/libgit2/src/transports/auth.c +0 -71
- data/vendor/libgit2/src/transports/auth.h +0 -63
- data/vendor/libgit2/src/transports/auth_negotiate.c +0 -275
- data/vendor/libgit2/src/transports/auth_negotiate.h +0 -27
- data/vendor/libgit2/src/transports/cred.h +0 -14
@@ -36,18 +36,10 @@ typedef struct git_mwindow_ctl {
|
|
36
36
|
} git_mwindow_ctl;
|
37
37
|
|
38
38
|
int git_mwindow_contains(git_mwindow *win, git_off_t offset);
|
39
|
-
void git_mwindow_free_all(git_mwindow_file *mwf);
|
40
|
-
void git_mwindow_free_all_locked(git_mwindow_file *mwf); /* run under lock */
|
39
|
+
void git_mwindow_free_all(git_mwindow_file *mwf);
|
41
40
|
unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, git_off_t offset, size_t extra, unsigned int *left);
|
42
41
|
int git_mwindow_file_register(git_mwindow_file *mwf);
|
43
42
|
void git_mwindow_file_deregister(git_mwindow_file *mwf);
|
44
43
|
void git_mwindow_close(git_mwindow **w_cursor);
|
45
44
|
|
46
|
-
int git_mwindow_files_init(void);
|
47
|
-
void git_mwindow_files_free(void);
|
48
|
-
|
49
|
-
struct git_pack_file; /* just declaration to avoid cyclical includes */
|
50
|
-
int git_mwindow_get_pack(struct git_pack_file **out, const char *path);
|
51
|
-
void git_mwindow_put_pack(struct git_pack_file *pack);
|
52
|
-
|
53
45
|
#endif
|
data/vendor/libgit2/src/netops.c
CHANGED
@@ -13,7 +13,6 @@
|
|
13
13
|
# include <netinet/in.h>
|
14
14
|
# include <arpa/inet.h>
|
15
15
|
#else
|
16
|
-
# include <winsock2.h>
|
17
16
|
# include <ws2tcpip.h>
|
18
17
|
# ifdef _MSC_VER
|
19
18
|
# pragma comment(lib, "ws2_32")
|
@@ -384,10 +383,10 @@ on_error:
|
|
384
383
|
cert_fail_name:
|
385
384
|
OPENSSL_free(peer_cn);
|
386
385
|
giterr_set(GITERR_SSL, "hostname does not match certificate");
|
387
|
-
return
|
386
|
+
return -1;
|
388
387
|
}
|
389
388
|
|
390
|
-
static int ssl_setup(gitno_socket *socket, const char *host)
|
389
|
+
static int ssl_setup(gitno_socket *socket, const char *host, int flags)
|
391
390
|
{
|
392
391
|
int ret;
|
393
392
|
|
@@ -406,6 +405,9 @@ static int ssl_setup(gitno_socket *socket, const char *host)
|
|
406
405
|
if ((ret = SSL_connect(socket->ssl.ssl)) <= 0)
|
407
406
|
return ssl_set_error(&socket->ssl, ret);
|
408
407
|
|
408
|
+
if (GITNO_CONNECT_SSL_NO_CHECK_CERT & flags)
|
409
|
+
return 0;
|
410
|
+
|
409
411
|
return verify_server_cert(&socket->ssl, host);
|
410
412
|
}
|
411
413
|
#endif
|
@@ -491,9 +493,8 @@ int gitno_connect(gitno_socket *s_out, const char *host, const char *port, int f
|
|
491
493
|
p_freeaddrinfo(info);
|
492
494
|
|
493
495
|
#ifdef GIT_SSL
|
494
|
-
if ((flags & GITNO_CONNECT_SSL) &&
|
495
|
-
|
496
|
-
return ret;
|
496
|
+
if ((flags & GITNO_CONNECT_SSL) && ssl_setup(s_out, host, flags) < 0)
|
497
|
+
return -1;
|
497
498
|
#else
|
498
499
|
/* SSL is not supported */
|
499
500
|
if (flags & GITNO_CONNECT_SSL) {
|
data/vendor/libgit2/src/netops.h
CHANGED
@@ -47,6 +47,10 @@ typedef struct gitno_buffer gitno_buffer;
|
|
47
47
|
enum {
|
48
48
|
/* Attempt to create an SSL connection. */
|
49
49
|
GITNO_CONNECT_SSL = 1,
|
50
|
+
|
51
|
+
/* Valid only when GITNO_CONNECT_SSL is also specified.
|
52
|
+
* Indicates that the server certificate should not be validated. */
|
53
|
+
GITNO_CONNECT_SSL_NO_CHECK_CERT = 2,
|
50
54
|
};
|
51
55
|
|
52
56
|
/**
|
@@ -210,7 +210,7 @@ static int packfile_load__cb(void *data, git_buf *path)
|
|
210
210
|
return 0;
|
211
211
|
}
|
212
212
|
|
213
|
-
error =
|
213
|
+
error = git_packfile_alloc(&pack, path->ptr);
|
214
214
|
|
215
215
|
/* ignore missing .pack file as git does */
|
216
216
|
if (error == GIT_ENOTFOUND) {
|
@@ -605,7 +605,7 @@ static void pack_backend__free(git_odb_backend *_backend)
|
|
605
605
|
|
606
606
|
for (i = 0; i < backend->packs.length; ++i) {
|
607
607
|
struct git_pack_file *p = git_vector_get(&backend->packs, i);
|
608
|
-
|
608
|
+
git_packfile_free(p);
|
609
609
|
}
|
610
610
|
|
611
611
|
git_vector_free(&backend->packs);
|
@@ -647,7 +647,7 @@ int git_odb_backend_one_pack(git_odb_backend **backend_out, const char *idx)
|
|
647
647
|
if (pack_backend__alloc(&backend, 1) < 0)
|
648
648
|
return -1;
|
649
649
|
|
650
|
-
if (
|
650
|
+
if (git_packfile_alloc(&packfile, idx) < 0 ||
|
651
651
|
git_vector_insert(&backend->packs, packfile) < 0)
|
652
652
|
{
|
653
653
|
pack_backend__free((git_odb_backend *)backend);
|
@@ -664,9 +664,6 @@ int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
|
|
664
664
|
struct pack_backend *backend = NULL;
|
665
665
|
git_buf path = GIT_BUF_INIT;
|
666
666
|
|
667
|
-
if (git_mwindow_files_init() < 0)
|
668
|
-
return -1;
|
669
|
-
|
670
667
|
if (pack_backend__alloc(&backend, 8) < 0)
|
671
668
|
return -1;
|
672
669
|
|
data/vendor/libgit2/src/oid.c
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
#include "common.h"
|
9
9
|
#include "git2/oid.h"
|
10
10
|
#include "repository.h"
|
11
|
-
#include "global.h"
|
12
11
|
#include <string.h>
|
13
12
|
#include <limits.h>
|
14
13
|
|
@@ -100,13 +99,6 @@ void git_oid_pathfmt(char *str, const git_oid *oid)
|
|
100
99
|
str = fmt_one(str, oid->id[i]);
|
101
100
|
}
|
102
101
|
|
103
|
-
char *git_oid_tostr_s(const git_oid *oid)
|
104
|
-
{
|
105
|
-
char *str = GIT_GLOBAL->oid_fmt;
|
106
|
-
git_oid_nfmt(str, GIT_OID_HEXSZ + 1, oid);
|
107
|
-
return str;
|
108
|
-
}
|
109
|
-
|
110
102
|
char *git_oid_allocfmt(const git_oid *oid)
|
111
103
|
{
|
112
104
|
char *str = git__malloc(GIT_OID_HEXSZ + 1);
|
data/vendor/libgit2/src/oid.h
CHANGED
@@ -9,17 +9,6 @@
|
|
9
9
|
|
10
10
|
#include "git2/oid.h"
|
11
11
|
|
12
|
-
/**
|
13
|
-
* Format a git_oid into a newly allocated c-string.
|
14
|
-
*
|
15
|
-
* The c-string is owned by the caller and needs to be manually freed.
|
16
|
-
*
|
17
|
-
* @param id the oid structure to format
|
18
|
-
* @return the c-string; NULL if memory is exhausted. Caller must
|
19
|
-
* deallocate the string with git__free().
|
20
|
-
*/
|
21
|
-
char *git_oid_allocfmt(const git_oid *id);
|
22
|
-
|
23
12
|
GIT_INLINE(int) git_oid__hashcmp(const unsigned char *sha1, const unsigned char *sha2)
|
24
13
|
{
|
25
14
|
int i;
|
data/vendor/libgit2/src/pack.c
CHANGED
@@ -648,6 +648,9 @@ int git_packfile_unpack(
|
|
648
648
|
base_type = elem->type;
|
649
649
|
}
|
650
650
|
|
651
|
+
if (error < 0)
|
652
|
+
goto cleanup;
|
653
|
+
|
651
654
|
switch (base_type) {
|
652
655
|
case GIT_OBJ_COMMIT:
|
653
656
|
case GIT_OBJ_TREE:
|
@@ -965,10 +968,10 @@ void git_packfile_free(struct git_pack_file *p)
|
|
965
968
|
|
966
969
|
cache_free(&p->bases);
|
967
970
|
|
968
|
-
|
969
|
-
|
971
|
+
git_mwindow_free_all(&p->mwf);
|
972
|
+
|
973
|
+
if (p->mwf.fd >= 0)
|
970
974
|
p_close(p->mwf.fd);
|
971
|
-
}
|
972
975
|
|
973
976
|
pack_index_free(p);
|
974
977
|
|
@@ -1060,23 +1063,6 @@ cleanup:
|
|
1060
1063
|
return -1;
|
1061
1064
|
}
|
1062
1065
|
|
1063
|
-
int git_packfile__name(char **out, const char *path)
|
1064
|
-
{
|
1065
|
-
size_t path_len;
|
1066
|
-
git_buf buf = GIT_BUF_INIT;
|
1067
|
-
|
1068
|
-
path_len = strlen(path);
|
1069
|
-
|
1070
|
-
if (path_len < strlen(".idx"))
|
1071
|
-
return git_odb__error_notfound("invalid packfile path", NULL);
|
1072
|
-
|
1073
|
-
if (git_buf_printf(&buf, "%.*s.pack", (int)(path_len - strlen(".idx")), path) < 0)
|
1074
|
-
return -1;
|
1075
|
-
|
1076
|
-
*out = git_buf_detach(&buf);
|
1077
|
-
return 0;
|
1078
|
-
}
|
1079
|
-
|
1080
1066
|
int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
|
1081
1067
|
{
|
1082
1068
|
struct stat st;
|
data/vendor/libgit2/src/pack.h
CHANGED
@@ -90,7 +90,6 @@ struct git_pack_file {
|
|
90
90
|
git_mwindow_file mwf;
|
91
91
|
git_map index_map;
|
92
92
|
git_mutex lock; /* protect updates to mwf and index_map */
|
93
|
-
git_atomic refcount;
|
94
93
|
|
95
94
|
uint32_t num_objects;
|
96
95
|
uint32_t num_bad_objects;
|
@@ -124,8 +123,6 @@ typedef struct git_packfile_stream {
|
|
124
123
|
|
125
124
|
size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype type);
|
126
125
|
|
127
|
-
int git_packfile__name(char **out, const char *path);
|
128
|
-
|
129
126
|
int git_packfile_unpack_header(
|
130
127
|
size_t *size_p,
|
131
128
|
git_otype *type_p,
|
data/vendor/libgit2/src/path.c
CHANGED
@@ -377,33 +377,26 @@ static int error_invalid_local_file_uri(const char *uri)
|
|
377
377
|
return -1;
|
378
378
|
}
|
379
379
|
|
380
|
-
|
380
|
+
int git_path_fromurl(git_buf *local_path_out, const char *file_url)
|
381
381
|
{
|
382
|
-
int
|
383
|
-
|
384
|
-
if (git__prefixcmp(file_url, "file://") == 0) {
|
385
|
-
if (file_url[7] == '/')
|
386
|
-
len = 8;
|
387
|
-
else if (git__prefixcmp(file_url + 7, "localhost/") == 0)
|
388
|
-
len = 17;
|
389
|
-
}
|
382
|
+
int offset = 0, len;
|
390
383
|
|
391
|
-
|
392
|
-
}
|
384
|
+
assert(local_path_out && file_url);
|
393
385
|
|
394
|
-
|
395
|
-
|
396
|
-
return (local_file_url_prefixlen(file_url) > 0);
|
397
|
-
}
|
386
|
+
if (git__prefixcmp(file_url, "file://") != 0)
|
387
|
+
return error_invalid_local_file_uri(file_url);
|
398
388
|
|
399
|
-
|
400
|
-
|
401
|
-
int offset;
|
389
|
+
offset += 7;
|
390
|
+
len = (int)strlen(file_url);
|
402
391
|
|
403
|
-
|
392
|
+
if (offset < len && file_url[offset] == '/')
|
393
|
+
offset++;
|
394
|
+
else if (offset < len && git__prefixcmp(file_url + offset, "localhost/") == 0)
|
395
|
+
offset += 10;
|
396
|
+
else
|
397
|
+
return error_invalid_local_file_uri(file_url);
|
404
398
|
|
405
|
-
if (
|
406
|
-
file_url[offset] == '\0' || file_url[offset] == '/')
|
399
|
+
if (offset >= len || file_url[offset] == '/')
|
407
400
|
return error_invalid_local_file_uri(file_url);
|
408
401
|
|
409
402
|
#ifndef GIT_WIN32
|
@@ -411,13 +404,14 @@ int git_path_fromurl(git_buf *local_path_out, const char *file_url)
|
|
411
404
|
#endif
|
412
405
|
|
413
406
|
git_buf_clear(local_path_out);
|
407
|
+
|
414
408
|
return git__percent_decode(local_path_out, file_url + offset);
|
415
409
|
}
|
416
410
|
|
417
411
|
int git_path_walk_up(
|
418
412
|
git_buf *path,
|
419
413
|
const char *ceiling,
|
420
|
-
int (*cb)(void *data,
|
414
|
+
int (*cb)(void *data, git_buf *),
|
421
415
|
void *data)
|
422
416
|
{
|
423
417
|
int error = 0;
|
@@ -435,20 +429,12 @@ int git_path_walk_up(
|
|
435
429
|
}
|
436
430
|
scan = git_buf_len(path);
|
437
431
|
|
438
|
-
/* empty path: yield only once */
|
439
|
-
if (!scan) {
|
440
|
-
error = cb(data, "");
|
441
|
-
if (error)
|
442
|
-
giterr_set_after_callback(error);
|
443
|
-
return error;
|
444
|
-
}
|
445
|
-
|
446
432
|
iter.ptr = path->ptr;
|
447
433
|
iter.size = git_buf_len(path);
|
448
434
|
iter.asize = path->asize;
|
449
435
|
|
450
436
|
while (scan >= stop) {
|
451
|
-
error = cb(data, iter
|
437
|
+
error = cb(data, &iter);
|
452
438
|
iter.ptr[scan] = oldc;
|
453
439
|
|
454
440
|
if (error) {
|
@@ -468,13 +454,6 @@ int git_path_walk_up(
|
|
468
454
|
if (scan >= 0)
|
469
455
|
iter.ptr[scan] = oldc;
|
470
456
|
|
471
|
-
/* relative path: yield for the last component */
|
472
|
-
if (!error && stop == 0 && iter.ptr[0] != '/') {
|
473
|
-
error = cb(data, "");
|
474
|
-
if (error)
|
475
|
-
giterr_set_after_callback(error);
|
476
|
-
}
|
477
|
-
|
478
457
|
return error;
|
479
458
|
}
|
480
459
|
|
@@ -515,23 +494,33 @@ bool git_path_is_empty_dir(const char *path)
|
|
515
494
|
WIN32_FIND_DATAW findData;
|
516
495
|
HANDLE hFind = FindFirstFileW(filter_w, &findData);
|
517
496
|
|
497
|
+
/* FindFirstFile will fail if there are no children to the given
|
498
|
+
* path, which can happen if the given path is a file (and obviously
|
499
|
+
* has no children) or if the given path is an empty mount point.
|
500
|
+
* (Most directories have at least directory entries '.' and '..',
|
501
|
+
* but ridiculously another volume mounted in another drive letter's
|
502
|
+
* path space do not, and thus have nothing to enumerate.) If
|
503
|
+
* FindFirstFile fails, check if this is a directory-like thing
|
504
|
+
* (a mount point).
|
505
|
+
*/
|
506
|
+
if (hFind == INVALID_HANDLE_VALUE)
|
507
|
+
return git_path_isdir(path);
|
508
|
+
|
518
509
|
/* If the find handle was created successfully, then it's a directory */
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
FindClose(hFind);
|
534
|
-
}
|
510
|
+
empty = true;
|
511
|
+
|
512
|
+
do {
|
513
|
+
/* Allow the enumeration to return . and .. and still be considered
|
514
|
+
* empty. In the special case of drive roots (i.e. C:\) where . and
|
515
|
+
* .. do not occur, we can still consider the path to be an empty
|
516
|
+
* directory if there's nothing there. */
|
517
|
+
if (!git_path_is_dot_or_dotdotW(findData.cFileName)) {
|
518
|
+
empty = false;
|
519
|
+
break;
|
520
|
+
}
|
521
|
+
} while (FindNextFileW(hFind, &findData));
|
522
|
+
|
523
|
+
FindClose(hFind);
|
535
524
|
}
|
536
525
|
|
537
526
|
return empty;
|
@@ -765,64 +754,6 @@ int git_path_cmp(
|
|
765
754
|
return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
|
766
755
|
}
|
767
756
|
|
768
|
-
int git_path_make_relative(git_buf *path, const char *parent)
|
769
|
-
{
|
770
|
-
const char *p, *q, *p_dirsep, *q_dirsep;
|
771
|
-
size_t plen = path->size, newlen, depth = 1, i, offset;
|
772
|
-
|
773
|
-
for (p_dirsep = p = path->ptr, q_dirsep = q = parent; *p && *q; p++, q++) {
|
774
|
-
if (*p == '/' && *q == '/') {
|
775
|
-
p_dirsep = p;
|
776
|
-
q_dirsep = q;
|
777
|
-
}
|
778
|
-
else if (*p != *q)
|
779
|
-
break;
|
780
|
-
}
|
781
|
-
|
782
|
-
/* need at least 1 common path segment */
|
783
|
-
if ((p_dirsep == path->ptr || q_dirsep == parent) &&
|
784
|
-
(*p_dirsep != '/' || *q_dirsep != '/')) {
|
785
|
-
giterr_set(GITERR_INVALID,
|
786
|
-
"%s is not a parent of %s", parent, path->ptr);
|
787
|
-
return GIT_ENOTFOUND;
|
788
|
-
}
|
789
|
-
|
790
|
-
if (*p == '/' && !*q)
|
791
|
-
p++;
|
792
|
-
else if (!*p && *q == '/')
|
793
|
-
q++;
|
794
|
-
else if (!*p && !*q)
|
795
|
-
return git_buf_clear(path), 0;
|
796
|
-
else {
|
797
|
-
p = p_dirsep + 1;
|
798
|
-
q = q_dirsep + 1;
|
799
|
-
}
|
800
|
-
|
801
|
-
plen -= (p - path->ptr);
|
802
|
-
|
803
|
-
if (!*q)
|
804
|
-
return git_buf_set(path, p, plen);
|
805
|
-
|
806
|
-
for (; (q = strchr(q, '/')) && *(q + 1); q++)
|
807
|
-
depth++;
|
808
|
-
|
809
|
-
newlen = (depth * 3) + plen;
|
810
|
-
|
811
|
-
/* save the offset as we might realllocate the pointer */
|
812
|
-
offset = p - path->ptr;
|
813
|
-
if (git_buf_try_grow(path, newlen + 1, 1, 0) < 0)
|
814
|
-
return -1;
|
815
|
-
p = path->ptr + offset;
|
816
|
-
|
817
|
-
memmove(path->ptr + (depth * 3), p, plen + 1);
|
818
|
-
|
819
|
-
for (i = 0; i < depth; i++)
|
820
|
-
memcpy(path->ptr + (i * 3), "../", 3);
|
821
|
-
|
822
|
-
path->size = newlen;
|
823
|
-
return 0;
|
824
|
-
}
|
825
|
-
|
826
757
|
bool git_path_has_non_ascii(const char *path, size_t pathlen)
|
827
758
|
{
|
828
759
|
const uint8_t *scan = (const uint8_t *)path, *end;
|
@@ -983,7 +914,7 @@ int git_path_direach(
|
|
983
914
|
path_dirent_data de_data;
|
984
915
|
struct dirent *de, *de_buf = (struct dirent *)&de_data;
|
985
916
|
|
986
|
-
|
917
|
+
(void)flags;
|
987
918
|
|
988
919
|
#ifdef GIT_USE_ICONV
|
989
920
|
git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
|
@@ -1054,7 +985,7 @@ int git_path_dirload(
|
|
1054
985
|
path_dirent_data de_data;
|
1055
986
|
struct dirent *de, *de_buf = (struct dirent *)&de_data;
|
1056
987
|
|
1057
|
-
|
988
|
+
(void)flags;
|
1058
989
|
|
1059
990
|
#ifdef GIT_USE_ICONV
|
1060
991
|
git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
|
@@ -1106,10 +1037,8 @@ int git_path_dirload(
|
|
1106
1037
|
entry_path[path_len] = '/';
|
1107
1038
|
memcpy(&entry_path[path_len + need_slash], de_path, de_len);
|
1108
1039
|
|
1109
|
-
if ((error = git_vector_insert(contents, entry_path)) < 0)
|
1110
|
-
git__free(entry_path);
|
1040
|
+
if ((error = git_vector_insert(contents, entry_path)) < 0)
|
1111
1041
|
break;
|
1112
|
-
}
|
1113
1042
|
}
|
1114
1043
|
|
1115
1044
|
closedir(dir);
|
@@ -1185,29 +1114,20 @@ int git_path_dirload_with_stat(
|
|
1185
1114
|
|
1186
1115
|
if ((error = git_buf_joinpath(&full, full.ptr, ps->path)) < 0 ||
|
1187
1116
|
(error = git_path_lstat(full.ptr, &ps->st)) < 0) {
|
1188
|
-
|
1189
1117
|
if (error == GIT_ENOTFOUND) {
|
1190
|
-
|
1118
|
+
giterr_clear();
|
1119
|
+
error = 0;
|
1191
1120
|
git_vector_remove(contents, i--);
|
1192
|
-
|
1193
|
-
/* Treat the file as unreadable if we get any other error */
|
1194
|
-
memset(&ps->st, 0, sizeof(ps->st));
|
1195
|
-
ps->st.st_mode = GIT_FILEMODE_UNREADABLE;
|
1121
|
+
continue;
|
1196
1122
|
}
|
1197
1123
|
|
1198
|
-
|
1199
|
-
error = 0;
|
1200
|
-
continue;
|
1124
|
+
break;
|
1201
1125
|
}
|
1202
1126
|
|
1203
1127
|
if (S_ISDIR(ps->st.st_mode)) {
|
1204
1128
|
ps->path[ps->path_len++] = '/';
|
1205
1129
|
ps->path[ps->path_len] = '\0';
|
1206
1130
|
}
|
1207
|
-
else if (!S_ISREG(ps->st.st_mode) && !S_ISLNK(ps->st.st_mode)) {
|
1208
|
-
/* skip everything but dirs, plain files, and symlinks */
|
1209
|
-
git_vector_remove(contents, i--);
|
1210
|
-
}
|
1211
1131
|
}
|
1212
1132
|
|
1213
1133
|
/* sort now that directory suffix is added */
|
@@ -1220,8 +1140,18 @@ int git_path_dirload_with_stat(
|
|
1220
1140
|
|
1221
1141
|
int git_path_from_url_or_path(git_buf *local_path_out, const char *url_or_path)
|
1222
1142
|
{
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1143
|
+
int error;
|
1144
|
+
|
1145
|
+
/* If url_or_path begins with file:// treat it as a URL */
|
1146
|
+
if (!git__prefixcmp(url_or_path, "file://")) {
|
1147
|
+
if ((error = git_path_fromurl(local_path_out, url_or_path)) < 0) {
|
1148
|
+
return error;
|
1149
|
+
}
|
1150
|
+
} else { /* We assume url_or_path is already a path */
|
1151
|
+
if ((error = git_buf_sets(local_path_out, url_or_path)) < 0) {
|
1152
|
+
return error;
|
1153
|
+
}
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
return 0;
|
1227
1157
|
}
|