line |
true |
false |
branch |
96
|
0 |
3 |
if (git_buf_joinpath(&path, repo->gitdir, REBASE_APPLY_DIR) < 0) |
99
|
0 |
3 |
if (git_path_isdir(git_buf_cstr(&path))) { |
105
|
0 |
3 |
if (git_buf_joinpath(&path, repo->gitdir, REBASE_MERGE_DIR) < 0) |
108
|
1 |
2 |
if (git_path_isdir(git_buf_cstr(&path))) { |
116
|
1 |
2 |
if (type != GIT_REBASE_NONE && path_out) |
|
1 |
0 |
if (type != GIT_REBASE_NONE && path_out) |
134
|
7 |
0 |
if ((error = git_buf_joinpath(state_path, state_path->ptr, filename)) < 0 || |
|
7 |
0 |
if ((error = git_buf_joinpath(state_path, state_path->ptr, filename)) < 0 || |
152
|
0 |
2 |
if ((error = rebase_readfile(asc_out, state_path, filename)) < 0) |
155
|
2 |
0 |
if (git__strntol32(&num, asc_out->ptr, asc_out->size, &eol, 10) < 0 || num < 0 || *eol) { |
|
2 |
0 |
if (git__strntol32(&num, asc_out->ptr, asc_out->size, &eol, 10) < 0 || num < 0 || *eol) { |
|
0 |
2 |
if (git__strntol32(&num, asc_out->ptr, asc_out->size, &eol, 10) < 0 || num < 0 || *eol) { |
170
|
0 |
4 |
if ((error = rebase_readfile(str_out, state_path, filename)) < 0) |
173
|
4 |
0 |
if (str_out->size != GIT_OID_HEXSZ || git_oid_fromstr(out, str_out->ptr) < 0) { |
|
0 |
4 |
if (str_out->size != GIT_OID_HEXSZ || git_oid_fromstr(out, str_out->ptr) < 0) { |
189
|
0 |
9 |
assert((type == GIT_REBASE_OPERATION_EXEC) == !id); |
190
|
0 |
9 |
assert((type == GIT_REBASE_OPERATION_EXEC) == !!exec); |
192
|
2 |
7 |
if ((operation = git_array_alloc(rebase->operations)) == NULL) |
|
7 |
0 |
if ((operation = git_array_alloc(rebase->operations)) == NULL) |
|
0 |
9 |
if ((operation = git_array_alloc(rebase->operations)) == NULL) |
210
|
0 |
1 |
if ((error = git_buf_puts(&state_path, rebase->state_path)) < 0) |
214
|
0 |
1 |
if ((error = rebase_readint(&msgnum, &buf, &state_path, MSGNUM_FILE)) < 0 && |
|
0 |
0 |
if ((error = rebase_readint(&msgnum, &buf, &state_path, MSGNUM_FILE)) < 0 && |
218
|
1 |
0 |
if (msgnum) { |
224
|
0 |
1 |
if ((error = rebase_readint(&end, &buf, &state_path, END_FILE)) < 0) |
228
|
0 |
1 |
if ((error = rebase_readoid(&id, &buf, &state_path, CURRENT_FILE)) < 0 && |
|
0 |
0 |
if ((error = rebase_readoid(&id, &buf, &state_path, CURRENT_FILE)) < 0 && |
234
|
0 |
1 |
GIT_ERROR_CHECK_ARRAY(rebase->operations); |
236
|
3 |
1 |
for (i = 0; i < end; i++) { |
239
|
3 |
0 |
if ((error = git_buf_printf(&cmt, "cmt.%" PRIuZ, (i+1))) < 0 || |
|
3 |
0 |
if ((error = git_buf_printf(&cmt, "cmt.%" PRIuZ, (i+1))) < 0 || |
244
|
0 |
3 |
GIT_ERROR_CHECK_ALLOC(operation); |
248
|
0 |
1 |
if ((error = rebase_readfile(&buf, &state_path, ONTO_NAME_FILE)) < 0) |
264
|
0 |
4 |
GIT_ERROR_CHECK_ALLOC(rebase); |
268
|
4 |
0 |
if (rebase_opts) |
273
|
4 |
0 |
if (rebase_opts && rebase_opts->rewrite_notes_ref) { |
|
0 |
4 |
if (rebase_opts && rebase_opts->rewrite_notes_ref) { |
275
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(rebase->options.rewrite_notes_ref); |
285
|
0 |
4 |
GIT_ERROR_CHECK_VERSION(given_opts, GIT_REBASE_OPTIONS_VERSION, "git_rebase_options"); |
287
|
4 |
0 |
if (given_opts) |
288
|
0 |
4 |
GIT_ERROR_CHECK_VERSION(&given_opts->checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, "git_checkout_options"); |
304
|
0 |
1 |
assert(repo); |
306
|
0 |
1 |
if ((error = rebase_check_versions(given_opts)) < 0) |
309
|
0 |
1 |
if (rebase_alloc(&rebase, given_opts) < 0) |
314
|
0 |
1 |
if ((error = rebase_state_type(&rebase->type, &rebase->state_path, repo)) < 0) |
317
|
0 |
1 |
if (rebase->type == GIT_REBASE_NONE) { |
323
|
0 |
1 |
if ((error = git_buf_puts(&path, rebase->state_path)) < 0) |
328
|
1 |
0 |
if ((error = git_buf_joinpath(&path, path.ptr, HEAD_NAME_FILE)) < 0 || |
|
1 |
0 |
if ((error = git_buf_joinpath(&path, path.ptr, HEAD_NAME_FILE)) < 0 || |
334
|
1 |
0 |
if (strcmp(ORIG_DETACHED_HEAD, orig_head_name.ptr) == 0) |
339
|
0 |
1 |
if ((error = git_buf_joinpath(&path, path.ptr, ORIG_HEAD_FILE)) < 0) |
342
|
0 |
1 |
if (!git_path_isfile(path.ptr)) { |
346
|
0 |
0 |
if ((error = git_buf_joinpath(&path, path.ptr, HEAD_FILE)) < 0) |
350
|
0 |
1 |
if ((error = git_futils_readbuffer(&orig_head_id, path.ptr)) < 0) |
355
|
0 |
1 |
if ((error = git_oid_fromstr(&rebase->orig_head_id, orig_head_id.ptr)) < 0) |
360
|
1 |
0 |
if ((error = git_buf_joinpath(&path, path.ptr, ONTO_FILE)) < 0 || |
|
1 |
0 |
if ((error = git_buf_joinpath(&path, path.ptr, ONTO_FILE)) < 0 || |
366
|
0 |
1 |
if ((error = git_oid_fromstr(&rebase->onto_id, onto_id.ptr)) < 0) |
369
|
0 |
1 |
if (!rebase->head_detached) |
389
|
1 |
0 |
if (error == 0) |
403
|
2 |
0 |
if (!rebase || rebase->inmemory) |
|
0 |
2 |
if (!rebase || rebase->inmemory) |
407
|
1 |
1 |
git_futils_rmdir_r(rebase->state_path, NULL, GIT_RMDIR_REMOVE_FILES) : |
422
|
24 |
0 |
if ((error = git_buf_joinpath(&path, rebase->state_path, filename)) == 0) |
433
|
2 |
2 |
if (onto->ref_name && git__strncmp(onto->ref_name, "refs/heads/", 11) == 0) |
|
2 |
0 |
if (onto->ref_name && git__strncmp(onto->ref_name, "refs/heads/", 11) == 0) |
435
|
0 |
2 |
else if (onto->ref_name) |
449
|
2 |
0 |
if ((error = rebase_setupfile(rebase, END_FILE, 0, "%" PRIuZ "\n", git_array_size(rebase->operations))) < 0 || |
|
2 |
0 |
if ((error = rebase_setupfile(rebase, END_FILE, 0, "%" PRIuZ "\n", git_array_size(rebase->operations))) < 0 || |
453
|
3 |
2 |
for (i = 0; i < git_array_size(rebase->operations); i++) { |
454
|
3 |
0 |
operation = git_array_get(rebase->operations, i); |
461
|
0 |
3 |
if ((error = rebase_setupfile(rebase, commit_filename.ptr, 0, |
479
|
0 |
2 |
if (p_mkdir(rebase->state_path, REBASE_DIR_MODE) < 0) { |
484
|
0 |
2 |
orig_head_name = rebase->head_detached ? ORIG_DETACHED_HEAD : |
488
|
2 |
0 |
rebase_setupfile(rebase, HEAD_NAME_FILE, 0, "%s\n", orig_head_name) < 0 || |
489
|
2 |
0 |
rebase_setupfile(rebase, ONTO_FILE, 0, "%.*s\n", GIT_OID_HEXSZ, onto) < 0 || |
490
|
0 |
2 |
rebase_setupfile(rebase, ORIG_HEAD_FILE, 0, "%.*s\n", GIT_OID_HEXSZ, orig_head) < 0 || |
491
|
1 |
1 |
rebase_setupfile(rebase, QUIET_FILE, 0, rebase->quiet ? "t\n" : "\n") < 0) |
499
|
0 |
0 |
GIT_INIT_STRUCTURE_FROM_TEMPLATE( |
514
|
0 |
2 |
if ((error = rebase_state_type(&type, NULL, repo)) < 0) |
517
|
0 |
2 |
if (type != GIT_REBASE_NONE) { |
536
|
2 |
3 |
if (check_index) { |
537
|
2 |
0 |
if ((error = git_repository_head_tree(&head, repo)) < 0 || |
|
2 |
0 |
if ((error = git_repository_head_tree(&head, repo)) < 0 || |
538
|
2 |
0 |
(error = git_repository_index(&index, repo)) < 0 || |
542
|
0 |
2 |
if (git_diff_num_deltas(diff) > 0) { |
552
|
5 |
0 |
if (check_workdir) { |
555
|
0 |
5 |
if ((error = git_diff_index_to_workdir(&diff, repo, index, &diff_opts)) < 0) |
558
|
0 |
5 |
if (git_diff_num_deltas(diff) > 0) { |
587
|
0 |
3 |
if (!upstream) |
590
|
3 |
0 |
if ((error = git_revwalk_new(&revwalk, rebase->repo)) < 0 || |
|
3 |
0 |
if ((error = git_revwalk_new(&revwalk, rebase->repo)) < 0 || |
591
|
3 |
0 |
(error = git_revwalk_push(revwalk, git_annotated_commit_id(branch))) < 0 || |
597
|
6 |
3 |
while ((error = git_revwalk_next(&id, revwalk)) == 0) { |
598
|
0 |
6 |
if ((error = git_commit_lookup(&commit, repo, &id)) < 0) |
604
|
0 |
6 |
if (merge) |
608
|
0 |
6 |
GIT_ERROR_CHECK_ALLOC(operation); |
633
|
0 |
2 |
if ((error = git_buf_joinpath(&state_path, repo->gitdir, REBASE_MERGE_DIR)) < 0) |
637
|
0 |
2 |
GIT_ERROR_CHECK_ALLOC(rebase->state_path); |
639
|
0 |
2 |
if (branch->ref_name && strcmp(branch->ref_name, "HEAD")) { |
|
0 |
0 |
if (branch->ref_name && strcmp(branch->ref_name, "HEAD")) { |
641
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(rebase->orig_head_name); |
647
|
0 |
2 |
GIT_ERROR_CHECK_ALLOC(rebase->onto_name); |
654
|
2 |
0 |
if ((error = rebase_setupfiles(rebase)) < 0 || |
|
2 |
0 |
if ((error = rebase_setupfiles(rebase)) < 0 || |
656
|
2 |
0 |
"rebase: checkout %s", rebase_onto_name(onto))) < 0 || |
658
|
2 |
0 |
&onto_commit, repo, git_annotated_commit_id(onto))) < 0 || |
699
|
3 |
0 |
bool inmemory = (given_opts && given_opts->inmemory); |
|
1 |
2 |
bool inmemory = (given_opts && given_opts->inmemory); |
702
|
3 |
0 |
assert(repo && (upstream || onto)); |
|
0 |
3 |
assert(repo && (upstream || onto)); |
|
0 |
0 |
assert(repo && (upstream || onto)); |
706
|
0 |
3 |
if (!onto) |
709
|
0 |
3 |
if ((error = rebase_check_versions(given_opts)) < 0) |
712
|
2 |
1 |
if (!inmemory) { |
713
|
2 |
0 |
if ((error = git_repository__ensure_not_bare(repo, "rebase")) < 0 || |
|
2 |
0 |
if ((error = git_repository__ensure_not_bare(repo, "rebase")) < 0 || |
714
|
2 |
0 |
(error = rebase_ensure_not_in_progress(repo)) < 0 || |
719
|
0 |
3 |
if (!branch) { |
720
|
0 |
0 |
if ((error = git_repository_head(&head_ref, repo)) < 0 || |
|
0 |
0 |
if ((error = git_repository_head(&head_ref, repo)) < 0 || |
727
|
0 |
3 |
if (rebase_alloc(&rebase, given_opts) < 0) |
734
|
0 |
3 |
if ((error = rebase_init_operations(rebase, repo, branch, upstream, onto)) < 0) |
737
|
1 |
2 |
if (inmemory) |
742
|
3 |
0 |
if (error == 0) |
749
|
0 |
3 |
if (error < 0) { |
764
|
3 |
0 |
if (!checkout_opts->ancestor_label) |
767
|
3 |
0 |
if (rebase->type == GIT_REBASE_MERGE) { |
768
|
3 |
0 |
if (!checkout_opts->our_label) |
771
|
3 |
0 |
if (!checkout_opts->their_label) |
780
|
3 |
2 |
size_t next = rebase->started ? rebase->current + 1 : 0; |
782
|
1 |
4 |
if (next == git_array_size(rebase->operations)) |
808
|
3 |
0 |
operation = git_array_get(rebase->operations, rebase->current); |
810
|
3 |
0 |
if ((error = git_commit_lookup(¤t_commit, rebase->repo, &operation->id)) < 0 || |
|
3 |
0 |
if ((error = git_commit_lookup(¤t_commit, rebase->repo, &operation->id)) < 0 || |
811
|
3 |
0 |
(error = git_commit_tree(¤t_tree, current_commit)) < 0 || |
815
|
0 |
3 |
if ((parent_count = git_commit_parentcount(current_commit)) > 1) { |
819
|
3 |
0 |
} else if (parent_count) { |
820
|
3 |
0 |
if ((error = git_commit_parent(&parent_commit, current_commit, 0)) < 0 || |
|
3 |
0 |
if ((error = git_commit_parent(&parent_commit, current_commit, 0)) < 0 || |
829
|
3 |
0 |
if ((error = git_indexwriter_init_for_operation(&indexwriter, rebase->repo, &checkout_opts.checkout_strategy)) < 0 || |
|
3 |
0 |
if ((error = git_indexwriter_init_for_operation(&indexwriter, rebase->repo, &checkout_opts.checkout_strategy)) < 0 || |
830
|
3 |
0 |
(error = rebase_setupfile(rebase, MSGNUM_FILE, 0, "%" PRIuZ "\n", rebase->current+1)) < 0 || |
831
|
3 |
0 |
(error = rebase_setupfile(rebase, CURRENT_FILE, 0, "%.*s\n", GIT_OID_HEXSZ, current_idstr)) < 0 || |
832
|
3 |
0 |
(error = git_merge_trees(&index, rebase->repo, parent_tree, head_tree, current_tree, &rebase->options.merge_options)) < 0 || |
833
|
3 |
0 |
(error = git_merge__check_result(rebase->repo, index)) < 0 || |
834
|
3 |
0 |
(error = git_checkout_index(rebase->repo, index, &checkout_opts)) < 0 || |
866
|
1 |
0 |
operation = git_array_get(rebase->operations, rebase->current); |
868
|
1 |
0 |
if ((error = git_commit_lookup(¤t_commit, rebase->repo, &operation->id)) < 0 || |
|
1 |
0 |
if ((error = git_commit_lookup(¤t_commit, rebase->repo, &operation->id)) < 0 || |
872
|
0 |
1 |
if ((parent_count = git_commit_parentcount(current_commit)) > 1) { |
876
|
1 |
0 |
} else if (parent_count) { |
877
|
1 |
0 |
if ((error = git_commit_parent(&parent_commit, current_commit, 0)) < 0 || |
|
1 |
0 |
if ((error = git_commit_parent(&parent_commit, current_commit, 0)) < 0 || |
882
|
1 |
0 |
if ((error = git_commit_tree(&head_tree, rebase->last_commit)) < 0 || |
|
1 |
0 |
if ((error = git_commit_tree(&head_tree, rebase->last_commit)) < 0 || |
886
|
1 |
0 |
if (!rebase->index) { |
890
|
0 |
0 |
if ((error = git_index_read_index(rebase->index, index)) < 0) |
913
|
5 |
0 |
assert(out && rebase); |
|
0 |
5 |
assert(out && rebase); |
915
|
1 |
4 |
if ((error = rebase_movenext(rebase)) < 0) |
918
|
1 |
3 |
if (rebase->inmemory) |
920
|
3 |
0 |
else if (rebase->type == GIT_REBASE_MERGE) |
932
|
1 |
0 |
assert(out && rebase && rebase->index); |
|
1 |
0 |
assert(out && rebase && rebase->index); |
|
0 |
1 |
assert(out && rebase && rebase->index); |
960
|
3 |
0 |
operation = git_array_get(rebase->operations, rebase->current); |
962
|
0 |
3 |
if (git_index_has_conflicts(index)) { |
968
|
3 |
0 |
if ((error = git_commit_lookup(¤t_commit, rebase->repo, &operation->id)) < 0 || |
|
3 |
0 |
if ((error = git_commit_lookup(¤t_commit, rebase->repo, &operation->id)) < 0 || |
969
|
3 |
0 |
(error = git_commit_tree(&parent_tree, parent_commit)) < 0 || |
970
|
3 |
0 |
(error = git_index_write_tree_to(&tree_id, index, rebase->repo)) < 0 || |
974
|
0 |
3 |
if (git_oid_equal(&tree_id, git_tree_id(parent_tree))) { |
980
|
0 |
3 |
if (!author) |
983
|
3 |
0 |
if (!message) { |
988
|
0 |
3 |
if ((error = git_commit_create_buffer(&commit_content, rebase->repo, author, committer, |
992
|
0 |
3 |
if (rebase->options.signing_cb) { |
997
|
0 |
0 |
if (error == GIT_PASSTHROUGH) { |
1002
|
0 |
0 |
} else if (error < 0) |
1006
|
0 |
3 |
if (git_buf_is_allocated(&commit_signature)) { |
1007
|
0 |
0 |
assert(git_buf_contains_nul(&commit_signature)); |
1011
|
0 |
3 |
if (git_buf_is_allocated(&signature_field)) { |
1012
|
0 |
0 |
assert(git_buf_contains_nul(&signature_field)); |
1016
|
0 |
3 |
if ((error = git_commit_create_with_signature(&commit_id, rebase->repo, |
1021
|
0 |
3 |
if ((error = git_commit_lookup(&commit, rebase->repo, &commit_id)) < 0) |
1027
|
0 |
3 |
if (error < 0) |
1055
|
3 |
0 |
operation = git_array_get(rebase->operations, rebase->current); |
1056
|
0 |
3 |
assert(operation); |
1058
|
3 |
0 |
if ((error = rebase_ensure_not_dirty(rebase->repo, false, true, GIT_EUNMERGED)) < 0 || |
|
3 |
0 |
if ((error = rebase_ensure_not_dirty(rebase->repo, false, true, GIT_EUNMERGED)) < 0 || |
1059
|
3 |
0 |
(error = git_repository_head(&head, rebase->repo)) < 0 || |
1060
|
3 |
0 |
(error = git_reference_peel((git_object **)&head_commit, head, GIT_OBJECT_COMMIT)) < 0 || |
1061
|
3 |
0 |
(error = git_repository_index(&index, rebase->repo)) < 0 || |
1063
|
3 |
0 |
author, committer, message_encoding, message)) < 0 || |
1071
|
0 |
3 |
if ((error = rebase_setupfile(rebase, REWRITTEN_FILE, O_CREAT|O_WRONLY|O_APPEND, |
1096
|
0 |
0 |
assert(rebase->index); |
1097
|
0 |
0 |
assert(rebase->last_commit); |
1098
|
0 |
0 |
assert(rebase->current < rebase->operations.size); |
1100
|
0 |
0 |
if ((error = rebase_commit__create(&commit, rebase, rebase->index, |
1110
|
0 |
0 |
if (error < 0) |
1126
|
3 |
0 |
assert(rebase && committer); |
|
0 |
3 |
assert(rebase && committer); |
1128
|
0 |
3 |
if (rebase->inmemory) |
1131
|
3 |
0 |
else if (rebase->type == GIT_REBASE_MERGE) |
1146
|
0 |
1 |
assert(rebase); |
1148
|
0 |
1 |
if (rebase->inmemory) |
1153
|
1 |
0 |
&rebase->orig_head_id, 1, "rebase: aborting") : |
1158
|
0 |
1 |
if (error < 0) |
1161
|
1 |
0 |
if ((error = git_commit_lookup( |
1162
|
1 |
0 |
&orig_head_commit, rebase->repo, &rebase->orig_head_id)) < 0 || |
1181
|
0 |
1 |
if (rebase->options.rewrite_notes_ref) { |
1188
|
1 |
0 |
if ((error = git_repository_config(&config, rebase->repo)) < 0 || |
|
1 |
0 |
if ((error = git_repository_config(&config, rebase->repo)) < 0 || |
1191
|
0 |
1 |
if (error != GIT_ENOTFOUND) |
1199
|
1 |
0 |
git_config_get_string_buf(out, config, "notes.rewriteref") : |
1219
|
0 |
0 |
if ((error = git_note_read(¬e, rebase->repo, notes_ref, from)) < 0) { |
1220
|
0 |
0 |
if (error == GIT_ENOTFOUND) { |
1228
|
0 |
0 |
if (!committer) { |
1229
|
0 |
0 |
if((error = git_signature_default(&who, rebase->repo)) < 0) { |
1230
|
0 |
0 |
if (error != GIT_ENOTFOUND || |
|
0 |
0 |
if (error != GIT_ENOTFOUND || |
1260
|
1 |
0 |
if ((error = notes_ref_lookup(¬es_ref, rebase)) < 0) { |
1261
|
1 |
0 |
if (error == GIT_ENOTFOUND) { |
1269
|
0 |
0 |
if ((error = git_buf_joinpath(&path, rebase->state_path, REWRITTEN_FILE)) < 0 || |
|
0 |
0 |
if ((error = git_buf_joinpath(&path, rebase->state_path, REWRITTEN_FILE)) < 0 || |
1275
|
0 |
0 |
while (*pair_list) { |
1278
|
0 |
0 |
if ((end = strchr(fromstr, '\n')) == NULL) |
1284
|
0 |
0 |
if ((end = strchr(fromstr, ' ')) == NULL) |
1290
|
0 |
0 |
if (strlen(fromstr) != GIT_OID_HEXSZ || |
|
0 |
0 |
if (strlen(fromstr) != GIT_OID_HEXSZ || |
1291
|
0 |
0 |
strlen(tostr) != GIT_OID_HEXSZ || |
1292
|
0 |
0 |
git_oid_fromstr(&from, fromstr) < 0 || |
1296
|
0 |
0 |
if ((error = rebase_copy_note(rebase, notes_ref.ptr, &from, &to, committer)) < 0) |
1326
|
0 |
0 |
if ((error = git_buf_printf(&branch_msg, |
1328
|
0 |
0 |
rebase->orig_head_name, GIT_OID_HEXSZ, onto)) == 0 && |
1331
|
0 |
0 |
rebase->orig_head_name)) == 0 && |
1332
|
0 |
0 |
(error = git_repository_head(&terminal_ref, rebase->repo)) == 0 && |
1334
|
0 |
0 |
terminal_ref, GIT_OBJECT_COMMIT)) == 0 && |
1359
|
0 |
1 |
assert(rebase); |
1361
|
0 |
1 |
if (rebase->inmemory) |
1364
|
0 |
1 |
if (!rebase->head_detached) |
1367
|
1 |
0 |
if (error == 0 && (error = rebase_copy_notes(rebase, signature)) == 0) |
|
1 |
0 |
if (error == 0 && (error = rebase_copy_notes(rebase, signature)) == 0) |
1391
|
0 |
10 |
assert(rebase); |
1398
|
0 |
3 |
assert(rebase); |
1400
|
2 |
1 |
return rebase->started ? rebase->current : GIT_REBASE_NO_OPERATION; |
1405
|
0 |
6 |
assert(rebase); |
1407
|
5 |
1 |
return git_array_get(rebase->operations, idx); |
1412
|
0 |
4 |
if (rebase == NULL) |