rugged 0.23.2 → 0.23.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +12 -3
  4. data/vendor/libgit2/COPYING +46 -0
  5. data/vendor/libgit2/include/git2/config.h +4 -2
  6. data/vendor/libgit2/include/git2/cred_helpers.h +1 -1
  7. data/vendor/libgit2/include/git2/diff.h +0 -19
  8. data/vendor/libgit2/include/git2/errors.h +12 -0
  9. data/vendor/libgit2/include/git2/sys/filter.h +1 -4
  10. data/vendor/libgit2/include/git2/sys/refdb_backend.h +2 -3
  11. data/vendor/libgit2/include/git2/transport.h +21 -14
  12. data/vendor/libgit2/include/git2/version.h +2 -2
  13. data/vendor/libgit2/src/blame.c +1 -1
  14. data/vendor/libgit2/src/blame_git.c +27 -7
  15. data/vendor/libgit2/src/blame_git.h +1 -1
  16. data/vendor/libgit2/src/branch.c +12 -1
  17. data/vendor/libgit2/src/checkout.c +2 -1
  18. data/vendor/libgit2/src/clone.c +2 -2
  19. data/vendor/libgit2/src/common.h +13 -13
  20. data/vendor/libgit2/src/curl_stream.c +8 -7
  21. data/vendor/libgit2/src/diff.c +0 -25
  22. data/vendor/libgit2/src/diff_driver.c +6 -7
  23. data/vendor/libgit2/src/diff_patch.c +4 -0
  24. data/vendor/libgit2/src/diff_xdiff.c +7 -0
  25. data/vendor/libgit2/src/diff_xdiff.h +5 -0
  26. data/vendor/libgit2/src/errors.c +40 -75
  27. data/vendor/libgit2/src/filter.c +2 -5
  28. data/vendor/libgit2/src/global.c +9 -25
  29. data/vendor/libgit2/src/global.h +0 -1
  30. data/vendor/libgit2/src/index.c +3 -3
  31. data/vendor/libgit2/src/iterator.c +2 -2
  32. data/vendor/libgit2/src/merge.c +0 -56
  33. data/vendor/libgit2/src/merge_file.c +76 -22
  34. data/vendor/libgit2/src/openssl_stream.c +2 -3
  35. data/vendor/libgit2/src/path.c +0 -16
  36. data/vendor/libgit2/src/path.h +0 -5
  37. data/vendor/libgit2/src/refdb_fs.c +0 -7
  38. data/vendor/libgit2/src/remote.c +9 -18
  39. data/vendor/libgit2/src/stransport_stream.c +1 -1
  40. data/vendor/libgit2/src/submodule.c +7 -3
  41. data/vendor/libgit2/src/sysdir.c +8 -22
  42. data/vendor/libgit2/src/transports/http.c +9 -1
  43. data/vendor/libgit2/src/transports/smart_protocol.c +1 -1
  44. data/vendor/libgit2/src/transports/ssh.c +2 -2
  45. data/vendor/libgit2/src/transports/winhttp.c +1 -1
  46. data/vendor/libgit2/src/util.c +0 -48
  47. data/vendor/libgit2/src/util.h +5 -13
  48. data/vendor/libgit2/src/win32/posix_w32.c +0 -2
  49. data/vendor/libgit2/src/xdiff/xdiff.h +5 -3
  50. data/vendor/libgit2/src/xdiff/xdiffi.c +8 -4
  51. data/vendor/libgit2/src/xdiff/xhistogram.c +4 -2
  52. data/vendor/libgit2/src/xdiff/xmerge.c +98 -44
  53. metadata +76 -81
  54. data/vendor/libgit2/src/merge_file.h +0 -14
  55. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -343
  56. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -93
  57. data/vendor/libgit2/src/win32/w32_stack.c +0 -192
  58. data/vendor/libgit2/src/win32/w32_stack.h +0 -138
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.23.2
4
+ version: 0.23.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon
@@ -9,48 +9,48 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-13 00:00:00.000000000 Z
12
+ date: 2015-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.9.0
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.9.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: pry
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: minitest
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '3.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '3.0'
56
56
  description: |
@@ -62,30 +62,9 @@ extensions:
62
62
  - ext/rugged/extconf.rb
63
63
  extra_rdoc_files: []
64
64
  files:
65
- - README.md
66
65
  - LICENSE
67
- - lib/rugged/attributes.rb
68
- - lib/rugged/blob.rb
69
- - lib/rugged/branch.rb
70
- - lib/rugged/commit.rb
71
- - lib/rugged/console.rb
72
- - lib/rugged/credentials.rb
73
- - lib/rugged/diff/delta.rb
74
- - lib/rugged/diff/hunk.rb
75
- - lib/rugged/diff/line.rb
76
- - lib/rugged/diff.rb
77
- - lib/rugged/index.rb
78
- - lib/rugged/object.rb
79
- - lib/rugged/patch.rb
80
- - lib/rugged/reference.rb
81
- - lib/rugged/remote.rb
82
- - lib/rugged/repository.rb
83
- - lib/rugged/submodule_collection.rb
84
- - lib/rugged/tag.rb
85
- - lib/rugged/tree.rb
86
- - lib/rugged/version.rb
87
- - lib/rugged/walker.rb
88
- - lib/rugged.rb
66
+ - README.md
67
+ - ext/rugged/extconf.rb
89
68
  - ext/rugged/rugged.c
90
69
  - ext/rugged/rugged.h
91
70
  - ext/rugged/rugged_backend.c
@@ -117,12 +96,72 @@ files:
117
96
  - ext/rugged/rugged_tag.c
118
97
  - ext/rugged/rugged_tag_collection.c
119
98
  - ext/rugged/rugged_tree.c
99
+ - lib/rugged.rb
100
+ - lib/rugged/attributes.rb
101
+ - lib/rugged/blob.rb
102
+ - lib/rugged/branch.rb
103
+ - lib/rugged/commit.rb
104
+ - lib/rugged/console.rb
105
+ - lib/rugged/credentials.rb
106
+ - lib/rugged/diff.rb
107
+ - lib/rugged/diff/delta.rb
108
+ - lib/rugged/diff/hunk.rb
109
+ - lib/rugged/diff/line.rb
110
+ - lib/rugged/index.rb
111
+ - lib/rugged/object.rb
112
+ - lib/rugged/patch.rb
113
+ - lib/rugged/reference.rb
114
+ - lib/rugged/remote.rb
115
+ - lib/rugged/repository.rb
116
+ - lib/rugged/submodule_collection.rb
117
+ - lib/rugged/tag.rb
118
+ - lib/rugged/tree.rb
119
+ - lib/rugged/version.rb
120
+ - lib/rugged/walker.rb
121
+ - vendor/libgit2/AUTHORS
122
+ - vendor/libgit2/CMakeLists.txt
123
+ - vendor/libgit2/COPYING
124
+ - vendor/libgit2/Makefile.embed
120
125
  - vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake
121
126
  - vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake
122
127
  - vendor/libgit2/cmake/Modules/FindGSSAPI.cmake
123
128
  - vendor/libgit2/cmake/Modules/FindHTTP_Parser.cmake
124
129
  - vendor/libgit2/cmake/Modules/FindIconv.cmake
125
130
  - vendor/libgit2/cmake/Modules/FindSecurity.cmake
131
+ - vendor/libgit2/deps/http-parser/LICENSE-MIT
132
+ - vendor/libgit2/deps/http-parser/http_parser.c
133
+ - vendor/libgit2/deps/http-parser/http_parser.h
134
+ - vendor/libgit2/deps/regex/config.h
135
+ - vendor/libgit2/deps/regex/regcomp.c
136
+ - vendor/libgit2/deps/regex/regex.c
137
+ - vendor/libgit2/deps/regex/regex.h
138
+ - vendor/libgit2/deps/regex/regex_internal.c
139
+ - vendor/libgit2/deps/regex/regex_internal.h
140
+ - vendor/libgit2/deps/regex/regexec.c
141
+ - vendor/libgit2/deps/winhttp/urlmon.h
142
+ - vendor/libgit2/deps/winhttp/winhttp.def
143
+ - vendor/libgit2/deps/winhttp/winhttp.h
144
+ - vendor/libgit2/deps/winhttp/winhttp64.def
145
+ - vendor/libgit2/deps/zlib/adler32.c
146
+ - vendor/libgit2/deps/zlib/crc32.c
147
+ - vendor/libgit2/deps/zlib/crc32.h
148
+ - vendor/libgit2/deps/zlib/deflate.c
149
+ - vendor/libgit2/deps/zlib/deflate.h
150
+ - vendor/libgit2/deps/zlib/infback.c
151
+ - vendor/libgit2/deps/zlib/inffast.c
152
+ - vendor/libgit2/deps/zlib/inffast.h
153
+ - vendor/libgit2/deps/zlib/inffixed.h
154
+ - vendor/libgit2/deps/zlib/inflate.c
155
+ - vendor/libgit2/deps/zlib/inflate.h
156
+ - vendor/libgit2/deps/zlib/inftrees.c
157
+ - vendor/libgit2/deps/zlib/inftrees.h
158
+ - vendor/libgit2/deps/zlib/trees.c
159
+ - vendor/libgit2/deps/zlib/trees.h
160
+ - vendor/libgit2/deps/zlib/zconf.h
161
+ - vendor/libgit2/deps/zlib/zlib.h
162
+ - vendor/libgit2/deps/zlib/zutil.c
163
+ - vendor/libgit2/deps/zlib/zutil.h
164
+ - vendor/libgit2/include/git2.h
126
165
  - vendor/libgit2/include/git2/annotated_commit.h
127
166
  - vendor/libgit2/include/git2/attr.h
128
167
  - vendor/libgit2/include/git2/blame.h
@@ -197,7 +236,7 @@ files:
197
236
  - vendor/libgit2/include/git2/tree.h
198
237
  - vendor/libgit2/include/git2/types.h
199
238
  - vendor/libgit2/include/git2/version.h
200
- - vendor/libgit2/include/git2.h
239
+ - vendor/libgit2/libgit2.pc.in
201
240
  - vendor/libgit2/src/annotated_commit.c
202
241
  - vendor/libgit2/src/annotated_commit.h
203
242
  - vendor/libgit2/src/array.h
@@ -276,14 +315,14 @@ files:
276
315
  - vendor/libgit2/src/global.c
277
316
  - vendor/libgit2/src/global.h
278
317
  - vendor/libgit2/src/graph.c
318
+ - vendor/libgit2/src/hash.c
319
+ - vendor/libgit2/src/hash.h
279
320
  - vendor/libgit2/src/hash/hash_common_crypto.h
280
321
  - vendor/libgit2/src/hash/hash_generic.c
281
322
  - vendor/libgit2/src/hash/hash_generic.h
282
323
  - vendor/libgit2/src/hash/hash_openssl.h
283
324
  - vendor/libgit2/src/hash/hash_win32.c
284
325
  - vendor/libgit2/src/hash/hash_win32.h
285
- - vendor/libgit2/src/hash.c
286
- - vendor/libgit2/src/hash.h
287
326
  - vendor/libgit2/src/hashsig.c
288
327
  - vendor/libgit2/src/ident.c
289
328
  - vendor/libgit2/src/ignore.c
@@ -299,7 +338,6 @@ files:
299
338
  - vendor/libgit2/src/merge.c
300
339
  - vendor/libgit2/src/merge.h
301
340
  - vendor/libgit2/src/merge_file.c
302
- - vendor/libgit2/src/merge_file.h
303
341
  - vendor/libgit2/src/message.c
304
342
  - vendor/libgit2/src/message.h
305
343
  - vendor/libgit2/src/mwindow.c
@@ -446,10 +484,6 @@ files:
446
484
  - vendor/libgit2/src/win32/version.h
447
485
  - vendor/libgit2/src/win32/w32_buffer.c
448
486
  - vendor/libgit2/src/win32/w32_buffer.h
449
- - vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c
450
- - vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h
451
- - vendor/libgit2/src/win32/w32_stack.c
452
- - vendor/libgit2/src/win32/w32_stack.h
453
487
  - vendor/libgit2/src/win32/w32_util.c
454
488
  - vendor/libgit2/src/win32/w32_util.h
455
489
  - vendor/libgit2/src/xdiff/xdiff.h
@@ -469,45 +503,6 @@ files:
469
503
  - vendor/libgit2/src/xdiff/xutils.h
470
504
  - vendor/libgit2/src/zstream.c
471
505
  - vendor/libgit2/src/zstream.h
472
- - vendor/libgit2/deps/http-parser/http_parser.c
473
- - vendor/libgit2/deps/http-parser/http_parser.h
474
- - vendor/libgit2/deps/http-parser/LICENSE-MIT
475
- - vendor/libgit2/deps/regex/config.h
476
- - vendor/libgit2/deps/regex/regcomp.c
477
- - vendor/libgit2/deps/regex/regex.c
478
- - vendor/libgit2/deps/regex/regex.h
479
- - vendor/libgit2/deps/regex/regex_internal.c
480
- - vendor/libgit2/deps/regex/regex_internal.h
481
- - vendor/libgit2/deps/regex/regexec.c
482
- - vendor/libgit2/deps/winhttp/urlmon.h
483
- - vendor/libgit2/deps/winhttp/winhttp.def
484
- - vendor/libgit2/deps/winhttp/winhttp.h
485
- - vendor/libgit2/deps/winhttp/winhttp64.def
486
- - vendor/libgit2/deps/zlib/adler32.c
487
- - vendor/libgit2/deps/zlib/crc32.c
488
- - vendor/libgit2/deps/zlib/crc32.h
489
- - vendor/libgit2/deps/zlib/deflate.c
490
- - vendor/libgit2/deps/zlib/deflate.h
491
- - vendor/libgit2/deps/zlib/infback.c
492
- - vendor/libgit2/deps/zlib/inffast.c
493
- - vendor/libgit2/deps/zlib/inffast.h
494
- - vendor/libgit2/deps/zlib/inffixed.h
495
- - vendor/libgit2/deps/zlib/inflate.c
496
- - vendor/libgit2/deps/zlib/inflate.h
497
- - vendor/libgit2/deps/zlib/inftrees.c
498
- - vendor/libgit2/deps/zlib/inftrees.h
499
- - vendor/libgit2/deps/zlib/trees.c
500
- - vendor/libgit2/deps/zlib/trees.h
501
- - vendor/libgit2/deps/zlib/zconf.h
502
- - vendor/libgit2/deps/zlib/zlib.h
503
- - vendor/libgit2/deps/zlib/zutil.c
504
- - vendor/libgit2/deps/zlib/zutil.h
505
- - vendor/libgit2/CMakeLists.txt
506
- - vendor/libgit2/Makefile.embed
507
- - vendor/libgit2/AUTHORS
508
- - vendor/libgit2/COPYING
509
- - vendor/libgit2/libgit2.pc.in
510
- - ext/rugged/extconf.rb
511
506
  homepage: https://github.com/libgit2/rugged
512
507
  licenses:
513
508
  - MIT
@@ -518,17 +513,17 @@ require_paths:
518
513
  - lib
519
514
  required_ruby_version: !ruby/object:Gem::Requirement
520
515
  requirements:
521
- - - '>='
516
+ - - ">="
522
517
  - !ruby/object:Gem::Version
523
518
  version: 1.9.3
524
519
  required_rubygems_version: !ruby/object:Gem::Requirement
525
520
  requirements:
526
- - - '>='
521
+ - - ">="
527
522
  - !ruby/object:Gem::Version
528
523
  version: '0'
529
524
  requirements: []
530
525
  rubyforge_project:
531
- rubygems_version: 2.0.14
526
+ rubygems_version: 2.2.2
532
527
  signing_key:
533
528
  specification_version: 4
534
529
  summary: Rugged is a Ruby binding to the libgit2 linkable library
@@ -1,14 +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_filediff_h__
8
- #define INCLUDE_filediff_h__
9
-
10
- #include "xdiff/xdiff.h"
11
-
12
- #include "git2/merge.h"
13
-
14
- #endif
@@ -1,343 +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
- #if defined(GIT_MSVC_CRTDBG)
9
- #include "w32_stack.h"
10
- #include "w32_crtdbg_stacktrace.h"
11
-
12
- #define CRTDBG_STACKTRACE__UID_LEN (15)
13
-
14
- /**
15
- * The stacktrace of an allocation can be distilled
16
- * to a unique id based upon the stackframe pointers
17
- * and ignoring any size arguments. We will use these
18
- * UIDs as the (char const*) __FILE__ argument we
19
- * give to the CRT malloc routines.
20
- */
21
- typedef struct {
22
- char uid[CRTDBG_STACKTRACE__UID_LEN + 1];
23
- } git_win32__crtdbg_stacktrace__uid;
24
-
25
- /**
26
- * All mallocs with the same stacktrace will be de-duped
27
- * and aggregated into this row.
28
- */
29
- typedef struct {
30
- git_win32__crtdbg_stacktrace__uid uid; /* must be first */
31
- git_win32__stack__raw_data raw_data;
32
- unsigned int count_allocs; /* times this alloc signature seen since init */
33
- unsigned int count_allocs_at_last_checkpoint; /* times since last mark */
34
- unsigned int transient_count_leaks; /* sum of leaks */
35
- } git_win32__crtdbg_stacktrace__row;
36
-
37
- static CRITICAL_SECTION g_crtdbg_stacktrace_cs;
38
-
39
- /**
40
- * CRTDBG memory leak tracking takes a "char const * const file_name"
41
- * and stores the pointer in the heap data (instead of allocing a copy
42
- * for itself). Normally, this is not a problem, since we usually pass
43
- * in __FILE__. But I'm going to lie to it and pass in the address of
44
- * the UID in place of the file_name. Also, I do not want to alloc the
45
- * stacktrace data (because we are called from inside our alloc routines).
46
- * Therefore, I'm creating a very large static pool array to store row
47
- * data. This also eliminates the temptation to realloc it (and move the
48
- * UID pointers).
49
- *
50
- * And to efficiently look for duplicates we need an index on the rows
51
- * so we can bsearch it. Again, without mallocing.
52
- *
53
- * If we observe more than MY_ROW_LIMIT unique malloc signatures, we
54
- * fall through and use the traditional __FILE__ processing and don't
55
- * try to de-dup them. If your testing hits this limit, just increase
56
- * it and try again.
57
- */
58
-
59
- #define MY_ROW_LIMIT (1024 * 1024)
60
- static git_win32__crtdbg_stacktrace__row g_cs_rows[MY_ROW_LIMIT];
61
- static git_win32__crtdbg_stacktrace__row *g_cs_index[MY_ROW_LIMIT];
62
-
63
- static unsigned int g_cs_end = MY_ROW_LIMIT;
64
- static unsigned int g_cs_ins = 0; /* insertion point == unique allocs seen */
65
- static unsigned int g_count_total_allocs = 0; /* number of allocs seen */
66
- static unsigned int g_transient_count_total_leaks = 0; /* number of total leaks */
67
- static unsigned int g_transient_count_dedup_leaks = 0; /* number of unique leaks */
68
- static bool g_limit_reached = false; /* had allocs after we filled row table */
69
-
70
- static unsigned int g_checkpoint_id = 0; /* to better label leak checkpoints */
71
- static bool g_transient_leaks_since_mark = false; /* payload for hook */
72
-
73
- /**
74
- * Compare function for bsearch on g_cs_index table.
75
- */
76
- static int row_cmp(const void *v1, const void *v2)
77
- {
78
- git_win32__stack__raw_data *d1 = (git_win32__stack__raw_data*)v1;
79
- git_win32__crtdbg_stacktrace__row *r2 = (git_win32__crtdbg_stacktrace__row *)v2;
80
-
81
- return (git_win32__stack_compare(d1, &r2->raw_data));
82
- }
83
-
84
- /**
85
- * Unique insert the new data into the row and index tables.
86
- * We have to sort by the stackframe data itself, not the uid.
87
- */
88
- static git_win32__crtdbg_stacktrace__row * insert_unique(
89
- const git_win32__stack__raw_data *pdata)
90
- {
91
- size_t pos;
92
- if (git__bsearch(g_cs_index, g_cs_ins, pdata, row_cmp, &pos) < 0) {
93
- /* Append new unique item to row table. */
94
- memcpy(&g_cs_rows[g_cs_ins].raw_data, pdata, sizeof(*pdata));
95
- sprintf(g_cs_rows[g_cs_ins].uid.uid, "##%08lx", g_cs_ins);
96
-
97
- /* Insert pointer to it into the proper place in the index table. */
98
- if (pos < g_cs_ins)
99
- memmove(&g_cs_index[pos+1], &g_cs_index[pos], (g_cs_ins - pos)*sizeof(g_cs_index[0]));
100
- g_cs_index[pos] = &g_cs_rows[g_cs_ins];
101
-
102
- g_cs_ins++;
103
- }
104
-
105
- g_cs_index[pos]->count_allocs++;
106
-
107
- return g_cs_index[pos];
108
- }
109
-
110
- /**
111
- * Hook function to receive leak data from the CRT. (This includes
112
- * both "<file_name>:(<line_number>)" data, but also each of the
113
- * various headers and fields.
114
- *
115
- * Scan this for the special "##<pos>" UID forms that we substituted
116
- * for the "<file_name>". Map <pos> back to the row data and
117
- * increment its leak count.
118
- *
119
- * See https://msdn.microsoft.com/en-us/library/74kabxyx.aspx
120
- *
121
- * We suppress the actual crtdbg output.
122
- */
123
- static int __cdecl report_hook(int nRptType, char *szMsg, int *retVal)
124
- {
125
- static int hook_result = TRUE; /* FALSE to get stock dump; TRUE to suppress. */
126
- unsigned int pos;
127
-
128
- *retVal = 0; /* do not invoke debugger */
129
-
130
- if ((szMsg[0] != '#') || (szMsg[1] != '#'))
131
- return hook_result;
132
-
133
- if (sscanf(&szMsg[2], "%08lx", &pos) < 1)
134
- return hook_result;
135
- if (pos >= g_cs_ins)
136
- return hook_result;
137
-
138
- if (g_transient_leaks_since_mark) {
139
- if (g_cs_rows[pos].count_allocs == g_cs_rows[pos].count_allocs_at_last_checkpoint)
140
- return hook_result;
141
- }
142
-
143
- g_cs_rows[pos].transient_count_leaks++;
144
-
145
- if (g_cs_rows[pos].transient_count_leaks == 1)
146
- g_transient_count_dedup_leaks++;
147
-
148
- g_transient_count_total_leaks++;
149
-
150
- return hook_result;
151
- }
152
-
153
- /**
154
- * Write leak data to all of the various places we need.
155
- * We force the caller to sprintf() the message first
156
- * because we want to avoid fprintf() because it allocs.
157
- */
158
- static void my_output(const char *buf)
159
- {
160
- fwrite(buf, strlen(buf), 1, stderr);
161
- OutputDebugString(buf);
162
- }
163
-
164
- /**
165
- * For each row with leaks, dump a stacktrace for it.
166
- */
167
- static void dump_summary(const char *label)
168
- {
169
- unsigned int k;
170
- char buf[10 * 1024];
171
-
172
- if (g_transient_count_total_leaks == 0)
173
- return;
174
-
175
- fflush(stdout);
176
- fflush(stderr);
177
- my_output("\n");
178
-
179
- if (g_limit_reached) {
180
- sprintf(buf,
181
- "LEAK SUMMARY: de-dup row table[%d] filled. Increase MY_ROW_LIMIT.\n",
182
- MY_ROW_LIMIT);
183
- my_output(buf);
184
- }
185
-
186
- if (!label)
187
- label = "";
188
-
189
- if (g_transient_leaks_since_mark) {
190
- sprintf(buf, "LEAK CHECKPOINT %d: leaks %d unique %d: %s\n",
191
- g_checkpoint_id, g_transient_count_total_leaks, g_transient_count_dedup_leaks, label);
192
- my_output(buf);
193
- } else {
194
- sprintf(buf, "LEAK SUMMARY: TOTAL leaks %d de-duped %d: %s\n",
195
- g_transient_count_total_leaks, g_transient_count_dedup_leaks, label);
196
- my_output(buf);
197
- }
198
- my_output("\n");
199
-
200
- for (k = 0; k < g_cs_ins; k++) {
201
- if (g_cs_rows[k].transient_count_leaks > 0) {
202
- sprintf(buf, "LEAK: %s leaked %d of %d times:\n",
203
- g_cs_rows[k].uid.uid,
204
- g_cs_rows[k].transient_count_leaks,
205
- g_cs_rows[k].count_allocs);
206
- my_output(buf);
207
-
208
- if (git_win32__stack_format(
209
- buf, sizeof(buf), &g_cs_rows[k].raw_data,
210
- NULL, NULL) >= 0) {
211
- my_output(buf);
212
- }
213
-
214
- my_output("\n");
215
- }
216
- }
217
-
218
- fflush(stderr);
219
- }
220
-
221
- void git_win32__crtdbg_stacktrace_init(void)
222
- {
223
- InitializeCriticalSection(&g_crtdbg_stacktrace_cs);
224
-
225
- EnterCriticalSection(&g_crtdbg_stacktrace_cs);
226
-
227
- _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
228
-
229
- _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
230
- _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
231
- _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
232
-
233
- _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
234
- _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
235
- _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
236
-
237
- LeaveCriticalSection(&g_crtdbg_stacktrace_cs);
238
- }
239
-
240
- int git_win32__crtdbg_stacktrace__dump(
241
- git_win32__crtdbg_stacktrace_options opt,
242
- const char *label)
243
- {
244
- _CRT_REPORT_HOOK old;
245
- unsigned int k;
246
- int r = 0;
247
-
248
- #define IS_BIT_SET(o,b) (((o) & (b)) != 0)
249
-
250
- bool b_set_mark = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK);
251
- bool b_leaks_since_mark = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK);
252
- bool b_leaks_total = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL);
253
- bool b_quiet = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__QUIET);
254
-
255
- if (b_leaks_since_mark && b_leaks_total) {
256
- giterr_set(GITERR_INVALID, "Cannot combine LEAKS_SINCE_MARK and LEAKS_TOTAL.");
257
- return GIT_ERROR;
258
- }
259
- if (!b_set_mark && !b_leaks_since_mark && !b_leaks_total) {
260
- giterr_set(GITERR_INVALID, "Nothing to do.");
261
- return GIT_ERROR;
262
- }
263
-
264
- EnterCriticalSection(&g_crtdbg_stacktrace_cs);
265
-
266
- if (b_leaks_since_mark || b_leaks_total) {
267
- /* All variables with "transient" in the name are per-dump counters
268
- * and reset before each dump. This lets us handle checkpoints.
269
- */
270
- g_transient_count_total_leaks = 0;
271
- g_transient_count_dedup_leaks = 0;
272
- for (k = 0; k < g_cs_ins; k++) {
273
- g_cs_rows[k].transient_count_leaks = 0;
274
- }
275
- }
276
-
277
- g_transient_leaks_since_mark = b_leaks_since_mark;
278
-
279
- old = _CrtSetReportHook(report_hook);
280
- _CrtDumpMemoryLeaks();
281
- _CrtSetReportHook(old);
282
-
283
- if (b_leaks_since_mark || b_leaks_total) {
284
- r = g_transient_count_dedup_leaks;
285
-
286
- if (!b_quiet)
287
- dump_summary(label);
288
- }
289
-
290
- if (b_set_mark) {
291
- for (k = 0; k < g_cs_ins; k++) {
292
- g_cs_rows[k].count_allocs_at_last_checkpoint = g_cs_rows[k].count_allocs;
293
- }
294
-
295
- g_checkpoint_id++;
296
- }
297
-
298
- LeaveCriticalSection(&g_crtdbg_stacktrace_cs);
299
-
300
- return r;
301
- }
302
-
303
- void git_win32__crtdbg_stacktrace_cleanup(void)
304
- {
305
- /* At shutdown/cleanup, dump cummulative leak info
306
- * with everything since startup. This might generate
307
- * extra noise if the caller has been doing checkpoint
308
- * dumps, but it might also eliminate some false
309
- * positives for resources previously reported during
310
- * checkpoints.
311
- */
312
- git_win32__crtdbg_stacktrace__dump(
313
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL,
314
- "CLEANUP");
315
-
316
- DeleteCriticalSection(&g_crtdbg_stacktrace_cs);
317
- }
318
-
319
- const char *git_win32__crtdbg_stacktrace(int skip, const char *file)
320
- {
321
- git_win32__stack__raw_data new_data;
322
- git_win32__crtdbg_stacktrace__row *row;
323
- const char * result = file;
324
-
325
- if (git_win32__stack_capture(&new_data, skip+1) < 0)
326
- return result;
327
-
328
- EnterCriticalSection(&g_crtdbg_stacktrace_cs);
329
-
330
- if (g_cs_ins < g_cs_end) {
331
- row = insert_unique(&new_data);
332
- result = row->uid.uid;
333
- } else {
334
- g_limit_reached = true;
335
- }
336
-
337
- g_count_total_allocs++;
338
-
339
- LeaveCriticalSection(&g_crtdbg_stacktrace_cs);
340
-
341
- return result;
342
- }
343
- #endif