rugged 0.27.5 → 0.27.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +2 -2
  4. data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
  5. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
  6. data/vendor/libgit2/include/git2.h +1 -0
  7. data/vendor/libgit2/include/git2/attr.h +18 -7
  8. data/vendor/libgit2/include/git2/blame.h +39 -22
  9. data/vendor/libgit2/include/git2/blob.h +1 -1
  10. data/vendor/libgit2/include/git2/branch.h +1 -1
  11. data/vendor/libgit2/include/git2/buffer.h +14 -2
  12. data/vendor/libgit2/include/git2/checkout.h +13 -12
  13. data/vendor/libgit2/include/git2/cherrypick.h +6 -4
  14. data/vendor/libgit2/include/git2/clone.h +8 -6
  15. data/vendor/libgit2/include/git2/commit.h +28 -0
  16. data/vendor/libgit2/include/git2/common.h +27 -0
  17. data/vendor/libgit2/include/git2/config.h +1 -0
  18. data/vendor/libgit2/include/git2/describe.h +30 -7
  19. data/vendor/libgit2/include/git2/diff.h +32 -22
  20. data/vendor/libgit2/include/git2/errors.h +1 -0
  21. data/vendor/libgit2/include/git2/ignore.h +2 -2
  22. data/vendor/libgit2/include/git2/mailmap.h +115 -0
  23. data/vendor/libgit2/include/git2/merge.h +10 -8
  24. data/vendor/libgit2/include/git2/proxy.h +9 -5
  25. data/vendor/libgit2/include/git2/rebase.h +7 -4
  26. data/vendor/libgit2/include/git2/refspec.h +17 -0
  27. data/vendor/libgit2/include/git2/remote.h +12 -10
  28. data/vendor/libgit2/include/git2/repository.h +7 -5
  29. data/vendor/libgit2/include/git2/revert.h +5 -3
  30. data/vendor/libgit2/include/git2/stash.h +11 -8
  31. data/vendor/libgit2/include/git2/status.h +7 -3
  32. data/vendor/libgit2/include/git2/submodule.h +8 -7
  33. data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
  34. data/vendor/libgit2/include/git2/sys/index.h +3 -0
  35. data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
  36. data/vendor/libgit2/include/git2/sys/merge.h +6 -1
  37. data/vendor/libgit2/include/git2/sys/path.h +55 -0
  38. data/vendor/libgit2/include/git2/transaction.h +1 -0
  39. data/vendor/libgit2/include/git2/types.h +8 -5
  40. data/vendor/libgit2/include/git2/version.h +2 -2
  41. data/vendor/libgit2/include/git2/worktree.h +46 -11
  42. data/vendor/libgit2/src/CMakeLists.txt +87 -15
  43. data/vendor/libgit2/src/alloc.c +47 -0
  44. data/vendor/libgit2/src/alloc.h +40 -0
  45. data/vendor/libgit2/src/apply.c +4 -4
  46. data/vendor/libgit2/src/attr.c +4 -4
  47. data/vendor/libgit2/src/attr_file.c +8 -7
  48. data/vendor/libgit2/src/attrcache.c +2 -2
  49. data/vendor/libgit2/src/blame.c +11 -4
  50. data/vendor/libgit2/src/blame.h +1 -0
  51. data/vendor/libgit2/src/blame_git.c +8 -5
  52. data/vendor/libgit2/src/blob.c +5 -5
  53. data/vendor/libgit2/src/branch.c +20 -20
  54. data/vendor/libgit2/src/buffer.c +9 -4
  55. data/vendor/libgit2/src/buffer.h +1 -1
  56. data/vendor/libgit2/src/checkout.c +33 -24
  57. data/vendor/libgit2/src/cherrypick.c +3 -3
  58. data/vendor/libgit2/src/clone.c +13 -13
  59. data/vendor/libgit2/src/commit.c +16 -3
  60. data/vendor/libgit2/src/common.h +3 -1
  61. data/vendor/libgit2/src/config.c +3 -3
  62. data/vendor/libgit2/src/config_file.c +193 -241
  63. data/vendor/libgit2/src/config_parse.c +89 -66
  64. data/vendor/libgit2/src/config_parse.h +2 -2
  65. data/vendor/libgit2/src/crlf.c +9 -3
  66. data/vendor/libgit2/src/diff.c +2 -2
  67. data/vendor/libgit2/src/diff_driver.c +3 -3
  68. data/vendor/libgit2/src/diff_file.c +3 -3
  69. data/vendor/libgit2/src/diff_generate.c +4 -3
  70. data/vendor/libgit2/src/diff_print.c +8 -8
  71. data/vendor/libgit2/src/diff_tform.c +1 -1
  72. data/vendor/libgit2/src/diff_xdiff.c +12 -0
  73. data/vendor/libgit2/src/features.h.in +2 -0
  74. data/vendor/libgit2/src/fetch.c +2 -2
  75. data/vendor/libgit2/src/fetchhead.c +5 -5
  76. data/vendor/libgit2/src/filebuf.c +4 -4
  77. data/vendor/libgit2/src/fileops.c +10 -10
  78. data/vendor/libgit2/src/filter.c +3 -3
  79. data/vendor/libgit2/src/global.c +17 -12
  80. data/vendor/libgit2/src/hash.h +2 -0
  81. data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
  82. data/vendor/libgit2/src/hash/hash_mbedtls.h +20 -0
  83. data/vendor/libgit2/src/ignore.c +15 -20
  84. data/vendor/libgit2/src/index.c +77 -36
  85. data/vendor/libgit2/src/index.h +10 -0
  86. data/vendor/libgit2/src/indexer.c +9 -9
  87. data/vendor/libgit2/src/iterator.c +8 -8
  88. data/vendor/libgit2/src/khash.h +3 -1
  89. data/vendor/libgit2/src/mailmap.c +485 -0
  90. data/vendor/libgit2/src/mailmap.h +35 -0
  91. data/vendor/libgit2/src/merge.c +7 -7
  92. data/vendor/libgit2/src/netops.c +5 -5
  93. data/vendor/libgit2/src/notes.c +2 -2
  94. data/vendor/libgit2/src/odb.c +7 -7
  95. data/vendor/libgit2/src/odb_loose.c +13 -13
  96. data/vendor/libgit2/src/odb_pack.c +3 -3
  97. data/vendor/libgit2/src/pack-objects.c +2 -2
  98. data/vendor/libgit2/src/pack.c +5 -5
  99. data/vendor/libgit2/src/pack.h +1 -1
  100. data/vendor/libgit2/src/patch.c +1 -1
  101. data/vendor/libgit2/src/patch_generate.c +2 -2
  102. data/vendor/libgit2/src/patch_parse.c +11 -4
  103. data/vendor/libgit2/src/path.c +42 -66
  104. data/vendor/libgit2/src/path.h +2 -72
  105. data/vendor/libgit2/src/pathspec.c +1 -1
  106. data/vendor/libgit2/src/push.c +2 -2
  107. data/vendor/libgit2/src/rebase.c +19 -22
  108. data/vendor/libgit2/src/refdb_fs.c +65 -34
  109. data/vendor/libgit2/src/refs.c +6 -6
  110. data/vendor/libgit2/src/refspec.c +30 -5
  111. data/vendor/libgit2/src/refspec.h +1 -1
  112. data/vendor/libgit2/src/remote.c +40 -40
  113. data/vendor/libgit2/src/repository.c +63 -59
  114. data/vendor/libgit2/src/reset.c +1 -1
  115. data/vendor/libgit2/src/revert.c +3 -3
  116. data/vendor/libgit2/src/revparse.c +4 -4
  117. data/vendor/libgit2/src/revwalk.c +44 -10
  118. data/vendor/libgit2/src/revwalk.h +2 -1
  119. data/vendor/libgit2/src/settings.c +25 -1
  120. data/vendor/libgit2/src/signature.c +1 -1
  121. data/vendor/libgit2/src/stash.c +80 -34
  122. data/vendor/libgit2/src/status.c +1 -1
  123. data/vendor/libgit2/src/stdalloc.c +120 -0
  124. data/vendor/libgit2/src/stdalloc.h +17 -0
  125. data/vendor/libgit2/src/streams/mbedtls.c +463 -0
  126. data/vendor/libgit2/src/streams/mbedtls.h +20 -0
  127. data/vendor/libgit2/src/streams/openssl.c +132 -34
  128. data/vendor/libgit2/src/streams/openssl.h +0 -107
  129. data/vendor/libgit2/src/streams/tls.c +3 -0
  130. data/vendor/libgit2/src/submodule.c +117 -82
  131. data/vendor/libgit2/src/sysdir.c +4 -4
  132. data/vendor/libgit2/src/tag.c +7 -7
  133. data/vendor/libgit2/src/trace.h +1 -1
  134. data/vendor/libgit2/src/trailer.c +6 -6
  135. data/vendor/libgit2/src/transport.c +2 -2
  136. data/vendor/libgit2/src/transports/auth.c +1 -1
  137. data/vendor/libgit2/src/transports/auth_negotiate.c +2 -2
  138. data/vendor/libgit2/src/transports/git.c +1 -1
  139. data/vendor/libgit2/src/transports/http.c +12 -12
  140. data/vendor/libgit2/src/transports/local.c +7 -7
  141. data/vendor/libgit2/src/transports/smart.c +17 -8
  142. data/vendor/libgit2/src/transports/smart.h +5 -5
  143. data/vendor/libgit2/src/transports/smart_pkt.c +122 -130
  144. data/vendor/libgit2/src/transports/smart_protocol.c +48 -38
  145. data/vendor/libgit2/src/transports/ssh.c +1 -1
  146. data/vendor/libgit2/src/transports/winhttp.c +6 -6
  147. data/vendor/libgit2/src/tree.c +12 -53
  148. data/vendor/libgit2/src/tree.h +0 -12
  149. data/vendor/libgit2/src/util.c +16 -0
  150. data/vendor/libgit2/src/util.h +12 -135
  151. data/vendor/libgit2/src/win32/findfile.c +2 -2
  152. data/vendor/libgit2/src/win32/posix_w32.c +1 -1
  153. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +94 -0
  154. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
  155. data/vendor/libgit2/src/worktree.c +64 -43
  156. data/vendor/libgit2/src/worktree.h +2 -0
  157. data/vendor/libgit2/src/xdiff/xdiffi.c +3 -1
  158. metadata +16 -2
@@ -130,15 +130,15 @@ end_parse:
130
130
 
131
131
  if (line[rpos] != '"' || line[rpos + 1] != ']') {
132
132
  set_parse_error(reader, rpos, "Unexpected text after closing quotes");
133
- git_buf_free(&buf);
133
+ git_buf_dispose(&buf);
134
134
  return -1;
135
135
  }
136
136
 
137
137
  *section_name = git_buf_detach(&buf);
138
- return 0;
138
+ return base_name_len + 1 /* SP */ + 1 /* " */ + rpos + 1 /* " */ + 1 /* ] */;
139
139
 
140
140
  end_error:
141
- git_buf_free(&buf);
141
+ git_buf_dispose(&buf);
142
142
 
143
143
  return -1;
144
144
  }
@@ -205,7 +205,7 @@ static int parse_section_header(git_config_parser *reader, char **section_out)
205
205
  name[name_length] = 0;
206
206
  *section_out = name;
207
207
 
208
- return 0;
208
+ return pos;
209
209
 
210
210
  fail_parse:
211
211
  git__free(line);
@@ -315,51 +315,49 @@ done:
315
315
 
316
316
  static int parse_multiline_variable(git_config_parser *reader, git_buf *value, int in_quotes)
317
317
  {
318
+ char *line = NULL, *proc_line = NULL;
318
319
  int quote_count;
319
- bool multiline = true;
320
-
321
- while (multiline) {
322
- char *line = NULL, *proc_line = NULL;
323
- int error;
324
-
325
- /* Check that the next line exists */
326
- git_parse_advance_line(&reader->ctx);
327
- line = git__strndup(reader->ctx.line, reader->ctx.line_len);
328
- GITERR_CHECK_ALLOC(line);
329
-
330
- /*
331
- * We've reached the end of the file, there is no continuation.
332
- * (this is not an error).
333
- */
334
- if (line[0] == '\0') {
335
- error = 0;
336
- goto out;
337
- }
320
+ bool multiline;
338
321
 
339
- /* If it was just a comment, pretend it didn't exist */
340
- quote_count = strip_comments(line, !!in_quotes);
341
- if (line[0] == '\0')
342
- goto next;
322
+ /* Check that the next line exists */
323
+ git_parse_advance_line(&reader->ctx);
324
+ line = git__strndup(reader->ctx.line, reader->ctx.line_len);
325
+ if (line == NULL)
326
+ return -1;
343
327
 
344
- if ((error = unescape_line(&proc_line, &multiline,
345
- line, in_quotes)) < 0)
346
- goto out;
328
+ /* We've reached the end of the file, there is no continuation.
329
+ * (this is not an error).
330
+ */
331
+ if (line[0] == '\0') {
332
+ git__free(line);
333
+ return 0;
334
+ }
347
335
 
348
- /* Add this line to the multiline var */
349
- if ((error = git_buf_puts(value, proc_line)) < 0)
350
- goto out;
336
+ quote_count = strip_comments(line, !!in_quotes);
351
337
 
352
- next:
338
+ /* If it was just a comment, pretend it didn't exist */
339
+ if (line[0] == '\0') {
353
340
  git__free(line);
354
- git__free(proc_line);
355
- in_quotes = quote_count;
356
- continue;
341
+ return parse_multiline_variable(reader, value, quote_count);
342
+ /* TODO: unbounded recursion. This **could** be exploitable */
343
+ }
357
344
 
358
- out:
345
+ if (unescape_line(&proc_line, &multiline, line, in_quotes) < 0) {
359
346
  git__free(line);
360
- git__free(proc_line);
361
- return error;
347
+ return -1;
362
348
  }
349
+ /* add this line to the multiline var */
350
+
351
+ git_buf_puts(value, proc_line);
352
+ git__free(line);
353
+ git__free(proc_line);
354
+
355
+ /*
356
+ * If we need to continue reading the next line, let's just
357
+ * keep putting stuff in the buffer
358
+ */
359
+ if (multiline)
360
+ return parse_multiline_variable(reader, value, quote_count);
363
361
 
364
362
  return 0;
365
363
  }
@@ -406,22 +404,21 @@ static int parse_name(
406
404
  static int parse_variable(git_config_parser *reader, char **var_name, char **var_value)
407
405
  {
408
406
  const char *value_start = NULL;
409
- char *line;
410
- int quote_count;
407
+ char *line = NULL, *name = NULL, *value = NULL;
408
+ int quote_count, error;
411
409
  bool multiline;
412
410
 
411
+ *var_name = NULL;
412
+ *var_value = NULL;
413
+
413
414
  git_parse_advance_ws(&reader->ctx);
414
415
  line = git__strndup(reader->ctx.line, reader->ctx.line_len);
415
- if (line == NULL)
416
- return -1;
416
+ GITERR_CHECK_ALLOC(line);
417
417
 
418
418
  quote_count = strip_comments(line, 0);
419
419
 
420
- /* If there is no value, boolean true is assumed */
421
- *var_value = NULL;
422
-
423
- if (parse_name(var_name, &value_start, reader, line) < 0)
424
- goto on_error;
420
+ if ((error = parse_name(&name, &value_start, reader, line)) < 0)
421
+ goto out;
425
422
 
426
423
  /*
427
424
  * Now, let's try to parse the value
@@ -430,30 +427,34 @@ static int parse_variable(git_config_parser *reader, char **var_name, char **var
430
427
  while (git__isspace(value_start[0]))
431
428
  value_start++;
432
429
 
433
- if (unescape_line(var_value, &multiline, value_start, 0) < 0)
434
- goto on_error;
430
+ if ((error = unescape_line(&value, &multiline, value_start, 0)) < 0)
431
+ goto out;
435
432
 
436
433
  if (multiline) {
437
434
  git_buf multi_value = GIT_BUF_INIT;
438
- git_buf_attach(&multi_value, *var_value, 0);
435
+ git_buf_attach(&multi_value, value, 0);
439
436
 
440
437
  if (parse_multiline_variable(reader, &multi_value, quote_count) < 0 ||
441
- git_buf_oom(&multi_value)) {
442
- git_buf_free(&multi_value);
443
- goto on_error;
438
+ git_buf_oom(&multi_value)) {
439
+ error = -1;
440
+ git_buf_dispose(&multi_value);
441
+ goto out;
444
442
  }
445
443
 
446
- *var_value = git_buf_detach(&multi_value);
444
+ value = git_buf_detach(&multi_value);
447
445
  }
448
446
  }
449
447
 
450
- git__free(line);
451
- return 0;
448
+ *var_name = name;
449
+ *var_value = value;
450
+ name = NULL;
451
+ value = NULL;
452
452
 
453
- on_error:
454
- git__free(*var_name);
453
+ out:
454
+ git__free(name);
455
+ git__free(value);
455
456
  git__free(line);
456
- return -1;
457
+ return error;
457
458
  }
458
459
 
459
460
  int git_config_parse(
@@ -465,7 +466,7 @@ int git_config_parse(
465
466
  void *data)
466
467
  {
467
468
  git_parse_ctx *ctx;
468
- char *current_section = NULL, *var_name, *var_value;
469
+ char *current_section = NULL, *var_name = NULL, *var_value = NULL;
469
470
  int result = 0;
470
471
 
471
472
  ctx = &parser->ctx;
@@ -473,10 +474,14 @@ int git_config_parse(
473
474
  skip_bom(ctx);
474
475
 
475
476
  for (; ctx->remain_len > 0; git_parse_advance_line(ctx)) {
476
- const char *line_start = parser->ctx.line;
477
- size_t line_len = parser->ctx.line_len;
477
+ const char *line_start;
478
+ size_t line_len;
478
479
  char c;
479
480
 
481
+ restart:
482
+ line_start = ctx->line;
483
+ line_len = ctx->line_len;
484
+
480
485
  /*
481
486
  * Get either first non-whitespace character or, if that does
482
487
  * not exist, the first whitespace character. This is required
@@ -491,9 +496,24 @@ int git_config_parse(
491
496
  git__free(current_section);
492
497
  current_section = NULL;
493
498
 
494
- if ((result = parse_section_header(parser, &current_section)) == 0 && on_section) {
499
+ result = parse_section_header(parser, &current_section);
500
+ if (result < 0)
501
+ break;
502
+
503
+ git_parse_advance_chars(ctx, result);
504
+
505
+ if (on_section)
495
506
  result = on_section(parser, current_section, line_start, line_len, data);
496
- }
507
+ /*
508
+ * After we've parsed the section header we may not be
509
+ * done with the line. If there's still data in there,
510
+ * run the next loop with the rest of the current line
511
+ * instead of moving forward.
512
+ */
513
+
514
+ if (!git_parse_peek(&c, ctx, GIT_PARSE_PEEK_SKIP_WHITESPACE))
515
+ goto restart;
516
+
497
517
  break;
498
518
 
499
519
  case '\n': /* comment or whitespace-only */
@@ -510,7 +530,10 @@ int git_config_parse(
510
530
  default: /* assume variable declaration */
511
531
  if ((result = parse_variable(parser, &var_name, &var_value)) == 0 && on_variable) {
512
532
  result = on_variable(parser, current_section, var_name, var_value, line_start, line_len, data);
533
+ git__free(var_name);
534
+ git__free(var_value);
513
535
  }
536
+
514
537
  break;
515
538
  }
516
539
 
@@ -36,8 +36,8 @@ typedef int (*git_config_parser_section_cb)(
36
36
  typedef int (*git_config_parser_variable_cb)(
37
37
  git_config_parser *parser,
38
38
  const char *current_section,
39
- char *var_name,
40
- char *var_value,
39
+ const char *var_name,
40
+ const char *var_value,
41
41
  const char *line,
42
42
  size_t line_len,
43
43
  void *data);
@@ -71,6 +71,9 @@ static int crlf_input_action(struct crlf_attrs *ca)
71
71
  if (ca->eol == GIT_EOL_LF)
72
72
  return GIT_CRLF_INPUT;
73
73
 
74
+ if (ca->crlf_action == GIT_CRLF_AUTO)
75
+ return GIT_CRLF_AUTO;
76
+
74
77
  if (ca->eol == GIT_EOL_CRLF)
75
78
  return GIT_CRLF_CRLF;
76
79
 
@@ -200,6 +203,8 @@ static const char *line_ending(struct crlf_attrs *ca)
200
203
  break;
201
204
 
202
205
  case GIT_CRLF_AUTO:
206
+ if (ca->eol == GIT_EOL_CRLF)
207
+ return "\r\n";
203
208
  case GIT_CRLF_TEXT:
204
209
  break;
205
210
 
@@ -253,8 +258,7 @@ static int crlf_apply_to_workdir(
253
258
  ca->crlf_action == GIT_CRLF_GUESS) {
254
259
 
255
260
  /* If we have any existing CR or CRLF line endings, do nothing */
256
- if (ca->crlf_action == GIT_CRLF_GUESS &&
257
- stats.cr > 0 && stats.crlf > 0)
261
+ if (stats.cr > 0 && stats.crlf > 0)
258
262
  return GIT_PASSTHROUGH;
259
263
 
260
264
  /* If we have bare CR characters, do nothing */
@@ -302,7 +306,8 @@ static int crlf_check(
302
306
  return GIT_PASSTHROUGH;
303
307
 
304
308
  if (ca.crlf_action == GIT_CRLF_GUESS ||
305
- ((ca.crlf_action == GIT_CRLF_AUTO || ca.crlf_action == GIT_CRLF_TEXT) &&
309
+ ((ca.crlf_action == GIT_CRLF_AUTO ||
310
+ ca.crlf_action == GIT_CRLF_TEXT) &&
306
311
  git_filter_source_mode(src) == GIT_FILTER_SMUDGE)) {
307
312
 
308
313
  error = git_repository__cvar(
@@ -315,6 +320,7 @@ static int crlf_check(
315
320
  return GIT_PASSTHROUGH;
316
321
 
317
322
  if (ca.auto_crlf == GIT_AUTO_CRLF_INPUT &&
323
+ ca.eol != GIT_EOL_CRLF &&
318
324
  git_filter_source_mode(src) == GIT_FILTER_SMUDGE)
319
325
  return GIT_PASSTHROUGH;
320
326
  }
@@ -439,7 +439,7 @@ static int file_cb(
439
439
  goto out;
440
440
 
441
441
  out:
442
- git_buf_free(&buf);
442
+ git_buf_dispose(&buf);
443
443
  return error;
444
444
  }
445
445
 
@@ -477,7 +477,7 @@ static int line_cb(
477
477
  goto out;
478
478
 
479
479
  out:
480
- git_buf_free(&buf);
480
+ git_buf_dispose(&buf);
481
481
  return error;
482
482
  }
483
483
 
@@ -121,7 +121,7 @@ static int diff_driver_add_patterns(
121
121
 
122
122
  if (error && pat != NULL)
123
123
  (void)git_array_pop(drv->fn_patterns); /* release last item */
124
- git_buf_free(&buf);
124
+ git_buf_dispose(&buf);
125
125
 
126
126
  /* We want to ignore bad patterns, so return success regardless */
127
127
  return 0;
@@ -338,7 +338,7 @@ static int git_diff_driver_load(
338
338
 
339
339
  done:
340
340
  git_config_entry_free(ce);
341
- git_buf_free(&name);
341
+ git_buf_dispose(&name);
342
342
  git_config_free(cfg);
343
343
 
344
344
  if (!*out) {
@@ -516,7 +516,7 @@ void git_diff_find_context_init(
516
516
  void git_diff_find_context_clear(git_diff_find_context_payload *payload)
517
517
  {
518
518
  if (payload) {
519
- git_buf_free(&payload->line);
519
+ git_buf_dispose(&payload->line);
520
520
  payload->driver = NULL;
521
521
  }
522
522
  }
@@ -280,7 +280,7 @@ static int diff_file_content_load_workdir_symlink_fake(
280
280
  fc->map.data = git_buf_detach(&target);
281
281
  fc->flags |= GIT_DIFF_FLAG__FREE_DATA;
282
282
 
283
- git_buf_free(&target);
283
+ git_buf_dispose(&target);
284
284
  return error;
285
285
  }
286
286
 
@@ -361,7 +361,7 @@ static int diff_file_content_load_workdir_file(
361
361
  error = git_filter_list_apply_to_data(&out, fl, &raw);
362
362
 
363
363
  if (out.ptr != raw.ptr)
364
- git_buf_free(&raw);
364
+ git_buf_dispose(&raw);
365
365
 
366
366
  if (!error) {
367
367
  fc->map.len = out.size;
@@ -406,7 +406,7 @@ static int diff_file_content_load_workdir(
406
406
  fc->file->flags |= GIT_DIFF_FLAG_VALID_ID;
407
407
  }
408
408
 
409
- git_buf_free(&path);
409
+ git_buf_dispose(&path);
410
410
  return error;
411
411
  }
412
412
 
@@ -273,7 +273,8 @@ static git_diff_delta *diff_delta__last_for_item(
273
273
  break;
274
274
  case GIT_DELTA_MODIFIED:
275
275
  if (git_oid__cmp(&delta->old_file.id, &item->id) == 0 ||
276
- git_oid__cmp(&delta->new_file.id, &item->id) == 0)
276
+ (delta->new_file.mode == item->mode &&
277
+ git_oid__cmp(&delta->new_file.id, &item->id) == 0))
277
278
  return delta;
278
279
  break;
279
280
  default:
@@ -600,7 +601,7 @@ int git_diff__oid_for_entry(
600
601
 
601
602
  if (p_stat(full_path.ptr, &st) < 0) {
602
603
  error = git_path_set_error(errno, entry.path, "stat");
603
- git_buf_free(&full_path);
604
+ git_buf_dispose(&full_path);
604
605
  return error;
605
606
  }
606
607
 
@@ -663,7 +664,7 @@ int git_diff__oid_for_entry(
663
664
  }
664
665
  }
665
666
 
666
- git_buf_free(&full_path);
667
+ git_buf_dispose(&full_path);
667
668
  return error;
668
669
  }
669
670
 
@@ -373,8 +373,8 @@ int diff_delta_format_similarity_header(
373
373
  error = -1;
374
374
 
375
375
  done:
376
- git_buf_free(&old_path);
377
- git_buf_free(&new_path);
376
+ git_buf_dispose(&old_path);
377
+ git_buf_dispose(&new_path);
378
378
 
379
379
  return error;
380
380
  }
@@ -446,8 +446,8 @@ int git_diff_delta__format_file_header(
446
446
  error = -1;
447
447
 
448
448
  done:
449
- git_buf_free(&old_path);
450
- git_buf_free(&new_path);
449
+ git_buf_dispose(&old_path);
450
+ git_buf_dispose(&new_path);
451
451
 
452
452
  return error;
453
453
  }
@@ -509,8 +509,8 @@ static int diff_print_patch_file_binary_noshow(
509
509
  old_path.ptr, new_path.ptr);
510
510
 
511
511
  done:
512
- git_buf_free(&old_path);
513
- git_buf_free(&new_path);
512
+ git_buf_dispose(&old_path);
513
+ git_buf_dispose(&new_path);
514
514
 
515
515
  return error;
516
516
  }
@@ -696,7 +696,7 @@ int git_diff_print(
696
696
  giterr_set_after_callback_function(error, "git_diff_print");
697
697
  }
698
698
 
699
- git_buf_free(&buf);
699
+ git_buf_dispose(&buf);
700
700
 
701
701
  return error;
702
702
  }
@@ -776,7 +776,7 @@ int git_patch_print(
776
776
  giterr_set_after_callback_function(error, "git_patch_print");
777
777
  }
778
778
 
779
- git_buf_free(&temp);
779
+ git_buf_dispose(&temp);
780
780
 
781
781
  return error;
782
782
  }