10000 Merge pull request #6829 from libgit2/ethomson/fix_constness · BenJam/libgit2@4516ca1 · GitHub
[go: up one dir, main page]

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 6 additions & 5 deletions
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[])
F41A 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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 5 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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", "rename@contoso.com", 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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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));

0 commit comments

Comments
 (0)
0