rugged 0.28.1 → 0.28.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41c09c3269464641b3b5452c1f67b47cc64454b98d188ea587dc00ca8a092534
4
- data.tar.gz: 20778302255e43e6adc45ae4dcd3e049d31b74830b6d584aeefbf39a28b9eb2e
3
+ metadata.gz: 21ad4b245e4a45334bffaa2e1c7080decc90b4c2a9b6b8671221271ea74347f9
4
+ data.tar.gz: 0a57d974cbe8c169b89786e530902ec7c6d84846e242ce85c07b41e75ba2ad38
5
5
  SHA512:
6
- metadata.gz: 6959d8e05e6d638cc054afb6056ee9100f65e6d478f8a08294118e698515e176668a897800629fcc610bb0711bfb72b01feabb482411498de736bfb992684af0
7
- data.tar.gz: af4d5efcef41deaf7ee43908f97e69269fc2783f0566d39cc63989e5a0d928a8e072ccb88a71f08d96fe8a43edcb9630e1b2ffa9c308821438c5687a36acf5b9
6
+ metadata.gz: 97555ccbeff0f04035ab45326112334bfea18a8d7457d6f073926713a719f6eee81b94546d6d4bedeebffc2572bf2249e8f5d461be04a2d2a3554d4ce2611131
7
+ data.tar.gz: f8260b5ff2d778cb305be6421ebe6c0db805c147df99f216ef39d6bec1abbde8c029ce81563e0088538ad610b408fb0f21e74dcd75ab3bdc225ea14ac70c3989
@@ -169,20 +169,22 @@ static VALUE rb_git_config_delete(VALUE self, VALUE rb_key)
169
169
  return Qtrue;
170
170
  }
171
171
 
172
- static int cb_config__each_key(const git_config_entry *entry, void *opaque)
172
+ static int cb_config__each_key(const git_config_entry *entry, void *payload)
173
173
  {
174
- rb_funcall((VALUE)opaque, rb_intern("call"), 1, rb_str_new_utf8(entry->name));
175
- return GIT_OK;
174
+ int *exception = (int *) payload;
175
+
176
+ rb_protect(rb_yield, rb_ary_new3(1, rb_str_new_utf8(entry->name)), exception);
177
+
178
+ return (*exception != 0) ? GIT_EUSER : GIT_OK;
176
179
  }
177
180
 
178
- static int cb_config__each_pair(const git_config_entry *entry, void *opaque)
181
+ static int cb_config__each_pair(const git_config_entry *entry, void *payload)
179
182
  {
180
- rb_funcall((VALUE)opaque, rb_intern("call"), 2,
181
- rb_str_new_utf8(entry->name),
182
- rb_str_new_utf8(entry->value)
183
- );
183
+ int *exception = (int *) payload;
184
184
 
185
- return GIT_OK;
185
+ rb_protect(rb_yield, rb_ary_new3(2, rb_str_new_utf8(entry->name), rb_str_new_utf8(entry->value)), exception);
186
+
187
+ return (*exception != 0) ? GIT_EUSER : GIT_OK;
186
188
  }
187
189
 
188
190
  static int cb_config__to_hash(const git_config_entry *entry, void *opaque)
@@ -210,12 +212,15 @@ static int cb_config__to_hash(const git_config_entry *entry, void *opaque)
210
212
  static VALUE rb_git_config_each_key(VALUE self)
211
213
  {
212
214
  git_config *config;
213
- int error;
215
+ int error, exception;
214
216
 
215
217
  RETURN_ENUMERATOR(self, 0, 0);
216
218
  Data_Get_Struct(self, git_config, config);
217
219
 
218
- error = git_config_foreach(config, &cb_config__each_key, (void *)rb_block_proc());
220
+ error = git_config_foreach(config, &cb_config__each_key, &exception);
221
+ if (error == GIT_EUSER)
222
+ rb_jump_tag(exception);
223
+
219
224
  rugged_exception_check(error);
220
225
  return Qnil;
221
226
  }
@@ -237,12 +242,15 @@ static VALUE rb_git_config_each_key(VALUE self)
237
242
  static VALUE rb_git_config_each_pair(VALUE self)
238
243
  {
239
244
  git_config *config;
240
- int error;
241
-
245
+ int error, exception;
246
+
242
247
  RETURN_ENUMERATOR(self, 0, 0);
243
248
  Data_Get_Struct(self, git_config, config);
244
249
 
245
- error = git_config_foreach(config, &cb_config__each_pair, (void *)rb_block_proc());
250
+ error = git_config_foreach(config, &cb_config__each_pair, &exception);
251
+ if (error == GIT_EUSER)
252
+ rb_jump_tag(exception);
253
+
246
254
  rugged_exception_check(error);
247
255
  return Qnil;
248
256
  }
@@ -204,12 +204,14 @@ struct nogvl_diff_patch_args {
204
204
  VALUE rb_str;
205
205
  };
206
206
 
207
- static void rb_git_diff_patch_nogvl(void * _args)
207
+ static void * rb_git_diff_patch_nogvl(void * _args)
208
208
  {
209
209
  struct nogvl_diff_patch_args * args;
210
210
 
211
211
  args = (struct nogvl_diff_patch_args *)_args;
212
212
  git_diff_print(args->diff, args->format, diff_print_cb, (void*) args->rb_str);
213
+
214
+ return NULL;
213
215
  }
214
216
 
215
217
  /*
@@ -1502,15 +1502,6 @@ static VALUE flags_to_rb(unsigned int flags)
1502
1502
  return rb_flags;
1503
1503
  }
1504
1504
 
1505
- static int rugged__status_cb(const char *path, unsigned int flags, void *payload)
1506
- {
1507
- rb_funcall((VALUE)payload, rb_intern("call"), 2,
1508
- rb_str_new_utf8(path), flags_to_rb(flags)
1509
- );
1510
-
1511
- return GIT_OK;
1512
- }
1513
-
1514
1505
  static VALUE rb_git_repo_file_status(VALUE self, VALUE rb_path)
1515
1506
  {
1516
1507
  unsigned int flags;
@@ -1527,8 +1518,10 @@ static VALUE rb_git_repo_file_status(VALUE self, VALUE rb_path)
1527
1518
 
1528
1519
  static VALUE rb_git_repo_file_each_status(VALUE self)
1529
1520
  {
1530
- int error;
1521
+ int error, exception;
1522
+ size_t i, nentries;
1531
1523
  git_repository *repo;
1524
+ git_status_list *list;
1532
1525
 
1533
1526
  Data_Get_Struct(self, git_repository, repo);
1534
1527
 
@@ -1537,13 +1530,30 @@ static VALUE rb_git_repo_file_each_status(VALUE self)
1537
1530
  "A block was expected for iterating through "
1538
1531
  "the repository contents.");
1539
1532
 
1540
- error = git_status_foreach(
1541
- repo,
1542
- &rugged__status_cb,
1543
- (void *)rb_block_proc()
1544
- );
1545
-
1533
+ error = git_status_list_new(&list, repo, NULL);
1546
1534
  rugged_exception_check(error);
1535
+
1536
+ nentries = git_status_list_entrycount(list);
1537
+ for (i = 0; i < nentries; i++) {
1538
+ const git_status_entry *entry;
1539
+ const char *path;
1540
+ VALUE args;
1541
+
1542
+ entry = git_status_byindex(list, i);
1543
+
1544
+ path = entry->head_to_index ?
1545
+ entry->head_to_index->old_file.path :
1546
+ entry->index_to_workdir->old_file.path;
1547
+ args = rb_ary_new3(2, rb_str_new_utf8(path), flags_to_rb(entry->status));
1548
+ rb_protect(rb_yield, args, &exception);
1549
+ if (exception != 0)
1550
+ break;
1551
+ }
1552
+ git_status_list_free(list);
1553
+
1554
+ if (exception != 0)
1555
+ rb_jump_tag(exception);
1556
+
1547
1557
  return Qnil;
1548
1558
  }
1549
1559
 
@@ -4,5 +4,5 @@
4
4
  # For full terms see the included LICENSE file.
5
5
 
6
6
  module Rugged
7
- Version = VERSION = '0.28.1'
7
+ Version = VERSION = '0.28.2'
8
8
  end
@@ -64,6 +64,7 @@ OPTION(USE_EXT_HTTP_PARSER "Use system HTTP_Parser if available" ON)
64
64
  OPTION(DEBUG_POOL "Enable debug pool allocator" OFF)
65
65
  OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
66
66
  OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF)
67
+ OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
67
68
 
68
69
  IF (UNIX AND NOT APPLE)
69
70
  OPTION(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
@@ -105,8 +106,9 @@ SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${
105
106
  FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBGIT2_SOVERSION [0-9]+$")
106
107
  STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}")
107
108
 
108
- # Ensure that we do not use deprecated functions internally
109
- ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
109
+ IF (DEPRECATE_HARD)
110
+ ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
111
+ ENDIF()
110
112
 
111
113
  # Platform specific compilation flags
112
114
  IF (MSVC)
@@ -7,10 +7,10 @@
7
7
  #ifndef INCLUDE_git_version_h__
8
8
  #define INCLUDE_git_version_h__
9
9
 
10
- #define LIBGIT2_VERSION "0.28.0"
10
+ #define LIBGIT2_VERSION "0.28.2"
11
11
  #define LIBGIT2_VER_MAJOR 0
12
12
  #define LIBGIT2_VER_MINOR 28
13
- #define LIBGIT2_VER_REVISION 0
13
+ #define LIBGIT2_VER_REVISION 2
14
14
  #define LIBGIT2_VER_PATCH 0
15
15
 
16
16
  #define LIBGIT2_SOVERSION 28
@@ -48,11 +48,23 @@ IF (ENABLE_TRACE STREQUAL "ON")
48
48
  ENDIF()
49
49
  ADD_FEATURE_INFO(tracing GIT_TRACE "tracing support")
50
50
 
51
+ # Use `regcomp_l` if available
51
52
  CHECK_SYMBOL_EXISTS(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
52
53
  IF (HAVE_REGCOMP_L)
53
54
  SET(GIT_USE_REGCOMP_L 1)
54
55
  ENDIF ()
55
56
 
57
+ # Otherwise, we either want to use system's `regcomp` or our
58
+ # bundled regcomp code, if system doesn't provide `regcomp`.
59
+ IF(NOT HAVE_REGCOMP_L)
60
+ CHECK_FUNCTION_EXISTS(regcomp HAVE_REGCOMP)
61
+ IF(NOT HAVE_REGCOMP)
62
+ ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/regex" "${libgit2_BINARY_DIR}/deps/regex")
63
+ LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/regex")
64
+ LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:regex>)
65
+ ENDIF()
66
+ ENDIF()
67
+
56
68
  CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS)
57
69
  IF (HAVE_FUTIMENS)
58
70
  SET(GIT_USE_FUTIMENS 1)
@@ -117,7 +129,7 @@ IF (WIN32 AND WINHTTP)
117
129
  IF (MINGW)
118
130
  ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
119
131
  LIST(APPEND LIBGIT2_LIBS winhttp)
120
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
132
+ LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
121
133
  ELSE()
122
134
  LIST(APPEND LIBGIT2_LIBS "winhttp")
123
135
  LIST(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
@@ -294,13 +306,6 @@ ELSE()
294
306
  MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend ${SHA1_BACKEND}")
295
307
  ENDIF()
296
308
 
297
- # Include POSIX regex when it is required
298
- IF(WIN32 OR AMIGA OR CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
299
- ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/regex" "${libgit2_BINARY_DIR}/deps/regex")
300
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/regex")
301
- LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:regex>)
302
- ENDIF()
303
-
304
309
  # Optional external dependency: http-parser
305
310
  FIND_PACKAGE(HTTP_Parser)
306
311
  IF (USE_EXT_HTTP_PARSER AND HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
@@ -311,7 +316,7 @@ IF (USE_EXT_HTTP_PARSER AND HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUA
311
316
  ELSE()
312
317
  MESSAGE(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
313
318
  ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/http-parser" "${libgit2_BINARY_DIR}/deps/http-parser")
314
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
319
+ LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
315
320
  LIST(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>")
316
321
  ADD_FEATURE_INFO(http-parser ON "http-parser support (bundled)")
317
322
  ENDIF()
@@ -335,7 +340,7 @@ IF(NOT USE_BUNDLED_ZLIB)
335
340
  ENDIF()
336
341
  IF(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
337
342
  ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
338
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
343
+ LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
339
344
  LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
340
345
  ADD_FEATURE_INFO(zlib ON "using bundled zlib")
341
346
  ENDIF()
@@ -429,18 +429,6 @@ bool git_attr_fnmatch__match(
429
429
  return (p_fnmatch(match->pattern, relpath, flags) != FNM_NOMATCH);
430
430
  }
431
431
 
432
- /* if path is a directory prefix of a negated pattern, then match */
433
- if ((match->flags & GIT_ATTR_FNMATCH_NEGATIVE) && path->is_dir) {
434
- size_t pathlen = strlen(relpath);
435
- bool prefixed = (pathlen <= match->length) &&
436
- ((match->flags & GIT_ATTR_FNMATCH_ICASE) ?
437
- !strncasecmp(match->pattern, relpath, pathlen) :
438
- !strncmp(match->pattern, relpath, pathlen));
439
-
440
- if (prefixed && git_path_at_end_of_segment(&match->pattern[pathlen]))
441
- return true;
442
- }
443
-
444
432
  return (p_fnmatch(match->pattern, filename, flags) != FNM_NOMATCH);
445
433
  }
446
434
 
@@ -79,6 +79,12 @@
79
79
  #include "thread-utils.h"
80
80
  #include "integer.h"
81
81
 
82
+ /*
83
+ * Include the declarations for deprecated functions; this ensures
84
+ * that they're decorated with the proper extern/visibility attributes.
85
+ */
86
+ #include "git2/deprecated.h"
87
+
82
88
  #include <regex.h>
83
89
 
84
90
  #define DEFAULT_BUFSIZE 65536
@@ -678,6 +678,7 @@ static int parse_include(git_config_parser *reader,
678
678
  return result;
679
679
 
680
680
  include = git_array_alloc(reader->file->includes);
681
+ GIT_ERROR_CHECK_ALLOC(include);
681
682
  memset(include, 0, sizeof(*include));
682
683
  git_array_init(include->includes);
683
684
  include->path = git_buf_detach(&path);
@@ -1132,7 +1133,7 @@ static int config_write(diskfile_backend *cfg, const char *orig_key, const char
1132
1133
  reader.file = &cfg->file;
1133
1134
 
1134
1135
  if (cfg->locked) {
1135
- result = git_buf_puts(&contents, git_buf_cstr(&cfg->locked_content));
1136
+ result = git_buf_puts(&contents, git_buf_cstr(&cfg->locked_content) == NULL ? "" : git_buf_cstr(&cfg->locked_content));
1136
1137
  } else {
1137
1138
  /* Lock the file */
1138
1139
  if ((result = git_filebuf_open(
@@ -489,10 +489,13 @@ int git_futils_mkdir(
489
489
 
490
490
  assert(len);
491
491
 
492
- /* we've walked all the given path's parents and it's either relative
493
- * or rooted. either way, give up and make the entire path.
492
+ /*
493
+ * We've walked all the given path's parents and it's either relative
494
+ * (the parent is simply '.') or rooted (the length is less than or
495
+ * equal to length of the root path). The path may be less than the
496
+ * root path length on Windows, where `C:` == `C:/`.
494
497
  */
495
- if ((len == 1 && parent_path.ptr[0] == '.') || len == root_len+1) {
498
+ if ((len == 1 && parent_path.ptr[0] == '.') || len <= root_len) {
496
499
  relative = make_path.ptr;
497
500
  break;
498
501
  }
@@ -534,7 +534,9 @@ int git_ignore_path_is_ignored(
534
534
  memset(&path, 0, sizeof(path));
535
535
  memset(&ignores, 0, sizeof(ignores));
536
536
 
537
- if (git_repository_is_bare(repo))
537
+ if (!git__suffixcmp(pathname, "/"))
538
+ dir_flag = GIT_DIR_FLAG_TRUE;
539
+ else if (git_repository_is_bare(repo))
538
540
  dir_flag = GIT_DIR_FLAG_FALSE;
539
541
 
540
542
  if ((error = git_attr_path__init(&path, pathname, workdir, dir_flag)) < 0 ||
@@ -443,8 +443,12 @@ int git_odb_new(git_odb **out)
443
443
  git_odb *db = git__calloc(1, sizeof(*db));
444
444
  GIT_ERROR_CHECK_ALLOC(db);
445
445
 
446
- if (git_cache_init(&db->own_cache) < 0 ||
447
- git_vector_init(&db->backends, 4, backend_sort_cmp) < 0) {
446
+ if (git_cache_init(&db->own_cache) < 0) {
447
+ git__free(db);
448
+ return -1;
449
+ }
450
+ if (git_vector_init(&db->backends, 4, backend_sort_cmp) < 0) {
451
+ git_cache_free(&db->own_cache);
448
452
  git__free(db);
449
453
  return -1;
450
454
  }
@@ -1124,6 +1128,7 @@ static int odb_otype_fast(git_object_t *type_p, git_odb *db, const git_oid *id)
1124
1128
 
1125
1129
  if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) {
1126
1130
  *type_p = object->cached.type;
1131
+ git_odb_object_free(object);
1127
1132
  return 0;
1128
1133
  }
1129
1134
 
@@ -328,7 +328,8 @@ static int parse_header_start(git_patch_parsed *patch, git_patch_parse_ctx *ctx)
328
328
  * proceeed here. We then hope for the "---" and "+++" lines to fix that
329
329
  * for us.
330
330
  */
331
- if (!git_parse_ctx_contains(&ctx->parse_ctx, "\n", 1)) {
331
+ if (!git_parse_ctx_contains(&ctx->parse_ctx, "\n", 1) &&
332
+ !git_parse_ctx_contains(&ctx->parse_ctx, "\r\n", 2)) {
332
333
  git_parse_advance_chars(&ctx->parse_ctx, ctx->parse_ctx.line_len - 1);
333
334
 
334
335
  git__free(patch->header_old_path);
@@ -921,21 +922,15 @@ static int check_filenames(git_patch_parsed *patch)
921
922
  return git_parse_err("missing old path");
922
923
 
923
924
  /* Ensure (non-renamed) paths match */
924
- if (check_header_names(
925
- patch->header_old_path, patch->old_path, "old", added) < 0 ||
926
- check_header_names(
927
- patch->header_new_path, patch->new_path, "new", deleted) < 0)
925
+ if (check_header_names(patch->header_old_path, patch->old_path, "old", added) < 0 ||
926
+ check_header_names(patch->header_new_path, patch->new_path, "new", deleted) < 0)
928
927
  return -1;
929
928
 
930
- prefixed_old = (!added && patch->old_path) ? patch->old_path :
931
- patch->header_old_path;
932
- prefixed_new = (!deleted && patch->new_path) ? patch->new_path :
933
- patch->header_new_path;
929
+ prefixed_old = (!added && patch->old_path) ? patch->old_path : patch->header_old_path;
930
+ prefixed_new = (!deleted && patch->new_path) ? patch->new_path : patch->header_new_path;
934
931
 
935
- if (check_prefix(
936
- &patch->old_prefix, &old_prefixlen, patch, prefixed_old) < 0 ||
937
- check_prefix(
938
- &patch->new_prefix, &new_prefixlen, patch, prefixed_new) < 0)
932
+ if ((prefixed_old && check_prefix(&patch->old_prefix, &old_prefixlen, patch, prefixed_old) < 0) ||
933
+ (prefixed_new && check_prefix(&patch->new_prefix, &new_prefixlen, patch, prefixed_new) < 0))
939
934
  return -1;
940
935
 
941
936
  /* Prefer the rename filenames as they are unambiguous and unprefixed */
@@ -950,7 +945,7 @@ static int check_filenames(git_patch_parsed *patch)
950
945
  patch->base.delta->new_file.path = prefixed_new + new_prefixlen;
951
946
 
952
947
  if (!patch->base.delta->old_file.path &&
953
- !patch->base.delta->new_file.path)
948
+ !patch->base.delta->new_file.path)
954
949
  return git_parse_err("git diff header lacks old / new paths");
955
950
 
956
951
  return 0;
@@ -964,14 +959,14 @@ static int check_patch(git_patch_parsed *patch)
964
959
  return -1;
965
960
 
966
961
  if (delta->old_file.path &&
967
- delta->status != GIT_DELTA_DELETED &&
968
- !delta->new_file.mode)
962
+ delta->status != GIT_DELTA_DELETED &&
963
+ !delta->new_file.mode)
969
964
  delta->new_file.mode = delta->old_file.mode;
970
965
 
971
966
  if (delta->status == GIT_DELTA_MODIFIED &&
972
- !(delta->flags & GIT_DIFF_FLAG_BINARY) &&
973
- delta->new_file.mode == delta->old_file.mode &&
974
- git_array_size(patch->base.hunks) == 0)
967
+ !(delta->flags & GIT_DIFF_FLAG_BINARY) &&
968
+ delta->new_file.mode == delta->old_file.mode &&
969
+ git_array_size(patch->base.hunks) == 0)
975
970
  return git_parse_err("patch with no hunks");
976
971
 
977
972
  if (delta->status == GIT_DELTA_ADDED) {
@@ -33,6 +33,10 @@
33
33
  # define SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE 0x02
34
34
  #endif
35
35
 
36
+ #ifndef SYMBOLIC_LINK_FLAG_DIRECTORY
37
+ # define SYMBOLIC_LINK_FLAG_DIRECTORY 0x01
38
+ #endif
39
+
36
40
  /* Allowable mode bits on Win32. Using mode bits that are not supported on
37
41
  * Win32 (eg S_IRWXU) is generally ignored, but Wine warns loudly about it
38
42
  * so we simply remove them.
@@ -397,13 +401,18 @@ int p_readlink(const char *path, char *buf, size_t bufsiz)
397
401
  int p_symlink(const char *target, const char *path)
398
402
  {
399
403
  git_win32_path target_w, path_w;
404
+ DWORD dwFlags;
400
405
 
401
406
  if (git_win32_path_from_utf8(path_w, path) < 0 ||
402
407
  git__utf8_to_16(target_w, MAX_PATH, target) < 0)
403
408
  return -1;
404
409
 
405
- if (!CreateSymbolicLinkW(path_w, target_w,
406
- SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE))
410
+ dwFlags = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
411
+
412
+ if (GetFileAttributesW(target_w) & FILE_ATTRIBUTE_DIRECTORY)
413
+ dwFlags |= SYMBOLIC_LINK_FLAG_DIRECTORY;
414
+
415
+ if (!CreateSymbolicLinkW(path_w, target_w, dwFlags))
407
416
  return -1;
408
417
 
409
418
  return 0;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rugged
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.1
4
+ version: 0.28.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-03-12 00:00:00.000000000 Z
12
+ date: 2019-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -607,7 +607,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
607
607
  version: '0'
608
608
  requirements: []
609
609
  rubyforge_project:
610
- rubygems_version: 2.7.6
610
+ rubygems_version: 2.7.6.2
611
611
  signing_key:
612
612
  specification_version: 4
613
613
  summary: Rugged is a Ruby binding to the libgit2 linkable library