rugged 0.23.0b1 → 0.23.0b2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_note.c +7 -2
  3. data/ext/rugged/rugged_revwalk.c +321 -145
  4. data/lib/rugged/version.rb +1 -1
  5. data/vendor/libgit2/CMakeLists.txt +83 -8
  6. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +9 -0
  7. data/vendor/libgit2/cmake/Modules/FindIconv.cmake +0 -3
  8. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +9 -0
  9. data/vendor/libgit2/deps/winhttp/urlmon.h +45 -0
  10. data/vendor/libgit2/deps/winhttp/winhttp.def +29 -0
  11. data/vendor/libgit2/deps/winhttp/winhttp.h +592 -0
  12. data/vendor/libgit2/deps/winhttp/winhttp64.def +29 -0
  13. data/vendor/libgit2/include/git2/diff.h +6 -1
  14. data/vendor/libgit2/include/git2/index.h +1 -1
  15. data/vendor/libgit2/include/git2/merge.h +2 -1
  16. data/vendor/libgit2/include/git2/notes.h +2 -2
  17. data/vendor/libgit2/include/git2/pack.h +12 -0
  18. data/vendor/libgit2/include/git2/push.h +30 -0
  19. data/vendor/libgit2/include/git2/rebase.h +36 -16
  20. data/vendor/libgit2/include/git2/remote.h +6 -0
  21. data/vendor/libgit2/include/git2/reset.h +2 -2
  22. data/vendor/libgit2/include/git2/revwalk.h +10 -8
  23. data/vendor/libgit2/include/git2/submodule.h +16 -0
  24. data/vendor/libgit2/include/git2/sys/transport.h +12 -4
  25. data/vendor/libgit2/include/git2/types.h +1 -0
  26. data/vendor/libgit2/src/attr.c +3 -3
  27. data/vendor/libgit2/src/attr_file.c +24 -3
  28. data/vendor/libgit2/src/attr_file.h +3 -1
  29. data/vendor/libgit2/src/checkout.c +31 -7
  30. data/vendor/libgit2/src/config.c +5 -6
  31. data/vendor/libgit2/src/config_file.c +533 -469
  32. data/vendor/libgit2/src/describe.c +1 -1
  33. data/vendor/libgit2/src/diff.c +20 -10
  34. data/vendor/libgit2/src/diff_driver.c +1 -1
  35. data/vendor/libgit2/src/diff_tform.c +8 -2
  36. data/vendor/libgit2/src/filter.c +6 -3
  37. data/vendor/libgit2/src/global.c +17 -15
  38. data/vendor/libgit2/src/global.h +3 -1
  39. data/vendor/libgit2/src/ignore.c +48 -8
  40. data/vendor/libgit2/src/ignore.h +1 -1
  41. data/vendor/libgit2/src/index.c +12 -8
  42. data/vendor/libgit2/src/iterator.c +133 -12
  43. data/vendor/libgit2/src/netops.h +2 -2
  44. data/vendor/libgit2/src/notes.c +40 -21
  45. data/vendor/libgit2/src/openssl_stream.c +5 -1
  46. data/vendor/libgit2/src/pack-objects.c +36 -0
  47. data/vendor/libgit2/src/path.c +277 -140
  48. data/vendor/libgit2/src/path.h +132 -60
  49. data/vendor/libgit2/src/posix.h +0 -1
  50. data/vendor/libgit2/src/push.c +43 -4
  51. data/vendor/libgit2/src/push.h +8 -1
  52. data/vendor/libgit2/src/rebase.c +139 -119
  53. data/vendor/libgit2/src/reflog.c +1 -1
  54. data/vendor/libgit2/src/refs.c +3 -5
  55. data/vendor/libgit2/src/remote.c +6 -5
  56. data/vendor/libgit2/src/repository.c +7 -3
  57. data/vendor/libgit2/src/reset.c +3 -3
  58. data/vendor/libgit2/src/revwalk.c +26 -2
  59. data/vendor/libgit2/src/settings.c +3 -3
  60. data/vendor/libgit2/src/stransport_stream.c +249 -0
  61. data/vendor/libgit2/src/stransport_stream.h +14 -0
  62. data/vendor/libgit2/src/submodule.c +26 -2
  63. data/vendor/libgit2/src/tls_stream.c +28 -0
  64. data/vendor/libgit2/src/tls_stream.h +21 -0
  65. data/vendor/libgit2/src/transport.c +4 -4
  66. data/vendor/libgit2/src/transports/git.c +4 -1
  67. data/vendor/libgit2/src/transports/http.c +6 -4
  68. data/vendor/libgit2/src/transports/local.c +2 -1
  69. data/vendor/libgit2/src/transports/smart.c +1 -1
  70. data/vendor/libgit2/src/transports/ssh.c +5 -1
  71. data/vendor/libgit2/src/transports/winhttp.c +30 -23
  72. data/vendor/libgit2/src/tree.c +2 -2
  73. data/vendor/libgit2/src/unix/posix.h +1 -0
  74. data/vendor/libgit2/src/util.h +117 -0
  75. data/vendor/libgit2/src/win32/buffer.c +55 -0
  76. data/vendor/libgit2/src/win32/buffer.h +18 -0
  77. data/vendor/libgit2/src/win32/path_w32.c +75 -0
  78. data/vendor/libgit2/src/win32/path_w32.h +3 -0
  79. data/vendor/libgit2/src/win32/posix.h +2 -2
  80. data/vendor/libgit2/src/win32/posix_w32.c +2 -118
  81. data/vendor/libgit2/src/win32/pthread.c +2 -0
  82. data/vendor/libgit2/src/win32/utf-conv.c +0 -4
  83. data/vendor/libgit2/src/win32/utf-conv.h +4 -0
  84. data/vendor/libgit2/src/win32/w32_util.h +72 -0
  85. metadata +14 -2
@@ -127,6 +127,18 @@ GIT_EXTERN(int) git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid
127
127
  */
128
128
  GIT_EXTERN(int) git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk);
129
129
 
130
+ /**
131
+ * Recursively insert an object and its referenced objects
132
+ *
133
+ * Insert the object as well as any object it references.
134
+ *
135
+ * @param pb the packbuilder
136
+ * @param id the id of the root object to insert
137
+ * @param name optional name for the object
138
+ * @return 0 or an error code
139
+ */
140
+ GIT_EXTERN(int) git_packbuilder_insert_recur(git_packbuilder *pb, const git_oid *id, const char *name);
141
+
130
142
  /**
131
143
  * Write the contents of the packfile to an in-memory buffer
132
144
  *
@@ -59,6 +59,36 @@ typedef int (*git_push_transfer_progress)(
59
59
  size_t bytes,
60
60
  void* payload);
61
61
 
62
+ /**
63
+ * Represents an update which will be performed on the remote during push
64
+ */
65
+ typedef struct {
66
+ /**
67
+ * The source name of the reference
68
+ */
69
+ char *src_refname;
70
+ /**
71
+ * The name of the reference to update on the server
72
+ */
73
+ char *dst_refname;
74
+ /**
75
+ * The current target of the reference
76
+ */
77
+ git_oid src;
78
+ /**
79
+ * The new target for the reference
80
+ */
81
+ git_oid dst;
82
+ } git_push_update;
83
+
84
+ /**
85
+ * @param updates an array containing the updates which will be sent
86
+ * as commands to the destination.
87
+ * @param len number of elements in `updates`
88
+ * @param payload Payload provided by the caller
89
+ */
90
+ typedef int (*git_push_negotiation)(const git_push_update **updates, size_t len, void *payload);
91
+
62
92
  /** @} */
63
93
  GIT_END_DECL
64
94
  #endif
@@ -30,19 +30,32 @@ typedef struct {
30
30
  unsigned int version;
31
31
 
32
32
  /**
33
- * Provide a quiet rebase experience; unused by libgit2 but provided for
34
- * interoperability with other clients.
33
+ * Used by `git_rebase_init`, this will instruct other clients working
34
+ * on this rebase that you want a quiet rebase experience, which they
35
+ * may choose to provide in an application-specific manner. This has no
36
+ * effect upon libgit2 directly, but is provided for interoperability
37
+ * between Git tools.
35
38
  */
36
39
  int quiet;
37
40
 
38
41
  /**
39
- * Canonical name of the notes reference used to rewrite notes for
40
- * rebased commits when finishing the rebase; if NULL, the contents of
41
- * the coniguration option `notes.rewriteRef` is examined, unless the
42
- * configuration option `notes.rewrite.rebase` is set to false. If
43
- * `notes.rewriteRef` is NULL, notes will not be rewritten.
42
+ * Used by `git_rebase_finish`, this is the name of the notes reference
43
+ * used to rewrite notes for rebased commits when finishing the rebase;
44
+ * if NULL, the contents of the coniguration option `notes.rewriteRef`
45
+ * is examined, unless the configuration option `notes.rewrite.rebase`
46
+ * is set to false. If `notes.rewriteRef` is also NULL, notes will
47
+ * not be rewritten.
44
48
  */
45
49
  const char *rewrite_notes_ref;
50
+
51
+ /**
52
+ * Options to control how files are written during `git_rebase_init`,
53
+ * `git_checkout_next` and `git_checkout_abort`. Note that a minimum
54
+ * strategy of `GIT_CHECKOUT_SAFE` is defaulted in `init` and `next`,
55
+ * and a minimum strategy of `GIT_CHECKOUT_FORCE` is defaulted in
56
+ * `abort` to match git semantics.
57
+ */
58
+ git_checkout_options checkout_options;
46
59
  } git_rebase_options;
47
60
 
48
61
  /**
@@ -87,7 +100,11 @@ typedef enum {
87
100
  } git_rebase_operation_t;
88
101
 
89
102
  #define GIT_REBASE_OPTIONS_VERSION 1
90
- #define GIT_REBASE_OPTIONS_INIT {GIT_REBASE_OPTIONS_VERSION}
103
+ #define GIT_REBASE_OPTIONS_INIT \
104
+ {GIT_REBASE_OPTIONS_VERSION, 0, NULL, GIT_CHECKOUT_OPTIONS_INIT}
105
+
106
+ /** Indicates that a rebase operation is not (yet) in progress. */
107
+ #define GIT_REBASE_NO_OPERATION SIZE_MAX
91
108
 
92
109
  /**
93
110
  * A rebase operation
@@ -139,7 +156,7 @@ GIT_EXTERN(int) git_rebase_init_options(
139
156
  * reachable commits
140
157
  * @param onto The branch to rebase onto, or NULL to rebase onto the given
141
158
  * upstream
142
- * @param opts Options to specify how rebase is performed
159
+ * @param opts Options to specify how rebase is performed, or NULL
143
160
  * @return Zero on success; -1 on failure.
144
161
  */
145
162
  GIT_EXTERN(int) git_rebase_init(
@@ -156,9 +173,13 @@ GIT_EXTERN(int) git_rebase_init(
156
173
  *
157
174
  * @param out Pointer to store the rebase object
158
175
  * @param repo The repository that has a rebase in-progress
176
+ * @param opts Options to specify how rebase is performed
159
177
  * @return Zero on success; -1 on failure.
160
178
  */
161
- GIT_EXTERN(int) git_rebase_open(git_rebase **out, git_repository *repo);
179
+ GIT_EXTERN(int) git_rebase_open(
180
+ git_rebase **out,
181
+ git_repository *repo,
182
+ const git_rebase_options *opts);
162
183
 
163
184
  /**
164
185
  * Gets the count of rebase operations that are to be applied.
@@ -170,6 +191,9 @@ GIT_EXTERN(size_t) git_rebase_operation_entrycount(git_rebase *rebase);
170
191
 
171
192
  /**
172
193
  * Gets the index of the rebase operation that is currently being applied.
194
+ * If the first operation has not yet been applied (because you have
195
+ * called `init` but not yet `next`) then this returns
196
+ * `GIT_REBASE_NO_OPERATION`.
173
197
  *
174
198
  * @param rebase The in-progress rebase
175
199
  * @return The index of the rebase operation currently being applied.
@@ -196,13 +220,11 @@ GIT_EXTERN(git_rebase_operation *) git_rebase_operation_byindex(
196
220
  *
197
221
  * @param operation Pointer to store the rebase operation that is to be performed next
198
222
  * @param rebase The rebase in progress
199
- * @param checkout_opts Options to specify how the patch should be checked out
200
223
  * @return Zero on success; -1 on failure.
201
224
  */
202
225
  GIT_EXTERN(int) git_rebase_next(
203
226
  git_rebase_operation **operation,
204
- git_rebase *rebase,
205
- git_checkout_options *checkout_opts);
227
+ git_rebase *rebase);
206
228
 
207
229
  /**
208
230
  * Commits the current patch. You must have resolved any conflicts that
@@ -250,13 +272,11 @@ GIT_EXTERN(int) git_rebase_abort(git_rebase *rebase);
250
272
  *
251
273
  * @param rebase The rebase that is in-progress
252
274
  * @param signature The identity that is finishing the rebase (optional)
253
- * @param opts Options to specify how rebase is finished
254
275
  * @return Zero on success; -1 on error
255
276
  */
256
277
  GIT_EXTERN(int) git_rebase_finish(
257
278
  git_rebase *rebase,
258
- const git_signature *signature,
259
- const git_rebase_options *opts);
279
+ const git_signature *signature);
260
280
 
261
281
  /**
262
282
  * Frees the `git_rebase` object.
@@ -520,6 +520,12 @@ struct git_remote_callbacks {
520
520
  */
521
521
  int (*push_update_reference)(const char *refname, const char *status, void *data);
522
522
 
523
+ /**
524
+ * Called once between the negotiation step and the upload. It
525
+ * provides information about what updates will be performed.
526
+ */
527
+ git_push_negotiation push_negotiation;
528
+
523
529
  /**
524
530
  * This will be passed to each of the callbacks in this struct
525
531
  * as the last parameter.
@@ -62,7 +62,7 @@ GIT_EXTERN(int) git_reset(
62
62
  git_repository *repo,
63
63
  git_object *target,
64
64
  git_reset_t reset_type,
65
- git_checkout_options *checkout_opts);
65
+ const git_checkout_options *checkout_opts);
66
66
 
67
67
  /**
68
68
  * Sets the current head to the specified commit oid and optionally
@@ -80,7 +80,7 @@ GIT_EXTERN(int) git_reset_from_annotated(
80
80
  git_repository *repo,
81
81
  git_annotated_commit *commit,
82
82
  git_reset_t reset_type,
83
- git_checkout_options *checkout_opts);
83
+ const git_checkout_options *checkout_opts);
84
84
 
85
85
  /**
86
86
  * Updates some entries in the index from the target commit tree.
@@ -90,15 +90,17 @@ GIT_EXTERN(int) git_revwalk_new(git_revwalk **out, git_repository *repo);
90
90
  GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker);
91
91
 
92
92
  /**
93
- * Mark a commit to start traversal from.
93
+ * Add a new root for the traversal
94
94
  *
95
- * The given OID must belong to a committish on the walked
96
- * repository.
95
+ * The pushed commit will be marked as one of the roots from which to
96
+ * start the walk. This commit may not be walked if it or a child is
97
+ * hidden.
98
+ *
99
+ * At least one commit must be pushed onto the walker before a walk
100
+ * can be started.
97
101
  *
98
- * The given commit will be used as one of the roots
99
- * when starting the revision walk. At least one commit
100
- * must be pushed onto the walker before a walk can
101
- * be started.
102
+ * The given id must belong to a committish on the walked
103
+ * repository.
102
104
  *
103
105
  * @param walk the walker being used for the traversal.
104
106
  * @param id the oid of the commit to start from.
@@ -135,7 +137,7 @@ GIT_EXTERN(int) git_revwalk_push_head(git_revwalk *walk);
135
137
  /**
136
138
  * Mark a commit (and its ancestors) uninteresting for the output.
137
139
  *
138
- * The given OID must belong to a committish on the walked
140
+ * The given id must belong to a committish on the walked
139
141
  * repository.
140
142
  *
141
143
  * The resolved commit and all its parents will be hidden from the
@@ -370,6 +370,22 @@ GIT_EXTERN(int) git_submodule_resolve_url(git_buf *out, git_repository *repo, co
370
370
  */
371
371
  GIT_EXTERN(const char *) git_submodule_branch(git_submodule *submodule);
372
372
 
373
+ /**
374
+ * Set the branch for the submodule.
375
+ *
376
+ * This sets the branch in memory for the submodule. This will be used for
377
+ * any following submodule actions while this submodule data is in memory.
378
+ *
379
+ * After calling this, you may wish to call `git_submodule_save()` to write
380
+ * the changes back to the ".gitmodules" file and `git_submodule_sync()` to
381
+ * write the changes to the checked out submodule repository.
382
+ *
383
+ * @param submodule Pointer to the submodule object
384
+ * @param branch Branch that should be used for the submodule
385
+ * @return 0 on success, <0 on failure
386
+ */
387
+ GIT_EXTERN(int) git_submodule_set_branch(git_submodule *submodule, const char *branch);
388
+
373
389
  /**
374
390
  * Set the URL for the submodule.
375
391
  *
@@ -289,7 +289,8 @@ struct git_smart_subtransport {
289
289
  /* A function which creates a new subtransport for the smart transport */
290
290
  typedef int (*git_smart_subtransport_cb)(
291
291
  git_smart_subtransport **out,
292
- git_transport* owner);
292
+ git_transport* owner,
293
+ void* param);
293
294
 
294
295
  /**
295
296
  * Definition for a "subtransport"
@@ -306,6 +307,10 @@ typedef struct git_smart_subtransport_definition {
306
307
  * http:// is stateless, but git:// is not.
307
308
  */
308
309
  unsigned rpc;
310
+
311
+ /** Param of the callback
312
+ */
313
+ void* param;
309
314
  } git_smart_subtransport_definition;
310
315
 
311
316
  /* Smart transport subtransports that come with libgit2 */
@@ -321,7 +326,8 @@ typedef struct git_smart_subtransport_definition {
321
326
  */
322
327
  GIT_EXTERN(int) git_smart_subtransport_http(
323
328
  git_smart_subtransport **out,
324
- git_transport* owner);
329
+ git_transport* owner,
330
+ void *param);
325
331
 
326
332
  /**
327
333
  * Create an instance of the git subtransport.
@@ -332,7 +338,8 @@ GIT_EXTERN(int) git_smart_subtransport_http(
332
338
  */
333
339
  GIT_EXTERN(int) git_smart_subtransport_git(
334
340
  git_smart_subtransport **out,
335
- git_transport* owner);
341
+ git_transport* owner,
342
+ void *param);
336
343
 
337
344
  /**
338
345
  * Create an instance of the ssh subtransport.
@@ -343,7 +350,8 @@ GIT_EXTERN(int) git_smart_subtransport_git(
343
350
  */
344
351
  GIT_EXTERN(int) git_smart_subtransport_ssh(
345
352
  git_smart_subtransport **out,
346
- git_transport* owner);
353
+ git_transport* owner,
354
+ void *param);
347
355
 
348
356
  /**
349
357
  * Sets a custom transport factory for the remote. The caller can use this
@@ -273,6 +273,7 @@ typedef int (*git_transfer_progress_cb)(const git_transfer_progress *stats, void
273
273
  */
274
274
  typedef int (*git_transport_message_cb)(const char *str, int len, void *payload);
275
275
 
276
+
276
277
  /**
277
278
  * Type of host certificate structure that is passed to the check callback
278
279
  */
@@ -55,7 +55,7 @@ int git_attr_get(
55
55
 
56
56
  *value = NULL;
57
57
 
58
- if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
58
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0)
59
59
  return -1;
60
60
 
61
61
  if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0)
@@ -114,7 +114,7 @@ int git_attr_get_many_with_session(
114
114
 
115
115
  assert(values && repo && names);
116
116
 
117
- if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
117
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0)
118
118
  return -1;
119
119
 
120
120
  if ((error = collect_attr_files(repo, attr_session, flags, pathname, &files)) < 0)
@@ -193,7 +193,7 @@ int git_attr_foreach(
193
193
 
194
194
  assert(repo && callback);
195
195
 
196
- if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
196
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0)
197
197
  return -1;
198
198
 
199
199
  if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0 ||
@@ -394,6 +394,7 @@ bool git_attr_fnmatch__match(
394
394
 
395
395
  if ((match->flags & GIT_ATTR_FNMATCH_DIRECTORY) && !path->is_dir) {
396
396
  int matchval;
397
+ char *matchpath;
397
398
 
398
399
  /* for attribute checks or root ignore checks, fail match */
399
400
  if (!(match->flags & GIT_ATTR_FNMATCH_IGNORE) ||
@@ -403,7 +404,13 @@ bool git_attr_fnmatch__match(
403
404
  /* for ignore checks, use container of current item for check */
404
405
  path->basename[-1] = '\0';
405
406
  flags |= FNM_LEADING_DIR;
406
- matchval = p_fnmatch(match->pattern, path->path, flags);
407
+
408
+ if (match->containing_dir)
409
+ matchpath = path->basename;
410
+ else
411
+ matchpath = path->path;
412
+
413
+ matchval = p_fnmatch(match->pattern, matchpath, flags);
407
414
  path->basename[-1] = '/';
408
415
  return (matchval != FNM_NOMATCH);
409
416
  }
@@ -450,7 +457,7 @@ git_attr_assignment *git_attr_rule__lookup_assignment(
450
457
  }
451
458
 
452
459
  int git_attr_path__init(
453
- git_attr_path *info, const char *path, const char *base)
460
+ git_attr_path *info, const char *path, const char *base, git_dir_flag dir_flag)
454
461
  {
455
462
  ssize_t root;
456
463
 
@@ -481,7 +488,21 @@ int git_attr_path__init(
481
488
  if (!info->basename || !*info->basename)
482
489
  info->basename = info->path;
483
490
 
484
- info->is_dir = (int)git_path_isdir(info->full.ptr);
491
+ switch (dir_flag)
492
+ {
493
+ case GIT_DIR_FLAG_FALSE:
494
+ info->is_dir = 0;
495
+ break;
496
+
497
+ case GIT_DIR_FLAG_TRUE:
498
+ info->is_dir = 1;
499
+ break;
500
+
501
+ case GIT_DIR_FLAG_UNKNOWN:
502
+ default:
503
+ info->is_dir = (int)git_path_isdir(info->full.ptr);
504
+ break;
505
+ }
485
506
 
486
507
  return 0;
487
508
  }
@@ -202,8 +202,10 @@ extern bool git_attr_rule__match(
202
202
  extern git_attr_assignment *git_attr_rule__lookup_assignment(
203
203
  git_attr_rule *rule, const char *name);
204
204
 
205
+ typedef enum { GIT_DIR_FLAG_TRUE = 1, GIT_DIR_FLAG_FALSE = 0, GIT_DIR_FLAG_UNKNOWN = -1 } git_dir_flag;
206
+
205
207
  extern int git_attr_path__init(
206
- git_attr_path *info, const char *path, const char *base);
208
+ git_attr_path *info, const char *path, const char *base, git_dir_flag is_dir);
207
209
 
208
210
  extern void git_attr_path__free(git_attr_path *info);
209
211
 
@@ -409,6 +409,14 @@ static bool submodule_is_config_only(
409
409
  return rval;
410
410
  }
411
411
 
412
+ static bool checkout_is_empty_dir(checkout_data *data, const char *path)
413
+ {
414
+ git_buf_truncate(&data->path, data->workdir_len);
415
+ if (git_buf_puts(&data->path, path) < 0)
416
+ return false;
417
+ return git_path_is_empty_dir(data->path.ptr);
418
+ }
419
+
412
420
  static int checkout_action_with_wd(
413
421
  int *action,
414
422
  checkout_data *data,
@@ -526,6 +534,7 @@ static int checkout_action_with_wd_dir(
526
534
  checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, NULL));
527
535
  GITERR_CHECK_ERROR(
528
536
  checkout_notify(data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd));
537
+ *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE);
529
538
  break;
530
539
  case GIT_DELTA_ADDED:/* case 4 (and 7 for dir) */
531
540
  case GIT_DELTA_MODIFIED: /* case 20 (or 37 but not really) */
@@ -550,8 +559,6 @@ static int checkout_action_with_wd_dir(
550
559
  * dir and it will succeed if no children are left.
551
560
  */
552
561
  *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
553
- if (*action != CHECKOUT_ACTION__NONE)
554
- *action |= CHECKOUT_ACTION__DEFER_REMOVE;
555
562
  }
556
563
  else if (delta->new_file.mode != GIT_FILEMODE_TREE)
557
564
  /* For typechange to dir, dir is already created so no action */
@@ -564,6 +571,20 @@ static int checkout_action_with_wd_dir(
564
571
  return checkout_action_common(action, data, delta, wd);
565
572
  }
566
573
 
574
+ static int checkout_action_with_wd_dir_empty(
575
+ int *action,
576
+ checkout_data *data,
577
+ const git_diff_delta *delta)
578
+ {
579
+ int error = checkout_action_no_wd(action, data, delta);
580
+
581
+ /* We can always safely remove an empty directory. */
582
+ if (error == 0 && *action != CHECKOUT_ACTION__NONE)
583
+ *action |= CHECKOUT_ACTION__REMOVE;
584
+
585
+ return error;
586
+ }
587
+
567
588
  static int checkout_action(
568
589
  int *action,
569
590
  checkout_data *data,
@@ -653,7 +674,9 @@ static int checkout_action(
653
674
  }
654
675
  }
655
676
 
656
- return checkout_action_with_wd_dir(action, data, delta, workdir, wd);
677
+ return checkout_is_empty_dir(data, wd->path) ?
678
+ checkout_action_with_wd_dir_empty(action, data, delta) :
679
+ checkout_action_with_wd_dir(action, data, delta, workdir, wd);
657
680
  }
658
681
 
659
682
  /* case 6 - wd is after delta */
@@ -1197,7 +1220,7 @@ static int checkout_verify_paths(
1197
1220
 
1198
1221
  if (action & ~CHECKOUT_ACTION__REMOVE) {
1199
1222
  if (!git_path_isvalid(repo, delta->new_file.path, flags)) {
1200
- giterr_set(GITERR_CHECKOUT, "Cannot checkout to invalid path '%s'", delta->old_file.path);
1223
+ giterr_set(GITERR_CHECKOUT, "Cannot checkout to invalid path '%s'", delta->new_file.path);
1201
1224
  return -1;
1202
1225
  }
1203
1226
  }
@@ -1457,7 +1480,7 @@ static int blob_content_to_file(
1457
1480
  writer.fd = fd;
1458
1481
  writer.open = 1;
1459
1482
 
1460
- error = git_filter_list_stream_blob(fl, blob, (git_writestream *)&writer);
1483
+ error = git_filter_list_stream_blob(fl, blob, &writer.base);
1461
1484
 
1462
1485
  assert(writer.open == 0);
1463
1486
 
@@ -2462,7 +2485,8 @@ int git_checkout_iterator(
2462
2485
  GIT_DIFF_INCLUDE_IGNORED |
2463
2486
  GIT_DIFF_INCLUDE_TYPECHANGE |
2464
2487
  GIT_DIFF_INCLUDE_TYPECHANGE_TREES |
2465
- GIT_DIFF_SKIP_BINARY_CHECK;
2488
+ GIT_DIFF_SKIP_BINARY_CHECK |
2489
+ GIT_DIFF_INCLUDE_CASECHANGE;
2466
2490
  if (data.opts.checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)
2467
2491
  diff_opts.flags |= GIT_DIFF_DISABLE_PATHSPEC_MATCH;
2468
2492
  if (data.opts.paths.count > 0)
@@ -2643,7 +2667,7 @@ int git_checkout_tree(
2643
2667
  if ((error = git_repository_index(&index, repo)) < 0)
2644
2668
  return error;
2645
2669
 
2646
- if (!(error = git_iterator_for_tree(&tree_i, tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)))
2670
+ if (!(error = git_iterator_for_tree(&tree_i, tree, 0, NULL, NULL)))
2647
2671
  error = git_checkout_iterator(tree_i, index, opts);
2648
2672
 
2649
2673
  git_iterator_free(tree_i);
@@ -343,7 +343,6 @@ typedef struct {
343
343
  git_config_iterator *current;
344
344
  const git_config *cfg;
345
345
  regex_t regex;
346
- int has_regex;
347
346
  size_t i;
348
347
  } all_iter;
349
348
 
@@ -478,9 +477,8 @@ int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cf
478
477
  iter = git__calloc(1, sizeof(all_iter));
479
478
  GITERR_CHECK_ALLOC(iter);
480
479
 
481
- if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) < 0) {
480
+ if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) != 0) {
482
481
  giterr_set_regex(&iter->regex, result);
483
- regfree(&iter->regex);
484
482
  git__free(iter);
485
483
  return -1;
486
484
  }
@@ -513,7 +511,7 @@ int git_config_backend_foreach_match(
513
511
  int error = 0;
514
512
 
515
513
  if (regexp != NULL) {
516
- if ((error = regcomp(&regex, regexp, REG_EXTENDED)) < 0) {
514
+ if ((error = regcomp(&regex, regexp, REG_EXTENDED)) != 0) {
517
515
  giterr_set_regex(&regex, error);
518
516
  regfree(&regex);
519
517
  return -1;
@@ -983,7 +981,8 @@ void multivar_iter_free(git_config_iterator *_iter)
983
981
  iter->iter->free(iter->iter);
984
982
 
985
983
  git__free(iter->name);
986
- regfree(&iter->regex);
984
+ if (iter->have_regex)
985
+ regfree(&iter->regex);
987
986
  git__free(iter);
988
987
  }
989
988
 
@@ -1004,7 +1003,7 @@ int git_config_multivar_iterator_new(git_config_iterator **out, const git_config
1004
1003
 
1005
1004
  if (regexp != NULL) {
1006
1005
  error = regcomp(&iter->regex, regexp, REG_EXTENDED);
1007
- if (error < 0) {
1006
+ if (error != 0) {
1008
1007
  giterr_set_regex(&iter->regex, error);
1009
1008
  error = -1;
1010
1009
  regfree(&iter->regex);