•  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
r5
r3
1나무위키 파서 개발하다 빡쳐서 쓴 내용들
2
r1
3{{{#!syntax diff
4diff --git a/builtin/commit.c b/builtin/commit.c
5index 2f45968222..25e26a2f70 100644
6--- a/builtin/commit.c
7+++ b/builtin/commit.c
8@@ -125,7 +125,7 @@ static int all, also, interactive, patch_interactive, only, amend, signoff;
9 static int edit_flag = -1; /* unspecified */
10 static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
11 static int config_commit_verbose = -1; /* unspecified */
12-static int no_post_rewrite, allow_empty_message, pathspec_file_nul;
13+static int no_post_rewrite, allow_empty_message = 1, pathspec_file_nul;
14 static const char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
15 static const char *sign_commit, *pathspec_from_file;
16 static struct strvec trailer_args = STRVEC_INIT;
17}}}
18
r2
19문제는 이대로 빌드하면 unit test가 실패하는 듯하다.
20
21{{{#!syntax sh
22error: builder for '/nix/store/m9iqhqfxxqs7p6jdj2jcf9aq2ygfiv0a-git-2.47.2.drv' failed with exit code 2;
23 last 25 log lines:
24 > t3404-rebase-interactive.sh (Wstat: 256 (exited 1) Tests: 131 Failed: 3)
25 > Failed tests: 42-44
26 > Non-zero exit status: 1
27 > t7500-commit-template-squash-signoff.sh (Wstat: 256 (exited 1) Tests: 54 Failed: 5)
28 > Failed tests: 4, 8, 22, 24, 34
29 > Non-zero exit status: 1
30 > t7501-commit-basic-functionality.sh (Wstat: 256 (exited 1) Tests: 77 Failed: 4)
31 > Failed tests: 27, 29, 39, 47
32 > Non-zero exit status: 1
33 > t7507-commit-verbose.sh (Wstat: 256 (exited 1) Tests: 45 Failed: 23)
34 > Failed tests: 8-10, 13-14, 19-21, 23-24, 26-27, 29-30
35 > 32-33, 35-36, 38-39, 41-42, 44
36 > Non-zero exit status: 1
37 > t7502-commit-porcelain.sh (Wstat: 256 (exited 1) Tests: 81 Failed: 1)
38 > Failed test: 39
39 > Non-zero exit status: 1
40 > t7508-status.sh (Wstat: 256 (exited 1) Tests: 125 Failed: 66)
41 > Failed tests: 13-19, 21-35, 37-41, 50-54, 58-66, 69, 71-93
42 > 107
43 > Non-zero exit status: 1
44 > Files=1023, Tests=30126, 216 wallclock secs (10.62 usr 2.79 sys + 449.92 cusr 960.70 csys = 1424.03 CPU)
45 > Result: FAIL
46 > make[1]: *** [Makefile:73: prove] Error 1
47 > make[1]: Leaving directory '/build/git-2.47.2/t'
48 > make: *** [Makefile:3273: test] Error 2
49 For full logs, run 'nix log /nix/store/m9iqhqfxxqs7p6jdj2jcf9aq2ygfiv0a-git-2.47.2.drv'.
50error: 1 dependencies of derivation '/nix/store/2i62rn1l27qy4gm30msn39i0ban9q5f1-git-2.47.2-fish-completions.drv' failed to build
51error: 1 dependencies of derivation '/nix/store/hx9d5rydwzi4inqhbfi33azafafv7071-home-manager-path.drv' failed to build
52error: 1 dependencies of derivation '/nix/store/whrrhjd3lwjv6kj6j7smd3xx1h3b1d3l-home-manager-generation.drv' failed to build}}}
53
r3
54근데 make test를 돌리려고 하는데 perl shebang이 hardcode되어있다.
55
56{{{
57{
58 fetchurl,
59 fetchpatch,
60 lib,
61 stdenv,
62 buildPackages,
63 curl,
64 openssl,
65 zlib,
66 expat,
67 perlPackages,
68 python3,
69 gettext,
70 cpio,
71 gnugrep,
72 gnused,
73 gawk,
74 coreutils, # needed at runtime by git-filter-branch etc
75 openssh,
76 pcre2,
77 bash,
78 asciidoc,
79 texinfo,
80 xmlto,
81 docbook2x,
82 docbook_xsl,
83 docbook_xml_dtd_45,
84 libxslt,
85 tcl,
86 tk,
87 makeWrapper,
88 libiconv,
89 libiconvReal,
90 svnSupport ? false,
91 subversionClient,
92 perlLibs,
93 smtpPerlLibs,
94 perlSupport ? stdenv.buildPlatform == stdenv.hostPlatform,
95 nlsSupport ? true,
96 osxkeychainSupport ? stdenv.hostPlatform.isDarwin,
97 guiSupport ? false,
98 withManual ? true,
99 pythonSupport ? true,
100 withpcre2 ? true,
101 sendEmailSupport ? perlSupport,
102 Security,
103 CoreServices,
104 nixosTests,
105 withLibsecret ? false,
106 pkg-config,
107 glib,
108 libsecret,
109 gzip, # needed at runtime by gitweb.cgi
110 withSsh ? false,
111 sysctl,
112 deterministic-host-uname, # trick Makefile into targeting the host platform when cross-compiling
113 doInstallCheck ? !stdenv.hostPlatform.isDarwin, # extremely slow on darwin
114 tests,
115}:
116
117assert osxkeychainSupport -> stdenv.hostPlatform.isDarwin;
118assert sendEmailSupport -> perlSupport;
119assert svnSupport -> perlSupport;
120
121let
122 version = "2.47.2";
123 svn = subversionClient.override { perlBindings = perlSupport; };
124 gitwebPerlLibs = with perlPackages; [
125 CGI
126 HTMLParser
127 CGIFast
128 FCGI
129 FCGIProcManager
130 HTMLTagCloud
131 ];
132in
133
134stdenv.mkDerivation (finalAttrs: {
135 pname =
136 "git"
137 + lib.optionalString svnSupport "-with-svn"
138 + lib.optionalString (
139 !svnSupport && !guiSupport && !sendEmailSupport && !withManual && !pythonSupport && !withpcre2
140 ) "-minimal";
141 inherit version;
142
143 src = fetchurl {
144 url = "https://www.kernel.org/pub/software/scm/git/git-${version}.tar.xz";
145 hash = "sha256-sZJovmtvFVa0ep3YNCcuFn06dXQM3NKDzzgS7f/jkw8=";
146 };
147
148 outputs = [ "out" ] ++ lib.optional withManual "doc";
149 separateDebugInfo = true;
150
151 hardeningDisable = [ "format" ];
152
153 enableParallelBuilding = true;
154
155 patches =
156 [
157 ./docbook2texi.patch
158 ./git-sh-i18n.patch
159 ./git-send-email-honor-PATH.patch
160 ./installCheck-path.patch
161 ]
162 ++ lib.optionals withSsh [
163 ./ssh-path.patch
164 ]
165 ++ lib.optionals (guiSupport && stdenv.hostPlatform.isDarwin) [
166 # Needed to workaround an issue in macOS where gitk shows a empty window
167 # https://github.com/Homebrew/homebrew-core/issues/68798
168 # https://github.com/git/git/pull/944
169 (fetchpatch {
170 name = "gitk_check_main_window_visibility_before_waiting_for_it_to_show.patch";
171 url = "https://github.com/git/git/commit/1db62e44b7ec93b6654271ef34065b31496cd02e.patch";
172 hash = "sha256-ntvnrYFFsJ1Ebzc6vM9/AMFLHMS1THts73PIOG5DkQo=";
173 })
174 ];
175
176 postPatch =
177 ''
178 # Fix references to gettext introduced by ./git-sh-i18n.patch
179 substituteInPlace git-sh-i18n.sh \
180 --subst-var-by gettext ${gettext}
181
182 # ensure we are using the correct shell when executing the test scripts
183 patchShebangs t/*.sh
184 ''
185 + lib.optionalString withSsh ''
186 for x in connect.c git-gui/lib/remote_add.tcl ; do
187 substituteInPlace "$x" \
188 --subst-var-by ssh "${openssh}/bin/ssh"
189 done
190 '';
191
192 nativeBuildInputs =
193 [
194 deterministic-host-uname
195 gettext
196 perlPackages.perl
197 makeWrapper
198 pkg-config
199 ]
200 ++ lib.optionals withManual [
201 asciidoc
202 texinfo
203 xmlto
204 docbook2x
205 docbook_xsl
206 docbook_xml_dtd_45
207 libxslt
208 ];
209 buildInputs =
210 [
211 curl
212 openssl
213 zlib
214 expat
215 cpio
216 (if stdenv.hostPlatform.isFreeBSD then libiconvReal else libiconv)
217 bash
218 ]
219 ++ lib.optionals perlSupport [ perlPackages.perl ]
220 ++ lib.optionals guiSupport [
221 tcl
222 tk
223 ]
224 ++ lib.optionals withpcre2 [ pcre2 ]
225 ++ lib.optionals stdenv.hostPlatform.isDarwin [
226 Security
227 CoreServices
228 ]
229 ++ lib.optionals withLibsecret [
230 glib
231 libsecret
232 ];
233
234 # required to support pthread_cancel()
235 NIX_LDFLAGS =
236 lib.optionalString (stdenv.cc.isGNU && stdenv.hostPlatform.libc == "glibc") "-lgcc_s"
237 + lib.optionalString (stdenv.hostPlatform.isFreeBSD) "-lthr";
238
239 configureFlags =
240 [
241 "ac_cv_prog_CURL_CONFIG=${lib.getDev curl}/bin/curl-config"
242 ]
243 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
244 "ac_cv_fread_reads_directories=yes"
245 "ac_cv_snprintf_returns_bogus=no"
246 "ac_cv_iconv_omits_bom=no"
247 ];
248
249 preBuild = ''
250 makeFlagsArray+=( perllibdir=$out/$(perl -MConfig -wle 'print substr $Config{installsitelib}, 1 + length $Config{siteprefixexp}') )
251 '';
252
253 makeFlags =
254 [
255 "prefix=\${out}"
256 ]
257 # Git does not allow setting a shell separately for building and run-time.
258 # Therefore lets leave it at the default /bin/sh when cross-compiling
259 ++ lib.optional (stdenv.buildPlatform == stdenv.hostPlatform) "SHELL_PATH=${stdenv.shell}"
260 ++ (if perlSupport then [ "PERL_PATH=${perlPackages.perl}/bin/perl" ] else [ "NO_PERL=1" ])
261 ++ (if pythonSupport then [ "PYTHON_PATH=${python3}/bin/python" ] else [ "NO_PYTHON=1" ])
262 ++ lib.optionals stdenv.hostPlatform.isSunOS [
263 "INSTALL=install"
264 "NO_INET_NTOP="
265 "NO_INET_PTON="
266 ]
267 ++ (if stdenv.hostPlatform.isDarwin then [ "NO_APPLE_COMMON_CRYPTO=1" ] else [ "sysconfdir=/etc" ])
268 ++ lib.optionals stdenv.hostPlatform.isMusl [
269 "NO_SYS_POLL_H=1"
270 "NO_GETTEXT=YesPlease"
271 ]
272 ++ lib.optional withpcre2 "USE_LIBPCRE2=1"
273 ++ lib.optional (!nlsSupport) "NO_GETTEXT=1"
274 # git-gui refuses to start with the version of tk distributed with
275 # macOS Catalina. We can prevent git from building the .app bundle
276 # by specifying an invalid tk framework. The postInstall step will
277 # then ensure that git-gui uses tcl/tk from nixpkgs, which is an
278 # acceptable version.
279 #
280 # See https://github.com/Homebrew/homebrew-core/commit/dfa3ccf1e7d3901e371b5140b935839ba9d8b706
281 ++ lib.optional stdenv.hostPlatform.isDarwin "TKFRAMEWORK=/nonexistent";
282
283 disallowedReferences = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
284 stdenv.shellPackage
285 ];
286
287 postBuild =
288 ''
289 make -C contrib/subtree
290 ''
291 + (lib.optionalString perlSupport ''
292 make -C contrib/diff-highlight
293 '')
294 + (lib.optionalString osxkeychainSupport ''
295 make -C contrib/credential/osxkeychain
296 '')
297 + (lib.optionalString withLibsecret ''
298 make -C contrib/credential/libsecret
299 '');
300
301 ## Install
302
303 # WARNING: Do not `rm` or `mv` files from the source tree; use `cp` instead.
304 # We need many of these files during the installCheckPhase.
305
306 installFlags = [ "NO_INSTALL_HARDLINKS=1" ];
307
308 preInstall =
309 (lib.optionalString osxkeychainSupport ''
310 mkdir -p $out/bin
311 ln -s $out/share/git/contrib/credential/osxkeychain/git-credential-osxkeychain $out/bin/
312 rm -f $PWD/contrib/credential/osxkeychain/git-credential-osxkeychain.o
313 '')
314 + (lib.optionalString withLibsecret ''
315 mkdir -p $out/bin
316 ln -s $out/share/git/contrib/credential/libsecret/git-credential-libsecret $out/bin/
317 rm -f $PWD/contrib/credential/libsecret/git-credential-libsecret.o
318 '');
319
320 postInstall =
321 ''
322 notSupported() {
323 unlink $1 || true
324 }
325
326 # Install git-subtree.
327 make -C contrib/subtree install ${lib.optionalString withManual "install-doc"}
328 rm -rf contrib/subtree
329
330 # Install contrib stuff.
331 mkdir -p $out/share/git
332 cp -a contrib $out/share/git/
333 mkdir -p $out/share/bash-completion/completions
334 ln -s $out/share/git/contrib/completion/git-completion.bash $out/share/bash-completion/completions/git
335 ln -s $out/share/git/contrib/completion/git-prompt.sh $out/share/bash-completion/completions/
336 # only readme, developed in another repo
337 rm -r contrib/hooks/multimail
338 mkdir -p $out/share/git-core/contrib
339 cp -a contrib/hooks/ $out/share/git-core/contrib/
340 substituteInPlace $out/share/git-core/contrib/hooks/pre-auto-gc-battery \
341 --replace ' grep' ' ${gnugrep}/bin/grep' \
342
343 # grep is a runtime dependency, need to patch so that it's found
344 substituteInPlace $out/libexec/git-core/git-sh-setup \
345 --replace ' grep' ' ${gnugrep}/bin/grep' \
346 --replace ' egrep' ' ${gnugrep}/bin/egrep'
347
348 # Fix references to the perl, sed, awk and various coreutil binaries used by
349 # shell scripts that git calls (e.g. filter-branch)
350 SCRIPT="$(cat <<'EOS'
351 BEGIN{
352 @a=(
353 '${gnugrep}/bin/grep', '${gnused}/bin/sed', '${gawk}/bin/awk',
354 '${coreutils}/bin/cut', '${coreutils}/bin/basename', '${coreutils}/bin/dirname',
355 '${coreutils}/bin/wc', '${coreutils}/bin/tr'
356 ${lib.optionalString perlSupport ", '${perlPackages.perl}/bin/perl'"}
357 );
358 }
359 foreach $c (@a) {
360 $n=(split("/", $c))[-1];
361 s|(?<=[^#][^/.-])\b''${n}(?=\s)|''${c}|g
362 }
363 EOS
364 )"
365 perl -0777 -i -pe "$SCRIPT" \
366 $out/libexec/git-core/git-{sh-setup,filter-branch,merge-octopus,mergetool,quiltimport,request-pull,submodule,subtree,web--browse}
367
368
369 # Also put git-http-backend into $PATH, so that we can use smart
370 # HTTP(s) transports for pushing
371 ln -s $out/libexec/git-core/git-http-backend $out/bin/git-http-backend
372 ln -s $out/share/git/contrib/git-jump/git-jump $out/bin/git-jump
373 ''
374 + lib.optionalString perlSupport ''
375 # wrap perl commands
376 makeWrapper "$out/share/git/contrib/credential/netrc/git-credential-netrc.perl" $out/bin/git-credential-netrc \
377 --set PERL5LIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}"
378 wrapProgram $out/libexec/git-core/git-cvsimport \
379 --set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}"
380 wrapProgram $out/libexec/git-core/git-archimport \
381 --set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}"
382 wrapProgram $out/libexec/git-core/git-instaweb \
383 --set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}"
384 wrapProgram $out/libexec/git-core/git-cvsexportcommit \
385 --set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath perlLibs}"
386
387 # gzip (and optionally bzip2, xz, zip) are runtime dependencies for
388 # gitweb.cgi, need to patch so that it's found
389 sed -i -e "s|'compressor' => \['gzip'|'compressor' => ['${gzip}/bin/gzip'|" \
390 $out/share/gitweb/gitweb.cgi
391 # Give access to CGI.pm and friends (was removed from perl core in 5.22)
392 for p in ${lib.concatStringsSep " " gitwebPerlLibs}; do
393 sed -i -e "/use CGI /i use lib \"$p/${perlPackages.perl.libPrefix}\";" \
394 "$out/share/gitweb/gitweb.cgi"
395 done
396 ''
397
398 + (
399 if svnSupport then
400 ''
401 # wrap git-svn
402 wrapProgram $out/libexec/git-core/git-svn \
403 --set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${
404 perlPackages.makePerlPath (perlLibs ++ [ svn.out ])
405 }" \
406 --prefix PATH : "${svn.out}/bin"
407 ''
408 else
409 ''
410 # replace git-svn by notification script
411 notSupported $out/libexec/git-core/git-svn
412 ''
413 )
414
415 + (
416 if sendEmailSupport then
417 ''
418 # wrap git-send-email
419 wrapProgram $out/libexec/git-core/git-send-email \
420 --set GITPERLLIB "$out/${perlPackages.perl.libPrefix}:${perlPackages.makePerlPath smtpPerlLibs}"
421 ''
422 else
423 ''
424 # replace git-send-email by notification script
425 notSupported $out/libexec/git-core/git-send-email
426 ''
427 )
428
429 + lib.optionalString withManual ''
430 # Install man pages
431 make -j $NIX_BUILD_CORES PERL_PATH="${buildPackages.perl}/bin/perl" cmd-list.made install install-html \
432 -C Documentation
433 ''
434
435 + (
436 if guiSupport then
437 ''
438 # Wrap Tcl/Tk programs
439 for prog in bin/gitk libexec/git-core/{git-gui,git-citool,git-gui--askpass}; do
440 sed -i -e "s|exec 'wish'|exec '${tk}/bin/wish'|g" \
441 -e "s|exec wish|exec '${tk}/bin/wish'|g" \
442 "$out/$prog"
443 done
444 ln -s $out/share/git/contrib/completion/git-completion.bash $out/share/bash-completion/completions/gitk
445 ''
446 else
447 ''
448 # Don't wrap Tcl/Tk, replace them by notification scripts
449 for prog in bin/gitk libexec/git-core/git-gui; do
450 notSupported "$out/$prog"
451 done
452 ''
453 )
454 + lib.optionalString osxkeychainSupport ''
455 # enable git-credential-osxkeychain on darwin if desired (default)
456 mkdir -p $out/etc
457 cat > $out/etc/gitconfig << EOF
458 [credential]
459 helper = osxkeychain
460 EOF
461 '';
462
463 ## InstallCheck
464
465 doCheck = false;
466 inherit doInstallCheck;
467
468 installCheckTarget = "test";
469
470 # see also installCheckFlagsArray
471 installCheckFlags = [
472 "DEFAULT_TEST_TARGET=prove"
473 "PERL_PATH=${buildPackages.perl}/bin/perl"
474 ];
475
476 nativeInstallCheckInputs = lib.optional (
477 stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isFreeBSD
478 ) sysctl;
479
480 preInstallCheck =
481 ''
482 installCheckFlagsArray+=(
483 GIT_PROVE_OPTS="--jobs $NIX_BUILD_CORES --failures --state=failed,save"
484 GIT_TEST_INSTALLED=$out/bin
485 ${lib.optionalString (!svnSupport) "NO_SVN_TESTS=y"}
486 )
487
488 function disable_test {
489 local test=$1 pattern=$2
490 if [ $# -eq 1 ]; then
491 mv t/{,skip-}$test.sh || true
492 else
493 sed -i t/$test.sh \
494 -e "/^\s*test_expect_.*$pattern/,/^\s*' *\$/{s/^/: #/}"
495 fi
496 }
497
498 # Shared permissions are forbidden in sandbox builds:
499 substituteInPlace t/test-lib.sh \
500 --replace "test_set_prereq POSIXPERM" ""
501 # TODO: Investigate while these still fail (without POSIXPERM):
502 # Tested to fail: 2.46.0
503 disable_test t0001-init 'shared overrides system'
504 # Tested to fail: 2.46.0
505 disable_test t0001-init 'init honors global core.sharedRepository'
506 # Tested to fail: 2.46.0
507 disable_test t1301-shared-repo
508 # /build/git-2.44.0/contrib/completion/git-completion.bash: line 452: compgen: command not found
509 disable_test t9902-completion
510
511 # Our patched gettext never fallbacks
512 disable_test t0201-gettext-fallbacks
513 ''
514 + lib.optionalString (!sendEmailSupport) ''
515 # Disable sendmail tests
516 disable_test t9001-send-email
517 ''
518 + ''
519 # Flaky tests:
520 disable_test t6421-merge-partial-clone
521
522 # Fails reproducibly on ZFS on Linux with formD normalization
523 disable_test t0021-conversion
524 disable_test t3910-mac-os-precompose
525 ''
526 + lib.optionalString stdenv.hostPlatform.isDarwin ''
527 # XXX: Some tests added in 2.24.0 fail.
528 # Please try to re-enable on the next release.
529 disable_test t7816-grep-binary-pattern
530 # fail (as of 2.33.0)
531 #===( 18623;1208 8/? 224/? 2/? )= =fatal: Not a valid object name refs/tags/signed-empty
532 disable_test t6300-for-each-ref
533 # not ok 1 - populate workdir (with 2.33.1 on x86_64-darwin)
534 disable_test t5003-archive-zip
535 ''
536 + lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
537 disable_test t7527-builtin-fsmonitor
538 ''
539 + lib.optionalString stdenv.hostPlatform.isMusl ''
540 # Test fails (as of 2.17.0, musl 1.1.19)
541 disable_test t3900-i18n-commit
542 # Fails largely due to assumptions about BOM
543 # Tested to fail: 2.18.0
544 disable_test t0028-working-tree-encoding
545 '';
546
547 stripDebugList = [
548 "lib"
549 "libexec"
550 "bin"
551 "share/git/contrib/credential/libsecret"
552 ];
553
554 passthru = {
555 shellPath = "/bin/git-shell";
556 tests = {
557 withInstallCheck = finalAttrs.finalPackage.overrideAttrs (_: {
558 doInstallCheck = true;
559 });
560 buildbot-integration = nixosTests.buildbot;
561 } // tests.fetchgit;
562 updateScript = ./update.sh;
563 };
564
565 meta = {
566 homepage = "https://git-scm.com/";
567 description = "Distributed version control system";
568 license = lib.licenses.gpl2;
569 changelog = "https://github.com/git/git/blob/v${version}/Documentation/RelNotes/${version}.txt";
570
571 longDescription = ''
572 Git, a popular distributed version control system designed to
573 handle very large projects with speed and efficiency.
574 '';
575
576 platforms = lib.platforms.all;
577 maintainers = with lib.maintainers; [
578 primeos
579 wmertens
580 globin
581 kashw2
582 ];
583 mainProgram = "git";
584 };
585})
586}}}
587
r4
588pkgs 원본 소스를 까봤는데 perlSupport 설정이 정신나갈 거 같다. 일단 그냥 symlink 강제로 박아서 해결할 듯. 일단 실행은 된다.
r3
589
r5
590{{{#!syntax
591 package = pkgs.git.overrideAttrs (p: {
592 patches = p.patches ++ [ ./allow-empty-message.patch ];
593 preInstallCheck =
594 p.preInstallCheck
595 + ''
596 # disable_test t3404-rebase-interactive
597 # disable_test t7501-commit-basic-functionality
598 # disable_test t7500-commit-template-squash-signoff
599 # disable_test t7507-commit-verbose
600 # disable_test t7502-commit-porcelain
601 # disable_test t7508-status
602 '';
603 });
604}}}
605
606왠지 hm switch 돌리고 실패하는 테스트만 스킵하면 될 거 같아서 이렇게 짬.
607
r4
608{{{#!syntax sh
609not ok 42 - aborted --continue does not squash commits after "edit"
610#
611# old=$(git rev-parse HEAD) &&
612# test_tick &&
613# (
614# set_fake_editor &&
615# FAKE_LINES="edit 1" git rebase -i HEAD^ &&
616# echo "edited again" > file7 &&
617# git add file7 &&
618# test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue
619# ) &&
620# test $old = $(git rev-parse HEAD) &&
621# git rebase --abort
622#
623not ok 43 - auto-amend only edited commits after "edit"
624#
625# test_tick &&
626# (
627# set_fake_editor &&
628# FAKE_LINES="edit 1" git rebase -i HEAD^ &&
629# echo "edited again" > file7 &&
630# git add file7 &&
631# FAKE_COMMIT_MESSAGE="edited file7 again" git commit &&
632# echo "and again" > file7 &&
633# git add file7 &&
634# test_tick &&
635# test_must_fail env FAKE_COMMIT_MESSAGE="and again" \
636# git rebase --continue
637# ) &&
638# git rebase --abort
639#
640not ok 44 - clean error after failed "exec"
641#
642# test_tick &&
643# test_when_finished "git rebase --abort || :" &&
644# (
645# set_fake_editor &&
646# test_must_fail env FAKE_LINES="1 exec_false" git rebase -i HEAD^
647# ) &&
648# echo "edited again" > file7 &&
649# git add file7 &&
650# test_must_fail git rebase --continue 2>error &&
651# test_grep "you have staged changes in your working tree" error &&
652# test_grep ! "could not open.*for reading" error
653#
654}}}
655
r1
656{{{#!syntax cpp
657struct delta_index {
658 unsigned long memsize;
659 const void *src_buf;
660 unsigned long src_size;
661 unsigned int hash_mask;
662 struct index_entry *hash[FLEX_ARRAY];
663};
664
665struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
666{
667 unsigned int i, hsize, hmask, entries, prev_val, *hash_count;
668 const unsigned char *data, *buffer = buf;
669 struct delta_index *index;
670 struct unpacked_index_entry *entry, **hash;
671 struct index_entry *packed_entry, **packed_hash;
672 void *mem;
673 unsigned long memsize;
674
675 if (!buf || !bufsize)
676 return NULL;
677
678 entries = (bufsize - 1) / RABIN_WINDOW;
679 if (bufsize >= 0xffffffffUL) {
680 entries = 0xfffffffeU / RABIN_WINDOW;
681 }
682 hsize = entries / 4;
683 for (i = 4; (1u << i) < hsize; i++);
684 hsize = 1 << i;
685 hmask = hsize - 1;
686
687 /* allocate lookup index */
688 memsize = sizeof(*hash) * hsize +
689 sizeof(*entry) * entries;
690 mem = malloc(memsize);
691 if (!mem)
692 return NULL;
693 hash = mem;
694 mem = hash + hsize;
695 entry = mem;
696
697 memset(hash, 0, hsize * sizeof(*hash));
698
699 hash_count = calloc(hsize, sizeof(*hash_count));
700 if (!hash_count) {
701 free(hash);
702 return NULL;
703 }
704
705 prev_val = ~0;
706 for (data = buffer + entries * RABIN_WINDOW - RABIN_WINDOW;
707 data >= buffer;
708 data -= RABIN_WINDOW) {
709 unsigned int val = 0;
710 for (i = 1; i <= RABIN_WINDOW; i++)
711 val = ((val << 8) | data[i]) ^ T[val >> RABIN_SHIFT];
712 if (val == prev_val) {
713 entry[-1].entry.ptr = data + RABIN_WINDOW;
714 --entries;
715 } else {
716 prev_val = val;
717 i = val & hmask;
718 entry->entry.ptr = data + RABIN_WINDOW;
719 entry->entry.val = val;
720 entry->next = hash[i];
721 hash[i] = entry++;
722 hash_count[i]++;
723 }
724 }
725
726 for (i = 0; i < hsize; i++) {
727 int acc;
728
729 if (hash_count[i] <= HASH_LIMIT)
730 continue;
731
732 entries -= hash_count[i] - HASH_LIMIT;
733
734 entry = hash[i];
735 acc = 0;
736
737 do {
738 acc += hash_count[i] - HASH_LIMIT;
739 if (acc > 0) {
740 struct unpacked_index_entry *keep = entry;
741 do {
742 entry = entry->next;
743 acc -= HASH_LIMIT;
744 } while (acc > 0);
745 keep->next = entry->next;
746 }
747 entry = entry->next;
748 } while (entry);
749 }
750 free(hash_count);
751
752 memsize = sizeof(*index)
753 + sizeof(*packed_hash) * (hsize+1)
754 + sizeof(*packed_entry) * entries;
755 mem = malloc(memsize);
756 if (!mem) {
757 free(hash);
758 return NULL;
759 }
760
761 index = mem;
762 index->memsize = memsize;
763 index->src_buf = buf;
764 index->src_size = bufsize;
765 index->hash_mask = hmask;
766
767 mem = index->hash;
768 packed_hash = mem;
769 mem = packed_hash + (hsize+1);
770 packed_entry = mem;
771
772 for (i = 0; i < hsize; i++) {
773 packed_hash[i] = packed_entry;
774 for (entry = hash[i]; entry; entry = entry->next)
775 *packed_entry++ = entry->entry;
776 }
777
778 packed_hash[hsize] = packed_entry;
779
780 assert(packed_entry - (struct index_entry *)mem == entries);
781 free(hash);
782
783 return index;
784}
785
786void free_delta_index(struct delta_index *index)
787{
788 free(index);
789}
790
791unsigned long sizeof_delta_index(struct delta_index *index)
792{
793 if (index)
794 return index->memsize;
795 else
796 return 0;
797}
798
799#define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7)
800
801void *
802create_delta(const struct delta_index *index,
803 const void *trg_buf, unsigned long trg_size,
804 unsigned long *delta_size, unsigned long max_size)
805{
806 unsigned int i, val;
807 off_t outpos, moff;
808 size_t l, outsize, msize;
809 int inscnt;
810 const unsigned char *ref_data, *ref_top, *data, *top;
811 unsigned char *out;
812
813 *delta_size = 0;
814
815 if (!trg_buf || !trg_size)
816 return NULL;
817
818 outpos = 0;
819 outsize = 8192;
820 if (max_size && outsize >= max_size)
821 outsize = max_size + MAX_OP_SIZE + 1;
822 out = malloc(outsize);
823 if (!out)
824 return NULL;
825
826 l = index->src_size;
827 while (l >= 0x80) {
828 out[outpos++] = l | 0x80;
829 l >>= 7;
830 }
831 out[outpos++] = l;
832
833 l = trg_size;
834 while (l >= 0x80) {
835 out[outpos++] = l | 0x80;
836 l >>= 7;
837 }
838 out[outpos++] = l;
839
840 ref_data = index->src_buf;
841 ref_top = ref_data + index->src_size;
842 data = trg_buf;
843 top = (const unsigned char *) trg_buf + trg_size;
844
845 outpos++;
846 val = 0;
847 for (i = 0; i < RABIN_WINDOW && data < top; i++, data++) {
848 out[outpos++] = *data;
849 val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT];
850 }
851 inscnt = i;
852
853 moff = 0;
854 msize = 0;
855 while (data < top) {
856 if (msize < 4096) {
857 struct index_entry *entry;
858 val ^= U[data[-RABIN_WINDOW]];
859 val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT];
860 i = val & index->hash_mask;
861 for (entry = index->hash[i]; entry < index->hash[i+1]; entry++) {
862 const unsigned char *ref = entry->ptr;
863 const unsigned char *src = data;
864 unsigned int ref_size = ref_top - ref;
865 if (entry->val != val)
866 continue;
867 if (ref_size > top - src)
868 ref_size = top - src;
869 if (ref_size <= msize)
870 break;
871 while (ref_size-- && *src++ == *ref)
872 ref++;
873 if (msize < ref - entry->ptr) {
874 msize = ref - entry->ptr;
875 moff = entry->ptr - ref_data;
876 if (msize >= 4096)
877 break;
878 }
879 }
880 }
881
882 if (msize < 4) {
883 if (!inscnt)
884 outpos++;
885 out[outpos++] = *data++;
886 inscnt++;
887 if (inscnt == 0x7f) {
888 out[outpos - inscnt - 1] = inscnt;
889 inscnt = 0;
890 }
891 msize = 0;
892 } else {
893 unsigned int left;
894 unsigned char *op;
895
896 if (inscnt) {
897 while (moff && ref_data[moff-1] == data[-1]) {
898 msize++;
899 moff--;
900 data--;
901 outpos--;
902 if (--inscnt)
903 continue;
904 outpos--;
905 inscnt--;
906 break;
907 }
908 out[outpos - inscnt - 1] = inscnt;
909 inscnt = 0;
910 }
911
912 left = (msize < 0x10000) ? 0 : (msize - 0x10000);
913 msize -= left;
914
915 op = out + outpos++;
916 i = 0x80;
917
918 if (moff & 0x000000ff)
919 out[outpos++] = moff >> 0, i |= 0x01;
920 if (moff & 0x0000ff00)
921 out[outpos++] = moff >> 8, i |= 0x02;
922 if (moff & 0x00ff0000)
923 out[outpos++] = moff >> 16, i |= 0x04;
924 if (moff & 0xff000000)
925 out[outpos++] = moff >> 24, i |= 0x08;
926
927 if (msize & 0x00ff)
928 out[outpos++] = msize >> 0, i |= 0x10;
929 if (msize & 0xff00)
930 out[outpos++] = msize >> 8, i |= 0x20;
931
932 *op = i;
933
934 data += msize;
935 moff += msize;
936 msize = left;
937
938 if (moff > 0xffffffff)
939 msize = 0;
940
941 if (msize < 4096) {
942 int j;
943 val = 0;
944 for (j = -RABIN_WINDOW; j < 0; j++)
945 val = ((val << 8) | data[j])
946 ^ T[val >> RABIN_SHIFT];
947 }
948 }
949
950 if (outpos >= outsize - MAX_OP_SIZE) {
951 void *tmp = out;
952 outsize = outsize * 3 / 2;
953 if (max_size && outsize >= max_size)
954 outsize = max_size + MAX_OP_SIZE + 1;
955 if (max_size && outpos > max_size)
956 break;
957 out = realloc(out, outsize);
958 if (!out) {
959 free(tmp);
960 return NULL;
961 }
962 }
963 }
964
965 if (inscnt)
966 out[outpos - inscnt - 1] = inscnt;
967
968 if (max_size && outpos > max_size) {
969 free(out);
970 return NULL;
971 }
972
973 *delta_size = outpos;
974 return out;
975}
976}}}