rugged 0.24.6.1 → 0.25.0b1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/rugged/rugged_repo.c +44 -36
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +10 -21
- data/vendor/libgit2/include/git2/checkout.h +0 -7
- data/vendor/libgit2/include/git2/commit.h +46 -0
- data/vendor/libgit2/include/git2/common.h +1 -16
- data/vendor/libgit2/include/git2/odb.h +47 -1
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/array.h +0 -40
- data/vendor/libgit2/src/blame.c +3 -8
- data/vendor/libgit2/src/blame_git.c +9 -20
- data/vendor/libgit2/src/checkout.c +5 -13
- data/vendor/libgit2/src/commit.c +132 -52
- data/vendor/libgit2/src/common.h +1 -1
- data/vendor/libgit2/src/config_cache.c +1 -2
- data/vendor/libgit2/src/config_file.c +20 -14
- data/vendor/libgit2/src/delta-apply.c +5 -36
- data/vendor/libgit2/src/delta-apply.h +0 -12
- data/vendor/libgit2/src/describe.c +1 -2
- data/vendor/libgit2/src/diff_tform.c +3 -5
- data/vendor/libgit2/src/filebuf.c +1 -6
- data/vendor/libgit2/src/global.c +8 -28
- data/vendor/libgit2/src/global.h +0 -1
- data/vendor/libgit2/src/ignore.c +19 -56
- data/vendor/libgit2/src/index.c +8 -27
- data/vendor/libgit2/src/indexer.c +7 -11
- data/vendor/libgit2/src/iterator.c +2 -2
- data/vendor/libgit2/src/merge.c +0 -1
- data/vendor/libgit2/src/mwindow.c +19 -8
- data/vendor/libgit2/src/mwindow.h +2 -1
- data/vendor/libgit2/src/object.c +6 -3
- data/vendor/libgit2/src/odb.c +188 -48
- data/vendor/libgit2/src/odb_loose.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +3 -0
- data/vendor/libgit2/src/openssl_stream.c +27 -60
- data/vendor/libgit2/src/openssl_stream.h +0 -106
- data/vendor/libgit2/src/pack-objects.c +2 -4
- data/vendor/libgit2/src/pack.c +9 -5
- data/vendor/libgit2/src/posix.c +0 -7
- data/vendor/libgit2/src/posix.h +0 -1
- data/vendor/libgit2/src/push.c +6 -6
- data/vendor/libgit2/src/refdb_fs.c +0 -1
- data/vendor/libgit2/src/refs.c +0 -3
- data/vendor/libgit2/src/refspec.c +2 -4
- data/vendor/libgit2/src/remote.c +5 -15
- data/vendor/libgit2/src/repository.c +21 -29
- data/vendor/libgit2/src/settings.c +1 -23
- data/vendor/libgit2/src/stransport_stream.c +9 -15
- data/vendor/libgit2/src/submodule.c +2 -3
- data/vendor/libgit2/src/sysdir.c +47 -41
- data/vendor/libgit2/src/sysdir.h +5 -0
- data/vendor/libgit2/src/tag.c +2 -8
- data/vendor/libgit2/src/thread-utils.h +51 -5
- data/vendor/libgit2/src/transports/http.c +3 -3
- data/vendor/libgit2/src/transports/smart_pkt.c +4 -13
- data/vendor/libgit2/src/transports/smart_protocol.c +17 -61
- data/vendor/libgit2/src/tree.c +100 -83
- data/vendor/libgit2/src/tree.h +5 -4
- data/vendor/libgit2/src/unix/map.c +0 -5
- data/vendor/libgit2/src/util.c +3 -3
- data/vendor/libgit2/src/win32/map.c +5 -24
- data/vendor/libgit2/src/win32/precompiled.h +1 -1
- data/vendor/libgit2/src/win32/{thread.c → pthread.c} +80 -50
- data/vendor/libgit2/src/win32/pthread.h +92 -0
- data/vendor/libgit2/src/xdiff/xprepare.c +1 -2
- metadata +7 -8
- data/vendor/libgit2/src/unix/pthread.h +0 -54
- data/vendor/libgit2/src/win32/thread.h +0 -62
data/vendor/libgit2/src/blame.c
CHANGED
@@ -178,7 +178,7 @@ const git_blame_hunk *git_blame_get_hunk_byline(git_blame *blame, size_t lineno)
|
|
178
178
|
return NULL;
|
179
179
|
}
|
180
180
|
|
181
|
-
static
|
181
|
+
static void normalize_options(
|
182
182
|
git_blame_options *out,
|
183
183
|
const git_blame_options *in,
|
184
184
|
git_repository *repo)
|
@@ -190,9 +190,7 @@ static int normalize_options(
|
|
190
190
|
|
191
191
|
/* No newest_commit => HEAD */
|
192
192
|
if (git_oid_iszero(&out->newest_commit)) {
|
193
|
-
|
194
|
-
return -1;
|
195
|
-
}
|
193
|
+
git_reference_name_to_id(&out->newest_commit, repo, "HEAD");
|
196
194
|
}
|
197
195
|
|
198
196
|
/* min_line 0 really means 1 */
|
@@ -206,8 +204,6 @@ static int normalize_options(
|
|
206
204
|
out->flags |= GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES;
|
207
205
|
if (out->flags & GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES)
|
208
206
|
out->flags |= GIT_BLAME_TRACK_COPIES_SAME_FILE;
|
209
|
-
|
210
|
-
return 0;
|
211
207
|
}
|
212
208
|
|
213
209
|
static git_blame_hunk *split_hunk_in_vector(
|
@@ -366,8 +362,7 @@ int git_blame_file(
|
|
366
362
|
git_blame *blame = NULL;
|
367
363
|
|
368
364
|
assert(out && repo && path);
|
369
|
-
|
370
|
-
goto on_error;
|
365
|
+
normalize_options(&normOptions, options, repo);
|
371
366
|
|
372
367
|
blame = git_blame__alloc(repo, normOptions, path);
|
373
368
|
GITERR_CHECK_ALLOC(blame);
|
@@ -37,27 +37,25 @@ static void origin_decref(git_blame__origin *o)
|
|
37
37
|
static int make_origin(git_blame__origin **out, git_commit *commit, const char *path)
|
38
38
|
{
|
39
39
|
git_blame__origin *o;
|
40
|
-
git_object *blob;
|
41
40
|
size_t path_len = strlen(path), alloc_len;
|
42
41
|
int error = 0;
|
43
42
|
|
44
|
-
if ((error = git_object_lookup_bypath(&blob, (git_object*)commit,
|
45
|
-
path, GIT_OBJ_BLOB)) < 0)
|
46
|
-
return error;
|
47
|
-
|
48
43
|
GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*o), path_len);
|
49
44
|
GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1);
|
50
45
|
o = git__calloc(1, alloc_len);
|
51
46
|
GITERR_CHECK_ALLOC(o);
|
52
47
|
|
53
48
|
o->commit = commit;
|
54
|
-
o->blob = (git_blob *) blob;
|
55
49
|
o->refcnt = 1;
|
56
50
|
strcpy(o->path, path);
|
57
51
|
|
58
|
-
|
59
|
-
|
60
|
-
|
52
|
+
if (!(error = git_object_lookup_bypath((git_object**)&o->blob, (git_object*)commit,
|
53
|
+
path, GIT_OBJ_BLOB))) {
|
54
|
+
*out = o;
|
55
|
+
} else {
|
56
|
+
origin_decref(o);
|
57
|
+
}
|
58
|
+
return error;
|
61
59
|
}
|
62
60
|
|
63
61
|
/* Locate an existing origin or create a new one. */
|
@@ -527,20 +525,11 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
|
|
527
525
|
if (sg_origin[i])
|
528
526
|
continue;
|
529
527
|
|
530
|
-
|
531
|
-
goto finish;
|
528
|
+
git_commit_parent(&p, origin->commit, i);
|
532
529
|
porigin = find_origin(blame, p, origin);
|
533
530
|
|
534
|
-
if (!porigin)
|
535
|
-
/*
|
536
|
-
* We only have to decrement the parent's
|
537
|
-
* reference count when no porigin has
|
538
|
-
* been created, as otherwise the commit
|
539
|
-
* is assigned to the created object.
|
540
|
-
*/
|
541
|
-
git_commit_free(p);
|
531
|
+
if (!porigin)
|
542
532
|
continue;
|
543
|
-
}
|
544
533
|
if (porigin->blob && origin->blob &&
|
545
534
|
!git_oid_cmp(git_blob_id(porigin->blob), git_blob_id(origin->blob))) {
|
546
535
|
pass_whole_blame(blame, origin, porigin);
|
@@ -464,8 +464,7 @@ static int checkout_action_with_wd(
|
|
464
464
|
*action = CHECKOUT_ACTION_IF(SAFE, REMOVE, NONE);
|
465
465
|
break;
|
466
466
|
case GIT_DELTA_MODIFIED: /* case 16, 17, 18 (or 36 but not really) */
|
467
|
-
if (
|
468
|
-
checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
|
467
|
+
if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
|
469
468
|
*action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
|
470
469
|
else
|
471
470
|
*action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
|
@@ -1343,11 +1342,9 @@ fail:
|
|
1343
1342
|
|
1344
1343
|
static bool should_remove_existing(checkout_data *data)
|
1345
1344
|
{
|
1346
|
-
int ignorecase;
|
1345
|
+
int ignorecase = 0;
|
1347
1346
|
|
1348
|
-
|
1349
|
-
ignorecase = 0;
|
1350
|
-
}
|
1347
|
+
git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE);
|
1351
1348
|
|
1352
1349
|
return (ignorecase &&
|
1353
1350
|
(data->strategy & GIT_CHECKOUT_DONT_REMOVE_EXISTING) == 0);
|
@@ -2408,13 +2405,8 @@ static int checkout_data_init(
|
|
2408
2405
|
|
2409
2406
|
if (!data->opts.baseline && !data->opts.baseline_index) {
|
2410
2407
|
data->opts_free_baseline = true;
|
2411
|
-
error = 0;
|
2412
2408
|
|
2413
|
-
|
2414
|
-
* should be against an empty baseline
|
2415
|
-
*/
|
2416
|
-
if (data->index->on_disk)
|
2417
|
-
error = checkout_lookup_head_tree(&data->opts.baseline, repo);
|
2409
|
+
error = checkout_lookup_head_tree(&data->opts.baseline, repo);
|
2418
2410
|
|
2419
2411
|
if (error == GIT_EUNBORNBRANCH) {
|
2420
2412
|
error = 0;
|
@@ -2699,7 +2691,7 @@ int git_checkout_tree(
|
|
2699
2691
|
if ((error = git_repository_index(&index, repo)) < 0)
|
2700
2692
|
return error;
|
2701
2693
|
|
2702
|
-
if (
|
2694
|
+
if ((opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
|
2703
2695
|
iter_opts.pathlist.count = opts->paths.count;
|
2704
2696
|
iter_opts.pathlist.strings = opts->paths.strings;
|
2705
2697
|
}
|
data/vendor/libgit2/src/commit.c
CHANGED
@@ -18,6 +18,7 @@
|
|
18
18
|
#include "message.h"
|
19
19
|
#include "refs.h"
|
20
20
|
#include "object.h"
|
21
|
+
#include "oidarray.h"
|
21
22
|
|
22
23
|
void git_commit__free(void *_commit)
|
23
24
|
{
|
@@ -37,94 +38,143 @@ void git_commit__free(void *_commit)
|
|
37
38
|
git__free(commit);
|
38
39
|
}
|
39
40
|
|
40
|
-
static int
|
41
|
-
|
41
|
+
static int git_commit__create_buffer_internal(
|
42
|
+
git_buf *out,
|
42
43
|
git_repository *repo,
|
43
|
-
const char *update_ref,
|
44
44
|
const git_signature *author,
|
45
45
|
const git_signature *committer,
|
46
46
|
const char *message_encoding,
|
47
47
|
const char *message,
|
48
48
|
const git_oid *tree,
|
49
|
-
|
50
|
-
void *parent_payload,
|
51
|
-
bool validate)
|
49
|
+
git_array_oid_t *parents)
|
52
50
|
{
|
53
|
-
git_reference *ref = NULL;
|
54
|
-
int error = 0, matched_parent = 0;
|
55
|
-
const git_oid *current_id = NULL;
|
56
|
-
git_buf commit = GIT_BUF_INIT;
|
57
51
|
size_t i = 0;
|
58
|
-
git_odb *odb;
|
59
52
|
const git_oid *parent;
|
60
53
|
|
61
|
-
assert(
|
54
|
+
assert(out && repo && tree);
|
62
55
|
|
63
|
-
|
64
|
-
return -1;
|
56
|
+
git_oid__writebuf(out, "tree ", tree);
|
65
57
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
return error;
|
58
|
+
for (i = 0; i < git_array_size(*parents); i++) {
|
59
|
+
parent = git_array_get(*parents, i);
|
60
|
+
git_oid__writebuf(out, "parent ", parent);
|
70
61
|
}
|
71
|
-
giterr_clear();
|
72
62
|
|
73
|
-
|
74
|
-
|
63
|
+
git_signature__writebuf(out, "author ", author);
|
64
|
+
git_signature__writebuf(out, "committer ", committer);
|
65
|
+
|
66
|
+
if (message_encoding != NULL)
|
67
|
+
git_buf_printf(out, "encoding %s\n", message_encoding);
|
68
|
+
|
69
|
+
git_buf_putc(out, '\n');
|
75
70
|
|
76
|
-
|
71
|
+
if (git_buf_puts(out, message) < 0)
|
72
|
+
goto on_error;
|
73
|
+
|
74
|
+
return 0;
|
75
|
+
|
76
|
+
on_error:
|
77
|
+
git_buf_free(out);
|
78
|
+
return -1;
|
79
|
+
}
|
77
80
|
|
81
|
+
static int validate_tree_and_parents(git_array_oid_t *parents, git_repository *repo, const git_oid *tree,
|
82
|
+
git_commit_parent_callback parent_cb, void *parent_payload,
|
83
|
+
const git_oid *current_id, bool validate)
|
84
|
+
{
|
85
|
+
size_t i;
|
86
|
+
int error;
|
87
|
+
git_oid *parent_cpy;
|
88
|
+
const git_oid *parent;
|
89
|
+
|
90
|
+
if (validate && !git_object__is_valid(repo, tree, GIT_OBJ_TREE))
|
91
|
+
return -1;
|
92
|
+
|
93
|
+
i = 0;
|
78
94
|
while ((parent = parent_cb(i, parent_payload)) != NULL) {
|
79
95
|
if (validate && !git_object__is_valid(repo, parent, GIT_OBJ_COMMIT)) {
|
80
96
|
error = -1;
|
81
97
|
goto on_error;
|
82
98
|
}
|
83
99
|
|
84
|
-
|
85
|
-
|
86
|
-
|
100
|
+
parent_cpy = git_array_alloc(*parents);
|
101
|
+
GITERR_CHECK_ALLOC(parent_cpy);
|
102
|
+
|
103
|
+
git_oid_cpy(parent_cpy, parent);
|
87
104
|
i++;
|
88
105
|
}
|
89
106
|
|
90
|
-
if (
|
91
|
-
git_reference_free(ref);
|
92
|
-
git_buf_free(&commit);
|
107
|
+
if (current_id && git_oid_cmp(current_id, git_array_get(*parents, 0))) {
|
93
108
|
giterr_set(GITERR_OBJECT, "failed to create commit: current tip is not the first parent");
|
94
|
-
|
109
|
+
error = GIT_EMODIFIED;
|
110
|
+
goto on_error;
|
95
111
|
}
|
96
112
|
|
97
|
-
|
98
|
-
git_signature__writebuf(&commit, "committer ", committer);
|
113
|
+
return 0;
|
99
114
|
|
100
|
-
|
101
|
-
|
115
|
+
on_error:
|
116
|
+
git_array_clear(*parents);
|
117
|
+
return error;
|
118
|
+
}
|
119
|
+
|
120
|
+
static int git_commit__create_internal(
|
121
|
+
git_oid *id,
|
122
|
+
git_repository *repo,
|
123
|
+
const char *update_ref,
|
124
|
+
const git_signature *author,
|
125
|
+
const git_signature *committer,
|
126
|
+
const char *message_encoding,
|
127
|
+
const char *message,
|
128
|
+
const git_oid *tree,
|
129
|
+
git_commit_parent_callback parent_cb,
|
130
|
+
void *parent_payload,
|
131
|
+
bool validate)
|
132
|
+
{
|
133
|
+
int error;
|
134
|
+
git_odb *odb;
|
135
|
+
git_reference *ref = NULL;
|
136
|
+
git_buf buf = GIT_BUF_INIT;
|
137
|
+
const git_oid *current_id = NULL;
|
138
|
+
git_array_oid_t parents = GIT_ARRAY_INIT;
|
102
139
|
|
103
|
-
|
140
|
+
if (update_ref) {
|
141
|
+
error = git_reference_lookup_resolved(&ref, repo, update_ref, 10);
|
142
|
+
if (error < 0 && error != GIT_ENOTFOUND)
|
143
|
+
return error;
|
144
|
+
}
|
145
|
+
giterr_clear();
|
104
146
|
|
105
|
-
if (
|
106
|
-
|
147
|
+
if (ref)
|
148
|
+
current_id = git_reference_target(ref);
|
149
|
+
|
150
|
+
if ((error = validate_tree_and_parents(&parents, repo, tree, parent_cb, parent_payload, current_id, validate)) < 0)
|
151
|
+
goto cleanup;
|
152
|
+
|
153
|
+
error = git_commit__create_buffer_internal(&buf, repo, author, committer,
|
154
|
+
message_encoding, message, tree,
|
155
|
+
&parents);
|
156
|
+
|
157
|
+
if (error < 0)
|
158
|
+
goto cleanup;
|
107
159
|
|
108
160
|
if (git_repository_odb__weakptr(&odb, repo) < 0)
|
109
|
-
goto
|
161
|
+
goto cleanup;
|
110
162
|
|
111
|
-
if (git_odb_write(id, odb,
|
112
|
-
goto
|
163
|
+
if (git_odb_write(id, odb, buf.ptr, buf.size, GIT_OBJ_COMMIT) < 0)
|
164
|
+
goto cleanup;
|
113
165
|
|
114
|
-
git_buf_free(&commit);
|
115
166
|
|
116
167
|
if (update_ref != NULL) {
|
117
168
|
error = git_reference__update_for_commit(
|
118
169
|
repo, ref, update_ref, id, "commit");
|
119
|
-
|
120
|
-
return error;
|
170
|
+
goto cleanup;
|
121
171
|
}
|
122
172
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
git_buf_free(&
|
127
|
-
return
|
173
|
+
cleanup:
|
174
|
+
git_array_clear(parents);
|
175
|
+
git_reference_free(ref);
|
176
|
+
git_buf_free(&buf);
|
177
|
+
return error;
|
128
178
|
}
|
129
179
|
|
130
180
|
int git_commit_create_from_callback(
|
@@ -410,11 +460,10 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
|
|
410
460
|
buffer = buffer_start + header_len + 1;
|
411
461
|
|
412
462
|
/* extract commit message */
|
413
|
-
if (buffer <= buffer_end)
|
463
|
+
if (buffer <= buffer_end) {
|
414
464
|
commit->raw_message = git__strndup(buffer, buffer_end - buffer);
|
415
|
-
|
416
|
-
|
417
|
-
GITERR_CHECK_ALLOC(commit->raw_message);
|
465
|
+
GITERR_CHECK_ALLOC(commit->raw_message);
|
466
|
+
}
|
418
467
|
|
419
468
|
return 0;
|
420
469
|
|
@@ -677,7 +726,7 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
|
|
677
726
|
|
678
727
|
buf = git_odb_object_data(obj);
|
679
728
|
|
680
|
-
while ((h = strchr(buf, '\n')) && h[1] != '\0') {
|
729
|
+
while ((h = strchr(buf, '\n')) && h[1] != '\0' && h[1] != '\n') {
|
681
730
|
h++;
|
682
731
|
if (git__prefixcmp(buf, field)) {
|
683
732
|
if (git_buf_put(signed_data, buf, h - buf) < 0)
|
@@ -740,3 +789,34 @@ cleanup:
|
|
740
789
|
git_buf_clear(signed_data);
|
741
790
|
return error;
|
742
791
|
}
|
792
|
+
|
793
|
+
int git_commit_create_buffer(git_buf *out,
|
794
|
+
git_repository *repo,
|
795
|
+
const git_signature *author,
|
796
|
+
const git_signature *committer,
|
797
|
+
const char *message_encoding,
|
798
|
+
const char *message,
|
799
|
+
const git_tree *tree,
|
800
|
+
size_t parent_count,
|
801
|
+
const git_commit *parents[])
|
802
|
+
{
|
803
|
+
int error;
|
804
|
+
commit_parent_data data = { parent_count, parents, repo };
|
805
|
+
git_array_oid_t parents_arr = GIT_ARRAY_INIT;
|
806
|
+
const git_oid *tree_id;
|
807
|
+
|
808
|
+
assert(tree && git_tree_owner(tree) == repo);
|
809
|
+
|
810
|
+
tree_id = git_tree_id(tree);
|
811
|
+
|
812
|
+
if ((error = validate_tree_and_parents(&parents_arr, repo, tree_id, commit_parent_from_array, &data, NULL, true)) < 0)
|
813
|
+
return error;
|
814
|
+
|
815
|
+
error = git_commit__create_buffer_internal(
|
816
|
+
out, repo, author, committer,
|
817
|
+
message_encoding, message, tree_id,
|
818
|
+
&parents_arr);
|
819
|
+
|
820
|
+
git_array_clear(parents_arr);
|
821
|
+
return error;
|
822
|
+
}
|
data/vendor/libgit2/src/common.h
CHANGED
@@ -86,8 +86,7 @@ int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar)
|
|
86
86
|
struct map_data *data = &_cvar_maps[(int)cvar];
|
87
87
|
git_config_entry *entry;
|
88
88
|
|
89
|
-
|
90
|
-
return error;
|
89
|
+
git_config__lookup_entry(&entry, config, data->cvar_name, false);
|
91
90
|
|
92
91
|
if (!entry)
|
93
92
|
*out = data->default_value;
|
@@ -553,15 +553,30 @@ static int config_set_multivar(
|
|
553
553
|
git_config_backend *cfg, const char *name, const char *regexp, const char *value)
|
554
554
|
{
|
555
555
|
diskfile_backend *b = (diskfile_backend *)cfg;
|
556
|
+
refcounted_strmap *map;
|
557
|
+
git_strmap *values;
|
556
558
|
char *key;
|
557
559
|
regex_t preg;
|
558
560
|
int result;
|
561
|
+
khiter_t pos;
|
559
562
|
|
560
563
|
assert(regexp);
|
561
564
|
|
562
565
|
if ((result = git_config__normalize_name(name, &key)) < 0)
|
563
566
|
return result;
|
564
567
|
|
568
|
+
map = refcounted_strmap_take(&b->header);
|
569
|
+
values = b->header.values->values;
|
570
|
+
|
571
|
+
pos = git_strmap_lookup_index(values, key);
|
572
|
+
if (!git_strmap_valid_index(values, pos)) {
|
573
|
+
/* If we don't have it, behave like a normal set */
|
574
|
+
result = config_set(cfg, name, value);
|
575
|
+
refcounted_strmap_free(map);
|
576
|
+
git__free(key);
|
577
|
+
return result;
|
578
|
+
}
|
579
|
+
|
565
580
|
result = regcomp(&preg, regexp, REG_EXTENDED);
|
566
581
|
if (result != 0) {
|
567
582
|
giterr_set_regex(&preg, result);
|
@@ -576,6 +591,7 @@ static int config_set_multivar(
|
|
576
591
|
result = config_refresh(cfg);
|
577
592
|
|
578
593
|
out:
|
594
|
+
refcounted_strmap_free(map);
|
579
595
|
git__free(key);
|
580
596
|
regfree(&preg);
|
581
597
|
|
@@ -1016,11 +1032,6 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
|
|
1016
1032
|
*/
|
1017
1033
|
|
1018
1034
|
first_quote = strchr(line, '"');
|
1019
|
-
if (first_quote == NULL) {
|
1020
|
-
set_parse_error(reader, 0, "Missing quotation marks in section header");
|
1021
|
-
return -1;
|
1022
|
-
}
|
1023
|
-
|
1024
1035
|
last_quote = strrchr(line, '"');
|
1025
1036
|
quoted_len = last_quote - first_quote;
|
1026
1037
|
|
@@ -1472,7 +1483,7 @@ static int config_parse(
|
|
1472
1483
|
int (*on_section)(struct reader **reader, const char *current_section, const char *line, size_t line_len, void *data),
|
1473
1484
|
int (*on_variable)(struct reader **reader, const char *current_section, char *var_name, char *var_value, const char *line, size_t line_len, void *data),
|
1474
1485
|
int (*on_comment)(struct reader **reader, const char *line, size_t line_len, void *data),
|
1475
|
-
int (*on_eof)(struct reader **reader,
|
1486
|
+
int (*on_eof)(struct reader **reader, void *data),
|
1476
1487
|
void *data)
|
1477
1488
|
{
|
1478
1489
|
char *current_section = NULL, *var_name, *var_value, *line_start;
|
@@ -1523,7 +1534,7 @@ static int config_parse(
|
|
1523
1534
|
}
|
1524
1535
|
|
1525
1536
|
if (on_eof)
|
1526
|
-
result = on_eof(&reader,
|
1537
|
+
result = on_eof(&reader, data);
|
1527
1538
|
|
1528
1539
|
git__free(current_section);
|
1529
1540
|
return result;
|
@@ -1839,8 +1850,7 @@ static int write_on_comment(struct reader **reader, const char *line, size_t lin
|
|
1839
1850
|
return write_line_to(&write_data->buffered_comment, line, line_len);
|
1840
1851
|
}
|
1841
1852
|
|
1842
|
-
static int write_on_eof(
|
1843
|
-
struct reader **reader, const char *current_section, void *data)
|
1853
|
+
static int write_on_eof(struct reader **reader, void *data)
|
1844
1854
|
{
|
1845
1855
|
struct write_data *write_data = (struct write_data *)data;
|
1846
1856
|
int result = 0;
|
@@ -1859,11 +1869,7 @@ static int write_on_eof(
|
|
1859
1869
|
* value.
|
1860
1870
|
*/
|
1861
1871
|
if ((!write_data->preg || !write_data->preg_replaced) && write_data->value) {
|
1862
|
-
|
1863
|
-
if (!current_section || strcmp(current_section, write_data->section))
|
1864
|
-
result = write_section(write_data->buf, write_data->section);
|
1865
|
-
|
1866
|
-
if (!result)
|
1872
|
+
if ((result = write_section(write_data->buf, write_data->section)) == 0)
|
1867
1873
|
result = write_value(write_data);
|
1868
1874
|
}
|
1869
1875
|
|