rugged 0.22.2 → 0.23.0b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/rugged.c +1 -2
- data/ext/rugged/rugged_branch_collection.c +6 -44
- data/ext/rugged/rugged_config.c +7 -3
- data/ext/rugged/rugged_diff_delta.c +1 -1
- data/ext/rugged/rugged_diff_line.c +1 -1
- data/ext/rugged/rugged_object.c +2 -2
- data/ext/rugged/rugged_reference_collection.c +12 -56
- data/ext/rugged/rugged_remote.c +4 -33
- data/ext/rugged/rugged_remote_collection.c +1 -1
- data/ext/rugged/rugged_repo.c +10 -36
- data/ext/rugged/rugged_settings.c +3 -3
- data/ext/rugged/rugged_tree.c +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +10 -3
- data/vendor/libgit2/COPYING +15 -21
- data/vendor/libgit2/include/git2/annotated_commit.h +20 -3
- data/vendor/libgit2/include/git2/branch.h +20 -16
- data/vendor/libgit2/include/git2/checkout.h +32 -18
- data/vendor/libgit2/include/git2/cherrypick.h +2 -2
- data/vendor/libgit2/include/git2/clone.h +4 -10
- data/vendor/libgit2/include/git2/config.h +66 -12
- data/vendor/libgit2/include/git2/describe.h +3 -2
- data/vendor/libgit2/include/git2/diff.h +3 -3
- data/vendor/libgit2/include/git2/errors.h +1 -0
- data/vendor/libgit2/include/git2/filter.h +21 -5
- data/vendor/libgit2/include/git2/index.h +32 -0
- data/vendor/libgit2/include/git2/merge.h +20 -3
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +13 -0
- data/vendor/libgit2/include/git2/patch.h +3 -6
- data/vendor/libgit2/include/git2/rebase.h +8 -12
- data/vendor/libgit2/include/git2/refs.h +19 -29
- data/vendor/libgit2/include/git2/remote.h +5 -11
- data/vendor/libgit2/include/git2/repository.h +44 -15
- data/vendor/libgit2/include/git2/reset.h +19 -10
- data/vendor/libgit2/include/git2/revert.h +2 -2
- data/vendor/libgit2/include/git2/submodule.h +3 -9
- data/vendor/libgit2/include/git2/sys/config.h +3 -1
- data/vendor/libgit2/include/git2/sys/filter.h +10 -2
- data/vendor/libgit2/include/git2/sys/hashsig.h +49 -22
- data/vendor/libgit2/include/git2/transport.h +1 -1
- data/vendor/libgit2/include/git2/types.h +10 -3
- data/vendor/libgit2/include/git2/version.h +3 -2
- data/vendor/libgit2/src/annotated_commit.c +28 -0
- data/vendor/libgit2/src/array.h +19 -8
- data/vendor/libgit2/src/attr.c +95 -35
- data/vendor/libgit2/src/attr_file.c +51 -17
- data/vendor/libgit2/src/attr_file.h +37 -10
- data/vendor/libgit2/src/attrcache.c +13 -7
- data/vendor/libgit2/src/attrcache.h +1 -0
- data/vendor/libgit2/src/blame.c +26 -2
- data/vendor/libgit2/src/blame_git.c +6 -2
- data/vendor/libgit2/src/blob.c +6 -8
- data/vendor/libgit2/src/branch.c +55 -43
- data/vendor/libgit2/src/buf_text.c +13 -6
- data/vendor/libgit2/src/buffer.c +110 -25
- data/vendor/libgit2/src/buffer.h +18 -0
- data/vendor/libgit2/src/checkout.c +164 -92
- data/vendor/libgit2/src/checkout.h +0 -7
- data/vendor/libgit2/src/cherrypick.c +13 -7
- data/vendor/libgit2/src/clone.c +23 -25
- data/vendor/libgit2/src/commit.c +3 -3
- data/vendor/libgit2/src/common.h +23 -1
- data/vendor/libgit2/src/config.c +137 -19
- data/vendor/libgit2/src/config.h +2 -2
- data/vendor/libgit2/src/config_cache.c +2 -1
- data/vendor/libgit2/src/config_file.c +39 -18
- data/vendor/libgit2/src/config_file.h +1 -1
- data/vendor/libgit2/src/crlf.c +1 -1
- data/vendor/libgit2/src/delta-apply.c +3 -2
- data/vendor/libgit2/src/delta.c +25 -6
- data/vendor/libgit2/src/describe.c +2 -0
- data/vendor/libgit2/src/diff.c +8 -5
- data/vendor/libgit2/src/diff_driver.c +39 -18
- data/vendor/libgit2/src/diff_file.c +1 -1
- data/vendor/libgit2/src/diff_patch.c +12 -6
- data/vendor/libgit2/src/diff_tform.c +21 -24
- data/vendor/libgit2/src/filebuf.c +14 -12
- data/vendor/libgit2/src/fileops.c +61 -18
- data/vendor/libgit2/src/fileops.h +11 -2
- data/vendor/libgit2/src/filter.c +351 -99
- data/vendor/libgit2/src/filter.h +17 -0
- data/vendor/libgit2/src/global.c +38 -9
- data/vendor/libgit2/src/hash/hash_generic.c +1 -1
- data/vendor/libgit2/src/hashsig.c +28 -16
- data/vendor/libgit2/src/ignore.c +2 -2
- data/vendor/libgit2/src/index.c +159 -42
- data/vendor/libgit2/src/index.h +29 -0
- data/vendor/libgit2/src/indexer.c +11 -2
- data/vendor/libgit2/src/integer.h +96 -0
- data/vendor/libgit2/src/iterator.c +5 -3
- data/vendor/libgit2/src/khash.h +41 -29
- data/vendor/libgit2/src/merge.c +48 -35
- data/vendor/libgit2/src/merge.h +0 -1
- data/vendor/libgit2/src/merge_file.c +13 -0
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/notes.c +1 -1
- data/vendor/libgit2/src/odb.c +13 -11
- data/vendor/libgit2/src/odb_loose.c +22 -10
- data/vendor/libgit2/src/odb_mempack.c +4 -2
- data/vendor/libgit2/src/offmap.h +3 -2
- data/vendor/libgit2/src/oid.c +1 -1
- data/vendor/libgit2/src/oidmap.h +2 -1
- data/vendor/libgit2/src/openssl_stream.c +6 -3
- data/vendor/libgit2/src/pack-objects.c +273 -12
- data/vendor/libgit2/src/pack-objects.h +10 -0
- data/vendor/libgit2/src/pack.c +17 -6
- data/vendor/libgit2/src/pack.h +1 -3
- data/vendor/libgit2/src/path.c +68 -38
- data/vendor/libgit2/src/pathspec.c +3 -0
- data/vendor/libgit2/src/pool.c +9 -8
- data/vendor/libgit2/src/posix.c +11 -1
- data/vendor/libgit2/src/push.c +15 -17
- data/vendor/libgit2/src/push.h +1 -6
- data/vendor/libgit2/src/rebase.c +77 -35
- data/vendor/libgit2/src/refdb_fs.c +2 -2
- data/vendor/libgit2/src/refs.c +107 -81
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +3 -0
- data/vendor/libgit2/src/remote.c +19 -21
- data/vendor/libgit2/src/repository.c +258 -67
- data/vendor/libgit2/src/repository.h +31 -16
- data/vendor/libgit2/src/reset.c +28 -12
- data/vendor/libgit2/src/revert.c +12 -7
- data/vendor/libgit2/src/revwalk.c +3 -5
- data/vendor/libgit2/src/revwalk.h +1 -1
- data/vendor/libgit2/src/sortedcache.c +5 -3
- data/vendor/libgit2/src/stash.c +3 -5
- data/vendor/libgit2/src/strmap.h +2 -1
- data/vendor/libgit2/src/submodule.c +5 -6
- data/vendor/libgit2/src/tag.c +7 -5
- data/vendor/libgit2/src/transaction.c +1 -1
- data/vendor/libgit2/src/transports/cred.c +5 -2
- data/vendor/libgit2/src/transports/git.c +2 -3
- data/vendor/libgit2/src/transports/local.c +15 -34
- data/vendor/libgit2/src/transports/smart.c +1 -1
- data/vendor/libgit2/src/transports/smart_pkt.c +58 -18
- data/vendor/libgit2/src/transports/smart_protocol.c +2 -2
- data/vendor/libgit2/src/transports/winhttp.c +2 -2
- data/vendor/libgit2/src/tree.c +7 -5
- data/vendor/libgit2/src/tsort.c +3 -1
- data/vendor/libgit2/src/util.c +25 -0
- data/vendor/libgit2/src/util.h +31 -27
- data/vendor/libgit2/src/vector.c +2 -7
- data/vendor/libgit2/src/win32/dir.c +5 -3
- data/vendor/libgit2/src/win32/git2.rc +8 -4
- data/vendor/libgit2/src/win32/mingw-compat.h +7 -0
- data/vendor/libgit2/src/win32/msvc-compat.h +3 -0
- data/vendor/libgit2/src/win32/posix.h +1 -3
- data/vendor/libgit2/src/win32/posix_w32.c +31 -7
- data/vendor/libgit2/src/win32/utf-conv.c +1 -3
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +5 -5
- data/vendor/libgit2/src/bswap.h +0 -97
data/vendor/libgit2/src/config.h
CHANGED
@@ -48,7 +48,7 @@ extern int git_config__normalize_name(const char *in, char **out);
|
|
48
48
|
|
49
49
|
/* internal only: does not normalize key and sets out to NULL if not found */
|
50
50
|
extern int git_config__lookup_entry(
|
51
|
-
|
51
|
+
git_config_entry **out,
|
52
52
|
const git_config *cfg,
|
53
53
|
const char *key,
|
54
54
|
bool no_errors);
|
@@ -67,7 +67,7 @@ extern int git_config__update_entry(
|
|
67
67
|
* failures occur while trying to access the value.
|
68
68
|
*/
|
69
69
|
|
70
|
-
extern
|
70
|
+
extern char *git_config__get_string_force(
|
71
71
|
const git_config *cfg, const char *key, const char *fallback_value);
|
72
72
|
|
73
73
|
extern int git_config__get_bool_force(
|
@@ -84,7 +84,7 @@ int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar)
|
|
84
84
|
{
|
85
85
|
int error = 0;
|
86
86
|
struct map_data *data = &_cvar_maps[(int)cvar];
|
87
|
-
|
87
|
+
git_config_entry *entry;
|
88
88
|
|
89
89
|
git_config__lookup_entry(&entry, config, data->cvar_name, false);
|
90
90
|
|
@@ -96,6 +96,7 @@ int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar)
|
|
96
96
|
else
|
97
97
|
error = git_config_parse_bool(out, entry->value);
|
98
98
|
|
99
|
+
git_config_entry_free(entry);
|
99
100
|
return error;
|
100
101
|
}
|
101
102
|
|
@@ -21,7 +21,7 @@
|
|
21
21
|
#include <sys/types.h>
|
22
22
|
#include <regex.h>
|
23
23
|
|
24
|
-
GIT__USE_STRMAP
|
24
|
+
GIT__USE_STRMAP
|
25
25
|
|
26
26
|
typedef struct cvar_t {
|
27
27
|
struct cvar_t *next;
|
@@ -96,7 +96,6 @@ typedef struct {
|
|
96
96
|
/* mutex to coordinate accessing the values */
|
97
97
|
git_mutex values_mutex;
|
98
98
|
refcounted_strmap *values;
|
99
|
-
int readonly;
|
100
99
|
} diskfile_header;
|
101
100
|
|
102
101
|
typedef struct {
|
@@ -504,19 +503,26 @@ out:
|
|
504
503
|
return ret;
|
505
504
|
}
|
506
505
|
|
506
|
+
/* release the map containing the entry as an equivalent to freeing it */
|
507
|
+
static void release_map(git_config_entry *entry)
|
508
|
+
{
|
509
|
+
refcounted_strmap *map = (refcounted_strmap *) entry->payload;
|
510
|
+
refcounted_strmap_free(map);
|
511
|
+
}
|
512
|
+
|
507
513
|
/*
|
508
514
|
* Internal function that actually gets the value in string form
|
509
515
|
*/
|
510
|
-
static int config_get(git_config_backend *cfg, const char *key,
|
516
|
+
static int config_get(git_config_backend *cfg, const char *key, git_config_entry **out)
|
511
517
|
{
|
512
518
|
diskfile_header *h = (diskfile_header *)cfg;
|
513
519
|
refcounted_strmap *map;
|
514
520
|
git_strmap *values;
|
515
521
|
khiter_t pos;
|
516
522
|
cvar_t *var;
|
517
|
-
int error;
|
523
|
+
int error = 0;
|
518
524
|
|
519
|
-
if (!h->readonly && ((error = config_refresh(cfg)) < 0))
|
525
|
+
if (!h->parent.readonly && ((error = config_refresh(cfg)) < 0))
|
520
526
|
return error;
|
521
527
|
|
522
528
|
map = refcounted_strmap_take(h);
|
@@ -534,9 +540,11 @@ static int config_get(git_config_backend *cfg, const char *key, const git_config
|
|
534
540
|
while (var->next)
|
535
541
|
var = var->next;
|
536
542
|
|
537
|
-
refcounted_strmap_free(map);
|
538
543
|
*out = var->entry;
|
539
|
-
|
544
|
+
(*out)->free = release_map;
|
545
|
+
(*out)->payload = map;
|
546
|
+
|
547
|
+
return error;
|
540
548
|
}
|
541
549
|
|
542
550
|
static int config_set_multivar(
|
@@ -763,7 +771,7 @@ static int config_readonly_open(git_config_backend *cfg, git_config_level_t leve
|
|
763
771
|
refcounted_strmap *src_map;
|
764
772
|
int error;
|
765
773
|
|
766
|
-
if (!src_header->readonly && (error = config_refresh(&src_header->parent)) < 0)
|
774
|
+
if (!src_header->parent.readonly && (error = config_refresh(&src_header->parent)) < 0)
|
767
775
|
return error;
|
768
776
|
|
769
777
|
/* We're just copying data, don't care about the level */
|
@@ -787,7 +795,7 @@ int git_config_file__snapshot(git_config_backend **out, diskfile_backend *in)
|
|
787
795
|
|
788
796
|
backend->snapshot_from = in;
|
789
797
|
|
790
|
-
backend->header.readonly = 1;
|
798
|
+
backend->header.parent.readonly = 1;
|
791
799
|
backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION;
|
792
800
|
backend->header.parent.open = config_readonly_open;
|
793
801
|
backend->header.parent.get = config_get;
|
@@ -885,7 +893,7 @@ static char *reader_readline(struct reader *reader, bool skip_whitespace)
|
|
885
893
|
{
|
886
894
|
char *line = NULL;
|
887
895
|
char *line_src, *line_end;
|
888
|
-
size_t line_len;
|
896
|
+
size_t line_len, alloc_len;
|
889
897
|
|
890
898
|
line_src = reader->read_ptr;
|
891
899
|
|
@@ -903,9 +911,10 @@ static char *reader_readline(struct reader *reader, bool skip_whitespace)
|
|
903
911
|
|
904
912
|
line_len = line_end - line_src;
|
905
913
|
|
906
|
-
|
907
|
-
|
914
|
+
if (GIT_ADD_SIZET_OVERFLOW(&alloc_len, line_len, 1) ||
|
915
|
+
(line = git__malloc(alloc_len)) == NULL) {
|
908
916
|
return NULL;
|
917
|
+
}
|
909
918
|
|
910
919
|
memcpy(line, line_src, line_len);
|
911
920
|
|
@@ -958,6 +967,8 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
|
|
958
967
|
int c, rpos;
|
959
968
|
char *first_quote, *last_quote;
|
960
969
|
git_buf buf = GIT_BUF_INIT;
|
970
|
+
size_t quoted_len, alloc_len, base_name_len = strlen(base_name);
|
971
|
+
|
961
972
|
/*
|
962
973
|
* base_name is what came before the space. We should be at the
|
963
974
|
* first quotation mark, except for now, line isn't being kept in
|
@@ -966,13 +977,17 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
|
|
966
977
|
|
967
978
|
first_quote = strchr(line, '"');
|
968
979
|
last_quote = strrchr(line, '"');
|
980
|
+
quoted_len = last_quote - first_quote;
|
969
981
|
|
970
|
-
if (
|
982
|
+
if (quoted_len == 0) {
|
971
983
|
set_parse_error(reader, 0, "Missing closing quotation mark in section header");
|
972
984
|
return -1;
|
973
985
|
}
|
974
986
|
|
975
|
-
|
987
|
+
GITERR_CHECK_ALLOC_ADD(&alloc_len, base_name_len, quoted_len);
|
988
|
+
GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
|
989
|
+
|
990
|
+
git_buf_grow(&buf, alloc_len);
|
976
991
|
git_buf_printf(&buf, "%s.", base_name);
|
977
992
|
|
978
993
|
rpos = 0;
|
@@ -1029,6 +1044,7 @@ static int parse_section_header(struct reader *reader, char **section_out)
|
|
1029
1044
|
int name_length, c, pos;
|
1030
1045
|
int result;
|
1031
1046
|
char *line;
|
1047
|
+
size_t line_len;
|
1032
1048
|
|
1033
1049
|
line = reader_readline(reader, true);
|
1034
1050
|
if (line == NULL)
|
@@ -1042,7 +1058,8 @@ static int parse_section_header(struct reader *reader, char **section_out)
|
|
1042
1058
|
return -1;
|
1043
1059
|
}
|
1044
1060
|
|
1045
|
-
|
1061
|
+
GITERR_CHECK_ALLOC_ADD(&line_len, (size_t)(name_end - line), 1);
|
1062
|
+
name = git__malloc(line_len);
|
1046
1063
|
GITERR_CHECK_ALLOC(name);
|
1047
1064
|
|
1048
1065
|
name_length = 0;
|
@@ -1604,11 +1621,15 @@ static char *escape_value(const char *ptr)
|
|
1604
1621
|
/* '\"' -> '"' etc */
|
1605
1622
|
static char *fixup_line(const char *ptr, int quote_count)
|
1606
1623
|
{
|
1607
|
-
char *str
|
1608
|
-
|
1624
|
+
char *str, *out, *esc;
|
1625
|
+
size_t ptr_len = strlen(ptr), alloc_len;
|
1609
1626
|
|
1610
|
-
if (
|
1627
|
+
if (GIT_ADD_SIZET_OVERFLOW(&alloc_len, ptr_len, 1) ||
|
1628
|
+
(str = git__malloc(alloc_len)) == NULL) {
|
1611
1629
|
return NULL;
|
1630
|
+
}
|
1631
|
+
|
1632
|
+
out = str;
|
1612
1633
|
|
1613
1634
|
while (*ptr != '\0') {
|
1614
1635
|
if (*ptr == '"') {
|
@@ -21,7 +21,7 @@ GIT_INLINE(void) git_config_file_free(git_config_backend *cfg)
|
|
21
21
|
}
|
22
22
|
|
23
23
|
GIT_INLINE(int) git_config_file_get_string(
|
24
|
-
|
24
|
+
git_config_entry **out, git_config_backend *cfg, const char *name)
|
25
25
|
{
|
26
26
|
return cfg->get(cfg, name, out);
|
27
27
|
}
|
data/vendor/libgit2/src/crlf.c
CHANGED
@@ -302,7 +302,7 @@ static int crlf_check(
|
|
302
302
|
return error;
|
303
303
|
|
304
304
|
/* downgrade FAIL to WARN if ALLOW_UNSAFE option is used */
|
305
|
-
if ((
|
305
|
+
if ((git_filter_source_flags(src) & GIT_FILTER_ALLOW_UNSAFE) &&
|
306
306
|
ca.safe_crlf == GIT_SAFE_CRLF_FAIL)
|
307
307
|
ca.safe_crlf = GIT_SAFE_CRLF_WARN;
|
308
308
|
}
|
@@ -57,7 +57,7 @@ int git__delta_apply(
|
|
57
57
|
size_t delta_len)
|
58
58
|
{
|
59
59
|
const unsigned char *delta_end = delta + delta_len;
|
60
|
-
size_t base_sz, res_sz;
|
60
|
+
size_t base_sz, res_sz, alloc_sz;
|
61
61
|
unsigned char *res_dp;
|
62
62
|
|
63
63
|
/* Check that the base size matches the data we were given;
|
@@ -74,7 +74,8 @@ int git__delta_apply(
|
|
74
74
|
return -1;
|
75
75
|
}
|
76
76
|
|
77
|
-
|
77
|
+
GITERR_CHECK_ALLOC_ADD(&alloc_sz, res_sz, 1);
|
78
|
+
res_dp = git__malloc(alloc_sz);
|
78
79
|
GITERR_CHECK_ALLOC(res_dp);
|
79
80
|
|
80
81
|
res_dp[res_sz] = '\0';
|
data/vendor/libgit2/src/delta.c
CHANGED
@@ -119,6 +119,29 @@ struct git_delta_index {
|
|
119
119
|
struct index_entry *hash[GIT_FLEX_ARRAY];
|
120
120
|
};
|
121
121
|
|
122
|
+
static int lookup_index_alloc(
|
123
|
+
void **out, unsigned long *out_len, size_t entries, size_t hash_count)
|
124
|
+
{
|
125
|
+
size_t entries_len, hash_len, index_len;
|
126
|
+
|
127
|
+
GITERR_CHECK_ALLOC_MULTIPLY(&entries_len, entries, sizeof(struct index_entry));
|
128
|
+
GITERR_CHECK_ALLOC_MULTIPLY(&hash_len, hash_count, sizeof(struct index_entry *));
|
129
|
+
|
130
|
+
GITERR_CHECK_ALLOC_ADD(&index_len, sizeof(struct git_delta_index), entries_len);
|
131
|
+
GITERR_CHECK_ALLOC_ADD(&index_len, index_len, hash_len);
|
132
|
+
|
133
|
+
if (!git__is_ulong(index_len)) {
|
134
|
+
giterr_set(GITERR_NOMEMORY, "Overly large delta");
|
135
|
+
return -1;
|
136
|
+
}
|
137
|
+
|
138
|
+
*out = git__malloc(index_len);
|
139
|
+
GITERR_CHECK_ALLOC(*out);
|
140
|
+
|
141
|
+
*out_len = index_len;
|
142
|
+
return 0;
|
143
|
+
}
|
144
|
+
|
122
145
|
struct git_delta_index *
|
123
146
|
git_delta_create_index(const void *buf, unsigned long bufsize)
|
124
147
|
{
|
@@ -148,13 +171,9 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
|
|
148
171
|
hsize = 1 << i;
|
149
172
|
hmask = hsize - 1;
|
150
173
|
|
151
|
-
|
152
|
-
memsize = sizeof(*index) +
|
153
|
-
sizeof(*hash) * hsize +
|
154
|
-
sizeof(*entry) * entries;
|
155
|
-
mem = git__malloc(memsize);
|
156
|
-
if (!mem)
|
174
|
+
if (lookup_index_alloc(&mem, &memsize, entries, hsize) < 0)
|
157
175
|
return NULL;
|
176
|
+
|
158
177
|
index = mem;
|
159
178
|
mem = index->hash;
|
160
179
|
hash = mem;
|
data/vendor/libgit2/src/diff.c
CHANGED
@@ -461,12 +461,13 @@ static int diff_list_apply_options(
|
|
461
461
|
|
462
462
|
/* if ignore_submodules not explicitly set, check diff config */
|
463
463
|
if (diff->opts.ignore_submodules <= 0) {
|
464
|
-
|
464
|
+
git_config_entry *entry;
|
465
465
|
git_config__lookup_entry(&entry, cfg, "diff.ignoresubmodules", true);
|
466
466
|
|
467
467
|
if (entry && git_submodule_parse_ignore(
|
468
468
|
&diff->opts.ignore_submodules, entry->value) < 0)
|
469
469
|
giterr_clear();
|
470
|
+
git_config_entry_free(entry);
|
470
471
|
}
|
471
472
|
|
472
473
|
/* if either prefix is not set, figure out appropriate value */
|
@@ -600,7 +601,7 @@ int git_diff__oid_for_entry(
|
|
600
601
|
error = -1;
|
601
602
|
} else if (!(error = git_filter_list_load(
|
602
603
|
&fl, diff->repo, NULL, entry.path,
|
603
|
-
GIT_FILTER_TO_ODB,
|
604
|
+
GIT_FILTER_TO_ODB, GIT_FILTER_ALLOW_UNSAFE)))
|
604
605
|
{
|
605
606
|
int fd = git_futils_open_ro(full_path.ptr);
|
606
607
|
if (fd < 0)
|
@@ -619,10 +620,9 @@ int git_diff__oid_for_entry(
|
|
619
620
|
if (!error && update_match && git_oid_equal(out, update_match)) {
|
620
621
|
git_index *idx;
|
621
622
|
|
622
|
-
if (!(error =
|
623
|
+
if (!(error = git_repository_index__weakptr(&idx, diff->repo))) {
|
623
624
|
memcpy(&entry.id, out, sizeof(entry.id));
|
624
625
|
error = git_index_add(idx, &entry);
|
625
|
-
git_index_free(idx);
|
626
626
|
}
|
627
627
|
}
|
628
628
|
|
@@ -1527,6 +1527,7 @@ int git_diff_format_email(
|
|
1527
1527
|
char *summary = NULL, *loc = NULL;
|
1528
1528
|
bool ignore_marker;
|
1529
1529
|
unsigned int format_flags = 0;
|
1530
|
+
size_t allocsize;
|
1530
1531
|
int error;
|
1531
1532
|
|
1532
1533
|
assert(out && diff && opts);
|
@@ -1558,8 +1559,10 @@ int git_diff_format_email(
|
|
1558
1559
|
goto on_error;
|
1559
1560
|
}
|
1560
1561
|
|
1561
|
-
|
1562
|
+
GITERR_CHECK_ALLOC_ADD(&allocsize, offset, 1);
|
1563
|
+
summary = git__calloc(allocsize, sizeof(char));
|
1562
1564
|
GITERR_CHECK_ALLOC(summary);
|
1565
|
+
|
1563
1566
|
strncpy(summary, opts->summary, offset);
|
1564
1567
|
}
|
1565
1568
|
|
@@ -17,7 +17,7 @@
|
|
17
17
|
#include "config.h"
|
18
18
|
#include "repository.h"
|
19
19
|
|
20
|
-
GIT__USE_STRMAP
|
20
|
+
GIT__USE_STRMAP
|
21
21
|
|
22
22
|
typedef enum {
|
23
23
|
DIFF_DRIVER_AUTO = 0,
|
@@ -158,6 +158,30 @@ static git_diff_driver_registry *git_repository_driver_registry(
|
|
158
158
|
return repo->diff_drivers;
|
159
159
|
}
|
160
160
|
|
161
|
+
static int diff_driver_alloc(
|
162
|
+
git_diff_driver **out, size_t *namelen_out, const char *name)
|
163
|
+
{
|
164
|
+
git_diff_driver *driver;
|
165
|
+
size_t driverlen = sizeof(git_diff_driver),
|
166
|
+
namelen = strlen(name),
|
167
|
+
alloclen;
|
168
|
+
|
169
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, driverlen, namelen);
|
170
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
|
171
|
+
|
172
|
+
driver = git__calloc(1, alloclen);
|
173
|
+
GITERR_CHECK_ALLOC(driver);
|
174
|
+
|
175
|
+
memcpy(driver->name, name, namelen);
|
176
|
+
|
177
|
+
*out = driver;
|
178
|
+
|
179
|
+
if (namelen_out)
|
180
|
+
*namelen_out = namelen;
|
181
|
+
|
182
|
+
return 0;
|
183
|
+
}
|
184
|
+
|
161
185
|
static int git_diff_driver_builtin(
|
162
186
|
git_diff_driver **out,
|
163
187
|
git_diff_driver_registry *reg,
|
@@ -166,7 +190,7 @@ static int git_diff_driver_builtin(
|
|
166
190
|
int error = 0;
|
167
191
|
git_diff_driver_definition *ddef = NULL;
|
168
192
|
git_diff_driver *drv = NULL;
|
169
|
-
size_t
|
193
|
+
size_t idx;
|
170
194
|
|
171
195
|
for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) {
|
172
196
|
if (!strcasecmp(driver_name, builtin_defs[idx].name)) {
|
@@ -177,13 +201,10 @@ static int git_diff_driver_builtin(
|
|
177
201
|
if (!ddef)
|
178
202
|
goto done;
|
179
203
|
|
180
|
-
|
181
|
-
|
182
|
-
drv = git__calloc(1, sizeof(git_diff_driver) + namelen + 1);
|
183
|
-
GITERR_CHECK_ALLOC(drv);
|
204
|
+
if ((error = diff_driver_alloc(&drv, NULL, ddef->name)) < 0)
|
205
|
+
goto done;
|
184
206
|
|
185
207
|
drv->type = DIFF_DRIVER_PATTERNLIST;
|
186
|
-
memcpy(drv->name, ddef->name, namelen);
|
187
208
|
|
188
209
|
if (ddef->fns &&
|
189
210
|
(error = diff_driver_add_patterns(
|
@@ -217,11 +238,11 @@ static int git_diff_driver_load(
|
|
217
238
|
int error = 0;
|
218
239
|
git_diff_driver_registry *reg;
|
219
240
|
git_diff_driver *drv = NULL;
|
220
|
-
size_t namelen
|
241
|
+
size_t namelen;
|
221
242
|
khiter_t pos;
|
222
|
-
git_config *cfg;
|
243
|
+
git_config *cfg = NULL;
|
223
244
|
git_buf name = GIT_BUF_INIT;
|
224
|
-
|
245
|
+
git_config_entry *ce = NULL;
|
225
246
|
bool found_driver = false;
|
226
247
|
|
227
248
|
if ((reg = git_repository_driver_registry(repo)) == NULL)
|
@@ -233,10 +254,10 @@ static int git_diff_driver_load(
|
|
233
254
|
return 0;
|
234
255
|
}
|
235
256
|
|
236
|
-
|
237
|
-
|
257
|
+
if ((error = diff_driver_alloc(&drv, &namelen, driver_name)) < 0)
|
258
|
+
goto done;
|
259
|
+
|
238
260
|
drv->type = DIFF_DRIVER_AUTO;
|
239
|
-
memcpy(drv->name, driver_name, namelen);
|
240
261
|
|
241
262
|
/* if you can't read config for repo, just use default driver */
|
242
263
|
if (git_repository_config_snapshot(&cfg, repo) < 0) {
|
@@ -320,6 +341,7 @@ static int git_diff_driver_load(
|
|
320
341
|
*out = drv;
|
321
342
|
|
322
343
|
done:
|
344
|
+
git_config_entry_free(ce);
|
323
345
|
git_buf_free(&name);
|
324
346
|
git_config_free(cfg);
|
325
347
|
|
@@ -397,14 +419,13 @@ void git_diff_driver_update_options(
|
|
397
419
|
int git_diff_driver_content_is_binary(
|
398
420
|
git_diff_driver *driver, const char *content, size_t content_len)
|
399
421
|
{
|
400
|
-
git_buf search;
|
401
|
-
|
402
|
-
search.ptr = (char *)content;
|
403
|
-
search.size = min(content_len, GIT_FILTER_BYTES_TO_CHECK_NUL);
|
404
|
-
search.asize = 0;
|
422
|
+
git_buf search = GIT_BUF_INIT;
|
405
423
|
|
406
424
|
GIT_UNUSED(driver);
|
407
425
|
|
426
|
+
git_buf_attach_notowned(&search, content,
|
427
|
+
min(content_len, GIT_FILTER_BYTES_TO_CHECK_NUL));
|
428
|
+
|
408
429
|
/* TODO: provide encoding / binary detection callbacks that can
|
409
430
|
* be UTF-8 aware, etc. For now, instead of trying to be smart,
|
410
431
|
* let's just use the simple NUL-byte detection that core git uses.
|