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
@@ -273,6 +273,7 @@ extern int git_path_apply_relative(git_buf *target, const char *relpath);
273
273
  enum {
274
274
  GIT_PATH_DIR_IGNORE_CASE = (1u << 0),
275
275
  GIT_PATH_DIR_PRECOMPOSE_UNICODE = (1u << 1),
276
+ GIT_PATH_DIR_INCLUDE_DOT_AND_DOTDOT = (1u << 2),
276
277
  };
277
278
 
278
279
  /**
@@ -326,66 +327,6 @@ extern int git_path_walk_up(
326
327
  int (*callback)(void *payload, const char *path),
327
328
  void *payload);
328
329
 
329
- /**
330
- * Load all directory entries (except '.' and '..') into a vector.
331
- *
332
- * For cases where `git_path_direach()` is not appropriate, this
333
- * allows you to load the filenames in a directory into a vector
334
- * of strings. That vector can then be sorted, iterated, or whatever.
335
- * Remember to free alloc of the allocated strings when you are done.
336
- *
337
- * @param path The directory to read from.
338
- * @param prefix_len When inserting entries, the trailing part of path
339
- * will be prefixed after this length. I.e. given path "/a/b" and
340
- * prefix_len 3, the entries will look like "b/e1", "b/e2", etc.
341
- * @param alloc_extra Extra bytes to add to each string allocation in
342
- * case you want to append anything funny.
343
- * @param flags Combination of GIT_PATH_DIR flags.
344
- * @param contents Vector to fill with directory entry names.
345
- */
346
- extern int git_path_dirload(
347
- const char *path,
348
- size_t prefix_len,
349
- size_t alloc_extra,
350
- uint32_t flags,
351
- git_vector *contents);
352
-
353
-
354
- typedef struct {
355
- struct stat st;
356
- size_t path_len;
357
- char path[GIT_FLEX_ARRAY];
358
- } git_path_with_stat;
359
-
360
- extern int git_path_with_stat_cmp(const void *a, const void *b);
361
- extern int git_path_with_stat_cmp_icase(const void *a, const void *b);
362
-
363
- /**
364
- * Load all directory entries along with stat info into a vector.
365
- *
366
- * This adds four things on top of plain `git_path_dirload`:
367
- *
368
- * 1. Each entry in the vector is a `git_path_with_stat` struct that
369
- * contains both the path and the stat info
370
- * 2. The entries will be sorted alphabetically
371
- * 3. Entries that are directories will be suffixed with a '/'
372
- * 4. Optionally, you can be a start and end prefix and only elements
373
- * after the start and before the end (inclusively) will be stat'ed.
374
- *
375
- * @param path The directory to read from
376
- * @param prefix_len The trailing part of path to prefix to entry paths
377
- * @param flags GIT_PATH_DIR flags from above
378
- * @param start_stat As optimization, only stat values after this prefix
379
- * @param end_stat As optimization, only stat values before this prefix
380
- * @param contents Vector to fill with git_path_with_stat structures
381
- */
382
- extern int git_path_dirload_with_stat(
383
- const char *path,
384
- size_t prefix_len,
385
- uint32_t flags,
386
- const char *start_stat,
387
- const char *end_stat,
388
- git_vector *contents);
389
330
 
390
331
  enum { GIT_PATH_NOTEQUAL = 0, GIT_PATH_EQUAL = 1, GIT_PATH_PREFIX = 2 };
391
332
 
@@ -472,6 +413,137 @@ extern int git_path_iconv(git_path_iconv_t *ic, char **in, size_t *inlen);
472
413
 
473
414
  extern bool git_path_does_fs_decompose_unicode(const char *root);
474
415
 
416
+
417
+ typedef struct git_path_diriter git_path_diriter;
418
+
419
+ #if defined(GIT_WIN32) && !defined(__MINGW32__)
420
+
421
+ struct git_path_diriter
422
+ {
423
+ git_win32_path path;
424
+ size_t parent_len;
425
+
426
+ git_buf path_utf8;
427
+ size_t parent_utf8_len;
428
+
429
+ HANDLE handle;
430
+
431
+ unsigned int flags;
432
+
433
+ WIN32_FIND_DATAW current;
434
+ unsigned int needs_next;
435
+ };
436
+
437
+ #define GIT_PATH_DIRITER_INIT { {0}, 0, GIT_BUF_INIT, 0, INVALID_HANDLE_VALUE }
438
+
439
+ #else
440
+
441
+ struct git_path_diriter
442
+ {
443
+ git_buf path;
444
+ size_t parent_len;
445
+
446
+ unsigned int flags;
447
+
448
+ DIR *dir;
449
+
450
+ #ifdef GIT_USE_ICONV
451
+ git_path_iconv_t ic;
452
+ #endif
453
+ };
454
+
455
+ #define GIT_PATH_DIRITER_INIT { GIT_BUF_INIT }
456
+
457
+ #endif
458
+
459
+ /**
460
+ * Initialize a directory iterator.
461
+ *
462
+ * @param diriter Pointer to a diriter structure that will be setup.
463
+ * @param path The path that will be iterated over
464
+ * @param flags Directory reader flags
465
+ * @return 0 or an error code
466
+ */
467
+ extern int git_path_diriter_init(
468
+ git_path_diriter *diriter,
469
+ const char *path,
470
+ unsigned int flags);
471
+
472
+ /**
473
+ * Advance the directory iterator. Will return GIT_ITEROVER when
474
+ * the iteration has completed successfully.
475
+ *
476
+ * @param diriter The directory iterator
477
+ * @return 0, GIT_ITEROVER, or an error code
478
+ */
479
+ extern int git_path_diriter_next(git_path_diriter *diriter);
480
+
481
+ /**
482
+ * Returns the file name of the current item in the iterator.
483
+ *
484
+ * @param out Pointer to store the path in
485
+ * @param out_len Pointer to store the length of the path in
486
+ * @param diriter The directory iterator
487
+ * @return 0 or an error code
488
+ */
489
+ extern int git_path_diriter_filename(
490
+ const char **out,
491
+ size_t *out_len,
492
+ git_path_diriter *diriter);
493
+
494
+ /**
495
+ * Returns the full path of the current item in the iterator; that
496
+ * is the current filename plus the path of the directory that the
497
+ * iterator was constructed with.
498
+ *
499
+ * @param out Pointer to store the path in
500
+ * @param out_len Pointer to store the length of the path in
501
+ * @param diriter The directory iterator
502
+ * @return 0 or an error code
503
+ */
504
+ extern int git_path_diriter_fullpath(
505
+ const char **out,
506
+ size_t *out_len,
507
+ git_path_diriter *diriter);
508
+
509
+ /**
510
+ * Performs an `lstat` on the current item in the iterator.
511
+ *
512
+ * @param out Pointer to store the stat data in
513
+ * @param diriter The directory iterator
514
+ * @return 0 or an error code
515
+ */
516
+ extern int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter);
517
+
518
+ /**
519
+ * Closes the directory iterator.
520
+ *
521
+ * @param diriter The directory iterator
522
+ */
523
+ extern void git_path_diriter_free(git_path_diriter *diriter);
524
+
525
+ /**
526
+ * Load all directory entries (except '.' and '..') into a vector.
527
+ *
528
+ * For cases where `git_path_direach()` is not appropriate, this
529
+ * allows you to load the filenames in a directory into a vector
530
+ * of strings. That vector can then be sorted, iterated, or whatever.
531
+ * Remember to free alloc of the allocated strings when you are done.
532
+ *
533
+ * @param contents Vector to fill with directory entry names.
534
+ * @param path The directory to read from.
535
+ * @param prefix_len When inserting entries, the trailing part of path
536
+ * will be prefixed after this length. I.e. given path "/a/b" and
537
+ * prefix_len 3, the entries will look like "b/e1", "b/e2", etc.
538
+ * @param flags Combination of GIT_PATH_DIR flags.
539
+ */
540
+ extern int git_path_dirload(
541
+ git_vector *contents,
542
+ const char *path,
543
+ size_t prefix_len,
544
+ uint32_t flags);
545
+
546
+
475
547
  /* Used for paths to repositories on the filesystem */
476
548
  extern bool git_path_is_local_file_url(const char *file_url);
477
549
  extern int git_path_from_url_or_path(git_buf *local_path_out, const char *url_or_path);
@@ -122,7 +122,6 @@ extern int git__page_size(size_t *page_size);
122
122
  #include "strnlen.h"
123
123
 
124
124
  #ifdef NO_READDIR_R
125
- # include <dirent.h>
126
125
  GIT_INLINE(int) p_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
127
126
  {
128
127
  GIT_UNUSED(entry);
@@ -54,6 +54,13 @@ int git_push_new(git_push **out, git_remote *remote)
54
54
  return -1;
55
55
  }
56
56
 
57
+ if (git_vector_init(&p->updates, 0, NULL) < 0) {
58
+ git_vector_free(&p->status);
59
+ git_vector_free(&p->specs);
60
+ git__free(p);
61
+ return -1;
62
+ }
63
+
57
64
  *out = p;
58
65
  return 0;
59
66
  }
@@ -75,7 +82,9 @@ int git_push_set_callbacks(
75
82
  git_packbuilder_progress pack_progress_cb,
76
83
  void *pack_progress_cb_payload,
77
84
  git_push_transfer_progress transfer_progress_cb,
78
- void *transfer_progress_cb_payload)
85
+ void *transfer_progress_cb_payload,
86
+ git_push_negotiation negotiation_cb,
87
+ void *negotiation_cb_payload)
79
88
  {
80
89
  if (!push)
81
90
  return -1;
@@ -86,6 +95,9 @@ int git_push_set_callbacks(
86
95
  push->transfer_progress_cb = transfer_progress_cb;
87
96
  push->transfer_progress_cb_payload = transfer_progress_cb_payload;
88
97
 
98
+ push->negotiation_cb = negotiation_cb;
99
+ push->negotiation_cb_payload = negotiation_cb_payload;
100
+
89
101
  return 0;
90
102
  }
91
103
 
@@ -534,6 +546,22 @@ on_error:
534
546
  return error;
535
547
  }
536
548
 
549
+ static int add_update(git_push *push, push_spec *spec)
550
+ {
551
+ git_push_update *u = git__calloc(1, sizeof(git_push_update));
552
+ GITERR_CHECK_ALLOC(u);
553
+
554
+ u->src_refname = git__strdup(spec->refspec.src);
555
+ GITERR_CHECK_ALLOC(u->src_refname);
556
+ u->dst_refname = git__strdup(spec->refspec.src);
557
+ GITERR_CHECK_ALLOC(u->dst_refname);
558
+
559
+ git_oid_cpy(&u->src, &spec->loid);
560
+ git_oid_cpy(&u->dst, &spec->roid);
561
+
562
+ return git_vector_insert(&push->updates, u);
563
+ }
564
+
537
565
  static int calculate_work(git_push *push)
538
566
  {
539
567
  git_remote_head *head;
@@ -559,6 +587,9 @@ static int calculate_work(git_push *push)
559
587
  break;
560
588
  }
561
589
  }
590
+
591
+ if (add_update(push, spec) < 0)
592
+ return -1;
562
593
  }
563
594
 
564
595
  return 0;
@@ -590,9 +621,17 @@ static int do_push(git_push *push)
590
621
  if ((error = git_packbuilder_set_callbacks(push->pb, push->pack_progress_cb, push->pack_progress_cb_payload)) < 0)
591
622
  goto on_error;
592
623
 
593
- if ((error = calculate_work(push)) < 0 ||
594
- (error = queue_objects(push)) < 0 ||
595
- (error = transport->push(transport, push)) < 0)
624
+ if ((error = calculate_work(push)) < 0)
625
+ goto on_error;
626
+
627
+ if (push->negotiation_cb &&
628
+ (error = push->negotiation_cb((const git_push_update **) push->updates.contents,
629
+ push->updates.length,
630
+ push->negotiation_cb_payload)))
631
+ goto on_error;
632
+
633
+ if ((error = queue_objects(push)) < 0 ||
634
+ (error = transport->push(transport, push)) < 0)
596
635
  goto on_error;
597
636
 
598
637
  on_error:
@@ -29,6 +29,7 @@ struct git_push {
29
29
  git_packbuilder *pb;
30
30
  git_remote *remote;
31
31
  git_vector specs;
32
+ git_vector updates;
32
33
  bool report_status;
33
34
 
34
35
  /* report-status */
@@ -42,6 +43,8 @@ struct git_push {
42
43
  void *pack_progress_cb_payload;
43
44
  git_push_transfer_progress transfer_progress_cb;
44
45
  void *transfer_progress_cb_payload;
46
+ git_push_negotiation negotiation_cb;
47
+ void *negotiation_cb_payload;
45
48
  };
46
49
 
47
50
  /**
@@ -85,6 +88,8 @@ int git_push_set_options(
85
88
  * the upload portion of a push. Be aware that this is called inline with
86
89
  * pack building operations, so performance may be affected.
87
90
  * @param transfer_progress_cb_payload Payload for the network progress callback.
91
+ * @param push_negotiation_cb Function to call before sending the commands to the remote.
92
+ * @param push_negotiation_cb_payload Payload for the negotiation callback
88
93
  * @return 0 or an error code
89
94
  */
90
95
  int git_push_set_callbacks(
@@ -92,7 +97,9 @@ int git_push_set_callbacks(
92
97
  git_packbuilder_progress pack_progress_cb,
93
98
  void *pack_progress_cb_payload,
94
99
  git_push_transfer_progress transfer_progress_cb,
95
- void *transfer_progress_cb_payload);
100
+ void *transfer_progress_cb_payload,
101
+ git_push_negotiation negotiation_cb,
102
+ void *negotiation_cb_payload);
96
103
 
97
104
  /**
98
105
  * Add a refspec to be pushed