rugged 0.21.4 → 0.22.0b1
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 +9 -9
- data/ext/rugged/rugged.c +4 -2
- data/ext/rugged/rugged.h +3 -7
- data/ext/rugged/rugged_blob.c +57 -0
- data/ext/rugged/rugged_cred.c +23 -0
- data/ext/rugged/rugged_index.c +6 -2
- data/ext/rugged/rugged_remote.c +65 -52
- data/ext/rugged/rugged_remote_collection.c +59 -10
- data/ext/rugged/rugged_repo.c +345 -11
- data/ext/rugged/rugged_revwalk.c +10 -0
- data/ext/rugged/rugged_submodule.c +1042 -0
- data/ext/rugged/rugged_submodule_collection.c +236 -0
- data/ext/rugged/rugged_tag_collection.c +70 -2
- data/ext/rugged/rugged_tree.c +29 -10
- data/lib/rugged.rb +3 -0
- data/lib/rugged/attributes.rb +41 -0
- data/lib/rugged/blob.rb +28 -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/repository.rb +7 -0
- data/lib/rugged/submodule_collection.rb +48 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +27 -3
- 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.h +4 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +99 -0
- data/vendor/libgit2/include/git2/attr.h +16 -13
- data/vendor/libgit2/include/git2/branch.h +11 -0
- 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/common.h +13 -1
- data/vendor/libgit2/include/git2/config.h +0 -14
- data/vendor/libgit2/include/git2/describe.h +162 -0
- data/vendor/libgit2/include/git2/diff.h +13 -8
- data/vendor/libgit2/include/git2/errors.h +5 -0
- data/vendor/libgit2/include/git2/global.h +38 -0
- data/vendor/libgit2/include/git2/merge.h +38 -64
- data/vendor/libgit2/include/git2/net.h +2 -2
- data/vendor/libgit2/include/git2/notes.h +17 -0
- data/vendor/libgit2/include/git2/oid.h +8 -4
- data/vendor/libgit2/include/git2/oidarray.h +40 -0
- data/vendor/libgit2/include/git2/rebase.h +261 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/remote.h +25 -47
- data/vendor/libgit2/include/git2/repository.h +4 -1
- data/vendor/libgit2/include/git2/reset.h +10 -1
- data/vendor/libgit2/include/git2/revert.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +28 -23
- data/vendor/libgit2/include/git2/status.h +19 -15
- data/vendor/libgit2/include/git2/submodule.h +18 -0
- data/vendor/libgit2/include/git2/sys/config.h +0 -1
- data/vendor/libgit2/{src → include/git2/sys}/hashsig.h +11 -7
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +13 -0
- data/vendor/libgit2/include/git2/sys/refs.h +0 -11
- data/vendor/libgit2/include/git2/sys/repository.h +13 -0
- data/vendor/libgit2/include/git2/sys/transport.h +352 -0
- data/vendor/libgit2/include/git2/threads.h +10 -20
- data/vendor/libgit2/include/git2/transaction.h +111 -0
- data/vendor/libgit2/include/git2/transport.h +79 -313
- data/vendor/libgit2/include/git2/tree.h +4 -2
- data/vendor/libgit2/include/git2/types.h +77 -8
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/annotated_commit.c +121 -0
- data/vendor/libgit2/src/annotated_commit.h +22 -0
- data/vendor/libgit2/src/attr.c +8 -4
- data/vendor/libgit2/src/attr_file.c +24 -2
- data/vendor/libgit2/src/blame.c +0 -1
- data/vendor/libgit2/src/branch.c +32 -3
- data/vendor/libgit2/src/buf_text.c +9 -5
- data/vendor/libgit2/src/buf_text.h +3 -2
- 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/cc-compat.h +2 -0
- data/vendor/libgit2/src/checkout.c +263 -82
- data/vendor/libgit2/src/checkout.h +1 -0
- data/vendor/libgit2/src/cherrypick.c +41 -44
- data/vendor/libgit2/src/clone.c +96 -58
- data/vendor/libgit2/src/commit.c +5 -31
- data/vendor/libgit2/src/commit_list.h +3 -1
- data/vendor/libgit2/src/config.c +0 -17
- data/vendor/libgit2/src/config_cache.c +0 -2
- data/vendor/libgit2/src/config_file.c +12 -15
- data/vendor/libgit2/src/crlf.c +2 -1
- data/vendor/libgit2/src/describe.c +886 -0
- data/vendor/libgit2/src/diff.c +29 -3
- data/vendor/libgit2/src/diff_file.c +1 -0
- data/vendor/libgit2/src/diff_patch.c +2 -3
- data/vendor/libgit2/src/diff_print.c +11 -9
- data/vendor/libgit2/src/diff_tform.c +4 -4
- data/vendor/libgit2/src/errors.c +9 -7
- data/vendor/libgit2/src/fetch.c +6 -6
- data/vendor/libgit2/src/fetchhead.h +2 -4
- data/vendor/libgit2/src/filebuf.c +0 -2
- data/vendor/libgit2/src/filebuf.h +2 -3
- data/vendor/libgit2/src/fileops.c +9 -7
- data/vendor/libgit2/src/global.c +44 -35
- data/vendor/libgit2/src/global.h +2 -0
- data/vendor/libgit2/src/graph.c +2 -2
- data/vendor/libgit2/src/hash.h +3 -1
- data/vendor/libgit2/src/hash/hash_common_crypto.h +44 -0
- data/vendor/libgit2/src/hash/hash_win32.c +1 -1
- data/vendor/libgit2/src/hashsig.c +1 -1
- data/vendor/libgit2/src/ignore.c +5 -88
- data/vendor/libgit2/src/index.c +70 -57
- data/vendor/libgit2/src/index.h +1 -0
- data/vendor/libgit2/src/indexer.c +16 -5
- data/vendor/libgit2/src/iterator.c +70 -1
- data/vendor/libgit2/src/iterator.h +5 -1
- data/vendor/libgit2/src/map.h +0 -1
- data/vendor/libgit2/src/merge.c +203 -327
- data/vendor/libgit2/src/merge.h +3 -13
- data/vendor/libgit2/src/mwindow.c +119 -8
- data/vendor/libgit2/src/mwindow.h +9 -1
- data/vendor/libgit2/src/netops.c +7 -8
- data/vendor/libgit2/src/netops.h +6 -16
- data/vendor/libgit2/src/notes.c +31 -4
- data/vendor/libgit2/src/notes.h +3 -0
- data/vendor/libgit2/src/odb.c +23 -1
- data/vendor/libgit2/src/odb_loose.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +6 -3
- data/vendor/libgit2/src/oid.c +9 -1
- 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/oidmap.h +16 -0
- data/vendor/libgit2/src/pack.c +20 -7
- data/vendor/libgit2/src/pack.h +3 -0
- data/vendor/libgit2/src/path.c +120 -293
- data/vendor/libgit2/src/path.h +21 -44
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/pool.c +5 -11
- data/vendor/libgit2/src/pool.h +0 -2
- data/vendor/libgit2/src/posix.c +6 -6
- data/vendor/libgit2/src/posix.h +48 -28
- data/vendor/libgit2/src/push.c +19 -48
- data/vendor/libgit2/src/push.h +2 -4
- data/vendor/libgit2/src/rebase.c +1125 -0
- data/vendor/libgit2/src/refdb.c +19 -0
- data/vendor/libgit2/src/refdb.h +2 -1
- data/vendor/libgit2/src/refdb_fs.c +101 -29
- data/vendor/libgit2/src/reflog.c +1 -1
- data/vendor/libgit2/src/refs.c +38 -3
- data/vendor/libgit2/src/refs.h +13 -2
- data/vendor/libgit2/src/refspec.c +20 -2
- data/vendor/libgit2/src/remote.c +288 -154
- data/vendor/libgit2/src/remote.h +5 -1
- data/vendor/libgit2/src/repository.c +75 -36
- data/vendor/libgit2/src/repository.h +3 -25
- data/vendor/libgit2/src/reset.c +5 -1
- data/vendor/libgit2/src/revert.c +4 -6
- data/vendor/libgit2/src/revparse.c +15 -18
- data/vendor/libgit2/src/revwalk.c +96 -22
- data/vendor/libgit2/src/revwalk.h +5 -4
- data/vendor/libgit2/src/settings.c +22 -0
- data/vendor/libgit2/src/signature.c +37 -2
- data/vendor/libgit2/src/signature.h +3 -0
- data/vendor/libgit2/src/stash.c +17 -12
- data/vendor/libgit2/src/status.c +13 -3
- data/vendor/libgit2/src/strnlen.h +2 -1
- data/vendor/libgit2/src/submodule.c +75 -35
- data/vendor/libgit2/src/thread-utils.h +4 -9
- data/vendor/libgit2/src/trace.h +9 -1
- data/vendor/libgit2/src/transaction.c +352 -0
- data/vendor/libgit2/src/transport.c +91 -97
- 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 +208 -82
- data/vendor/libgit2/src/transports/local.c +2 -2
- data/vendor/libgit2/src/transports/smart.c +2 -0
- data/vendor/libgit2/src/transports/smart.h +2 -0
- data/vendor/libgit2/src/transports/smart_protocol.c +10 -10
- data/vendor/libgit2/src/transports/ssh.c +243 -57
- data/vendor/libgit2/src/transports/winhttp.c +139 -35
- data/vendor/libgit2/src/tree-cache.c +118 -31
- data/vendor/libgit2/src/tree-cache.h +12 -7
- data/vendor/libgit2/src/tree.c +83 -64
- data/vendor/libgit2/src/tree.h +2 -3
- data/vendor/libgit2/src/unix/map.c +8 -2
- data/vendor/libgit2/src/unix/posix.h +23 -9
- data/vendor/libgit2/src/unix/realpath.c +8 -7
- data/vendor/libgit2/src/userdiff.h +3 -3
- data/vendor/libgit2/src/util.c +2 -92
- data/vendor/libgit2/src/util.h +3 -15
- data/vendor/libgit2/src/win32/findfile.c +0 -1
- data/vendor/libgit2/src/win32/map.c +3 -2
- 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 -32
- data/vendor/libgit2/src/win32/posix_w32.c +103 -31
- data/vendor/libgit2/src/win32/utf-conv.c +6 -36
- data/vendor/libgit2/src/win32/utf-conv.h +39 -0
- data/vendor/libgit2/src/win32/w32_util.h +0 -1
- metadata +32 -7
- data/vendor/libgit2/src/win32/path_w32.c +0 -305
- data/vendor/libgit2/src/win32/path_w32.h +0 -82
@@ -9,24 +9,29 @@
|
|
9
9
|
#define INCLUDE_tree_cache_h__
|
10
10
|
|
11
11
|
#include "common.h"
|
12
|
+
#include "pool.h"
|
13
|
+
#include "buffer.h"
|
12
14
|
#include "git2/oid.h"
|
13
15
|
|
14
|
-
struct git_tree_cache {
|
15
|
-
struct git_tree_cache *parent;
|
16
|
+
typedef struct git_tree_cache {
|
16
17
|
struct git_tree_cache **children;
|
17
18
|
size_t children_count;
|
18
19
|
|
19
|
-
ssize_t
|
20
|
+
ssize_t entry_count;
|
20
21
|
git_oid oid;
|
21
22
|
size_t namelen;
|
22
23
|
char name[GIT_FLEX_ARRAY];
|
23
|
-
};
|
24
|
+
} git_tree_cache;
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size);
|
26
|
+
int git_tree_cache_write(git_buf *out, git_tree_cache *tree);
|
27
|
+
int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size, git_pool *pool);
|
28
28
|
void git_tree_cache_invalidate_path(git_tree_cache *tree, const char *path);
|
29
29
|
const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char *path);
|
30
|
+
int git_tree_cache_new(git_tree_cache **out, const char *name, git_pool *pool);
|
31
|
+
/**
|
32
|
+
* Read a tree as the root of the tree cache (like for `git read-tree`)
|
33
|
+
*/
|
34
|
+
int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_pool *pool);
|
30
35
|
void git_tree_cache_free(git_tree_cache *tree);
|
31
36
|
|
32
37
|
#endif
|
data/vendor/libgit2/src/tree.c
CHANGED
@@ -17,6 +17,8 @@
|
|
17
17
|
#define DEFAULT_TREE_SIZE 16
|
18
18
|
#define MAX_FILEMODE_BYTES 6
|
19
19
|
|
20
|
+
GIT__USE_STRMAP;
|
21
|
+
|
20
22
|
static bool valid_filemode(const int filemode)
|
21
23
|
{
|
22
24
|
return (filemode == GIT_FILEMODE_TREE
|
@@ -55,7 +57,7 @@ static int valid_entry_name(const char *filename)
|
|
55
57
|
(*filename != '.' ||
|
56
58
|
(strcmp(filename, ".") != 0 &&
|
57
59
|
strcmp(filename, "..") != 0 &&
|
58
|
-
|
60
|
+
strcmp(filename, DOT_GIT) != 0));
|
59
61
|
}
|
60
62
|
|
61
63
|
static int entry_sort_cmp(const void *a, const void *b)
|
@@ -365,7 +367,8 @@ size_t git_tree_entrycount(const git_tree *tree)
|
|
365
367
|
unsigned int git_treebuilder_entrycount(git_treebuilder *bld)
|
366
368
|
{
|
367
369
|
assert(bld);
|
368
|
-
|
370
|
+
|
371
|
+
return git_strmap_num_entries(bld->map);
|
369
372
|
}
|
370
373
|
|
371
374
|
static int tree_error(const char *str, const char *path)
|
@@ -450,6 +453,7 @@ static int append_entry(
|
|
450
453
|
git_filemode_t filemode)
|
451
454
|
{
|
452
455
|
git_tree_entry *entry;
|
456
|
+
int error = 0;
|
453
457
|
|
454
458
|
if (!valid_entry_name(filename))
|
455
459
|
return tree_error("Failed to insert entry. Invalid name for a tree entry", filename);
|
@@ -460,12 +464,13 @@ static int append_entry(
|
|
460
464
|
git_oid_cpy(&entry->oid, id);
|
461
465
|
entry->attr = (uint16_t)filemode;
|
462
466
|
|
463
|
-
|
464
|
-
|
467
|
+
git_strmap_insert(bld->map, entry->filename, entry, error);
|
468
|
+
if (error < 0) {
|
469
|
+
git_tree_entry_free(entry);
|
470
|
+
giterr_set(GITERR_TREE, "failed to append entry %s to the tree builder", filename);
|
465
471
|
return -1;
|
466
472
|
}
|
467
473
|
|
468
|
-
bld->entrycount++;
|
469
474
|
return 0;
|
470
475
|
}
|
471
476
|
|
@@ -483,7 +488,7 @@ static int write_tree(
|
|
483
488
|
const git_tree_cache *cache;
|
484
489
|
|
485
490
|
cache = git_tree_cache_get(index->tree, dirname);
|
486
|
-
if (cache != NULL && cache->
|
491
|
+
if (cache != NULL && cache->entry_count >= 0){
|
487
492
|
git_oid_cpy(oid, &cache->oid);
|
488
493
|
return (int)find_next_dir(dirname, index, start);
|
489
494
|
}
|
@@ -574,6 +579,7 @@ int git_tree__write_index(
|
|
574
579
|
git_oid *oid, git_index *index, git_repository *repo)
|
575
580
|
{
|
576
581
|
int ret;
|
582
|
+
git_tree *tree;
|
577
583
|
bool old_ignore_case = false;
|
578
584
|
|
579
585
|
assert(oid && index && repo);
|
@@ -584,7 +590,7 @@ int git_tree__write_index(
|
|
584
590
|
return GIT_EUNMERGED;
|
585
591
|
}
|
586
592
|
|
587
|
-
if (index->tree != NULL && index->tree->
|
593
|
+
if (index->tree != NULL && index->tree->entry_count >= 0) {
|
588
594
|
git_oid_cpy(oid, &index->tree->oid);
|
589
595
|
return 0;
|
590
596
|
}
|
@@ -604,24 +610,37 @@ int git_tree__write_index(
|
|
604
610
|
if (old_ignore_case)
|
605
611
|
git_index__set_ignore_case(index, true);
|
606
612
|
|
607
|
-
|
613
|
+
index->tree = NULL;
|
614
|
+
|
615
|
+
if (ret < 0)
|
616
|
+
return ret;
|
617
|
+
|
618
|
+
git_pool_clear(&index->tree_pool);
|
619
|
+
|
620
|
+
if ((ret = git_tree_lookup(&tree, repo, oid)) < 0)
|
621
|
+
return ret;
|
622
|
+
|
623
|
+
/* Read the tree cache into the index */
|
624
|
+
ret = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool);
|
625
|
+
git_tree_free(tree);
|
626
|
+
|
627
|
+
return ret;
|
608
628
|
}
|
609
629
|
|
610
630
|
int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source)
|
611
631
|
{
|
612
632
|
git_treebuilder *bld;
|
613
|
-
size_t i
|
633
|
+
size_t i;
|
614
634
|
|
615
635
|
assert(builder_p);
|
616
636
|
|
617
637
|
bld = git__calloc(1, sizeof(git_treebuilder));
|
618
638
|
GITERR_CHECK_ALLOC(bld);
|
619
639
|
|
620
|
-
if (
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
goto on_error;
|
640
|
+
if (git_strmap_alloc(&bld->map) < 0) {
|
641
|
+
git__free(bld);
|
642
|
+
return -1;
|
643
|
+
}
|
625
644
|
|
626
645
|
if (source != NULL) {
|
627
646
|
git_tree_entry *entry_src;
|
@@ -651,7 +670,8 @@ int git_treebuilder_insert(
|
|
651
670
|
git_filemode_t filemode)
|
652
671
|
{
|
653
672
|
git_tree_entry *entry;
|
654
|
-
|
673
|
+
int error;
|
674
|
+
git_strmap_iter pos;
|
655
675
|
|
656
676
|
assert(bld && id && filename);
|
657
677
|
|
@@ -661,30 +681,25 @@ int git_treebuilder_insert(
|
|
661
681
|
if (!valid_entry_name(filename))
|
662
682
|
return tree_error("Failed to insert entry. Invalid name for a tree entry", filename);
|
663
683
|
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
entry->removed = 0;
|
668
|
-
bld->entrycount++;
|
669
|
-
}
|
670
|
-
|
671
|
-
entry->attr = filemode;
|
672
|
-
git_oid_cpy(&entry->oid, id);
|
684
|
+
pos = git_strmap_lookup_index(bld->map, filename);
|
685
|
+
if (git_strmap_valid_index(bld->map, pos)) {
|
686
|
+
entry = git_strmap_value_at(bld->map, pos);
|
673
687
|
} else {
|
674
688
|
entry = alloc_entry(filename);
|
675
689
|
GITERR_CHECK_ALLOC(entry);
|
676
690
|
|
677
|
-
entry->
|
678
|
-
git_oid_cpy(&entry->oid, id);
|
691
|
+
git_strmap_insert(bld->map, entry->filename, entry, error);
|
679
692
|
|
680
|
-
if (
|
681
|
-
|
693
|
+
if (error < 0) {
|
694
|
+
git_tree_entry_free(entry);
|
695
|
+
giterr_set(GITERR_TREE, "failed to insert %s", filename);
|
682
696
|
return -1;
|
683
697
|
}
|
684
|
-
|
685
|
-
bld->entrycount++;
|
686
698
|
}
|
687
699
|
|
700
|
+
git_oid_cpy(&entry->oid, id);
|
701
|
+
entry->attr = filemode;
|
702
|
+
|
688
703
|
if (entry_out)
|
689
704
|
*entry_out = entry;
|
690
705
|
|
@@ -693,17 +708,14 @@ int git_treebuilder_insert(
|
|
693
708
|
|
694
709
|
static git_tree_entry *treebuilder_get(git_treebuilder *bld, const char *filename)
|
695
710
|
{
|
696
|
-
|
697
|
-
|
711
|
+
git_tree_entry *entry = NULL;
|
712
|
+
git_strmap_iter pos;
|
698
713
|
|
699
714
|
assert(bld && filename);
|
700
715
|
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
entry = git_vector_get(&bld->entries, idx);
|
705
|
-
if (entry->removed)
|
706
|
-
return NULL;
|
716
|
+
pos = git_strmap_lookup_index(bld->map, filename);
|
717
|
+
if (git_strmap_valid_index(bld->map, pos))
|
718
|
+
entry = git_strmap_value_at(bld->map, pos);
|
707
719
|
|
708
720
|
return entry;
|
709
721
|
}
|
@@ -715,35 +727,44 @@ const git_tree_entry *git_treebuilder_get(git_treebuilder *bld, const char *file
|
|
715
727
|
|
716
728
|
int git_treebuilder_remove(git_treebuilder *bld, const char *filename)
|
717
729
|
{
|
718
|
-
git_tree_entry *
|
730
|
+
git_tree_entry *entry = treebuilder_get(bld, filename);
|
719
731
|
|
720
|
-
if (
|
732
|
+
if (entry == NULL)
|
721
733
|
return tree_error("Failed to remove entry. File isn't in the tree", filename);
|
722
734
|
|
723
|
-
|
724
|
-
|
735
|
+
git_strmap_delete(bld->map, filename);
|
736
|
+
git_tree_entry_free(entry);
|
737
|
+
|
725
738
|
return 0;
|
726
739
|
}
|
727
740
|
|
728
741
|
int git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *bld)
|
729
742
|
{
|
730
743
|
int error = 0;
|
731
|
-
size_t i;
|
744
|
+
size_t i, entrycount;
|
732
745
|
git_buf tree = GIT_BUF_INIT;
|
733
746
|
git_odb *odb;
|
747
|
+
git_tree_entry *entry;
|
748
|
+
git_vector entries;
|
734
749
|
|
735
750
|
assert(bld);
|
736
751
|
|
737
|
-
|
752
|
+
entrycount = git_strmap_num_entries(bld->map);
|
753
|
+
if (git_vector_init(&entries, entrycount, entry_sort_cmp) < 0)
|
754
|
+
return -1;
|
738
755
|
|
739
|
-
|
740
|
-
|
756
|
+
git_strmap_foreach_value(bld->map, entry, {
|
757
|
+
if (git_vector_insert(&entries, entry) < 0)
|
758
|
+
return -1;
|
759
|
+
});
|
741
760
|
|
742
|
-
|
743
|
-
git_tree_entry *entry = git_vector_get(&bld->entries, i);
|
761
|
+
git_vector_sort(&entries);
|
744
762
|
|
745
|
-
|
746
|
-
|
763
|
+
/* Grow the buffer beforehand to an estimated size */
|
764
|
+
error = git_buf_grow(&tree, entrycount * 72);
|
765
|
+
|
766
|
+
for (i = 0; i < entries.length && !error; ++i) {
|
767
|
+
git_tree_entry *entry = git_vector_get(&entries, i);
|
747
768
|
|
748
769
|
git_buf_printf(&tree, "%o ", entry->attr);
|
749
770
|
git_buf_put(&tree, entry->filename, entry->filename_len + 1);
|
@@ -753,6 +774,8 @@ int git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *b
|
|
753
774
|
error = -1;
|
754
775
|
}
|
755
776
|
|
777
|
+
git_vector_free(&entries);
|
778
|
+
|
756
779
|
if (!error &&
|
757
780
|
!(error = git_repository_odb__weakptr(&odb, repo)))
|
758
781
|
error = git_odb_write(oid, odb, tree.ptr, tree.size, GIT_OBJ_TREE);
|
@@ -766,31 +789,27 @@ void git_treebuilder_filter(
|
|
766
789
|
git_treebuilder_filter_cb filter,
|
767
790
|
void *payload)
|
768
791
|
{
|
769
|
-
|
792
|
+
const char *filename;
|
770
793
|
git_tree_entry *entry;
|
771
794
|
|
772
795
|
assert(bld && filter);
|
773
796
|
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
}
|
797
|
+
git_strmap_foreach(bld->map, filename, entry, {
|
798
|
+
if (filter(entry, payload)) {
|
799
|
+
git_strmap_delete(bld->map, filename);
|
800
|
+
git_tree_entry_free(entry);
|
801
|
+
}
|
802
|
+
});
|
780
803
|
}
|
781
804
|
|
782
805
|
void git_treebuilder_clear(git_treebuilder *bld)
|
783
806
|
{
|
784
|
-
size_t i;
|
785
807
|
git_tree_entry *e;
|
786
808
|
|
787
809
|
assert(bld);
|
788
810
|
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
git_vector_clear(&bld->entries);
|
793
|
-
bld->entrycount = 0;
|
811
|
+
git_strmap_foreach_value(bld->map, e, git_tree_entry_free(e));
|
812
|
+
git_strmap_clear(bld->map);
|
794
813
|
}
|
795
814
|
|
796
815
|
void git_treebuilder_free(git_treebuilder *bld)
|
@@ -799,7 +818,7 @@ void git_treebuilder_free(git_treebuilder *bld)
|
|
799
818
|
return;
|
800
819
|
|
801
820
|
git_treebuilder_clear(bld);
|
802
|
-
|
821
|
+
git_strmap_free(bld->map);
|
803
822
|
git__free(bld);
|
804
823
|
}
|
805
824
|
|
data/vendor/libgit2/src/tree.h
CHANGED
@@ -11,9 +11,9 @@
|
|
11
11
|
#include "repository.h"
|
12
12
|
#include "odb.h"
|
13
13
|
#include "vector.h"
|
14
|
+
#include "strmap.h"
|
14
15
|
|
15
16
|
struct git_tree_entry {
|
16
|
-
uint16_t removed;
|
17
17
|
uint16_t attr;
|
18
18
|
git_oid oid;
|
19
19
|
size_t filename_len;
|
@@ -26,8 +26,7 @@ struct git_tree {
|
|
26
26
|
};
|
27
27
|
|
28
28
|
struct git_treebuilder {
|
29
|
-
|
30
|
-
size_t entrycount; /* vector may contain "removed" entries */
|
29
|
+
git_strmap *map;
|
31
30
|
};
|
32
31
|
|
33
32
|
GIT_INLINE(bool) git_tree_entry__is_tree(const struct git_tree_entry *e)
|
@@ -13,9 +13,15 @@
|
|
13
13
|
#include <unistd.h>
|
14
14
|
#include <errno.h>
|
15
15
|
|
16
|
-
|
16
|
+
int git__page_size(size_t *page_size)
|
17
17
|
{
|
18
|
-
|
18
|
+
long sc_page_size = sysconf(_SC_PAGE_SIZE);
|
19
|
+
if (sc_page_size < 0) {
|
20
|
+
giterr_set_str(GITERR_OS, "Can't determine system page size");
|
21
|
+
return -1;
|
22
|
+
}
|
23
|
+
*page_size = (size_t) sc_page_size;
|
24
|
+
return 0;
|
19
25
|
}
|
20
26
|
|
21
27
|
int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
|
@@ -4,33 +4,47 @@
|
|
4
4
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
6
6
|
*/
|
7
|
-
#ifndef
|
8
|
-
#define
|
7
|
+
#ifndef INCLUDE_posix__unix_h__
|
8
|
+
#define INCLUDE_posix__unix_h__
|
9
9
|
|
10
10
|
#include <stdio.h>
|
11
11
|
#include <sys/param.h>
|
12
12
|
|
13
|
+
typedef int GIT_SOCKET;
|
14
|
+
#define INVALID_SOCKET -1
|
15
|
+
|
16
|
+
#define p_lseek(f,n,w) lseek(f, n, w)
|
17
|
+
#define p_fstat(f,b) fstat(f, b)
|
13
18
|
#define p_lstat(p,b) lstat(p,b)
|
19
|
+
#define p_stat(p,b) stat(p, b)
|
20
|
+
|
14
21
|
#define p_readlink(a, b, c) readlink(a, b, c)
|
15
22
|
#define p_symlink(o,n) symlink(o, n)
|
16
23
|
#define p_link(o,n) link(o, n)
|
17
24
|
#define p_unlink(p) unlink(p)
|
18
25
|
#define p_mkdir(p,m) mkdir(p, m)
|
19
26
|
#define p_fsync(fd) fsync(fd)
|
27
|
+
extern char *p_realpath(const char *, char *);
|
20
28
|
|
21
|
-
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#else
|
25
|
-
char *p_realpath(const char *, char *);
|
26
|
-
#endif
|
29
|
+
#define p_recv(s,b,l,f) recv(s,b,l,f)
|
30
|
+
#define p_send(s,b,l,f) send(s,b,l,f)
|
31
|
+
#define p_inet_pton(a, b, c) inet_pton(a, b, c)
|
27
32
|
|
33
|
+
#define p_strcasecmp(s1, s2) strcasecmp(s1, s2)
|
34
|
+
#define p_strncasecmp(s1, s2, c) strncasecmp(s1, s2, c)
|
28
35
|
#define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a)
|
29
36
|
#define p_snprintf(b, c, f, ...) snprintf(b, c, f, __VA_ARGS__)
|
30
37
|
#define p_mkstemp(p) mkstemp(p)
|
31
|
-
#define
|
38
|
+
#define p_chdir(p) chdir(p)
|
39
|
+
#define p_chmod(p,m) chmod(p, m)
|
40
|
+
#define p_rmdir(p) rmdir(p)
|
41
|
+
#define p_access(p,m) access(p,m)
|
42
|
+
#define p_ftruncate(fd, sz) ftruncate(fd, sz)
|
32
43
|
|
33
44
|
/* see win32/posix.h for explanation about why this exists */
|
34
45
|
#define p_lstat_posixly(p,b) lstat(p,b)
|
35
46
|
|
47
|
+
#define p_localtime_r(c, r) localtime_r(c, r)
|
48
|
+
#define p_gmtime_r(c, r) gmtime_r(c, r)
|
49
|
+
|
36
50
|
#endif
|
@@ -6,7 +6,7 @@
|
|
6
6
|
*/
|
7
7
|
#include <git2/common.h>
|
8
8
|
|
9
|
-
#
|
9
|
+
#ifndef GIT_WIN32
|
10
10
|
|
11
11
|
#include <limits.h>
|
12
12
|
#include <stdlib.h>
|
@@ -16,15 +16,16 @@
|
|
16
16
|
char *p_realpath(const char *pathname, char *resolved)
|
17
17
|
{
|
18
18
|
char *ret;
|
19
|
-
|
20
19
|
if ((ret = realpath(pathname, resolved)) == NULL)
|
21
20
|
return NULL;
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
#ifdef __OpenBSD__
|
23
|
+
/* The OpenBSD realpath function behaves differently,
|
24
|
+
* figure out if the file exists */
|
25
|
+
if (access(ret, F_OK) < 0)
|
26
|
+
ret = NULL;
|
27
|
+
#endif
|
28
|
+
return ret;
|
28
29
|
}
|
29
30
|
|
30
31
|
#endif
|