rugged 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -160,8 +160,10 @@ int git_diff_file_content__init_from_src(
160
160
 
161
161
  fc->flags |= GIT_DIFF_FLAG__FREE_BLOB;
162
162
  } else {
163
+ int error;
164
+ if ((error = git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB)) < 0)
165
+ return error;
163
166
  fc->file->size = src->buflen;
164
- git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB);
165
167
  fc->file->id_abbrev = GIT_OID_HEXSZ;
166
168
 
167
169
  fc->map.len = src->buflen;
@@ -301,14 +301,14 @@ GIT_INLINE(const char *) diff_delta__i2w_path(const git_diff_delta *delta)
301
301
  delta->old_file.path : delta->new_file.path;
302
302
  }
303
303
 
304
- int git_diff_delta__i2w_cmp(const void *a, const void *b)
304
+ static int diff_delta_i2w_cmp(const void *a, const void *b)
305
305
  {
306
306
  const git_diff_delta *da = a, *db = b;
307
307
  int val = strcmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db));
308
308
  return val ? val : ((int)da->status - (int)db->status);
309
309
  }
310
310
 
311
- int git_diff_delta__i2w_casecmp(const void *a, const void *b)
311
+ static int diff_delta_i2w_casecmp(const void *a, const void *b)
312
312
  {
313
313
  const git_diff_delta *da = a, *db = b;
314
314
  int val = strcasecmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db));
@@ -361,7 +361,7 @@ static const char *diff_mnemonic_prefix(
361
361
  return pfx;
362
362
  }
363
363
 
364
- void git_diff__set_ignore_case(git_diff *diff, bool ignore_case)
364
+ static void diff_set_ignore_case(git_diff *diff, bool ignore_case)
365
365
  {
366
366
  if (!ignore_case) {
367
367
  diff->opts.flags &= ~GIT_DIFF_IGNORE_CASE;
@@ -423,16 +423,15 @@ static git_diff_generated *diff_generated_alloc(
423
423
  git_attr_session__init(&diff->base.attrsession, repo);
424
424
  memcpy(&diff->base.opts, &dflt, sizeof(git_diff_options));
425
425
 
426
- git_pool_init(&diff->base.pool, 1);
427
-
428
- if (git_vector_init(&diff->base.deltas, 0, git_diff_delta__cmp) < 0) {
426
+ if (git_pool_init(&diff->base.pool, 1) < 0 ||
427
+ git_vector_init(&diff->base.deltas, 0, git_diff_delta__cmp) < 0) {
429
428
  git_diff_free(&diff->base);
430
429
  return NULL;
431
430
  }
432
431
 
433
432
  /* Use case-insensitive compare if either iterator has
434
433
  * the ignore_case bit set */
435
- git_diff__set_ignore_case(
434
+ diff_set_ignore_case(
436
435
  &diff->base,
437
436
  git_iterator_ignore_case(old_iter) ||
438
437
  git_iterator_ignore_case(new_iter));
@@ -1376,7 +1375,7 @@ int git_diff_tree_to_index(
1376
1375
 
1377
1376
  /* if index is in case-insensitive order, re-sort deltas to match */
1378
1377
  if (index_ignore_case)
1379
- git_diff__set_ignore_case(diff, true);
1378
+ diff_set_ignore_case(diff, true);
1380
1379
 
1381
1380
  *out = diff;
1382
1381
  diff = NULL;
@@ -1527,7 +1526,7 @@ int git_diff_index_to_index(
1527
1526
 
1528
1527
  /* if index is in case-insensitive order, re-sort deltas to match */
1529
1528
  if (old_index->ignore_case || new_index->ignore_case)
1530
- git_diff__set_ignore_case(diff, true);
1529
+ diff_set_ignore_case(diff, true);
1531
1530
 
1532
1531
  *out = diff;
1533
1532
  diff = NULL;
@@ -1584,10 +1583,10 @@ int git_diff__paired_foreach(
1584
1583
  if (i2w_icase && !icase_mismatch) {
1585
1584
  strcomp = git__strcasecmp;
1586
1585
 
1587
- git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_casecmp);
1586
+ git_vector_set_cmp(&idx2wd->deltas, diff_delta_i2w_casecmp);
1588
1587
  git_vector_sort(&idx2wd->deltas);
1589
1588
  } else if (idx2wd != NULL) {
1590
- git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_cmp);
1589
+ git_vector_set_cmp(&idx2wd->deltas, diff_delta_i2w_cmp);
1591
1590
  git_vector_sort(&idx2wd->deltas);
1592
1591
  }
1593
1592
 
@@ -52,9 +52,8 @@ static git_diff_parsed *diff_parsed_alloc(void)
52
52
 
53
53
  diff->base.opts.flags &= ~GIT_DIFF_IGNORE_CASE;
54
54
 
55
- git_pool_init(&diff->base.pool, 1);
56
-
57
- if (git_vector_init(&diff->patches, 0, NULL) < 0 ||
55
+ if (git_pool_init(&diff->base.pool, 1) < 0 ||
56
+ git_vector_init(&diff->patches, 0, NULL) < 0 ||
58
57
  git_vector_init(&diff->base.deltas, 0, git_diff_delta__cmp) < 0) {
59
58
  git_diff_free(&diff->base);
60
59
  return NULL;
@@ -337,7 +337,7 @@ static int diff_delta_format_with_paths(
337
337
  return git_buf_printf(out, template, oldpath, newpath);
338
338
  }
339
339
 
340
- int diff_delta_format_similarity_header(
340
+ static int diff_delta_format_similarity_header(
341
341
  git_buf *out,
342
342
  const git_diff_delta *delta)
343
343
  {
@@ -351,17 +351,16 @@ int diff_delta_format_similarity_header(
351
351
  goto done;
352
352
  }
353
353
 
354
+ GIT_ASSERT(delta->status == GIT_DELTA_RENAMED || delta->status == GIT_DELTA_COPIED);
354
355
  if (delta->status == GIT_DELTA_RENAMED)
355
356
  type = "rename";
356
- else if (delta->status == GIT_DELTA_COPIED)
357
- type = "copy";
358
357
  else
359
- abort();
358
+ type = "copy";
360
359
 
361
360
  if ((error = git_buf_puts(&old_path, delta->old_file.path)) < 0 ||
362
- (error = git_buf_puts(&new_path, delta->new_file.path)) < 0 ||
363
- (error = git_buf_quote(&old_path)) < 0 ||
364
- (error = git_buf_quote(&new_path)) < 0)
361
+ (error = git_buf_puts(&new_path, delta->new_file.path)) < 0 ||
362
+ (error = git_buf_quote(&old_path)) < 0 ||
363
+ (error = git_buf_quote(&new_path)) < 0)
365
364
  goto done;
366
365
 
367
366
  git_buf_printf(out,
@@ -428,8 +427,11 @@ int git_diff_delta__format_file_header(
428
427
  git_buf_printf(out, "diff --git %s %s\n",
429
428
  old_path.ptr, new_path.ptr);
430
429
 
430
+ if (unchanged && delta->old_file.mode != delta->new_file.mode)
431
+ diff_print_modes(out, delta);
432
+
431
433
  if (delta->status == GIT_DELTA_RENAMED ||
432
- (delta->status == GIT_DELTA_COPIED && unchanged)) {
434
+ (delta->status == GIT_DELTA_COPIED && unchanged)) {
433
435
  if ((error = diff_delta_format_similarity_header(out, delta)) < 0)
434
436
  goto done;
435
437
  }
@@ -444,9 +446,6 @@ int git_diff_delta__format_file_header(
444
446
  "--- %s\n+++ %s\n", old_path.ptr, new_path.ptr);
445
447
  }
446
448
 
447
- if (unchanged && delta->old_file.mode != delta->new_file.mode)
448
- diff_print_modes(out, delta);
449
-
450
449
  if (git_buf_oom(out))
451
450
  error = -1;
452
451
 
@@ -492,6 +491,9 @@ static int format_binary(
492
491
  }
493
492
  git_buf_putc(pi->buf, '\n');
494
493
 
494
+ if (git_buf_oom(pi->buf))
495
+ return -1;
496
+
495
497
  return 0;
496
498
  }
497
499
 
@@ -502,21 +504,17 @@ static int diff_print_patch_file_binary_noshow(
502
504
  git_buf old_path = GIT_BUF_INIT, new_path = GIT_BUF_INIT;
503
505
  int error;
504
506
 
505
- if ((error = diff_delta_format_path(
506
- &old_path, old_pfx, delta->old_file.path)) < 0 ||
507
- (error = diff_delta_format_path(
508
- &new_path, new_pfx, delta->new_file.path)) < 0)
507
+ if ((error = diff_delta_format_path(&old_path, old_pfx, delta->old_file.path)) < 0 ||
508
+ (error = diff_delta_format_path(&new_path, new_pfx, delta->new_file.path)) < 0 ||
509
+ (error = diff_delta_format_with_paths(pi->buf, delta, "Binary files %s and %s differ\n",
510
+ old_path.ptr, new_path.ptr)) < 0)
509
511
  goto done;
510
512
 
511
513
  pi->line.num_lines = 1;
512
- error = diff_delta_format_with_paths(
513
- pi->buf, delta, "Binary files %s and %s differ\n",
514
- old_path.ptr, new_path.ptr);
515
514
 
516
515
  done:
517
516
  git_buf_dispose(&old_path);
518
517
  git_buf_dispose(&new_path);
519
-
520
518
  return error;
521
519
  }
522
520
 
@@ -540,10 +538,9 @@ static int diff_print_patch_file_binary(
540
538
  pi->line.num_lines++;
541
539
 
542
540
  if ((error = format_binary(pi, binary->new_file.type, binary->new_file.data,
543
- binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 ||
544
- (error = format_binary(pi, binary->old_file.type, binary->old_file.data,
545
- binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) {
546
-
541
+ binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 ||
542
+ (error = format_binary(pi, binary->old_file.type, binary->old_file.data,
543
+ binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) {
547
544
  if (error == GIT_EBUFS) {
548
545
  git_error_clear();
549
546
  git_buf_truncate(pi->buf, pre_binary_size);
@@ -580,16 +577,15 @@ static int diff_print_patch_file(
580
577
  GIT_UNUSED(progress);
581
578
 
582
579
  if (S_ISDIR(delta->new_file.mode) ||
583
- delta->status == GIT_DELTA_UNMODIFIED ||
584
- delta->status == GIT_DELTA_IGNORED ||
585
- delta->status == GIT_DELTA_UNREADABLE ||
586
- (delta->status == GIT_DELTA_UNTRACKED &&
580
+ delta->status == GIT_DELTA_UNMODIFIED ||
581
+ delta->status == GIT_DELTA_IGNORED ||
582
+ delta->status == GIT_DELTA_UNREADABLE ||
583
+ (delta->status == GIT_DELTA_UNTRACKED &&
587
584
  (pi->flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) == 0))
588
585
  return 0;
589
586
 
590
- if ((error = git_diff_delta__format_file_header(
591
- pi->buf, delta, oldpfx, newpfx,
592
- id_strlen, print_index)) < 0)
587
+ if ((error = git_diff_delta__format_file_header(pi->buf, delta, oldpfx, newpfx,
588
+ id_strlen, print_index)) < 0)
593
589
  return error;
594
590
 
595
591
  pi->line.origin = GIT_DIFF_LINE_FILE_HDR;
@@ -699,17 +695,16 @@ int git_diff_print(
699
695
  return -1;
700
696
  }
701
697
 
702
- if (!(error = diff_print_info_init_fromdiff(
703
- &pi, &buf, diff, format, print_cb, payload))) {
704
- error = git_diff_foreach(
705
- diff, print_file, print_binary, print_hunk, print_line, &pi);
698
+ if ((error = diff_print_info_init_fromdiff(&pi, &buf, diff, format, print_cb, payload)) < 0)
699
+ goto out;
706
700
 
707
- if (error) /* make sure error message is set */
708
- git_error_set_after_callback_function(error, "git_diff_print");
701
+ if ((error = git_diff_foreach(diff, print_file, print_binary, print_hunk, print_line, &pi)) != 0) {
702
+ git_error_set_after_callback_function(error, "git_diff_print");
703
+ goto out;
709
704
  }
710
705
 
706
+ out:
711
707
  git_buf_dispose(&buf);
712
-
713
708
  return error;
714
709
  }
715
710
 
@@ -728,8 +723,8 @@ int git_diff_print_callback__to_buf(
728
723
  }
729
724
 
730
725
  if (line->origin == GIT_DIFF_LINE_ADDITION ||
731
- line->origin == GIT_DIFF_LINE_DELETION ||
732
- line->origin == GIT_DIFF_LINE_CONTEXT)
726
+ line->origin == GIT_DIFF_LINE_DELETION ||
727
+ line->origin == GIT_DIFF_LINE_CONTEXT)
733
728
  git_buf_putc(output, line->origin);
734
729
 
735
730
  return git_buf_put(output, line->content, line->content_len);
@@ -742,14 +737,27 @@ int git_diff_print_callback__to_file_handle(
742
737
  void *payload)
743
738
  {
744
739
  FILE *fp = payload ? payload : stdout;
740
+ int error;
745
741
 
746
- GIT_UNUSED(delta); GIT_UNUSED(hunk);
742
+ GIT_UNUSED(delta);
743
+ GIT_UNUSED(hunk);
747
744
 
748
745
  if (line->origin == GIT_DIFF_LINE_CONTEXT ||
749
- line->origin == GIT_DIFF_LINE_ADDITION ||
750
- line->origin == GIT_DIFF_LINE_DELETION)
751
- fputc(line->origin, fp);
752
- fwrite(line->content, 1, line->content_len, fp);
746
+ line->origin == GIT_DIFF_LINE_ADDITION ||
747
+ line->origin == GIT_DIFF_LINE_DELETION) {
748
+ while ((error = fputc(line->origin, fp)) == EINTR)
749
+ continue;
750
+ if (error) {
751
+ git_error_set(GIT_ERROR_OS, "could not write status");
752
+ return -1;
753
+ }
754
+ }
755
+
756
+ if (fwrite(line->content, line->content_len, 1, fp) != 1) {
757
+ git_error_set(GIT_ERROR_OS, "could not write line");
758
+ return -1;
759
+ }
760
+
753
761
  return 0;
754
762
  }
755
763
 
@@ -758,8 +766,7 @@ int git_diff_to_buf(git_buf *out, git_diff *diff, git_diff_format_t format)
758
766
  {
759
767
  assert(out && diff);
760
768
  git_buf_sanitize(out);
761
- return git_diff_print(
762
- diff, format, git_diff_print_callback__to_buf, out);
769
+ return git_diff_print(diff, format, git_diff_print_callback__to_buf, out);
763
770
  }
764
771
 
765
772
  /* print a git_patch to an output callback */
@@ -768,28 +775,24 @@ int git_patch_print(
768
775
  git_diff_line_cb print_cb,
769
776
  void *payload)
770
777
  {
771
- int error;
772
778
  git_buf temp = GIT_BUF_INIT;
773
779
  diff_print_info pi;
780
+ int error;
774
781
 
775
782
  assert(patch && print_cb);
776
783
 
777
- if (!(error = diff_print_info_init_frompatch(
778
- &pi, &temp, patch,
779
- GIT_DIFF_FORMAT_PATCH, print_cb, payload)))
780
- {
781
- error = git_patch__invoke_callbacks(
782
- patch,
783
- diff_print_patch_file, diff_print_patch_binary,
784
- diff_print_patch_hunk, diff_print_patch_line,
785
- &pi);
786
-
787
- if (error) /* make sure error message is set */
788
- git_error_set_after_callback_function(error, "git_patch_print");
784
+ if ((error = diff_print_info_init_frompatch(&pi, &temp, patch,
785
+ GIT_DIFF_FORMAT_PATCH, print_cb, payload)) < 0)
786
+ goto out;
787
+
788
+ if ((error = git_patch__invoke_callbacks(patch, diff_print_patch_file, diff_print_patch_binary,
789
+ diff_print_patch_hunk, diff_print_patch_line, &pi)) < 0) {
790
+ git_error_set_after_callback_function(error, "git_patch_print");
791
+ goto out;
789
792
  }
790
793
 
794
+ out:
791
795
  git_buf_dispose(&temp);
792
-
793
796
  return error;
794
797
  }
795
798
 
@@ -46,14 +46,14 @@ static int digits_for_value(size_t val)
46
46
  return count;
47
47
  }
48
48
 
49
- int git_diff_file_stats__full_to_buf(
49
+ static int diff_file_stats_full_to_buf(
50
50
  git_buf *out,
51
51
  const git_diff_delta *delta,
52
52
  const diff_file_stats *filestat,
53
53
  const git_diff_stats *stats,
54
54
  size_t width)
55
55
  {
56
- const char *old_path = NULL, *new_path = NULL;
56
+ const char *old_path = NULL, *new_path = NULL, *adddel_path = NULL;
57
57
  size_t padding;
58
58
  git_object_size_t old_size, new_size;
59
59
 
@@ -62,7 +62,7 @@ int git_diff_file_stats__full_to_buf(
62
62
  old_size = delta->old_file.size;
63
63
  new_size = delta->new_file.size;
64
64
 
65
- if (strcmp(old_path, new_path) != 0) {
65
+ if (old_path && new_path && strcmp(old_path, new_path) != 0) {
66
66
  size_t common_dirlen;
67
67
  int error;
68
68
 
@@ -82,10 +82,11 @@ int git_diff_file_stats__full_to_buf(
82
82
  if (error < 0)
83
83
  goto on_error;
84
84
  } else {
85
- if (git_buf_printf(out, " %s", old_path) < 0)
85
+ adddel_path = new_path ? new_path : old_path;
86
+ if (git_buf_printf(out, " %s", adddel_path) < 0)
86
87
  goto on_error;
87
88
 
88
- padding = stats->max_name - strlen(old_path);
89
+ padding = stats->max_name - strlen(adddel_path);
89
90
 
90
91
  if (stats->renames > 0)
91
92
  padding += strlen(DIFF_RENAME_FILE_SEPARATOR);
@@ -134,7 +135,7 @@ on_error:
134
135
  return (git_buf_oom(out) ? -1 : 0);
135
136
  }
136
137
 
137
- int git_diff_file_stats__number_to_buf(
138
+ static int diff_file_stats_number_to_buf(
138
139
  git_buf *out,
139
140
  const git_diff_delta *delta,
140
141
  const diff_file_stats *filestats)
@@ -151,7 +152,7 @@ int git_diff_file_stats__number_to_buf(
151
152
  return error;
152
153
  }
153
154
 
154
- int git_diff_file_stats__summary_to_buf(
155
+ static int diff_file_stats_summary_to_buf(
155
156
  git_buf *out,
156
157
  const git_diff_delta *delta)
157
158
  {
@@ -211,7 +212,7 @@ int git_diff_get_stats(
211
212
 
212
213
  /* TODO ugh */
213
214
  namelen = strlen(delta->new_file.path);
214
- if (strcmp(delta->old_file.path, delta->new_file.path) != 0) {
215
+ if (delta->old_file.path && strcmp(delta->old_file.path, delta->new_file.path) != 0) {
215
216
  namelen += strlen(delta->old_file.path);
216
217
  stats->renames++;
217
218
  }
@@ -288,7 +289,7 @@ int git_diff_stats_to_buf(
288
289
  if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
289
290
  continue;
290
291
 
291
- error = git_diff_file_stats__number_to_buf(
292
+ error = diff_file_stats_number_to_buf(
292
293
  out, delta, &stats->filestats[i]);
293
294
  if (error < 0)
294
295
  return error;
@@ -309,7 +310,7 @@ int git_diff_stats_to_buf(
309
310
  if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
310
311
  continue;
311
312
 
312
- error = git_diff_file_stats__full_to_buf(
313
+ error = diff_file_stats_full_to_buf(
313
314
  out, delta, &stats->filestats[i], stats, width);
314
315
  if (error < 0)
315
316
  return error;
@@ -342,7 +343,7 @@ int git_diff_stats_to_buf(
342
343
  if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
343
344
  continue;
344
345
 
345
- error = git_diff_file_stats__summary_to_buf(out, delta);
346
+ error = diff_file_stats_summary_to_buf(out, delta);
346
347
  if (error < 0)
347
348
  return error;
348
349
  }
@@ -136,11 +136,10 @@ int git_diff__merge(
136
136
  return -1;
137
137
  }
138
138
 
139
- if (git_vector_init(&onto_new, onto->deltas.length, git_diff_delta__cmp) < 0)
139
+ if (git_vector_init(&onto_new, onto->deltas.length, git_diff_delta__cmp) < 0 ||
140
+ git_pool_init(&onto_pool, 1) < 0)
140
141
  return -1;
141
142
 
142
- git_pool_init(&onto_pool, 1);
143
-
144
143
  for (i = 0, j = 0; i < onto->deltas.length || j < from->deltas.length; ) {
145
144
  git_diff_delta *o = GIT_VECTOR_GET(&onto->deltas, i);
146
145
  const git_diff_delta *f = GIT_VECTOR_GET(&from->deltas, j);
@@ -210,6 +210,7 @@ void git_error_system_set(int code)
210
210
 
211
211
  /* Deprecated error values and functions */
212
212
 
213
+ #ifndef GIT_DEPRECATE_HARD
213
214
  const git_error *giterr_last(void)
214
215
  {
215
216
  return git_error_last();
@@ -229,3 +230,4 @@ void giterr_set_oom(void)
229
230
  {
230
231
  git_error_set_oom();
231
232
  }
233
+ #endif