rugged 0.27.7 → 0.27.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +6 -2
  4. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +29 -0
  5. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +96 -0
  6. data/vendor/libgit2/cmake/Modules/FindIconv.cmake +11 -6
  7. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -2
  8. data/vendor/libgit2/include/git2.h +0 -1
  9. data/vendor/libgit2/include/git2/attr.h +7 -18
  10. data/vendor/libgit2/include/git2/blame.h +22 -39
  11. data/vendor/libgit2/include/git2/blob.h +1 -1
  12. data/vendor/libgit2/include/git2/branch.h +1 -1
  13. data/vendor/libgit2/include/git2/buffer.h +2 -14
  14. data/vendor/libgit2/include/git2/checkout.h +12 -13
  15. data/vendor/libgit2/include/git2/cherrypick.h +4 -6
  16. data/vendor/libgit2/include/git2/clone.h +6 -8
  17. data/vendor/libgit2/include/git2/commit.h +0 -28
  18. data/vendor/libgit2/include/git2/common.h +0 -27
  19. data/vendor/libgit2/include/git2/config.h +0 -1
  20. data/vendor/libgit2/include/git2/describe.h +7 -30
  21. data/vendor/libgit2/include/git2/diff.h +22 -32
  22. data/vendor/libgit2/include/git2/errors.h +0 -1
  23. data/vendor/libgit2/include/git2/ignore.h +2 -2
  24. data/vendor/libgit2/include/git2/merge.h +8 -10
  25. data/vendor/libgit2/include/git2/proxy.h +5 -9
  26. data/vendor/libgit2/include/git2/rebase.h +4 -7
  27. data/vendor/libgit2/include/git2/refs.h +1 -1
  28. data/vendor/libgit2/include/git2/refspec.h +0 -17
  29. data/vendor/libgit2/include/git2/remote.h +10 -12
  30. data/vendor/libgit2/include/git2/repository.h +5 -7
  31. data/vendor/libgit2/include/git2/revert.h +3 -5
  32. data/vendor/libgit2/include/git2/stash.h +8 -11
  33. data/vendor/libgit2/include/git2/status.h +3 -7
  34. data/vendor/libgit2/include/git2/submodule.h +7 -8
  35. data/vendor/libgit2/include/git2/sys/index.h +0 -3
  36. data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
  37. data/vendor/libgit2/include/git2/sys/merge.h +1 -6
  38. data/vendor/libgit2/include/git2/transaction.h +0 -1
  39. data/vendor/libgit2/include/git2/types.h +5 -8
  40. data/vendor/libgit2/include/git2/version.h +2 -2
  41. data/vendor/libgit2/include/git2/worktree.h +11 -46
  42. data/vendor/libgit2/src/CMakeLists.txt +28 -91
  43. data/vendor/libgit2/src/annotated_commit.c +4 -4
  44. data/vendor/libgit2/src/apply.c +6 -5
  45. data/vendor/libgit2/src/attr.c +4 -4
  46. data/vendor/libgit2/src/attr_file.c +5 -5
  47. data/vendor/libgit2/src/attrcache.c +2 -2
  48. data/vendor/libgit2/src/blame.c +4 -11
  49. data/vendor/libgit2/src/blame.h +0 -1
  50. data/vendor/libgit2/src/blame_git.c +5 -8
  51. data/vendor/libgit2/src/blob.c +5 -5
  52. data/vendor/libgit2/src/branch.c +20 -20
  53. data/vendor/libgit2/src/buffer.c +4 -9
  54. data/vendor/libgit2/src/buffer.h +1 -1
  55. data/vendor/libgit2/src/checkout.c +24 -33
  56. data/vendor/libgit2/src/cherrypick.c +3 -3
  57. data/vendor/libgit2/src/clone.c +13 -13
  58. data/vendor/libgit2/src/commit.c +5 -18
  59. data/vendor/libgit2/src/commit_list.c +9 -3
  60. data/vendor/libgit2/src/common.h +1 -3
  61. data/vendor/libgit2/src/config.c +15 -6
  62. data/vendor/libgit2/src/config_file.c +249 -193
  63. data/vendor/libgit2/src/config_parse.c +66 -89
  64. data/vendor/libgit2/src/config_parse.h +2 -2
  65. data/vendor/libgit2/src/crlf.c +3 -9
  66. data/vendor/libgit2/src/diff.c +2 -2
  67. data/vendor/libgit2/src/diff_driver.c +3 -3
  68. data/vendor/libgit2/src/diff_file.c +3 -3
  69. data/vendor/libgit2/src/diff_generate.c +3 -4
  70. data/vendor/libgit2/src/diff_print.c +8 -8
  71. data/vendor/libgit2/src/diff_tform.c +4 -2
  72. data/vendor/libgit2/src/diff_xdiff.c +0 -12
  73. data/vendor/libgit2/src/features.h.in +0 -2
  74. data/vendor/libgit2/src/fetch.c +2 -2
  75. data/vendor/libgit2/src/fetchhead.c +5 -5
  76. data/vendor/libgit2/src/filebuf.c +4 -4
  77. data/vendor/libgit2/src/fileops.c +10 -10
  78. data/vendor/libgit2/src/filter.c +9 -3
  79. data/vendor/libgit2/src/global.c +12 -17
  80. data/vendor/libgit2/src/hash.h +0 -2
  81. data/vendor/libgit2/src/ignore.c +5 -5
  82. data/vendor/libgit2/src/index.c +40 -80
  83. data/vendor/libgit2/src/index.h +0 -10
  84. data/vendor/libgit2/src/indexer.c +9 -9
  85. data/vendor/libgit2/src/iterator.c +8 -8
  86. data/vendor/libgit2/src/khash.h +1 -3
  87. data/vendor/libgit2/src/merge.c +7 -7
  88. data/vendor/libgit2/src/netops.c +5 -5
  89. data/vendor/libgit2/src/notes.c +2 -2
  90. data/vendor/libgit2/src/odb.c +9 -9
  91. data/vendor/libgit2/src/odb_loose.c +22 -18
  92. data/vendor/libgit2/src/odb_pack.c +3 -3
  93. data/vendor/libgit2/src/pack-objects.c +3 -3
  94. data/vendor/libgit2/src/pack.c +5 -5
  95. data/vendor/libgit2/src/pack.h +1 -1
  96. data/vendor/libgit2/src/parse.c +7 -4
  97. data/vendor/libgit2/src/patch.c +1 -1
  98. data/vendor/libgit2/src/patch_generate.c +2 -2
  99. data/vendor/libgit2/src/patch_parse.c +4 -24
  100. data/vendor/libgit2/src/path.c +140 -39
  101. data/vendor/libgit2/src/path.h +84 -2
  102. data/vendor/libgit2/src/pathspec.c +1 -1
  103. data/vendor/libgit2/src/push.c +2 -2
  104. data/vendor/libgit2/src/rebase.c +23 -20
  105. data/vendor/libgit2/src/refdb_fs.c +34 -65
  106. data/vendor/libgit2/src/refs.c +16 -13
  107. data/vendor/libgit2/src/refspec.c +5 -30
  108. data/vendor/libgit2/src/refspec.h +1 -1
  109. data/vendor/libgit2/src/remote.c +43 -43
  110. data/vendor/libgit2/src/repository.c +56 -56
  111. data/vendor/libgit2/src/reset.c +1 -1
  112. data/vendor/libgit2/src/revert.c +3 -3
  113. data/vendor/libgit2/src/revparse.c +7 -6
  114. data/vendor/libgit2/src/revwalk.c +20 -48
  115. data/vendor/libgit2/src/revwalk.h +1 -2
  116. data/vendor/libgit2/src/settings.c +1 -25
  117. data/vendor/libgit2/src/signature.c +4 -2
  118. data/vendor/libgit2/src/stash.c +34 -80
  119. data/vendor/libgit2/src/status.c +1 -1
  120. data/vendor/libgit2/src/streams/curl.c +1 -1
  121. data/vendor/libgit2/src/streams/openssl.c +34 -132
  122. data/vendor/libgit2/src/streams/openssl.h +107 -0
  123. data/vendor/libgit2/src/streams/tls.c +0 -3
  124. data/vendor/libgit2/src/submodule.c +83 -118
  125. data/vendor/libgit2/src/sysdir.c +4 -4
  126. data/vendor/libgit2/src/tag.c +12 -12
  127. data/vendor/libgit2/src/trace.h +1 -1
  128. data/vendor/libgit2/src/trailer.c +6 -6
  129. data/vendor/libgit2/src/transport.c +2 -2
  130. data/vendor/libgit2/src/transports/auth.c +1 -1
  131. data/vendor/libgit2/src/transports/auth_negotiate.c +2 -2
  132. data/vendor/libgit2/src/transports/git.c +1 -1
  133. data/vendor/libgit2/src/transports/http.c +15 -12
  134. data/vendor/libgit2/src/transports/local.c +7 -7
  135. data/vendor/libgit2/src/transports/smart.c +15 -20
  136. data/vendor/libgit2/src/transports/smart.h +5 -5
  137. data/vendor/libgit2/src/transports/smart_pkt.c +131 -123
  138. data/vendor/libgit2/src/transports/smart_protocol.c +38 -48
  139. data/vendor/libgit2/src/transports/ssh.c +1 -1
  140. data/vendor/libgit2/src/transports/winhttp.c +26 -21
  141. data/vendor/libgit2/src/tree-cache.c +2 -2
  142. data/vendor/libgit2/src/tree.c +69 -23
  143. data/vendor/libgit2/src/tree.h +12 -0
  144. data/vendor/libgit2/src/util.c +99 -52
  145. data/vendor/libgit2/src/util.h +138 -14
  146. data/vendor/libgit2/src/vector.c +13 -8
  147. data/vendor/libgit2/src/win32/findfile.c +2 -2
  148. data/vendor/libgit2/src/win32/posix_w32.c +1 -1
  149. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -94
  150. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +75 -28
  151. data/vendor/libgit2/src/worktree.c +44 -65
  152. data/vendor/libgit2/src/worktree.h +0 -2
  153. data/vendor/libgit2/src/xdiff/xdiffi.c +1 -3
  154. metadata +5 -17
  155. data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +0 -93
  156. data/vendor/libgit2/include/git2/mailmap.h +0 -115
  157. data/vendor/libgit2/include/git2/sys/alloc.h +0 -101
  158. data/vendor/libgit2/include/git2/sys/path.h +0 -55
  159. data/vendor/libgit2/src/alloc.c +0 -47
  160. data/vendor/libgit2/src/alloc.h +0 -40
  161. data/vendor/libgit2/src/hash/hash_mbedtls.c +0 -38
  162. data/vendor/libgit2/src/hash/hash_mbedtls.h +0 -20
  163. data/vendor/libgit2/src/mailmap.c +0 -485
  164. data/vendor/libgit2/src/mailmap.h +0 -35
  165. data/vendor/libgit2/src/stdalloc.c +0 -120
  166. data/vendor/libgit2/src/stdalloc.h +0 -17
  167. data/vendor/libgit2/src/streams/mbedtls.c +0 -463
  168. data/vendor/libgit2/src/streams/mbedtls.h +0 -20
@@ -67,7 +67,6 @@ typedef struct git_blame__entry {
67
67
  struct git_blame {
68
68
  char *path;
69
69
  git_repository *repository;
70
- git_mailmap *mailmap;
71
70
  git_blame_options options;
72
71
 
73
72
  git_vector hunks;
@@ -623,8 +623,6 @@ static void coalesce(git_blame *blame)
623
623
 
624
624
  int git_blame__like_git(git_blame *blame, uint32_t opt)
625
625
  {
626
- int error = 0;
627
-
628
626
  while (true) {
629
627
  git_blame__entry *ent;
630
628
  git_blame__origin *suspect = NULL;
@@ -634,13 +632,13 @@ int git_blame__like_git(git_blame *blame, uint32_t opt)
634
632
  if (!ent->guilty)
635
633
  suspect = ent->suspect;
636
634
  if (!suspect)
637
- break;
635
+ return 0; /* all done */
638
636
 
639
637
  /* We'll use this suspect later in the loop, so hold on to it for now. */
640
638
  origin_incref(suspect);
641
639
 
642
- if ((error = pass_blame(blame, suspect, opt)) < 0)
643
- break;
640
+ if (pass_blame(blame, suspect, opt) < 0)
641
+ return -1;
644
642
 
645
643
  /* Take responsibility for the remaining entries */
646
644
  for (ent = blame->ent; ent; ent = ent->next) {
@@ -654,10 +652,9 @@ int git_blame__like_git(git_blame *blame, uint32_t opt)
654
652
  origin_decref(suspect);
655
653
  }
656
654
 
657
- if (!error)
658
- coalesce(blame);
655
+ coalesce(blame);
659
656
 
660
- return error;
657
+ return 0;
661
658
  }
662
659
 
663
660
  void git_blame__free_entry(git_blame__entry *ent)
@@ -126,7 +126,7 @@ static int write_file_filtered(
126
126
  error = git_odb_write(id, odb, tgt.ptr, tgt.size, GIT_OBJ_BLOB);
127
127
  }
128
128
 
129
- git_buf_dispose(&tgt);
129
+ git_buf_free(&tgt);
130
130
  return error;
131
131
  }
132
132
 
@@ -238,7 +238,7 @@ int git_blob__create_from_paths(
238
238
 
239
239
  done:
240
240
  git_odb_free(odb);
241
- git_buf_dispose(&path);
241
+ git_buf_free(&path);
242
242
 
243
243
  return error;
244
244
  }
@@ -257,7 +257,7 @@ int git_blob_create_fromdisk(
257
257
  const char *workdir, *hintpath;
258
258
 
259
259
  if ((error = git_path_prettify(&full_path, path, NULL)) < 0) {
260
- git_buf_dispose(&full_path);
260
+ git_buf_free(&full_path);
261
261
  return error;
262
262
  }
263
263
 
@@ -270,7 +270,7 @@ int git_blob_create_fromdisk(
270
270
  error = git_blob__create_from_paths(
271
271
  id, NULL, repo, git_buf_cstr(&full_path), hintpath, 0, true);
272
272
 
273
- git_buf_dispose(&full_path);
273
+ git_buf_free(&full_path);
274
274
  return error;
275
275
  }
276
276
 
@@ -340,7 +340,7 @@ cleanup:
340
340
  if (error < 0)
341
341
  blob_writestream_free((git_writestream *) stream);
342
342
 
343
- git_buf_dispose(&path);
343
+ git_buf_free(&path);
344
344
  return error;
345
345
  }
346
346
 
@@ -40,7 +40,7 @@ static int retrieve_branch_reference(
40
40
 
41
41
  *branch_reference_out = branch; /* will be NULL on error */
42
42
 
43
- git_buf_dispose(&ref_name);
43
+ git_buf_free(&ref_name);
44
44
  return error;
45
45
  }
46
46
 
@@ -108,8 +108,8 @@ static int create_branch(
108
108
  *ref_out = branch;
109
109
 
110
110
  cleanup:
111
- git_buf_dispose(&canonical_branch_name);
112
- git_buf_dispose(&log_message);
111
+ git_buf_free(&canonical_branch_name);
112
+ git_buf_free(&log_message);
113
113
  return error;
114
114
  }
115
115
 
@@ -199,7 +199,7 @@ int git_branch_delete(git_reference *branch)
199
199
  error = git_reference_delete(branch);
200
200
 
201
201
  on_error:
202
- git_buf_dispose(&config_section);
202
+ git_buf_free(&config_section);
203
203
  return error;
204
204
  }
205
205
 
@@ -310,10 +310,10 @@ int git_branch_move(
310
310
  git_buf_cstr(&new_config_section));
311
311
 
312
312
  done:
313
- git_buf_dispose(&new_reference_name);
314
- git_buf_dispose(&old_config_section);
315
- git_buf_dispose(&new_config_section);
316
- git_buf_dispose(&log_message);
313
+ git_buf_free(&new_reference_name);
314
+ git_buf_free(&old_config_section);
315
+ git_buf_free(&new_config_section);
316
+ git_buf_free(&log_message);
317
317
 
318
318
  return error;
319
319
  }
@@ -366,7 +366,7 @@ static int retrieve_upstream_configuration(
366
366
  return -1;
367
367
 
368
368
  error = git_config_get_string_buf(out, config, git_buf_cstr(&buf));
369
- git_buf_dispose(&buf);
369
+ git_buf_free(&buf);
370
370
  return error;
371
371
  }
372
372
 
@@ -429,9 +429,9 @@ int git_branch_upstream_name(
429
429
  cleanup:
430
430
  git_config_free(config);
431
431
  git_remote_free(remote);
432
- git_buf_dispose(&remote_name);
433
- git_buf_dispose(&merge_name);
434
- git_buf_dispose(&buf);
432
+ git_buf_free(&remote_name);
433
+ git_buf_free(&merge_name);
434
+ git_buf_free(&buf);
435
435
  return error;
436
436
  }
437
437
 
@@ -522,7 +522,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna
522
522
 
523
523
  cleanup:
524
524
  if (error < 0)
525
- git_buf_dispose(buf);
525
+ git_buf_free(buf);
526
526
 
527
527
  git_strarray_free(&remote_list);
528
528
  return error;
@@ -544,7 +544,7 @@ int git_branch_upstream(
544
544
  git_reference_owner(branch),
545
545
  git_buf_cstr(&tracking_name));
546
546
 
547
- git_buf_dispose(&tracking_name);
547
+ git_buf_free(&tracking_name);
548
548
  return error;
549
549
  }
550
550
 
@@ -565,11 +565,11 @@ static int unset_upstream(git_config *config, const char *shortname)
565
565
  if (git_config_delete_entry(config, git_buf_cstr(&buf)) < 0)
566
566
  goto on_error;
567
567
 
568
- git_buf_dispose(&buf);
568
+ git_buf_free(&buf);
569
569
  return 0;
570
570
 
571
571
  on_error:
572
- git_buf_dispose(&buf);
572
+ git_buf_free(&buf);
573
573
  return -1;
574
574
  }
575
575
 
@@ -655,15 +655,15 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name)
655
655
  goto on_error;
656
656
 
657
657
  git_reference_free(upstream);
658
- git_buf_dispose(&key);
659
- git_buf_dispose(&value);
658
+ git_buf_free(&key);
659
+ git_buf_free(&value);
660
660
 
661
661
  return 0;
662
662
 
663
663
  on_error:
664
664
  git_reference_free(upstream);
665
- git_buf_dispose(&key);
666
- git_buf_dispose(&value);
665
+ git_buf_free(&key);
666
+ git_buf_free(&value);
667
667
  git_remote_free(remote);
668
668
 
669
669
  return -1;
@@ -116,7 +116,7 @@ int git_buf_grow_by(git_buf *buffer, size_t additional_size)
116
116
  return git_buf_try_grow(buffer, newsize, true);
117
117
  }
118
118
 
119
- void git_buf_dispose(git_buf *buf)
119
+ void git_buf_free(git_buf *buf)
120
120
  {
121
121
  if (!buf) return;
122
122
 
@@ -126,11 +126,6 @@ void git_buf_dispose(git_buf *buf)
126
126
  git_buf_init(buf, 0);
127
127
  }
128
128
 
129
- void git_buf_free(git_buf *buf)
130
- {
131
- git_buf_dispose(buf);
132
- }
133
-
134
129
  void git_buf_sanitize(git_buf *buf)
135
130
  {
136
131
  if (buf->ptr == NULL) {
@@ -615,7 +610,7 @@ char *git_buf_detach(git_buf *buf)
615
610
 
616
611
  int git_buf_attach(git_buf *buf, char *ptr, size_t asize)
617
612
  {
618
- git_buf_dispose(buf);
613
+ git_buf_free(buf);
619
614
 
620
615
  if (ptr) {
621
616
  buf->ptr = ptr;
@@ -633,7 +628,7 @@ int git_buf_attach(git_buf *buf, char *ptr, size_t asize)
633
628
  void git_buf_attach_notowned(git_buf *buf, const char *ptr, size_t size)
634
629
  {
635
630
  if (git_buf_is_allocated(buf))
636
- git_buf_dispose(buf);
631
+ git_buf_free(buf);
637
632
 
638
633
  if (!size) {
639
634
  git_buf_init(buf, 0);
@@ -954,7 +949,7 @@ int git_buf_quote(git_buf *buf)
954
949
  git_buf_swap(&quoted, buf);
955
950
 
956
951
  done:
957
- git_buf_dispose(&quoted);
952
+ git_buf_free(&quoted);
958
953
  return error;
959
954
  }
960
955
 
@@ -76,7 +76,7 @@ extern char *git_buf_detach(git_buf *buf);
76
76
  extern int git_buf_attach(git_buf *buf, char *ptr, size_t asize);
77
77
 
78
78
  /* Populates a `git_buf` where the contents are not "owned" by the
79
- * buffer, and calls to `git_buf_dispose` will not free the given buf.
79
+ * buffer, and calls to `git_buf_free` will not free the given buf.
80
80
  */
81
81
  extern void git_buf_attach_notowned(
82
82
  git_buf *buf, const char *ptr, size_t size);
@@ -1604,7 +1604,7 @@ static int blob_content_to_link(
1604
1604
  st->st_mode = GIT_FILEMODE_LINK;
1605
1605
  }
1606
1606
 
1607
- git_buf_dispose(&linktarget);
1607
+ git_buf_free(&linktarget);
1608
1608
 
1609
1609
  return error;
1610
1610
  }
@@ -2161,13 +2161,13 @@ static int checkout_write_merge(
2161
2161
  done:
2162
2162
  git_filter_list_free(fl);
2163
2163
 
2164
- git_buf_dispose(&out_data);
2165
- git_buf_dispose(&our_label);
2166
- git_buf_dispose(&their_label);
2164
+ git_buf_free(&out_data);
2165
+ git_buf_free(&our_label);
2166
+ git_buf_free(&their_label);
2167
2167
 
2168
2168
  git_merge_file_result_free(&result);
2169
- git_buf_dispose(&path_workdir);
2170
- git_buf_dispose(&path_suffixed);
2169
+ git_buf_free(&path_workdir);
2170
+ git_buf_free(&path_suffixed);
2171
2171
 
2172
2172
  return error;
2173
2173
  }
@@ -2347,8 +2347,8 @@ static void checkout_data_clear(checkout_data *data)
2347
2347
  git__free(data->pfx);
2348
2348
  data->pfx = NULL;
2349
2349
 
2350
- git_buf_dispose(&data->target_path);
2351
- git_buf_dispose(&data->tmp);
2350
+ git_buf_free(&data->target_path);
2351
+ git_buf_free(&data->tmp);
2352
2352
 
2353
2353
  git_index_free(data->index);
2354
2354
  data->index = NULL;
@@ -2397,9 +2397,6 @@ static int checkout_data_init(
2397
2397
  GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR)) < 0)
2398
2398
  goto cleanup;
2399
2399
 
2400
- if ((error = git_repository_index(&data->index, data->repo)) < 0)
2401
- goto cleanup;
2402
-
2403
2400
  /* refresh config and index content unless NO_REFRESH is given */
2404
2401
  if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) {
2405
2402
  git_config *cfg;
@@ -2407,30 +2404,24 @@ static int checkout_data_init(
2407
2404
  if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
2408
2405
  goto cleanup;
2409
2406
 
2410
- /* Reload the repository index (unless we're checking out the
2411
- * index; then it has the changes we're trying to check out
2412
- * and those should not be overwritten.)
2407
+ /* Get the repository index and reload it (unless we're checking
2408
+ * out the index; then it has the changes we're trying to check
2409
+ * out and those should not be overwritten.)
2413
2410
  */
2414
- if (data->index != git_iterator_index(target)) {
2415
- if (data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) {
2416
- /* When forcing, we can blindly re-read the index */
2417
- if ((error = git_index_read(data->index, false)) < 0)
2418
- goto cleanup;
2419
- } else {
2420
- /*
2421
- * When not being forced, we need to check for unresolved
2422
- * conflicts and unsaved changes in the index before
2423
- * proceeding.
2424
- */
2425
- if (git_index_has_conflicts(data->index)) {
2426
- error = GIT_ECONFLICT;
2427
- giterr_set(GITERR_CHECKOUT,
2428
- "unresolved conflicts exist in the index");
2429
- goto cleanup;
2430
- }
2411
+ if ((error = git_repository_index(&data->index, data->repo)) < 0)
2412
+ goto cleanup;
2431
2413
 
2432
- if ((error = git_index_read_safely(data->index)) < 0)
2433
- goto cleanup;
2414
+ if (data->index != git_iterator_index(target)) {
2415
+ if ((error = git_index_read(data->index, true)) < 0)
2416
+ goto cleanup;
2417
+
2418
+ /* cannot checkout if unresolved conflicts exist */
2419
+ if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) == 0 &&
2420
+ git_index_has_conflicts(data->index)) {
2421
+ error = GIT_ECONFLICT;
2422
+ giterr_set(GITERR_CHECKOUT,
2423
+ "unresolved conflicts exist in the index");
2424
+ goto cleanup;
2434
2425
  }
2435
2426
 
2436
2427
  /* clean conflict data in the current index */
@@ -37,7 +37,7 @@ static int write_cherrypick_head(
37
37
  if (error < 0)
38
38
  git_filebuf_cleanup(&file);
39
39
 
40
- git_buf_dispose(&file_path);
40
+ git_buf_free(&file_path);
41
41
 
42
42
  return error;
43
43
  }
@@ -61,7 +61,7 @@ cleanup:
61
61
  if (error < 0)
62
62
  git_filebuf_cleanup(&file);
63
63
 
64
- git_buf_dispose(&file_path);
64
+ git_buf_free(&file_path);
65
65
 
66
66
  return error;
67
67
  }
@@ -216,7 +216,7 @@ done:
216
216
  git_index_free(index);
217
217
  git_commit_free(our_commit);
218
218
  git_reference_free(our_ref);
219
- git_buf_dispose(&their_label);
219
+ git_buf_free(&their_label);
220
220
 
221
221
  return error;
222
222
  }
@@ -48,7 +48,7 @@ static int create_branch(
48
48
  return error;
49
49
 
50
50
  error = git_reference_create(&branch_ref, repo, git_buf_cstr(&refname), target, 0, log_message);
51
- git_buf_dispose(&refname);
51
+ git_buf_free(&refname);
52
52
  git_commit_free(head_obj);
53
53
 
54
54
  if (!error)
@@ -87,8 +87,8 @@ static int setup_tracking_config(
87
87
  error = 0;
88
88
 
89
89
  cleanup:
90
- git_buf_dispose(&remote_key);
91
- git_buf_dispose(&merge_key);
90
+ git_buf_free(&remote_key);
91
+ git_buf_free(&merge_key);
92
92
  return error;
93
93
  }
94
94
 
@@ -195,8 +195,8 @@ static int update_head_to_remote(
195
195
  reflog_message);
196
196
 
197
197
  cleanup:
198
- git_buf_dispose(&remote_master_name);
199
- git_buf_dispose(&branch);
198
+ git_buf_free(&remote_master_name);
199
+ git_buf_free(&branch);
200
200
 
201
201
  return error;
202
202
  }
@@ -225,7 +225,7 @@ static int update_head_to_branch(
225
225
 
226
226
  cleanup:
227
227
  git_reference_free(remote_ref);
228
- git_buf_dispose(&remote_branch_name);
228
+ git_buf_free(&remote_branch_name);
229
229
  return retcode;
230
230
  }
231
231
 
@@ -351,7 +351,7 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
351
351
 
352
352
  cleanup:
353
353
  git_remote_free(remote);
354
- git_buf_dispose(&reflog_message);
354
+ git_buf_free(&reflog_message);
355
355
 
356
356
  return error;
357
357
  }
@@ -378,7 +378,7 @@ int git_clone__should_clone_local(const char *url_or_path, git_clone_local_t loc
378
378
  git_path_isdir(path);
379
379
 
380
380
  done:
381
- git_buf_dispose(&fromurl);
381
+ git_buf_free(&fromurl);
382
382
  return is_local;
383
383
  }
384
384
 
@@ -510,7 +510,7 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
510
510
 
511
511
  /* Copy .git/objects/ from the source to the target */
512
512
  if ((error = git_repository_open(&src, git_buf_cstr(&src_path))) < 0) {
513
- git_buf_dispose(&src_path);
513
+ git_buf_free(&src_path);
514
514
  return error;
515
515
  }
516
516
 
@@ -549,10 +549,10 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
549
549
  error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message));
550
550
 
551
551
  cleanup:
552
- git_buf_dispose(&reflog_message);
553
- git_buf_dispose(&src_path);
554
- git_buf_dispose(&src_odb);
555
- git_buf_dispose(&dst_odb);
552
+ git_buf_free(&reflog_message);
553
+ git_buf_free(&src_path);
554
+ git_buf_free(&src_odb);
555
+ git_buf_free(&dst_odb);
556
556
  git_repository_free(src);
557
557
  return error;
558
558
  }