rugged 0.99.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +1 -0
  4. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +4 -37
  5. data/vendor/libgit2/cmake/Modules/SanitizeBool.cmake +20 -0
  6. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +3 -0
  7. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +3 -0
  8. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +3 -0
  9. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +2 -0
  10. data/vendor/libgit2/deps/ntlmclient/compat.h +22 -0
  11. data/vendor/libgit2/include/git2/deprecated.h +7 -0
  12. data/vendor/libgit2/include/git2/repository.h +5 -4
  13. data/vendor/libgit2/include/git2/sys/refdb_backend.h +109 -2
  14. data/vendor/libgit2/include/git2/version.h +4 -4
  15. data/vendor/libgit2/src/CMakeLists.txt +11 -13
  16. data/vendor/libgit2/src/blame.c +1 -1
  17. data/vendor/libgit2/src/cache.c +8 -4
  18. data/vendor/libgit2/src/indexer.c +3 -3
  19. data/vendor/libgit2/src/notes.c +6 -3
  20. data/vendor/libgit2/src/odb_pack.c +0 -1
  21. data/vendor/libgit2/src/pack-objects.c +3 -1
  22. data/vendor/libgit2/src/pack.c +21 -1
  23. data/vendor/libgit2/src/push.c +3 -2
  24. data/vendor/libgit2/src/refdb_fs.c +3 -0
  25. data/vendor/libgit2/src/repository.c +63 -50
  26. data/vendor/libgit2/src/revwalk.c +1 -1
  27. data/vendor/libgit2/src/streams/openssl.c +1 -1
  28. data/vendor/libgit2/src/transports/auth_ntlm.c +2 -2
  29. data/vendor/libgit2/src/transports/httpclient.c +13 -2
  30. data/vendor/libgit2/src/unix/posix.h +1 -1
  31. data/vendor/libgit2/src/win32/path_w32.c +28 -1
  32. data/vendor/libgit2/src/win32/path_w32.h +16 -1
  33. data/vendor/libgit2/src/win32/posix_w32.c +1 -2
  34. data/vendor/libgit2/src/worktree.c +44 -28
  35. metadata +4 -6
  36. data/vendor/libgit2/src/sha1_lookup.c +0 -35
  37. data/vendor/libgit2/src/sha1_lookup.h +0 -19
@@ -29,7 +29,18 @@ static git_http_auth_scheme auth_schemes[] = {
29
29
  { GIT_HTTP_AUTH_BASIC, "Basic", GIT_CREDENTIAL_USERPASS_PLAINTEXT, git_http_auth_basic },
30
30
  };
31
31
 
32
- #define GIT_READ_BUFFER_SIZE 8192
32
+ /*
33
+ * Use a 16kb read buffer to match the maximum size of a TLS packet. This
34
+ * is critical for compatibility with SecureTransport, which will always do
35
+ * a network read on every call, even if it has data buffered to return to
36
+ * you. That buffered data may be the _end_ of a keep-alive response, so
37
+ * if SecureTransport performs another network read, it will wait until the
38
+ * server ultimately times out before it returns that buffered data to you.
39
+ * Since SecureTransport only reads a single TLS packet at a time, by
40
+ * calling it with a read buffer that is the maximum size of a TLS packet,
41
+ * we ensure that it will never buffer.
42
+ */
43
+ #define GIT_READ_BUFFER_SIZE (16 * 1024)
33
44
 
34
45
  typedef struct {
35
46
  git_net_url url;
@@ -585,7 +596,7 @@ static int apply_credentials(
585
596
  if (auth->connection_affinity)
586
597
  free_auth_context(server);
587
598
  } else if (!token.size) {
588
- git_error_set(GIT_ERROR_HTTP, "failed to respond to authentication challange");
599
+ git_error_set(GIT_ERROR_HTTP, "failed to respond to authentication challenge");
589
600
  error = -1;
590
601
  goto done;
591
602
  }
@@ -33,7 +33,7 @@ typedef int GIT_SOCKET;
33
33
  # define st_atime_nsec st_atim.tv_nsec
34
34
  # define st_mtime_nsec st_mtim.tv_nsec
35
35
  # define st_ctime_nsec st_ctim.tv_nsec
36
- #elif !defined(GIT_USE_STAT_MTIME_NSEC) && defined(GIT_USE_NEC)
36
+ #elif !defined(GIT_USE_STAT_MTIME_NSEC) && defined(GIT_USE_NSEC)
37
37
  # error GIT_USE_NSEC defined but unknown struct stat nanosecond type
38
38
  #endif
39
39
 
@@ -25,6 +25,9 @@
25
25
  #define path__is_unc(p) \
26
26
  (((p)[0] == '\\' && (p)[1] == '\\') || ((p)[0] == '/' && (p)[1] == '/'))
27
27
 
28
+ #define path__startswith_slash(p) \
29
+ ((p)[0] == '\\' || (p)[0] == '/')
30
+
28
31
  GIT_INLINE(int) path__cwd(wchar_t *path, int size)
29
32
  {
30
33
  int len;
@@ -221,7 +224,7 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
221
224
  goto on_error;
222
225
  }
223
226
  /* Absolute paths omitting the drive letter */
224
- else if (src[0] == '\\' || src[0] == '/') {
227
+ else if (path__startswith_slash(src)) {
225
228
  if (path__cwd(dest, MAX_PATH) < 0)
226
229
  goto on_error;
227
230
 
@@ -257,6 +260,30 @@ on_error:
257
260
  return -1;
258
261
  }
259
262
 
263
+ int git_win32_path_relative_from_utf8(git_win32_path out, const char *src)
264
+ {
265
+ wchar_t *dest = out, *p;
266
+ int len;
267
+
268
+ /* Handle absolute paths */
269
+ if (git_path_is_absolute(src) ||
270
+ path__is_nt_namespace(src) ||
271
+ path__is_unc(src) ||
272
+ path__startswith_slash(src)) {
273
+ return git_win32_path_from_utf8(out, src);
274
+ }
275
+
276
+ if ((len = git__utf8_to_16(dest, MAX_PATH, src)) < 0)
277
+ return -1;
278
+
279
+ for (p = dest; p < (dest + len); p++) {
280
+ if (*p == L'/')
281
+ *p = L'\\';
282
+ }
283
+
284
+ return len;
285
+ }
286
+
260
287
  int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src)
261
288
  {
262
289
  char *out = dest;
@@ -11,7 +11,9 @@
11
11
  #include "vector.h"
12
12
 
13
13
  /**
14
- * Create a Win32 path (in UCS-2 format) from a UTF-8 string.
14
+ * Create a Win32 path (in UCS-2 format) from a UTF-8 string. If the given
15
+ * path is relative, then it will be turned into an absolute path by having
16
+ * the current working directory prepended.
15
17
  *
16
18
  * @param dest The buffer to receive the wide string.
17
19
  * @param src The UTF-8 string to convert.
@@ -19,6 +21,16 @@
19
21
  */
20
22
  extern int git_win32_path_from_utf8(git_win32_path dest, const char *src);
21
23
 
24
+ /**
25
+ * Create a Win32 path (in UCS-2 format) from a UTF-8 string. If the given
26
+ * path is relative, then it will not be turned into an absolute path.
27
+ *
28
+ * @param dest The buffer to receive the wide string.
29
+ * @param src The UTF-8 string to convert.
30
+ * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure
31
+ */
32
+ extern int git_win32_path_relative_from_utf8(git_win32_path dest, const char *src);
33
+
22
34
  /**
23
35
  * Canonicalize a Win32 UCS-2 path so that it is suitable for delivery to the
24
36
  * Win32 APIs: remove multiple directory separators, squashing to a single one,
@@ -26,6 +38,9 @@ extern int git_win32_path_from_utf8(git_win32_path dest, const char *src);
26
38
  * canonical (always backslashes, never forward slashes) and process any
27
39
  * directory entries of '.' or '..'.
28
40
  *
41
+ * Note that this is intended to be used on absolute Windows paths, those
42
+ * that start with `C:\`, `\\server\share`, `\\?\`, etc.
43
+ *
29
44
  * This processes the buffer in place.
30
45
  *
31
46
  * @param path The buffer to process
@@ -447,8 +447,7 @@ int p_symlink(const char *target, const char *path)
447
447
  * relative symlinks, this is not someting we want.
448
448
  */
449
449
  if (git_win32_path_from_utf8(path_w, path) < 0 ||
450
- git__utf8_to_16(target_w, MAX_PATH, target) < 0 ||
451
- git_win32_path_canonicalize(target_w) < 0)
450
+ git_win32_path_relative_from_utf8(target_w, target) < 0)
452
451
  return -1;
453
452
 
454
453
  dwFlags = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
@@ -136,11 +136,11 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
136
136
  goto out;
137
137
  }
138
138
 
139
- if ((wt->name = git__strdup(name)) == NULL
140
- || (wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL
141
- || (wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL
142
- || (parent && (wt->parent_path = git__strdup(parent)) == NULL)
143
- || (wt->worktree_path = git_path_dirname(wt->gitlink_path)) == NULL) {
139
+ if ((wt->name = git__strdup(name)) == NULL ||
140
+ (wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL ||
141
+ (wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL ||
142
+ (parent && (wt->parent_path = git__strdup(parent)) == NULL) ||
143
+ (wt->worktree_path = git_path_dirname(wt->gitlink_path)) == NULL) {
144
144
  error = -1;
145
145
  goto out;
146
146
  }
@@ -149,7 +149,10 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
149
149
  goto out;
150
150
  wt->gitdir_path = git_buf_detach(&gitdir);
151
151
 
152
- wt->locked = !!git_worktree_is_locked(NULL, wt);
152
+ if ((error = git_worktree_is_locked(NULL, wt)) < 0)
153
+ goto out;
154
+ wt->locked = !!error;
155
+ error = 0;
153
156
 
154
157
  *out = wt;
155
158
 
@@ -403,20 +406,24 @@ out:
403
406
  int git_worktree_lock(git_worktree *wt, const char *reason)
404
407
  {
405
408
  git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
406
- int err;
409
+ int error;
407
410
 
408
411
  assert(wt);
409
412
 
410
- if ((err = git_worktree_is_locked(NULL, wt)) < 0)
413
+ if ((error = git_worktree_is_locked(NULL, wt)) < 0)
414
+ goto out;
415
+ if (error) {
416
+ error = GIT_ELOCKED;
411
417
  goto out;
418
+ }
412
419
 
413
- if ((err = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
420
+ if ((error = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
414
421
  goto out;
415
422
 
416
423
  if (reason)
417
424
  git_buf_attach_notowned(&buf, reason, strlen(reason));
418
425
 
419
- if ((err = git_futils_writebuffer(&buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0)
426
+ if ((error = git_futils_writebuffer(&buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0)
420
427
  goto out;
421
428
 
422
429
  wt->locked = 1;
@@ -424,16 +431,19 @@ int git_worktree_lock(git_worktree *wt, const char *reason)
424
431
  out:
425
432
  git_buf_dispose(&path);
426
433
 
427
- return err;
434
+ return error;
428
435
  }
429
436
 
430
437
  int git_worktree_unlock(git_worktree *wt)
431
438
  {
432
439
  git_buf path = GIT_BUF_INIT;
440
+ int error;
433
441
 
434
442
  assert(wt);
435
443
 
436
- if (!git_worktree_is_locked(NULL, wt))
444
+ if ((error = git_worktree_is_locked(NULL, wt)) < 0)
445
+ return error;
446
+ if (!error)
437
447
  return 1;
438
448
 
439
449
  if (git_buf_joinpath(&path, wt->gitdir_path, "locked") < 0)
@@ -454,22 +464,25 @@ int git_worktree_unlock(git_worktree *wt)
454
464
  int git_worktree_is_locked(git_buf *reason, const git_worktree *wt)
455
465
  {
456
466
  git_buf path = GIT_BUF_INIT;
457
- int ret;
467
+ int error, locked;
458
468
 
459
469
  assert(wt);
460
470
 
461
471
  if (reason)
462
472
  git_buf_clear(reason);
463
473
 
464
- if ((ret = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
474
+ if ((error = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
475
+ goto out;
476
+ locked = git_path_exists(path.ptr);
477
+ if (locked && reason &&
478
+ (error = git_futils_readbuffer(reason, path.ptr)) < 0)
465
479
  goto out;
466
- if ((ret = git_path_exists(path.ptr)) && reason)
467
- git_futils_readbuffer(reason, path.ptr);
468
480
 
481
+ error = locked;
469
482
  out:
470
483
  git_buf_dispose(&path);
471
484
 
472
- return ret;
485
+ return error;
473
486
  }
474
487
 
475
488
  const char *git_worktree_name(const git_worktree *wt)
@@ -502,7 +515,6 @@ int git_worktree_pruneinit_options(git_worktree_prune_options *opts,
502
515
  int git_worktree_is_prunable(git_worktree *wt,
503
516
  git_worktree_prune_options *opts)
504
517
  {
505
- git_buf reason = GIT_BUF_INIT;
506
518
  git_worktree_prune_options popts = GIT_WORKTREE_PRUNE_OPTIONS_INIT;
507
519
 
508
520
  GIT_ERROR_CHECK_VERSION(
@@ -512,20 +524,24 @@ int git_worktree_is_prunable(git_worktree *wt,
512
524
  if (opts)
513
525
  memcpy(&popts, opts, sizeof(popts));
514
526
 
515
- if ((popts.flags & GIT_WORKTREE_PRUNE_LOCKED) == 0 &&
516
- git_worktree_is_locked(&reason, wt))
517
- {
518
- if (!reason.size)
519
- git_buf_attach_notowned(&reason, "no reason given", 15);
520
- git_error_set(GIT_ERROR_WORKTREE, "not pruning locked working tree: '%s'", reason.ptr);
521
- git_buf_dispose(&reason);
527
+ if ((popts.flags & GIT_WORKTREE_PRUNE_LOCKED) == 0) {
528
+ git_buf reason = GIT_BUF_INIT;
529
+ int error;
522
530
 
523
- return 0;
531
+ if ((error = git_worktree_is_locked(&reason, wt)) < 0)
532
+ return error;
533
+
534
+ if (error) {
535
+ if (!reason.size)
536
+ git_buf_attach_notowned(&reason, "no reason given", 15);
537
+ git_error_set(GIT_ERROR_WORKTREE, "not pruning locked working tree: '%s'", reason.ptr);
538
+ git_buf_dispose(&reason);
539
+ return 0;
540
+ }
524
541
  }
525
542
 
526
543
  if ((popts.flags & GIT_WORKTREE_PRUNE_VALID) == 0 &&
527
- git_worktree_validate(wt) == 0)
528
- {
544
+ git_worktree_validate(wt) == 0) {
529
545
  git_error_set(GIT_ERROR_WORKTREE, "not pruning valid working tree");
530
546
  return 0;
531
547
  }
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.99.0
4
+ version: 1.0.0
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: 2020-03-09 00:00:00.000000000 Z
12
+ date: 2020-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -140,6 +140,7 @@ files:
140
140
  - vendor/libgit2/cmake/Modules/FindmbedTLS.cmake
141
141
  - vendor/libgit2/cmake/Modules/IdeSplitSources.cmake
142
142
  - vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake
143
+ - vendor/libgit2/cmake/Modules/SanitizeBool.cmake
143
144
  - vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake
144
145
  - vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake
145
146
  - vendor/libgit2/cmake/Modules/SelectHashes.cmake
@@ -526,8 +527,6 @@ files:
526
527
  - vendor/libgit2/src/revwalk.c
527
528
  - vendor/libgit2/src/revwalk.h
528
529
  - vendor/libgit2/src/settings.c
529
- - vendor/libgit2/src/sha1_lookup.c
530
- - vendor/libgit2/src/sha1_lookup.h
531
530
  - vendor/libgit2/src/signature.c
532
531
  - vendor/libgit2/src/signature.h
533
532
  - vendor/libgit2/src/sortedcache.c
@@ -675,8 +674,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
675
674
  - !ruby/object:Gem::Version
676
675
  version: '0'
677
676
  requirements: []
678
- rubyforge_project:
679
- rubygems_version: 2.7.6.2
677
+ rubygems_version: 3.1.2
680
678
  signing_key:
681
679
  specification_version: 4
682
680
  summary: Rugged is a Ruby binding to the libgit2 linkable library
@@ -1,35 +0,0 @@
1
- /*
2
- * Copyright (C) the libgit2 contributors. All rights reserved.
3
- *
4
- * This file is part of libgit2, distributed under the GNU GPL v2 with
5
- * a Linking Exception. For full terms see the included COPYING file.
6
- */
7
-
8
- #include "sha1_lookup.h"
9
-
10
- #include <stdio.h>
11
-
12
- #include "oid.h"
13
-
14
- int sha1_position(const void *table,
15
- size_t stride,
16
- unsigned lo, unsigned hi,
17
- const unsigned char *key)
18
- {
19
- const unsigned char *base = table;
20
-
21
- while (lo < hi) {
22
- unsigned mi = (lo + hi) / 2;
23
- int cmp = git_oid__hashcmp(base + mi * stride, key);
24
-
25
- if (!cmp)
26
- return mi;
27
-
28
- if (cmp > 0)
29
- hi = mi;
30
- else
31
- lo = mi+1;
32
- }
33
-
34
- return -((int)lo)-1;
35
- }
@@ -1,19 +0,0 @@
1
- /*
2
- * Copyright (C) the libgit2 contributors. All rights reserved.
3
- *
4
- * This file is part of libgit2, distributed under the GNU GPL v2 with
5
- * a Linking Exception. For full terms see the included COPYING file.
6
- */
7
- #ifndef INCLUDE_sha1_lookup_h__
8
- #define INCLUDE_sha1_lookup_h__
9
-
10
- #include "common.h"
11
-
12
- #include <stdlib.h>
13
-
14
- int sha1_position(const void *table,
15
- size_t stride,
16
- unsigned lo, unsigned hi,
17
- const unsigned char *key);
18
-
19
- #endif