rugged 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_commit.c +1 -1
  3. data/lib/rugged/commit.rb +16 -2
  4. data/lib/rugged/version.rb +1 -1
  5. data/vendor/libgit2/CMakeLists.txt +31 -69
  6. data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
  7. data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
  8. data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
  9. data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
  10. data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
  11. data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
  12. data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
  13. data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
  14. data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
  15. data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
  16. data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
  17. data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
  18. data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
  19. data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
  20. data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
  21. data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
  22. data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
  23. data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +25 -32
  24. data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +20 -28
  25. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
  26. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +6 -5
  27. data/vendor/libgit2/deps/ntlmclient/compat.h +8 -1
  28. data/vendor/libgit2/deps/ntlmclient/ntlm.c +8 -11
  29. data/vendor/libgit2/deps/pcre/LICENCE +93 -0
  30. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  31. data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
  32. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
  33. data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
  34. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
  35. data/vendor/libgit2/deps/zlib/deflate.c +1 -0
  36. data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
  37. data/vendor/libgit2/include/git2/blame.h +2 -0
  38. data/vendor/libgit2/include/git2/common.h +15 -3
  39. data/vendor/libgit2/include/git2/deprecated.h +42 -2
  40. data/vendor/libgit2/include/git2/errors.h +2 -1
  41. data/vendor/libgit2/include/git2/index.h +1 -2
  42. data/vendor/libgit2/include/git2/pack.h +1 -1
  43. data/vendor/libgit2/include/git2/strarray.h +6 -10
  44. data/vendor/libgit2/include/git2/version.h +4 -4
  45. data/vendor/libgit2/src/CMakeLists.txt +53 -41
  46. data/vendor/libgit2/src/apply.c +5 -1
  47. data/vendor/libgit2/src/assert_safe.h +58 -0
  48. data/vendor/libgit2/src/attr_file.c +8 -3
  49. data/vendor/libgit2/src/attrcache.c +2 -3
  50. data/vendor/libgit2/src/blame.c +2 -0
  51. data/vendor/libgit2/src/blame_git.c +6 -3
  52. data/vendor/libgit2/src/blob.c +2 -0
  53. data/vendor/libgit2/src/branch.c +19 -21
  54. data/vendor/libgit2/src/buffer.c +6 -3
  55. data/vendor/libgit2/src/cache.c +1 -22
  56. data/vendor/libgit2/src/checkout.c +49 -72
  57. data/vendor/libgit2/src/cherrypick.c +2 -0
  58. data/vendor/libgit2/src/clone.c +78 -18
  59. data/vendor/libgit2/src/common.h +1 -0
  60. data/vendor/libgit2/src/config.c +3 -7
  61. data/vendor/libgit2/src/config_entries.c +35 -27
  62. data/vendor/libgit2/src/config_parse.c +1 -1
  63. data/vendor/libgit2/src/config_snapshot.c +2 -1
  64. data/vendor/libgit2/src/describe.c +5 -1
  65. data/vendor/libgit2/src/diff.c +12 -11
  66. data/vendor/libgit2/src/diff_file.c +3 -1
  67. data/vendor/libgit2/src/diff_generate.c +10 -11
  68. data/vendor/libgit2/src/diff_parse.c +2 -3
  69. data/vendor/libgit2/src/diff_print.c +63 -60
  70. data/vendor/libgit2/src/diff_stats.c +12 -11
  71. data/vendor/libgit2/src/diff_tform.c +2 -3
  72. data/vendor/libgit2/src/errors.c +2 -0
  73. data/vendor/libgit2/src/fetch.c +2 -0
  74. data/vendor/libgit2/src/filter.c +3 -3
  75. data/vendor/libgit2/src/futils.c +3 -3
  76. data/vendor/libgit2/src/futils.h +3 -3
  77. data/vendor/libgit2/src/global.c +3 -1
  78. data/vendor/libgit2/src/idxmap.c +0 -22
  79. data/vendor/libgit2/src/index.c +12 -7
  80. data/vendor/libgit2/src/indexer.c +10 -4
  81. data/vendor/libgit2/src/iterator.c +4 -4
  82. data/vendor/libgit2/src/merge.c +13 -7
  83. data/vendor/libgit2/src/merge_file.c +4 -6
  84. data/vendor/libgit2/src/midx.c +418 -0
  85. data/vendor/libgit2/src/midx.h +83 -0
  86. data/vendor/libgit2/src/mwindow.c +124 -51
  87. data/vendor/libgit2/src/net.c +6 -1
  88. data/vendor/libgit2/src/object.c +2 -1
  89. data/vendor/libgit2/src/odb.c +9 -6
  90. data/vendor/libgit2/src/odb_loose.c +3 -3
  91. data/vendor/libgit2/src/odb_mempack.c +2 -0
  92. data/vendor/libgit2/src/oid.c +2 -0
  93. data/vendor/libgit2/src/pack-objects.c +29 -21
  94. data/vendor/libgit2/src/pack.c +47 -28
  95. data/vendor/libgit2/src/pack.h +19 -2
  96. data/vendor/libgit2/src/patch_generate.c +1 -3
  97. data/vendor/libgit2/src/patch_parse.c +4 -2
  98. data/vendor/libgit2/src/path.c +4 -4
  99. data/vendor/libgit2/src/pathspec.c +4 -3
  100. data/vendor/libgit2/src/pool.c +21 -15
  101. data/vendor/libgit2/src/pool.h +9 -1
  102. data/vendor/libgit2/src/proxy.c +2 -0
  103. data/vendor/libgit2/src/push.c +2 -0
  104. data/vendor/libgit2/src/rebase.c +2 -0
  105. data/vendor/libgit2/src/refdb.c +135 -0
  106. data/vendor/libgit2/src/refdb.h +69 -0
  107. data/vendor/libgit2/src/refdb_fs.c +19 -81
  108. data/vendor/libgit2/src/reflog.c +2 -6
  109. data/vendor/libgit2/src/refs.c +60 -188
  110. data/vendor/libgit2/src/refs.h +1 -19
  111. data/vendor/libgit2/src/regexp.c +2 -2
  112. data/vendor/libgit2/src/remote.c +32 -17
  113. data/vendor/libgit2/src/repository.c +168 -79
  114. data/vendor/libgit2/src/repository.h +10 -27
  115. data/vendor/libgit2/src/revert.c +2 -0
  116. data/vendor/libgit2/src/revparse.c +5 -4
  117. data/vendor/libgit2/src/revwalk.c +3 -5
  118. data/vendor/libgit2/src/settings.c +9 -0
  119. data/vendor/libgit2/src/sortedcache.c +2 -3
  120. data/vendor/libgit2/src/stash.c +2 -0
  121. data/vendor/libgit2/src/status.c +2 -0
  122. data/vendor/libgit2/src/strarray.c +63 -0
  123. data/vendor/libgit2/src/streams/openssl.c +12 -6
  124. data/vendor/libgit2/src/streams/registry.c +5 -3
  125. data/vendor/libgit2/src/submodule.c +6 -4
  126. data/vendor/libgit2/src/sysdir.c +4 -20
  127. data/vendor/libgit2/src/sysdir.h +0 -11
  128. data/vendor/libgit2/src/tag.c +2 -0
  129. data/vendor/libgit2/src/thread-utils.h +139 -21
  130. data/vendor/libgit2/src/transaction.c +2 -1
  131. data/vendor/libgit2/src/transports/credential.c +2 -0
  132. data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
  133. data/vendor/libgit2/src/transports/httpclient.c +6 -8
  134. data/vendor/libgit2/src/transports/local.c +2 -2
  135. data/vendor/libgit2/src/transports/smart.c +2 -2
  136. data/vendor/libgit2/src/transports/winhttp.c +18 -7
  137. data/vendor/libgit2/src/unix/posix.h +13 -1
  138. data/vendor/libgit2/src/util.c +25 -58
  139. data/vendor/libgit2/src/util.h +2 -2
  140. data/vendor/libgit2/src/win32/git2.rc +18 -3
  141. data/vendor/libgit2/src/win32/path_w32.c +2 -2
  142. data/vendor/libgit2/src/worktree.c +4 -0
  143. metadata +27 -25
  144. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
  145. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
  146. data/vendor/libgit2/src/refdb_fs.h +0 -19
@@ -391,11 +391,10 @@ int git_attr_cache__init(git_repository *repo)
391
391
  * hashtable for attribute macros, and string pool
392
392
  */
393
393
  if ((ret = git_strmap_new(&cache->files)) < 0 ||
394
- (ret = git_strmap_new(&cache->macros)) < 0)
394
+ (ret = git_strmap_new(&cache->macros)) < 0 ||
395
+ (ret = git_pool_init(&cache->pool, 1)) < 0)
395
396
  goto cancel;
396
397
 
397
- git_pool_init(&cache->pool, 1);
398
-
399
398
  cache = git__compare_and_swap(&repo->attrcache, NULL, cache);
400
399
  if (cache)
401
400
  goto cancel; /* raced with another thread, free this but no error */
@@ -538,7 +538,9 @@ int git_blame_options_init(git_blame_options *opts, unsigned int version)
538
538
  return 0;
539
539
  }
540
540
 
541
+ #ifndef GIT_DEPRECATE_HARD
541
542
  int git_blame_init_options(git_blame_options *opts, unsigned int version)
542
543
  {
543
544
  return git_blame_options_init(opts, version);
544
545
  }
546
+ #endif
@@ -365,11 +365,14 @@ static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx)
365
365
  b->size -= trimmed - recovered;
366
366
  }
367
367
 
368
- static int diff_hunks(mmfile_t file_a, mmfile_t file_b, void *cb_data)
368
+ static int diff_hunks(mmfile_t file_a, mmfile_t file_b, void *cb_data, git_blame_options *options)
369
369
  {
370
- xpparam_t xpp = {0};
371
370
  xdemitconf_t xecfg = {0};
372
371
  xdemitcb_t ecb = {0};
372
+ xpparam_t xpp = {0};
373
+
374
+ if (options->flags & GIT_BLAME_IGNORE_WHITESPACE)
375
+ xpp.flags |= XDF_IGNORE_WHITESPACE;
373
376
 
374
377
  xecfg.hunk_func = my_emit;
375
378
  ecb.priv = cb_data;
@@ -409,7 +412,7 @@ static int pass_blame_to_parent(
409
412
  fill_origin_blob(parent, &file_p);
410
413
  fill_origin_blob(target, &file_o);
411
414
 
412
- if (diff_hunks(file_p, file_o, &d) < 0)
415
+ if (diff_hunks(file_p, file_o, &d, &blame->options) < 0)
413
416
  return -1;
414
417
 
415
418
  /* The reset (i.e. anything after tlno) are the same as the parent */
@@ -445,6 +445,7 @@ int git_blob_filter(
445
445
 
446
446
  /* Deprecated functions */
447
447
 
448
+ #ifndef GIT_DEPRECATE_HARD
448
449
  int git_blob_create_frombuffer(
449
450
  git_oid *id, git_repository *repo, const void *buffer, size_t len)
450
451
  {
@@ -491,3 +492,4 @@ int git_blob_filtered_content(
491
492
 
492
493
  return git_blob_filter(out, blob, path, &opts);
493
494
  }
495
+ #endif
@@ -134,39 +134,37 @@ int git_branch_create_from_annotated(
134
134
  repository, branch_name, commit->commit, commit->description, force);
135
135
  }
136
136
 
137
- static int branch_equals(git_repository *repo, const char *path, void *payload)
137
+ static int branch_is_checked_out(git_repository *worktree, void *payload)
138
138
  {
139
139
  git_reference *branch = (git_reference *) payload;
140
140
  git_reference *head = NULL;
141
- int equal = 0;
141
+ int error;
142
142
 
143
- if (git_reference__read_head(&head, repo, path) < 0 ||
144
- git_reference_type(head) != GIT_REFERENCE_SYMBOLIC)
145
- goto done;
143
+ if (git_repository_is_bare(worktree))
144
+ return 0;
146
145
 
147
- equal = !git__strcmp(head->target.symbolic, branch->name);
146
+ if ((error = git_reference_lookup(&head, worktree, GIT_HEAD_FILE)) < 0) {
147
+ if (error == GIT_ENOTFOUND)
148
+ error = 0;
149
+ goto out;
150
+ }
148
151
 
149
- done:
152
+ if (git_reference_type(head) != GIT_REFERENCE_SYMBOLIC)
153
+ goto out;
154
+
155
+ error = !git__strcmp(head->target.symbolic, branch->name);
156
+
157
+ out:
150
158
  git_reference_free(head);
151
- return equal;
159
+ return error;
152
160
  }
153
161
 
154
162
  int git_branch_is_checked_out(const git_reference *branch)
155
163
  {
156
- git_repository *repo;
157
- int flags = 0;
158
-
159
- assert(branch);
160
-
161
164
  if (!git_reference_is_branch(branch))
162
165
  return 0;
163
-
164
- repo = git_reference_owner(branch);
165
-
166
- if (git_repository_is_bare(repo))
167
- flags |= GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO;
168
-
169
- return git_repository_foreach_head(repo, branch_equals, flags, (void *) branch) == 1;
166
+ return git_repository_foreach_worktree(git_reference_owner(branch),
167
+ branch_is_checked_out, (void *)branch) == 1;
170
168
  }
171
169
 
172
170
  int git_branch_delete(git_reference *branch)
@@ -548,7 +546,7 @@ cleanup:
548
546
  if (error < 0)
549
547
  git_buf_dispose(buf);
550
548
 
551
- git_strarray_free(&remote_list);
549
+ git_strarray_dispose(&remote_list);
552
550
  return error;
553
551
  }
554
552
 
@@ -133,10 +133,12 @@ void git_buf_dispose(git_buf *buf)
133
133
  git_buf_init(buf, 0);
134
134
  }
135
135
 
136
+ #ifndef GIT_DEPRECATE_HARD
136
137
  void git_buf_free(git_buf *buf)
137
138
  {
138
139
  git_buf_dispose(buf);
139
140
  }
141
+ #endif
140
142
 
141
143
  void git_buf_sanitize(git_buf *buf)
142
144
  {
@@ -363,7 +365,7 @@ int git_buf_encode_base85(git_buf *buf, const char *data, size_t len)
363
365
 
364
366
  for (i = 24; i >= 0; i -= 8) {
365
367
  uint8_t ch = *data++;
366
- acc |= ch << i;
368
+ acc |= (uint32_t)ch << i;
367
369
 
368
370
  if (--len == 0)
369
371
  break;
@@ -757,7 +759,8 @@ int git_buf_join(
757
759
  ssize_t offset_a = -1;
758
760
 
759
761
  /* not safe to have str_b point internally to the buffer */
760
- assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size);
762
+ if (buf->size)
763
+ assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size);
761
764
 
762
765
  /* figure out if we need to insert a separator */
763
766
  if (separator && strlen_a) {
@@ -767,7 +770,7 @@ int git_buf_join(
767
770
  }
768
771
 
769
772
  /* str_a could be part of the buffer */
770
- if (str_a >= buf->ptr && str_a < buf->ptr + buf->size)
773
+ if (buf->size && str_a >= buf->ptr && str_a < buf->ptr + buf->size)
771
774
  offset_a = str_a - buf->ptr;
772
775
 
773
776
  GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, strlen_a, strlen_b);
@@ -41,27 +41,6 @@ int git_cache_set_max_object_size(git_object_t type, size_t size)
41
41
  return 0;
42
42
  }
43
43
 
44
- void git_cache_dump_stats(git_cache *cache)
45
- {
46
- git_cached_obj *object;
47
-
48
- if (git_cache_size(cache) == 0)
49
- return;
50
-
51
- printf("Cache %p: %"PRIuZ" items cached, %"PRIdZ" bytes\n",
52
- cache, git_cache_size(cache), cache->used_memory);
53
-
54
- git_oidmap_foreach_value(cache->map, object, {
55
- char oid_str[9];
56
- printf(" %s%c %s (%"PRIuZ")\n",
57
- git_object_type2string(object->type),
58
- object->flags == GIT_CACHE_STORE_PARSED ? '*' : ' ',
59
- git_oid_tostr(oid_str, sizeof(oid_str), &object->oid),
60
- object->size
61
- );
62
- });
63
- }
64
-
65
44
  int git_cache_init(git_cache *cache)
66
45
  {
67
46
  memset(cache, 0, sizeof(*cache));
@@ -189,7 +168,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
189
168
  return entry;
190
169
 
191
170
  /* soften the load on the cache */
192
- if (git_cache__current_storage.val > git_cache__max_storage)
171
+ if (git_atomic_ssize_get(&git_cache__current_storage) > git_cache__max_storage)
193
172
  cache_evict_entries(cache);
194
173
 
195
174
  /* not found */
@@ -44,7 +44,6 @@ enum {
44
44
  CHECKOUT_ACTION__REMOVE_CONFLICT = 16,
45
45
  CHECKOUT_ACTION__UPDATE_CONFLICT = 32,
46
46
  CHECKOUT_ACTION__MAX = 32,
47
- CHECKOUT_ACTION__DEFER_REMOVE = 64,
48
47
  CHECKOUT_ACTION__REMOVE_AND_UPDATE =
49
48
  (CHECKOUT_ACTION__UPDATE_BLOB | CHECKOUT_ACTION__REMOVE),
50
49
  };
@@ -196,7 +195,7 @@ static bool checkout_is_workdir_modified(
196
195
  }
197
196
 
198
197
  if (git_submodule_status(&sm_status, data->repo, wditem->path, GIT_SUBMODULE_IGNORE_UNSPECIFIED) < 0 ||
199
- GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status))
198
+ GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status))
200
199
  rval = true;
201
200
  else if ((sm_oid = git_submodule_wd_id(sm)) == NULL)
202
201
  rval = false;
@@ -217,9 +216,10 @@ static bool checkout_is_workdir_modified(
217
216
  ie = git_index_get_bypath(data->index, wditem->path, 0);
218
217
 
219
218
  if (ie != NULL &&
220
- git_index_time_eq(&wditem->mtime, &ie->mtime) &&
221
- wditem->file_size == ie->file_size &&
222
- !is_filemode_changed(wditem->mode, ie->mode, data->respect_filemode)) {
219
+ !git_index_entry_newer_than_index(ie, data->index) &&
220
+ git_index_time_eq(&wditem->mtime, &ie->mtime) &&
221
+ wditem->file_size == ie->file_size &&
222
+ !is_filemode_changed(wditem->mode, ie->mode, data->respect_filemode)) {
223
223
 
224
224
  /* The workdir is modified iff the index entry is modified */
225
225
  return !is_workdir_base_or_new(&ie->id, baseitem, newitem) ||
@@ -273,9 +273,8 @@ static int checkout_action_common(
273
273
 
274
274
  /* if the file is on disk and doesn't match our mode, force update */
275
275
  if (wd &&
276
- GIT_PERMS_IS_EXEC(wd->mode) !=
277
- GIT_PERMS_IS_EXEC(delta->new_file.mode))
278
- *action |= CHECKOUT_ACTION__REMOVE;
276
+ GIT_PERMS_IS_EXEC(wd->mode) != GIT_PERMS_IS_EXEC(delta->new_file.mode))
277
+ *action |= CHECKOUT_ACTION__REMOVE;
279
278
 
280
279
  notify = GIT_CHECKOUT_NOTIFY_UPDATED;
281
280
  }
@@ -371,8 +370,13 @@ static int checkout_action_wd_only(
371
370
  if (!git_pathspec__match(
372
371
  pathspec, wd->path,
373
372
  (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0,
374
- git_iterator_ignore_case(workdir), NULL, NULL))
375
- return git_iterator_advance(wditem, workdir);
373
+ git_iterator_ignore_case(workdir), NULL, NULL)) {
374
+
375
+ if (wd->mode == GIT_FILEMODE_TREE)
376
+ return git_iterator_advance_into(wditem, workdir);
377
+ else
378
+ return git_iterator_advance(wditem, workdir);
379
+ }
376
380
 
377
381
  /* check if item is tracked in the index but not in the checkout diff */
378
382
  if (data->index != NULL) {
@@ -794,13 +798,13 @@ static int checkout_conflictdata_cmp(const void *a, const void *b)
794
798
  int diff;
795
799
 
796
800
  if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 &&
797
- (diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0)
801
+ (diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0)
798
802
  diff = checkout_idxentry_cmp(ca->theirs, cb->theirs);
799
803
 
800
804
  return diff;
801
805
  }
802
806
 
803
- int checkout_conflictdata_empty(
807
+ static int checkout_conflictdata_empty(
804
808
  const git_vector *conflicts, size_t idx, void *payload)
805
809
  {
806
810
  checkout_conflictdata *conflict;
@@ -1173,7 +1177,7 @@ static int checkout_conflicts_mark_directoryfile(
1173
1177
  /* Find d/f conflicts */
1174
1178
  git_vector_foreach(&data->update_conflicts, i, conflict) {
1175
1179
  if ((conflict->ours && conflict->theirs) ||
1176
- (!conflict->ours && !conflict->theirs))
1180
+ (!conflict->ours && !conflict->theirs))
1177
1181
  continue;
1178
1182
 
1179
1183
  path = conflict->ours ?
@@ -1222,8 +1226,8 @@ static int checkout_get_update_conflicts(
1222
1226
  return 0;
1223
1227
 
1224
1228
  if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 ||
1225
- (error = checkout_conflicts_coalesce_renames(data)) < 0 ||
1226
- (error = checkout_conflicts_mark_directoryfile(data)) < 0)
1229
+ (error = checkout_conflicts_coalesce_renames(data)) < 0 ||
1230
+ (error = checkout_conflicts_mark_directoryfile(data)) < 0)
1227
1231
  goto done;
1228
1232
 
1229
1233
  done:
@@ -1304,14 +1308,15 @@ static int checkout_get_actions(
1304
1308
  size_t i, *counts = NULL;
1305
1309
  uint32_t *actions = NULL;
1306
1310
 
1307
- git_pool_init(&pathpool, 1);
1311
+ if (git_pool_init(&pathpool, 1) < 0)
1312
+ return -1;
1308
1313
 
1309
1314
  if (data->opts.paths.count > 0 &&
1310
- git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0)
1315
+ git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0)
1311
1316
  return -1;
1312
1317
 
1313
1318
  if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
1314
- error != GIT_ITEROVER)
1319
+ error != GIT_ITEROVER)
1315
1320
  goto fail;
1316
1321
 
1317
1322
  deltas = &data->diff->deltas;
@@ -1350,8 +1355,7 @@ static int checkout_get_actions(
1350
1355
  counts[CHECKOUT_ACTION__REMOVE] += data->removes.length;
1351
1356
 
1352
1357
  if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
1353
- (data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0)
1354
- {
1358
+ (data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0) {
1355
1359
  git_error_set(GIT_ERROR_CHECKOUT, "%"PRIuZ" %s checkout",
1356
1360
  counts[CHECKOUT_ACTION__CONFLICT],
1357
1361
  counts[CHECKOUT_ACTION__CONFLICT] == 1 ?
@@ -1362,7 +1366,7 @@ static int checkout_get_actions(
1362
1366
 
1363
1367
 
1364
1368
  if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 ||
1365
- (error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0)
1369
+ (error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0)
1366
1370
  goto fail;
1367
1371
 
1368
1372
  counts[CHECKOUT_ACTION__REMOVE_CONFLICT] = git_vector_length(&data->remove_conflicts);
@@ -1853,26 +1857,6 @@ static int checkout_remove_the_old(
1853
1857
  return 0;
1854
1858
  }
1855
1859
 
1856
- static int checkout_deferred_remove(git_repository *repo, const char *path)
1857
- {
1858
- #if 0
1859
- int error = git_futils_rmdir_r(
1860
- path, data->opts.target_directory, GIT_RMDIR_EMPTY_PARENTS);
1861
-
1862
- if (error == GIT_ENOTFOUND) {
1863
- error = 0;
1864
- git_error_clear();
1865
- }
1866
-
1867
- return error;
1868
- #else
1869
- GIT_UNUSED(repo);
1870
- GIT_UNUSED(path);
1871
- assert(false);
1872
- return 0;
1873
- #endif
1874
- }
1875
-
1876
1860
  static int checkout_create_the_new(
1877
1861
  unsigned int *actions,
1878
1862
  checkout_data *data)
@@ -1882,15 +1866,6 @@ static int checkout_create_the_new(
1882
1866
  size_t i;
1883
1867
 
1884
1868
  git_vector_foreach(&data->diff->deltas, i, delta) {
1885
- if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
1886
- /* this had a blocker directory that should only be removed iff
1887
- * all of the contents of the directory were safely removed
1888
- */
1889
- if ((error = checkout_deferred_remove(
1890
- data->repo, delta->old_file.path)) < 0)
1891
- return error;
1892
- }
1893
-
1894
1869
  if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && !S_ISLNK(delta->new_file.mode)) {
1895
1870
  if ((error = checkout_blob(data, &delta->new_file)) < 0)
1896
1871
  return error;
@@ -1915,20 +1890,10 @@ static int checkout_create_submodules(
1915
1890
  unsigned int *actions,
1916
1891
  checkout_data *data)
1917
1892
  {
1918
- int error = 0;
1919
1893
  git_diff_delta *delta;
1920
1894
  size_t i;
1921
1895
 
1922
1896
  git_vector_foreach(&data->diff->deltas, i, delta) {
1923
- if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
1924
- /* this has a blocker directory that should only be removed iff
1925
- * all of the contents of the directory were safely removed
1926
- */
1927
- if ((error = checkout_deferred_remove(
1928
- data->repo, delta->old_file.path)) < 0)
1929
- return error;
1930
- }
1931
-
1932
1897
  if (actions[i] & CHECKOUT_ACTION__UPDATE_SUBMODULE) {
1933
1898
  int error = checkout_submodule(data, &delta->new_file);
1934
1899
  if (error < 0)
@@ -2520,9 +2485,8 @@ static int checkout_data_init(
2520
2485
  git_config_entry_free(conflict_style);
2521
2486
  }
2522
2487
 
2523
- git_pool_init(&data->pool, 1);
2524
-
2525
- if ((error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
2488
+ if ((error = git_pool_init(&data->pool, 1)) < 0 ||
2489
+ (error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
2526
2490
  (error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 ||
2527
2491
  (error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 ||
2528
2492
  (error = git_buf_puts(&data->target_path, data->opts.target_directory)) < 0 ||
@@ -2544,6 +2508,17 @@ cleanup:
2544
2508
  #define CHECKOUT_INDEX_DONT_WRITE_MASK \
2545
2509
  (GIT_CHECKOUT_DONT_UPDATE_INDEX | GIT_CHECKOUT_DONT_WRITE_INDEX)
2546
2510
 
2511
+ GIT_INLINE(void) setup_pathspecs(
2512
+ git_iterator_options *iter_opts,
2513
+ const git_checkout_options *checkout_opts)
2514
+ {
2515
+ if (checkout_opts &&
2516
+ (checkout_opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
2517
+ iter_opts->pathlist.count = checkout_opts->paths.count;
2518
+ iter_opts->pathlist.strings = checkout_opts->paths.strings;
2519
+ }
2520
+ }
2521
+
2547
2522
  int git_checkout_iterator(
2548
2523
  git_iterator *target,
2549
2524
  git_index *index,
@@ -2586,6 +2561,8 @@ int git_checkout_iterator(
2586
2561
  workdir_opts.start = data.pfx;
2587
2562
  workdir_opts.end = data.pfx;
2588
2563
 
2564
+ setup_pathspecs(&workdir_opts, opts);
2565
+
2589
2566
  if ((error = git_iterator_reset_range(target, data.pfx, data.pfx)) < 0 ||
2590
2567
  (error = git_iterator_for_workdir_ext(
2591
2568
  &workdir, data.repo, data.opts.target_directory, index, NULL,
@@ -2596,10 +2573,8 @@ int git_checkout_iterator(
2596
2573
  GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE;
2597
2574
  baseline_opts.start = data.pfx;
2598
2575
  baseline_opts.end = data.pfx;
2599
- if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
2600
- baseline_opts.pathlist.count = opts->paths.count;
2601
- baseline_opts.pathlist.strings = opts->paths.strings;
2602
- }
2576
+
2577
+ setup_pathspecs(&baseline_opts, opts);
2603
2578
 
2604
2579
  if (data.opts.baseline_index) {
2605
2580
  if ((error = git_iterator_for_index(
@@ -2689,6 +2664,7 @@ int git_checkout_index(
2689
2664
  git_index *index,
2690
2665
  const git_checkout_options *opts)
2691
2666
  {
2667
+ git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
2692
2668
  int error, owned = 0;
2693
2669
  git_iterator *index_i;
2694
2670
 
@@ -2716,7 +2692,9 @@ int git_checkout_index(
2716
2692
  return error;
2717
2693
  GIT_REFCOUNT_INC(index);
2718
2694
 
2719
- if (!(error = git_iterator_for_index(&index_i, repo, index, NULL)))
2695
+ setup_pathspecs(&iter_opts, opts);
2696
+
2697
+ if (!(error = git_iterator_for_index(&index_i, repo, index, &iter_opts)))
2720
2698
  error = git_checkout_iterator(index_i, index, opts);
2721
2699
 
2722
2700
  if (owned)
@@ -2773,10 +2751,7 @@ int git_checkout_tree(
2773
2751
  if ((error = git_repository_index(&index, repo)) < 0)
2774
2752
  return error;
2775
2753
 
2776
- if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
2777
- iter_opts.pathlist.count = opts->paths.count;
2778
- iter_opts.pathlist.strings = opts->paths.strings;
2779
- }
2754
+ setup_pathspecs(&iter_opts, opts);
2780
2755
 
2781
2756
  if (!(error = git_iterator_for_tree(&tree_i, tree, &iter_opts)))
2782
2757
  error = git_checkout_iterator(tree_i, index, opts);
@@ -2803,7 +2778,9 @@ int git_checkout_options_init(git_checkout_options *opts, unsigned int version)
2803
2778
  return 0;
2804
2779
  }
2805
2780
 
2781
+ #ifndef GIT_DEPRECATE_HARD
2806
2782
  int git_checkout_init_options(git_checkout_options *opts, unsigned int version)
2807
2783
  {
2808
2784
  return git_checkout_options_init(opts, version);
2809
2785
  }
2786
+ #endif