Skip to content

Commit 4516ca1

Browse files
authored
Merge pull request libgit2#6829 from libgit2/ethomson/fix_constness
Fix constness issue introduced in libgit2#6716
2 parents 93cb09f + 49d3fad commit 4516ca1

File tree

17 files changed

+36
-33
lines changed

17 files changed

+36
-33
lines changed

examples/merge.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, struct me
263263
sign, sign,
264264
NULL, msg,
265265
tree,
266-
opts->annotated_count + 1, parents);
266+
opts->annotated_count + 1, (const git_commit **)parents);
267267
check_lg2(err, "failed to create commit", NULL);
268268

269269
/* We're done merging, cleanup the repository state */

include/git2/commit.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ GIT_EXTERN(int) git_commit_create(
366366
const char *message,
367367
const git_tree *tree,
368368
size_t parent_count,
369-
git_commit * const parents[]);
369+
const git_commit *parents[]);
370370

371371
/**
372372
* Create new commit in the repository using a variable argument list.
@@ -512,7 +512,7 @@ GIT_EXTERN(int) git_commit_create_buffer(
512512
const char *message,
513513
const git_tree *tree,
514514
size_t parent_count,
515-
git_commit * const parents[]);
515+
const git_commit *parents[]);
516516

517517
/**
518518
* Create a commit object from the given buffer and signature
@@ -581,7 +581,7 @@ typedef int (*git_commit_create_cb)(
581581
const char *message,
582582
const git_tree *tree,
583583
size_t parent_count,
584-
git_commit * const parents[],
584+
const git_commit *parents[],
585585
void *payload);
586586

587587
/** An array of commits returned from the library */

src/libgit2/commit.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ int git_commit_create_from_ids(
281281

282282
typedef struct {
283283
size_t total;
284-
git_commit * const *parents;
284+
const git_commit **parents;
285285
git_repository *repo;
286286
} commit_parent_data;
287287

@@ -307,7 +307,7 @@ int git_commit_create(
307307
const char *message,
308308
const git_tree *tree,
309309
size_t parent_count,
310-
git_commit * const parents[])
310+
const git_commit *parents[])
311311
{
312312
commit_parent_data data = { parent_count, parents, repo };
313313

@@ -945,7 +945,7 @@ int git_commit_create_buffer(
945945
const char *message,
946946
const git_tree *tree,
947947
size_t parent_count,
948-
git_commit * const parents[])
948+
const git_commit *parents[])
949949
{
950950
GIT_BUF_WRAP_PRIVATE(out, git_commit__create_buffer, repo,
951951
author, committer, message_encoding, message,
@@ -961,7 +961,7 @@ int git_commit__create_buffer(
961961
const char *message,
962962
const git_tree *tree,
963963
size_t parent_count,
964-
git_commit * const parents[])
964+
const git_commit *parents[])
965965
{
966966
int error;
967967
commit_parent_data data = { parent_count, parents, repo };
@@ -1150,7 +1150,8 @@ int git_commit_create_from_stage(
11501150

11511151
error = git_commit_create(out, repo, "HEAD", author, committer,
11521152
opts.message_encoding, message,
1153-
tree, parents.count, parents.commits);
1153+
tree, parents.count,
1154+
(const git_commit **)parents.commits);
11541155

11551156
done:
11561157
git_commitarray_dispose(&parents);

src/libgit2/commit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int git_commit__create_buffer(
6464
const char *message,
6565
const git_tree *tree,
6666
size_t parent_count,
67-
git_commit * const parents[]);
67+
const git_commit *parents[]);
6868

6969
int git_commit__parse(
7070
void *commit,

src/libgit2/notes.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static int note_write(
303303

304304
error = git_commit_create(&oid, repo, notes_ref, author, committer,
305305
NULL, GIT_NOTES_DEFAULT_MSG_ADD,
306-
tree, *parents == NULL ? 0 : 1, parents);
306+
tree, *parents == NULL ? 0 : 1, (const git_commit **) parents);
307307

308308
if (notes_commit_out)
309309
git_oid_cpy(notes_commit_out, &oid);
@@ -394,7 +394,7 @@ static int note_remove(
394394
NULL, GIT_NOTES_DEFAULT_MSG_RM,
395395
tree_after_removal,
396396
*parents == NULL ? 0 : 1,
397-
parents);
397+
(const git_commit **) parents);
398398

399399
if (error < 0)
400400
goto cleanup;

src/libgit2/rebase.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ static int create_signed(
952952
const char *message,
953953
git_tree *tree,
954954
size_t parent_count,
955-
git_commit * const *parents)
955+
const git_commit **parents)
956956
{
957957
git_str commit_content = GIT_STR_INIT;
958958
git_buf commit_signature = { NULL, 0, 0 },
@@ -1040,7 +1040,8 @@ static int rebase_commit__create(
10401040
if (rebase->options.commit_create_cb) {
10411041
error = rebase->options.commit_create_cb(&commit_id,
10421042
author, committer, message_encoding, message,
1043-
tree, 1, &parent_commit, rebase->options.payload);
1043+
tree, 1, (const git_commit **)&parent_commit,
1044+
rebase->options.payload);
10441045

10451046
git_error_set_after_callback_function(error,
10461047
"commit_create_cb");
@@ -1049,14 +1050,14 @@ static int rebase_commit__create(
10491050
else if (rebase->options.signing_cb) {
10501051
error = create_signed(&commit_id, rebase, author,
10511052
committer, message_encoding, message, tree,
1052-
1, &parent_commit);
1053+
1, (const git_commit **)&parent_commit);
10531054
}
10541055
#endif
10551056

10561057
if (error == GIT_PASSTHROUGH)
10571058
error = git_commit_create(&commit_id, rebase->repo, NULL,
10581059
author, committer, message_encoding, message,
1059-
tree, 1, &parent_commit);
1060+
tree, 1, (const git_commit **)&parent_commit);
10601061

10611062
if (error)
10621063
goto done;

src/libgit2/stash.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static int commit_index(
124124
git_index *index,
125125
const git_signature *stasher,
126126
const char *message,
127-
git_commit *parent)
127+
const git_commit *parent)
128128
{
129129
git_tree *i_tree = NULL;
130130
git_oid i_commit_oid;
@@ -423,7 +423,7 @@ static int build_stash_commit_from_tree(
423423
git_commit *u_commit,
424424
const git_tree *tree)
425425
{
426-
git_commit *parents[] = { NULL, NULL, NULL };
426+
const git_commit *parents[] = { NULL, NULL, NULL };
427427

428428
parents[0] = b_commit;
429429
parents[1] = i_commit;

tests/libgit2/checkout/tree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ void test_checkout_tree__case_changing_rename(void)
12351235

12361236
cl_git_pass(git_signature_new(&signature, "Renamer", "[email protected]", time(NULL), 0));
12371237

1238-
cl_git_pass(git_commit_create(&commit_id, g_repo, "refs/heads/dir", signature, signature, NULL, "case-changing rename", tree, 1, &dir_commit));
1238+
cl_git_pass(git_commit_create(&commit_id, g_repo, "refs/heads/dir", signature, signature, NULL, "case-changing rename", tree, 1, (const git_commit **)&dir_commit));
12391239

12401240
cl_assert(git_fs_path_isfile("testrepo/readme"));
12411241
if (case_sensitive)

tests/libgit2/cherrypick/workdir.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void test_cherrypick_workdir__automerge(void)
7777
cl_git_pass(git_index_write_tree(&cherrypicked_tree_oid, repo_index));
7878
cl_git_pass(git_tree_lookup(&cherrypicked_tree, repo, &cherrypicked_tree_oid));
7979
cl_git_pass(git_commit_create(&cherrypicked_oid, repo, "HEAD", signature, signature, NULL,
80-
"Cherry picked!", cherrypicked_tree, 1, &head));
80+
"Cherry picked!", cherrypicked_tree, 1, (const git_commit **)&head));
8181

8282
cl_assert(merge_test_index(repo_index, merge_index_entries + i * 3, 3));
8383

tests/libgit2/commit/commit.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ void test_commit_commit__create_unexisting_update_ref(void)
3636

3737
cl_git_fail(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar"));
3838
cl_git_pass(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s,
39-
NULL, "some msg", tree, 1, &commit));
39+
NULL, "some msg", tree, 1, (const git_commit **) &commit));
4040

4141
/* fail because the parent isn't the tip of the branch anymore */
4242
cl_git_fail(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s,
43-
NULL, "some msg", tree, 1, &commit));
43+
NULL, "some msg", tree, 1, (const git_commit **) &commit));
4444

4545
cl_git_pass(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar"));
4646
cl_assert_equal_oid(&oid, git_reference_target(ref));

tests/libgit2/commit/write.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void test_commit_write__into_buf(void)
118118
cl_git_pass(git_commit_lookup(&parent, g_repo, &parent_id));
119119

120120
cl_git_pass(git_commit_create_buffer(&commit, g_repo, author, committer,
121-
NULL, root_commit_message, tree, 1, &parent));
121+
NULL, root_commit_message, tree, 1, (const git_commit **) &parent));
122122

123123
cl_assert_equal_s(commit.ptr,
124124
"tree 1810dff58d8a660512d4832e740f692884338ccd\n\

tests/libgit2/diff/rename.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ void test_diff_rename__test_small_files(void)
424424
cl_git_pass(git_index_write_tree(&oid, index));
425425
cl_git_pass(git_tree_lookup(&commit_tree, g_repo, &oid));
426426
cl_git_pass(git_signature_new(&signature, "Rename", "[email protected]", 1404157834, 0));
427-
cl_git_pass(git_commit_create(&oid, g_repo, "HEAD", signature, signature, NULL, "Test commit", commit_tree, 1, &head_commit));
427+
cl_git_pass(git_commit_create(&oid, g_repo, "HEAD", signature, signature, NULL, "Test commit", commit_tree, 1, (const git_commit**)&head_commit));
428428

429429
cl_git_mkfile("renames/copy.txt", "Hello World!\n");
430430
cl_git_rmfile("renames/small.txt");

tests/libgit2/odb/freshen.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void test_odb_freshen__tree_during_commit(void)
125125

126126
cl_git_pass(git_commit_create(&commit_id, repo, NULL,
127127
signature, signature, NULL, "New commit pointing to old tree",
128-
tree, 1, &parent));
128+
tree, 1, (const git_commit **)&parent));
129129

130130
/* make sure we freshen the tree the commit points to */
131131
cl_must_pass(p_lstat("testrepo.git/objects/" LOOSE_TREE_FN, &after));

tests/libgit2/rebase/sign.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int create_cb_passthrough(
2626
const char *message,
2727
const git_tree *tree,
2828
size_t parent_count,
29-
git_commit * const parents[],
29+
const git_commit *parents[],
3030
void *payload)
3131
{
3232
GIT_UNUSED(out);
@@ -94,7 +94,7 @@ static int create_cb_signed_gpg(
9494
const char *message,
9595
const git_tree *tree,
9696
size_t parent_count,
97-
git_commit * const parents[],
97+
const git_commit *parents[],
9898
void *payload)
9999
{
100100
git_buf commit_content = GIT_BUF_INIT;
@@ -202,7 +202,7 @@ static int create_cb_error(
202202
const char *message,
203203
const git_tree *tree,
204204
size_t parent_count,
205-
git_commit * const parents[],
205+
const git_commit *parents[],
206206
void *payload)
207207
{
208208
GIT_UNUSED(out);

tests/libgit2/refs/reflog/messages.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void test_refs_reflog_messages__show_merge_for_merge_commits(void)
233233
cl_git_pass(git_commit_create(&merge_commit_oid,
234234
g_repo, "HEAD", s, s, NULL,
235235
"Merge commit", tree,
236-
2, parent_commits));
236+
2, (const struct git_commit **) parent_commits));
237237

238238
cl_reflog_check_entry(g_repo, GIT_HEAD_FILE, 0,
239239
NULL,

tests/libgit2/revert/workdir.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void test_revert_workdir__again(void)
188188
cl_git_pass(git_tree_lookup(&reverted_tree, repo, &reverted_tree_oid));
189189

190190
cl_git_pass(git_signature_new(&signature, "Reverter", "[email protected]", time(NULL), 0));
191-
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, &orig_head));
191+
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, (const git_commit **)&orig_head));
192192

193193
cl_git_pass(git_revert(repo, orig_head, NULL));
194194
cl_assert(merge_test_index(repo_index, merge_index_entries, 4));
@@ -238,7 +238,7 @@ void test_revert_workdir__again_after_automerge(void)
238238
cl_git_pass(git_tree_lookup(&reverted_tree, repo, &reverted_tree_oid));
239239

240240
cl_git_pass(git_signature_new(&signature, "Reverter", "[email protected]", time(NULL), 0));
241-
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, &head));
241+
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, (const git_commit **)&head));
242242

243243
cl_git_pass(git_revert(repo, commit, NULL));
244244
cl_assert(merge_test_index(repo_index, second_revert_entries, 6));
@@ -287,7 +287,7 @@ void test_revert_workdir__again_after_edit(void)
287287
cl_git_pass(git_tree_lookup(&reverted_tree, repo, &reverted_tree_oid));
288288

289289
cl_git_pass(git_signature_new(&signature, "Reverter", "[email protected]", time(NULL), 0));
290-
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, &orig_head));
290+
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, (const git_commit **)&orig_head));
291291

292292
cl_git_pass(git_revert(repo, commit, NULL));
293293
cl_assert(merge_test_index(repo_index, merge_index_entries, 4));

tests/libgit2/revwalk/basic.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ void test_revwalk_basic__big_timestamp(void)
550550
cl_git_pass(git_signature_new(&sig, "Joe", "[email protected]", INT64_C(2399662595), 0));
551551
cl_git_pass(git_commit_tree(&tree, tip));
552552

553-
cl_git_pass(git_commit_create(&id, _repo, "HEAD", sig, sig, NULL, "some message", tree, 1, &tip));
553+
cl_git_pass(git_commit_create(&id, _repo, "HEAD", sig, sig, NULL, "some message", tree, 1,
554+
(const git_commit **)&tip));
554555

555556
cl_git_pass(git_revwalk_push_head(_walk));
556557

0 commit comments

Comments
 (0)