@noldova/checkpoints.git.linux-arm64 0.0.0-stage → 0.0.1

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 (131) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +11 -2
  3. package/git/bin/git +0 -0
  4. package/git/bin/scalar +0 -0
  5. package/git/etc/gitconfig +13 -0
  6. package/git/libexec/git-core/git +0 -0
  7. package/git/libexec/git-core/git-archimport +1136 -0
  8. package/git/libexec/git-core/git-cvsexportcommit +469 -0
  9. package/git/libexec/git-core/git-cvsimport +1185 -0
  10. package/git/libexec/git-core/git-cvsserver +5109 -0
  11. package/git/libexec/git-core/git-daemon +0 -0
  12. package/git/libexec/git-core/git-difftool--helper +125 -0
  13. package/git/libexec/git-core/git-filter-branch +665 -0
  14. package/git/libexec/git-core/git-http-backend +0 -0
  15. package/git/libexec/git-core/git-http-fetch +0 -0
  16. package/git/libexec/git-core/git-imap-send +0 -0
  17. package/git/libexec/git-core/git-instaweb +786 -0
  18. package/git/libexec/git-core/git-merge-octopus +112 -0
  19. package/git/libexec/git-core/git-merge-one-file +167 -0
  20. package/git/libexec/git-core/git-merge-resolve +64 -0
  21. package/git/libexec/git-core/git-mergetool +579 -0
  22. package/git/libexec/git-core/git-mergetool--lib +549 -0
  23. package/git/libexec/git-core/git-quiltimport +155 -0
  24. package/git/libexec/git-core/git-receive-pack +0 -0
  25. package/git/libexec/git-core/git-remote-ftp +0 -0
  26. package/git/libexec/git-core/git-remote-ftps +0 -0
  27. package/git/libexec/git-core/git-remote-http +0 -0
  28. package/git/libexec/git-core/git-remote-https +0 -0
  29. package/git/libexec/git-core/git-request-pull +178 -0
  30. package/git/libexec/git-core/git-send-email +2474 -0
  31. package/git/libexec/git-core/git-sh-i18n +79 -0
  32. package/git/libexec/git-core/git-sh-i18n--envsubst +0 -0
  33. package/git/libexec/git-core/git-sh-setup +357 -0
  34. package/git/libexec/git-core/git-shell +0 -0
  35. package/git/libexec/git-core/git-submodule +671 -0
  36. package/git/libexec/git-core/git-upload-archive +0 -0
  37. package/git/libexec/git-core/git-upload-pack +0 -0
  38. package/git/libexec/git-core/git-web--browse +196 -0
  39. package/git/libexec/git-core/mergetools/araxis +26 -0
  40. package/git/libexec/git-core/mergetools/bc +37 -0
  41. package/git/libexec/git-core/mergetools/codecompare +31 -0
  42. package/git/libexec/git-core/mergetools/deltawalker +33 -0
  43. package/git/libexec/git-core/mergetools/diffmerge +26 -0
  44. package/git/libexec/git-core/mergetools/diffuse +23 -0
  45. package/git/libexec/git-core/mergetools/ecmerge +22 -0
  46. package/git/libexec/git-core/mergetools/emerge +34 -0
  47. package/git/libexec/git-core/mergetools/examdiff +24 -0
  48. package/git/libexec/git-core/mergetools/guiffy +26 -0
  49. package/git/libexec/git-core/mergetools/gvimdiff +1 -0
  50. package/git/libexec/git-core/mergetools/kdiff3 +44 -0
  51. package/git/libexec/git-core/mergetools/kompare +19 -0
  52. package/git/libexec/git-core/mergetools/meld +97 -0
  53. package/git/libexec/git-core/mergetools/nvimdiff +1 -0
  54. package/git/libexec/git-core/mergetools/opendiff +22 -0
  55. package/git/libexec/git-core/mergetools/p4merge +44 -0
  56. package/git/libexec/git-core/mergetools/smerge +20 -0
  57. package/git/libexec/git-core/mergetools/tkdiff +24 -0
  58. package/git/libexec/git-core/mergetools/tortoisemerge +40 -0
  59. package/git/libexec/git-core/mergetools/vimdiff +657 -0
  60. package/git/libexec/git-core/mergetools/vscode +19 -0
  61. package/git/libexec/git-core/mergetools/winmerge +23 -0
  62. package/git/libexec/git-core/mergetools/xxdiff +38 -0
  63. package/git/libexec/git-core/scalar +0 -0
  64. package/git/share/bash-completion/completions/git +4115 -0
  65. package/git/share/git-core/templates/description +1 -0
  66. package/git/share/git-core/templates/hooks/applypatch-msg.sample +15 -0
  67. package/git/share/git-core/templates/hooks/commit-msg.sample +74 -0
  68. package/git/share/git-core/templates/hooks/fsmonitor-watchman.sample +168 -0
  69. package/git/share/git-core/templates/hooks/post-update.sample +8 -0
  70. package/git/share/git-core/templates/hooks/pre-applypatch.sample +14 -0
  71. package/git/share/git-core/templates/hooks/pre-commit.sample +49 -0
  72. package/git/share/git-core/templates/hooks/pre-merge-commit.sample +13 -0
  73. package/git/share/git-core/templates/hooks/pre-push.sample +53 -0
  74. package/git/share/git-core/templates/hooks/pre-rebase.sample +169 -0
  75. package/git/share/git-core/templates/hooks/pre-receive.sample +24 -0
  76. package/git/share/git-core/templates/hooks/prepare-commit-msg.sample +42 -0
  77. package/git/share/git-core/templates/hooks/push-to-checkout.sample +78 -0
  78. package/git/share/git-core/templates/hooks/sendemail-validate.sample +77 -0
  79. package/git/share/git-core/templates/hooks/update.sample +128 -0
  80. package/git/share/git-core/templates/info/exclude +6 -0
  81. package/git/share/gitweb/gitweb.cgi +8499 -0
  82. package/git/share/gitweb/static/git-favicon.png +0 -0
  83. package/git/share/gitweb/static/git-logo.png +0 -0
  84. package/git/share/gitweb/static/gitweb.css +756 -0
  85. package/git/share/gitweb/static/gitweb.js +1579 -0
  86. package/git/share/locale/af/LC_MESSAGES/git.mo +0 -0
  87. package/git/share/locale/bg/LC_MESSAGES/git.mo +0 -0
  88. package/git/share/locale/ca/LC_MESSAGES/git.mo +0 -0
  89. package/git/share/locale/de/LC_MESSAGES/git.mo +0 -0
  90. package/git/share/locale/el/LC_MESSAGES/git.mo +0 -0
  91. package/git/share/locale/es/LC_MESSAGES/git.mo +0 -0
  92. package/git/share/locale/fr/LC_MESSAGES/git.mo +0 -0
  93. package/git/share/locale/ga/LC_MESSAGES/git.mo +0 -0
  94. package/git/share/locale/id/LC_MESSAGES/git.mo +0 -0
  95. package/git/share/locale/is/LC_MESSAGES/git.mo +0 -0
  96. package/git/share/locale/it/LC_MESSAGES/git.mo +0 -0
  97. package/git/share/locale/ko/LC_MESSAGES/git.mo +0 -0
  98. package/git/share/locale/pl/LC_MESSAGES/git.mo +0 -0
  99. package/git/share/locale/pt_BR/LC_MESSAGES/git.mo +0 -0
  100. package/git/share/locale/pt_PT/LC_MESSAGES/git.mo +0 -0
  101. package/git/share/locale/ru/LC_MESSAGES/git.mo +0 -0
  102. package/git/share/locale/sv/LC_MESSAGES/git.mo +0 -0
  103. package/git/share/locale/tr/LC_MESSAGES/git.mo +0 -0
  104. package/git/share/locale/uk/LC_MESSAGES/git.mo +0 -0
  105. package/git/share/locale/vi/LC_MESSAGES/git.mo +0 -0
  106. package/git/share/locale/zh_CN/LC_MESSAGES/git.mo +0 -0
  107. package/git/share/locale/zh_TW/LC_MESSAGES/git.mo +0 -0
  108. package/git/share/perl5/FromCPAN/Error.pm +1040 -0
  109. package/git/share/perl5/FromCPAN/Mail/Address.pm +280 -0
  110. package/git/share/perl5/Git/I18N.pm +125 -0
  111. package/git/share/perl5/Git/IndexInfo.pm +35 -0
  112. package/git/share/perl5/Git/LoadCPAN/Error.pm +10 -0
  113. package/git/share/perl5/Git/LoadCPAN/Mail/Address.pm +10 -0
  114. package/git/share/perl5/Git/LoadCPAN.pm +104 -0
  115. package/git/share/perl5/Git/Packet.pm +173 -0
  116. package/git/share/perl5/Git/SVN/Editor.pm +605 -0
  117. package/git/share/perl5/Git/SVN/Fetcher.pm +622 -0
  118. package/git/share/perl5/Git/SVN/GlobSpec.pm +65 -0
  119. package/git/share/perl5/Git/SVN/Log.pm +400 -0
  120. package/git/share/perl5/Git/SVN/Memoize/YAML.pm +93 -0
  121. package/git/share/perl5/Git/SVN/Migration.pm +265 -0
  122. package/git/share/perl5/Git/SVN/Prompt.pm +184 -0
  123. package/git/share/perl5/Git/SVN/Ra.pm +708 -0
  124. package/git/share/perl5/Git/SVN/Utils.pm +232 -0
  125. package/git/share/perl5/Git/SVN.pm +2573 -0
  126. package/git/share/perl5/Git.pm +1780 -0
  127. package/licenses/git/COPYING +360 -0
  128. package/licenses/git/LGPL-2.1 +511 -0
  129. package/licenses/perl-modules-from-cpan/Artistic +131 -0
  130. package/licenses/perl-modules-from-cpan/Copying +250 -0
  131. package/package.json +167 -4
@@ -0,0 +1,469 @@
1
+ #!/usr/bin/perl
2
+
3
+ use lib (split(/:/, $ENV{GITPERLLIB} || '//share/perl5'));
4
+
5
+ require v5.26;
6
+ use strict;
7
+ use warnings;
8
+ use Getopt::Std;
9
+ use File::Temp qw(tempdir);
10
+ use Data::Dumper;
11
+ use File::Basename qw(basename dirname);
12
+ use File::Spec;
13
+ use Git;
14
+
15
+ our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d, $opt_u, $opt_w, $opt_W, $opt_k);
16
+
17
+ getopts('uhPpvcfkam:d:w:W');
18
+
19
+ $opt_h && usage();
20
+
21
+ die "Need at least one commit identifier!" unless @ARGV;
22
+
23
+ # Get git-config settings
24
+ my $repo = Git->repository();
25
+ $opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w;
26
+
27
+ my $tmpdir = File::Temp::tempdir(CLEANUP => 1);
28
+ my $hash_algo = $repo->config('extensions.objectformat') || 'sha1';
29
+ my $hexsz = $hash_algo eq 'sha256' ? 64 : 40;
30
+
31
+ if ($opt_w || $opt_W) {
32
+ # Remember where GIT_DIR is before changing to CVS checkout
33
+ unless ($ENV{GIT_DIR}) {
34
+ # No GIT_DIR set. Figure it out for ourselves
35
+ my $gd =`git rev-parse --git-dir`;
36
+ chomp($gd);
37
+ $ENV{GIT_DIR} = $gd;
38
+ }
39
+
40
+ # On MSYS, convert a Windows-style path to an MSYS-style path
41
+ # so that rel2abs() below works correctly.
42
+ if ($^O eq 'msys') {
43
+ $ENV{GIT_DIR} =~ s#^([[:alpha:]]):/#/$1/#;
44
+ }
45
+
46
+ # Make sure GIT_DIR is absolute
47
+ $ENV{GIT_DIR} = File::Spec->rel2abs($ENV{GIT_DIR});
48
+ }
49
+
50
+ if ($opt_w) {
51
+ if (! -d $opt_w."/CVS" ) {
52
+ die "$opt_w is not a CVS checkout";
53
+ }
54
+ chdir $opt_w or die "Cannot change to CVS checkout at $opt_w";
55
+ }
56
+ unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){
57
+ die "GIT_DIR is not defined or is unreadable";
58
+ }
59
+
60
+
61
+ my @cvs;
62
+ if ($opt_d) {
63
+ @cvs = ('cvs', '-d', $opt_d);
64
+ } else {
65
+ @cvs = ('cvs');
66
+ }
67
+
68
+ # resolve target commit
69
+ my $commit;
70
+ $commit = pop @ARGV;
71
+ $commit = safe_pipe_capture('git', 'rev-parse', '--verify', "$commit^0");
72
+ chomp $commit;
73
+ if ($?) {
74
+ die "The commit reference $commit did not resolve!";
75
+ }
76
+
77
+ # resolve what parent we want
78
+ my $parent;
79
+ if (@ARGV) {
80
+ $parent = pop @ARGV;
81
+ $parent = safe_pipe_capture('git', 'rev-parse', '--verify', "$parent^0");
82
+ chomp $parent;
83
+ if ($?) {
84
+ die "The parent reference did not resolve!";
85
+ }
86
+ }
87
+
88
+ # find parents from the commit itself
89
+ my @commit = safe_pipe_capture('git', 'cat-file', 'commit', $commit);
90
+ my @parents;
91
+ my $committer;
92
+ my $author;
93
+ my $stage = 'headers'; # headers, msg
94
+ my $title;
95
+ my $msg = '';
96
+
97
+ foreach my $line (@commit) {
98
+ chomp $line;
99
+ if ($stage eq 'headers' && $line eq '') {
100
+ $stage = 'msg';
101
+ next;
102
+ }
103
+
104
+ if ($stage eq 'headers') {
105
+ if ($line =~ m/^parent ([0-9a-f]{$hexsz})$/) { # found a parent
106
+ push @parents, $1;
107
+ } elsif ($line =~ m/^author (.+) \d+ [-+]\d+$/) {
108
+ $author = $1;
109
+ } elsif ($line =~ m/^committer (.+) \d+ [-+]\d+$/) {
110
+ $committer = $1;
111
+ }
112
+ } else {
113
+ $msg .= $line . "\n";
114
+ unless ($title) {
115
+ $title = $line;
116
+ }
117
+ }
118
+ }
119
+
120
+ my $noparent = "0" x $hexsz;
121
+ if ($parent) {
122
+ my $found;
123
+ # double check that it's a valid parent
124
+ foreach my $p (@parents) {
125
+ if ($p eq $parent) {
126
+ $found = 1;
127
+ last;
128
+ }; # found it
129
+ }
130
+ die "Did not find $parent in the parents for this commit!" if !$found and !$opt_P;
131
+ } else { # we don't have a parent from the cmdline...
132
+ if (@parents == 1) { # it's safe to get it from the commit
133
+ $parent = $parents[0];
134
+ } elsif (@parents == 0) { # there is no parent
135
+ $parent = $noparent;
136
+ } else { # cannot choose automatically from multiple parents
137
+ die "This commit has more than one parent -- please name the parent you want to use explicitly";
138
+ }
139
+ }
140
+
141
+ my $go_back_to = 0;
142
+
143
+ if ($opt_W) {
144
+ $opt_v && print "Resetting to $parent\n";
145
+ $go_back_to = `git symbolic-ref HEAD 2> /dev/null ||
146
+ git rev-parse HEAD` || die "Could not determine current branch";
147
+ system("git checkout -q $parent^0") && die "Could not check out $parent^0";
148
+ }
149
+
150
+ $opt_v && print "Applying to CVS commit $commit from parent $parent\n";
151
+
152
+ # grab the commit message
153
+ open(MSG, ">.msg") or die "Cannot open .msg for writing";
154
+ if ($opt_m) {
155
+ print MSG $opt_m;
156
+ }
157
+ print MSG $msg;
158
+ if ($opt_a) {
159
+ print MSG "\n\nAuthor: $author\n";
160
+ if ($author ne $committer) {
161
+ print MSG "Committer: $committer\n";
162
+ }
163
+ }
164
+ close MSG;
165
+
166
+ if ($parent eq $noparent) {
167
+ `git diff-tree --binary -p --root $commit >.cvsexportcommit.diff`;# || die "Cannot diff";
168
+ } else {
169
+ `git diff-tree --binary -p $parent $commit >.cvsexportcommit.diff`;# || die "Cannot diff";
170
+ }
171
+
172
+ ## apply non-binary changes
173
+
174
+ # In pedantic mode require all lines of context to match. In normal
175
+ # mode, be compatible with diff/patch: assume 3 lines of context and
176
+ # require at least one line match, i.e. ignore at most 2 lines of
177
+ # context, like diff/patch do by default.
178
+ my $context = $opt_p ? '' : '-C1';
179
+
180
+ print "Checking if patch will apply\n";
181
+
182
+ my @stat;
183
+ open APPLY, "GIT_INDEX_FILE=$tmpdir/index git apply $context --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch";
184
+ @stat=<APPLY>;
185
+ close APPLY || die "Cannot patch";
186
+ my (@bfiles,@files,@afiles,@dfiles);
187
+ chomp @stat;
188
+ foreach (@stat) {
189
+ push (@bfiles,$1) if m/^-\t-\t(.*)$/;
190
+ push (@files, $1) if m/^-\t-\t(.*)$/;
191
+ push (@files, $1) if m/^\d+\t\d+\t(.*)$/;
192
+ push (@afiles,$1) if m/^ create mode [0-7]+ (.*)$/;
193
+ push (@dfiles,$1) if m/^ delete mode [0-7]+ (.*)$/;
194
+ }
195
+ map { s/^"(.*)"$/$1/g } @bfiles,@files;
196
+ map { s/\\([0-7]{3})/sprintf('%c',oct $1)/eg } @bfiles,@files;
197
+
198
+ # check that the files are clean and up to date according to cvs
199
+ my $dirty;
200
+ my @dirs;
201
+ foreach my $p (@afiles) {
202
+ my $path = dirname $p;
203
+ while (!-d $path and ! grep { $_ eq $path } @dirs) {
204
+ unshift @dirs, $path;
205
+ $path = dirname $path;
206
+ }
207
+ }
208
+
209
+ # ... check dirs,
210
+ foreach my $d (@dirs) {
211
+ if (-e $d) {
212
+ $dirty = 1;
213
+ warn "$d exists and is not a directory!\n";
214
+ }
215
+ }
216
+
217
+ # ... query status of all files that we have a directory for and parse output of 'cvs status' to %cvsstat.
218
+ my @canstatusfiles;
219
+ foreach my $f (@files) {
220
+ my $path = dirname $f;
221
+ next if (grep { $_ eq $path } @dirs);
222
+ push @canstatusfiles, $f;
223
+ }
224
+
225
+ my %cvsstat;
226
+ if (@canstatusfiles) {
227
+ if ($opt_u) {
228
+ my @updated = xargs_safe_pipe_capture([@cvs, 'update'], @canstatusfiles);
229
+ print @updated;
230
+ }
231
+ # "cvs status" reorders the parameters, notably when there are multiple
232
+ # arguments with the same basename. So be precise here.
233
+
234
+ my %added = map { $_ => 1 } @afiles;
235
+ my %todo = map { $_ => 1 } @canstatusfiles;
236
+
237
+ while (%todo) {
238
+ my @canstatusfiles2 = ();
239
+ my %fullname = ();
240
+ foreach my $name (keys %todo) {
241
+ my $basename = basename($name);
242
+
243
+ # CVS reports files that don't exist in the current revision as
244
+ # "no file $basename" in its "status" output, so we should
245
+ # anticipate that. Totally unknown files will have a status
246
+ # "Unknown". However, if they exist in the Attic, their status
247
+ # will be "Up-to-date" (this means they were added once but have
248
+ # been removed).
249
+ $basename = "no file $basename" if $added{$basename};
250
+
251
+ $basename =~ s/^\s+//;
252
+ $basename =~ s/\s+$//;
253
+
254
+ if (!exists($fullname{$basename})) {
255
+ $fullname{$basename} = $name;
256
+ push (@canstatusfiles2, $name);
257
+ delete($todo{$name});
258
+ }
259
+ }
260
+ my @cvsoutput;
261
+ @cvsoutput = xargs_safe_pipe_capture([@cvs, 'status'], @canstatusfiles2);
262
+ foreach my $l (@cvsoutput) {
263
+ chomp $l;
264
+ next unless
265
+ my ($file, $status) = $l =~ /^File:\s+(.*\S)\s+Status: (.*)$/;
266
+
267
+ my $fullname = $fullname{$file};
268
+ print STDERR "Huh? Status '$status' reported for unexpected file '$file'\n"
269
+ unless defined $fullname;
270
+
271
+ # This response means the file does not exist except in
272
+ # CVS's attic, so set the status accordingly
273
+ $status = "In-attic"
274
+ if $file =~ /^no file /
275
+ && $status eq 'Up-to-date';
276
+
277
+ $cvsstat{$fullname{$file}} = $status
278
+ if defined $fullname{$file};
279
+ }
280
+ }
281
+ }
282
+
283
+ # ... Validate that new files have the correct status
284
+ foreach my $f (@afiles) {
285
+ next unless defined(my $stat = $cvsstat{$f});
286
+
287
+ # This means the file has never been seen before
288
+ next if $stat eq 'Unknown';
289
+
290
+ # This means the file has been seen before but was removed
291
+ next if $stat eq 'In-attic';
292
+
293
+ $dirty = 1;
294
+ warn "File $f is already known in your CVS checkout -- perhaps it has been added by another user. Or this may indicate that it exists on a different branch. If this is the case, use -f to force the merge.\n";
295
+ warn "Status was: $cvsstat{$f}\n";
296
+ }
297
+
298
+ # ... validate known files.
299
+ foreach my $f (@files) {
300
+ next if grep { $_ eq $f } @afiles;
301
+ # TODO:we need to handle removed in cvs
302
+ unless (defined ($cvsstat{$f}) and $cvsstat{$f} eq "Up-to-date") {
303
+ $dirty = 1;
304
+ warn "File $f not up to date but has status '$cvsstat{$f}' in your CVS checkout!\n";
305
+ }
306
+
307
+ # Depending on how your GIT tree got imported from CVS you may
308
+ # have a conflict between expanded keywords in your CVS tree and
309
+ # unexpanded keywords in the patch about to be applied.
310
+ if ($opt_k) {
311
+ my $orig_file ="$f.orig";
312
+ rename $f, $orig_file;
313
+ open(FILTER_IN, "<$orig_file") or die "Cannot open $orig_file\n";
314
+ open(FILTER_OUT, ">$f") or die "Cannot open $f\n";
315
+ while (<FILTER_IN>)
316
+ {
317
+ my $line = $_;
318
+ $line =~ s/\$([A-Z][a-z]+):[^\$]+\$/\$$1\$/g;
319
+ print FILTER_OUT $line;
320
+ }
321
+ close FILTER_IN;
322
+ close FILTER_OUT;
323
+ }
324
+ }
325
+
326
+ if ($dirty) {
327
+ if ($opt_f) { warn "The tree is not clean -- forced merge\n";
328
+ $dirty = 0;
329
+ } else {
330
+ die "Exiting: your CVS tree is not clean for this merge.";
331
+ }
332
+ }
333
+
334
+ print "Applying\n";
335
+ if ($opt_W) {
336
+ system("git checkout -q $commit^0") && die "cannot patch";
337
+ } else {
338
+ `GIT_INDEX_FILE=$tmpdir/index git apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch";
339
+ }
340
+
341
+ print "Patch applied successfully. Adding new files and directories to CVS\n";
342
+ my $dirtypatch = 0;
343
+
344
+ #
345
+ # We have to add the directories in order otherwise we will have
346
+ # problems when we try and add the sub-directory of a directory we
347
+ # have not added yet.
348
+ #
349
+ # Luckily this is easy to deal with by sorting the directories and
350
+ # dealing with the shortest ones first.
351
+ #
352
+ @dirs = sort { length $a <=> length $b} @dirs;
353
+
354
+ foreach my $d (@dirs) {
355
+ if (system(@cvs,'add',$d)) {
356
+ $dirtypatch = 1;
357
+ warn "Failed to cvs add directory $d -- you may need to do it manually";
358
+ }
359
+ }
360
+
361
+ foreach my $f (@afiles) {
362
+ if (grep { $_ eq $f } @bfiles) {
363
+ system(@cvs, 'add','-kb',$f);
364
+ } else {
365
+ system(@cvs, 'add', $f);
366
+ }
367
+ if ($?) {
368
+ $dirtypatch = 1;
369
+ warn "Failed to cvs add $f -- you may need to do it manually";
370
+ }
371
+ }
372
+
373
+ foreach my $f (@dfiles) {
374
+ system(@cvs, 'rm', '-f', $f);
375
+ if ($?) {
376
+ $dirtypatch = 1;
377
+ warn "Failed to cvs rm -f $f -- you may need to do it manually";
378
+ }
379
+ }
380
+
381
+ print "Commit to CVS\n";
382
+ print "Patch title (first comment line): $title\n";
383
+ my @commitfiles = map { unless (m/\s/) { '\''.$_.'\''; } else { $_; }; } (@files);
384
+ my $cmd = join(' ', @cvs)." commit -F .msg @commitfiles";
385
+
386
+ if ($dirtypatch) {
387
+ print "NOTE: One or more hunks failed to apply cleanly.\n";
388
+ print "You'll need to apply the patch in .cvsexportcommit.diff manually\n";
389
+ print "using a patch program. After applying the patch and resolving the\n";
390
+ print "problems you may commit using:";
391
+ print "\n cd \"$opt_w\"" if $opt_w;
392
+ print "\n $cmd\n";
393
+ print "\n git checkout $go_back_to\n" if $go_back_to;
394
+ print "\n";
395
+ exit(1);
396
+ }
397
+
398
+ if ($opt_c) {
399
+ print "Autocommit\n $cmd\n";
400
+ print xargs_safe_pipe_capture([@cvs, 'commit', '-F', '.msg'], @files);
401
+ if ($?) {
402
+ die "Exiting: The commit did not succeed";
403
+ }
404
+ print "Committed successfully to CVS\n";
405
+ # clean up
406
+ unlink(".msg");
407
+ } else {
408
+ print "Ready for you to commit, just run:\n\n $cmd\n";
409
+ }
410
+
411
+ # clean up
412
+ unlink(".cvsexportcommit.diff");
413
+
414
+ if ($opt_W) {
415
+ system("git checkout $go_back_to") && die "cannot move back to $go_back_to";
416
+ if (!($go_back_to =~ /^[0-9a-fA-F]{$hexsz}$/)) {
417
+ system("git symbolic-ref HEAD $go_back_to") &&
418
+ die "cannot move back to $go_back_to";
419
+ }
420
+ }
421
+
422
+ # CVS version 1.11.x and 1.12.x sleeps the wrong way to ensure the timestamp
423
+ # used by CVS and the one set by subsequence file modifications are different.
424
+ # If they are not different CVS will not detect changes.
425
+ sleep(1);
426
+
427
+ sub usage {
428
+ print STDERR <<END;
429
+ usage: GIT_DIR=/path/to/.git git cvsexportcommit [-h] [-p] [-v] [-c] [-f] [-u] [-k] [-w cvsworkdir] [-m msgprefix] [ parent ] commit
430
+ END
431
+ exit(1);
432
+ }
433
+
434
+ # An alternative to `command` that allows input to be passed as an array
435
+ # to work around shell problems with weird characters in arguments
436
+ # if the exec returns non-zero we die
437
+ sub safe_pipe_capture {
438
+ my @output;
439
+ if (my $pid = open my $child, '-|') {
440
+ binmode($child, ":crlf");
441
+ @output = (<$child>);
442
+ close $child or die join(' ',@_).": $! $?";
443
+ } else {
444
+ exec(@_) or die "$! $?"; # exec() can fail the executable can't be found
445
+ }
446
+ return wantarray ? @output : join('',@output);
447
+ }
448
+
449
+ sub xargs_safe_pipe_capture {
450
+ my $MAX_ARG_LENGTH = 65536;
451
+ my $cmd = shift;
452
+ my @output;
453
+ my $output;
454
+ while(@_) {
455
+ my @args;
456
+ my $length = 0;
457
+ while(@_ && $length < $MAX_ARG_LENGTH) {
458
+ push @args, shift;
459
+ $length += length($args[$#args]);
460
+ }
461
+ if (wantarray) {
462
+ push @output, safe_pipe_capture(@$cmd, @args);
463
+ }
464
+ else {
465
+ $output .= safe_pipe_capture(@$cmd, @args);
466
+ }
467
+ }
468
+ return wantarray ? @output : $output;
469
+ }