From 8518a7a51faaf50f830646d4c3585f51236b9349 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 22 May 2020 17:46:45 +0100 Subject: Squashed 'third_party/git/' changes from 5fa0f5238b..ef7aa56f96 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit af6b65d45e Git 2.26.2 7397ca3373 Git 2.25.4 b86a4be245 Git 2.24.3 f2771efd07 Git 2.23.3 c9808fa014 Git 2.22.4 9206d27eb5 Git 2.21.3 041bc65923 Git 2.20.4 76b54ee9b9 Git 2.19.5 ba6f0905fd Git 2.18.4 df5be6dc3f Git 2.17.5 1a3609e402 fsck: reject URL with empty host in .gitmodules e7fab62b73 credential: treat URL with empty scheme as invalid c44088ecc4 credential: treat URL without scheme as invalid fe29a9b7b0 credential: die() when parsing invalid urls a2b26ffb1a fsck: convert gitmodules url to URL passed to curl 8ba8ed568e credential: refuse to operate when missing host or protocol 24036686c4 credential: parse URL without host as empty host, not unset 73aafe9bc2 t0300: use more realistic inputs a88dbd2f8c t0300: make "quit" helper more realistic de49261b05 Git 2.26.1 274b9cc253 Git 2.26 55a7568606 Merge branch 'en/rebase-backend' c452dfa3f8 Merge tag 'l10n-2.26.0-rnd2.1' of git://github.com/git-l10n/git-po.git 1557364fb4 l10n: tr.po: change file mode to 644 2da1b05674 t3419: prevent failure when run with EXPENSIVE 1ae3a389c7 l10n: de.po: Update German translation for Git 2.26.0 5804c6ec40 l10n: de.po: add missing space 98cedd0233 Merge https://github.com/prati0100/git-gui 4914ba4bcf l10n: tr: Fix a couple of ambiguities a5728022e0 Merge branch 'py/remove-tcloo' 7fcb965970 RelNotes/2.26.0: fix various typos f0c03bcf95 l10n: Update Catalan translation 67b0a24910 Git 2.25.3 be8661a328 Sync with Git 2.25.2 0822e66b5d Git 2.25.2 65588b0b2e unicode: update the width tables to Unicode 13.0 7be274b0ff Merge branch 'js/ci-windows-update' into maint 9a75ecda1b Merge branch 'jk/run-command-formatfix' into maint 221887a492 Merge branch 'jk/doc-credential-helper' into maint 32fc2c6dd6 Merge branch 'js/mingw-open-in-gdb' into maint fe0d2c8ddb Merge branch 'js/test-unc-fetch' into maint 618db3621a Merge branch 'js/test-write-junit-xml-fix' into maint 50e1b4166f Merge branch 'en/simplify-check-updates-in-unpack-trees' into maint fda2baffd2 Merge branch 'jc/doc-single-h-is-for-help' into maint 41d910ea6c Merge branch 'hd/show-one-mergetag-fix' into maint 2d7247af6f Merge branch 'am/mingw-poll-fix' into maint 4e730fcd18 Merge branch 'hi/gpg-use-check-signature' into maint 76ccbdaf97 Merge branch 'ds/partial-clone-fixes' into maint 569b89842d Merge branch 'en/t3433-rebase-stat-dirty-failure' into maint 16a4bf1035 Merge branch 'en/check-ignore' into maint 3246495a5c Merge branch 'jk/push-option-doc-markup-fix' into maint 56f97d5896 Merge branch 'jk/doc-diff-parallel' into maint 1a4abcbb3b Merge branch 'jh/notes-fanout-fix' into maint 7e84f4608f Merge branch 'jk/index-pack-dupfix' into maint fa24bbe864 Merge branch 'js/rebase-i-with-colliding-hash' into maint a7a2e12b6e Merge branch 'jk/clang-sanitizer-fixes' into maint 93d0892891 Merge branch 'dt/submodule-rm-with-stale-cache' into maint dae477777e Merge branch 'pb/recurse-submodule-in-worktree-fix' into maint 758d0773ba Merge branch 'es/outside-repo-errmsg-hints' into maint f0c344ce57 Merge branch 'js/builtin-add-i-cmds' into maint 506223f9c5 Git 2.24.2 17a02783d8 Git 2.23.2 69fab82147 Git 2.22.3 fe22686494 Git 2.21.2 d1259ce117 Git 2.20.3 a5979d7009 Git 2.19.4 21a3e5016b Git 2.18.3 c42c0f1297 Git 2.17.4 d7d8b208da l10n: sv.po: Update Swedish translation (4839t0f0u) 3891a84ccd git-gui: create a new namespace for chord script evaluation 8a8efbe414 git-gui: reduce Tcl version requirement from 8.6 to 8.5 440e7442d1 l10n: zh_CN: Revise v2.26.0 translation 2b472aae5c l10n: zh_CN: for git v2.26.0 l10n round 1 and 2 6c85aac65f Git 2.26-rc2 74f172e39e Merge branch 'en/test-cleanup' e96327c947 Merge branch 'es/outside-repo-errmsg-hints' ee94b979b2 l10n: vi(4839t): Updated Vietnamese translation for v2.26.0 15fa8d9667 l10n: vi: fix translation + grammar 5c20398699 prefix_path: show gitdir if worktree unavailable 1fae9a4b1b l10n: zh_TW.po: v2.26.0 round 2 (0 untranslated) c73cfd5c79 l10n: zh_TW.po: v2.26.0 round 1 (11 untranslated) a4a2f64642 Merge branch 'js/askpass-coerce-utf8' 850cf9ae96 git-gui--askpass: coerce answers to UTF-8 on Windows d769dcc5cd Merge branch 'py/blame-status-error' 70e24186c0 t6022, t6046: fix flaky files-are-updated checks 30e9940356 Hopefully the final batch before -rc2 b4f0038525 Merge branch 'en/rebase-backend' 25f7d68ba9 Merge branch of github.com:ChrisADR/git-po into master 07259e74ec fsck: detect gitmodules URLs with embedded newlines c716fe4bd9 credential: detect unrepresentable values when parsing urls 17f1c0b8c7 t/lib-credential: use test_i18ncmp to check stderr 9a6bbee800 credential: avoid writing values with newlines 17ed936e96 l10n: it.po: update the Italian translation for Git 2.26.0 round 2 1afe18a3bb l10n: es: 2.26.0 round#2 5ab9217a3c Merge branch of github.com:alshopov/git-po into master c6713676d6 Merge branch of github.com:bitigchi/git-po into master b22e556314 l10n: bg.po: Updated Bulgarian translation (4839t) 2713dec02d l10n: tr: v2.26.0 round 2 c9ef57cc3a l10n: fr : v2.26.0 rnd 2 120b1eb731 git-rebase.txt: highlight backend differences with commit rewording 9a1b7474d6 sequencer: clear state upon dropping a become-empty commit 937d143630 i18n: unmark a message in rebase.c a56d361f66 Merge branch 'ds/sparse-add' 5fa9169ced Merge branch 'dr/push-remote-ref-update' cdef998b46 Merge branch 'jc/doc-single-h-is-for-help' 051fae4d51 l10n: git.pot: v2.26.0 round 2 (7 new, 2 removed) 52b2742df8 Merge branch 'master' of github.com:git/git into git-po-master 9643441983 l10n: tr: Add glossary for Turkish translations 438393202c Merge branch 'master' of github.com:nafmo/git-l10n-sv fa89e04fe1 Merge branch 'fr_2.26.0' of github.com:jnavila/git 2591c4cf6d l10n: sv.po: Update Swedish translation (4835t0f0u) dd2c269652 l10n: tr: Add Turkish translations 8f4f099f8b l10n: tr: Add Turkish translation team info b4374e96c8 Git 2.26-rc1 4a5c3e10f2 Merge branch 'rs/show-progress-in-dumb-http-fetch' 3658d77f8e Merge branch 'hd/show-one-mergetag-fix' 6125104b88 Merge branch 'rt/format-zero-length-fix' 1ac37deba2 Merge branch 'am/mingw-poll-fix' cf372dc815 Merge branch 'en/test-cleanup' d1075adfdf Merge branch 'en/merge-path-collision' a4fd114ffc Merge branch 'kk/complete-diff-color-moved' a0d752c1a3 Merge branch 'rj/t1050-use-test-path-is-file' 0e0d717537 Merge branch 'pb/am-show-current-patch' 9b7f726dfc Merge branch 'am/pathspec-f-f-more' 4605a73073 t1091: don't grep for `strerror()` string 4d9c2902a1 l10n: fr v2.26.0 rnd1 ad182bee3f Merge branch of github.com:alshopov/git-po into master 23fa46712a l10n: it.po: update the Italian translation for Git 2.26.0 round 1 98f24073a5 l10n: bg.po: Updated Bulgarian translation (4835t) f7c6172e97 l10n: git.pot: v2.26.0 round 1 (73 new, 38 removed) 76b1dcd1b2 Merge branch 'master' of github.com:git-l10n/git-po 076cbdcd73 Git 2.26-rc0 0d65f3fb1a t5537: adjust test_oid label e63cefb024 Merge branch 'hi/gpg-use-check-signature' 5da7329e29 Merge branch 'rs/commit-graph-code-simplification' 0108fc1b46 Merge branch 'js/ci-windows-update' f3ccd9f0d9 Merge branch 'be/describe-multiroot' a6b4709302 Merge branch 'ag/rebase-remove-redundant-code' b22db265d6 Merge branch 'es/recursive-single-branch-clone' e8e71848ea Merge branch 'jk/nth-packed-object-id' a0ab37de61 Merge branch 'es/do-not-let-rebase-switch-to-protected-branch' 4a2e91db65 Merge branch 'hv/receive-denycurrent-everywhere' 49e5043b09 Merge branch 'es/worktree-avoid-duplication-fix' 2cbb058669 Merge branch 'bc/wildcard-credential' 25063e2530 Merge branch 'mr/bisect-in-c-1' f4d7dfce4d Merge branch 'ds/sparse-add' 4d864895a2 t2402: test worktree path when called in .git directory af8ccd8ade remote: drop "explicit" parameter from remote_ref_for_branch() 7655b4119d remote-curl: show progress for fetches over dumb HTTP 2f268890c2 The eighth batch for 2.26 aa5a7e02ad Merge branch 'ma/test-cleanup' 58595e713c Merge branch 'rs/blame-typefix-for-fingerprint' ff41848e99 Merge branch 'rs/micro-cleanups' 4cbf1a0e22 Merge branch 'es/worktree-cleanup' 46703057c1 Merge branch 'ak/test-log-graph' 777815f5f9 Merge branch 'jk/run-command-formatfix' 444cff61b4 Merge branch 'ds/partial-clone-fixes' 48d5f25ddd Merge branch 'en/t3433-rebase-stat-dirty-failure' 8c22bd9ff9 Merge branch 'en/rebase-backend' cb2f5a8e97 Merge branch 'en/check-ignore' 0df82d99da Merge branch 'jk/object-filter-with-bitmap' 80648bb3f2 Merge branch 'jk/push-option-doc-markup-fix' 29b09c518c Merge branch 'jk/doc-diff-parallel' 237a28173f show_one_mergetag: print non-parent in hex form. 5eb9397e88 git-gui: fix error popup when doing blame -> "Show History Context" 6d1210e133 l10n: Update Catalan translation 0106b1d4be Revert "gpg-interface: prefer check_signature() for GPG verification" 7329d94be7 config.mak.dev: re-enable -Wformat-zero-length 7daf4f2ac7 rebase-interactive.c: silence format-zero-length warnings 94f4d01932 mingw: workaround for hangs when sending STDIN 1ff466c018 Documentation: clarify that `-h` alone stands for `help` 65bf820d0e t6020: new test with interleaved lexicographic ordering of directories 9f697ded88 t6022, t6046: test expected behavior instead of testing a proxy for it d5bb92eced t3035: prefer test_must_fail to bash negation for git commands b821ca788b t6020, t6022, t6035: update merge tests to use test helper functions 42d180dd01 t602[1236], t6034: modernize test formatting 802050400a merge-recursive: apply collision handling unification to recursive case 7f487ce062 Azure Pipeline: switch to the latest agent pools 5ed9fc3fc8 ci: prevent `perforce` from being quarantined eafff6e41e t/lib-httpd: avoid using macOS' sed d68ce906c7 commit-graph: use progress title directly 30b1c7ad9d describe: don't abort too early when searching tags 240fc04f81 builtin/rebase: remove a call to get_oid() on `options.switch_to' 2d2118b814 The seventh batch for 2.26 325eb66830 Merge branch 'es/doc-mentoring' 87f17d790d Merge branch 'es/bright-colors' d0038f4b31 Merge branch 'bw/remote-rename-update-config' 132f600b06 clone: pass --single-branch during --recurse-submodules 47319576f1 submodule--helper: use C99 named initializer ffe005576a lib-log-graph: consolidate colored graph cmp logic 989eea958b lib-log-graph: consolidate test_cmp_graph logic bb69b3b009 worktree: don't allow "add" validation to be fooled by suffix matching bb4995fc3f worktree: add utility to find worktree by pathname a80c4c2214 worktree: improve find_worktree() documentation 2fecc48cad packfile: drop nth_packed_object_sha1() 6ac9760a30 packed_object_info(): use object_id internally for delta base b99b6bcc57 packed_object_info(): use object_id for returning delta base 63f4a7fc01 pack-check: push oid lookup into loop e31c71083a pack-check: convert "internal error" die to a BUG() 500e4f2366 pack-bitmap: use object_id when loading on-disk bitmaps f66d4e0250 pack-objects: use object_id struct in pack-reuse code a93c141dde pack-objects: convert oe_set_delta_ext() to use object_id 3f83fd5e44 pack-objects: read delta base oid into object_id struct 0763671b8e nth_packed_object_oid(): use customary integer return 02bbbe9df9 worktree: drop unused code from get_main_worktree() 27f182b3fc blame: provide type of fingerprints pointer b5cabb4a96 rebase: refuse to switch to branch already checked out elsewhere df126ca142 t3400: make test clean up after itself 3c29e21eb0 t: drop debug `cat` calls cac439b56d t9810: drop debug `cat` call 91de82adc9 t4117: check for files using `test_path_is_file` 4ef346482d receive.denyCurrentBranch: respect all worktrees f8692114db t5509: use a bare repository for test push target 45f274fbb1 get_main_worktree(): allow it to be called in the Git directory fd0bc17557 completion: add diff --color-moved[-ws] 2ce6d075fa use strpbrk(3) to search for characters from a given set 2b3c430bce quote: use isalnum() to check for alphanumeric characters a51d9e8f07 t1050: replace test -f with test_path_is_file 3e96c66805 partial-clone: avoid fetching when looking for objects d0badf8797 partial-clone: demonstrate bugs in partial fetch 539052f42f run-command.h: fix mis-indented struct member 6c11c6a124 sparse-checkout: allow one-character directories in cone mode aa416b22ea am: support --show-current-patch=diff to retrieve .git/rebase-apply/patch f3b4822899 am: support --show-current-patch=raw as a synonym for--show-current-patch e8ef1e8d6e am: convert "resume" variable to a struct bc8620b440 parse-options: convert "command mode" to a flag 62e7a6f7a1 parse-options: add testcases for OPT_CMDMODE() 46fd7b3900 credential: allow wildcard patterns when matching config 82eb249853 credential: use the last matching username in the config 588c70e10f t0300: add tests for some additional cases 732f934408 t1300: add test for urlmatch with multiple wildcards 3fa0e04667 mailmap: add an additional email address for brian m. carlson 8a98758a8d stash push: support the --pathspec-from-file option 8c3713cede stash: eliminate crude option parsing 3f3d8068f5 doc: stash: synchronize description b22909144c doc: stash: document more options 0093abc286 doc: stash: split options from description (2) 2b7460d167 doc: stash: split options from description (1) 5f393dc3aa rm: support the --pathspec-from-file option fb1c18fc46 merge-recursive: fix the refresh logic in update_file_flags 73113c5922 t3433: new rebase testcase documenting a stat-dirty-like failure 6c69f22233 bisect: libify `bisect_next_all` 9ec598e0d5 bisect: libify `handle_bad_merge_base` and its dependents 45b6370812 bisect: libify `check_good_are_ancestors_of_bad` and its dependents cdd4dc2d6a bisect: libify `check_merge_bases` and its dependents e8e3ce6718 bisect: libify `bisect_checkout` ce58b5d8b1 bisect: libify `exit_if_skipped_commits` to `error_if_skipped*` and its dependents 7613ec594a bisect--helper: return error codes from `cmd_bisect__helper()` 680e8a01e5 bisect: add enum to represent bisect returning codes bfacfce7d9 bisect--helper: introduce new `decide_next()` function b8e3b2f339 bisect: use the standard 'if (!var)' way to check for 0 292731c4c2 bisect--helper: change `retval` to `res` 16538bfd2c bisect--helper: convert `vocab_*` char pointers to char arrays 7ec8125fba check-ignore: fix documentation and implementation to match 2607d39da3 doc-diff: use single-colon rule in rendering Makefile 0aa6ce3094 doc/config/push: use longer "--" line for preformatted example 20a5fd881a rev-list --count: comment on the use of count_right++ 63a58457e0 Merge branch 'py/missing-bracket' 51ebf55b93 The sixth batch for 2.26 f97741f6e9 Merge branch 'es/outside-repo-errmsg-hints' 123538444f Merge branch 'jk/doc-credential-helper' e154451a2f Merge branch 'js/mingw-open-in-gdb' fc25a19265 Merge branch 'js/test-unc-fetch' 6365058605 Merge branch 'js/test-avoid-pipe' 966b69f02f Merge branch 'js/test-write-junit-xml-fix' d880c3de23 Merge branch 'jk/mailinfo-cleanup' 5d55554b1d Merge branch 'mr/show-config-scope' 9f3f38769d Merge branch 'rs/strbuf-insertstr' cbecc168d4 Merge branch 'rs/parse-options-concat-dup' 5af345a438 Merge branch 'bc/hash-independent-tests-part-8' 0460c109c3 Merge branch 'rs/name-rev-memsave' 6b9919c0a2 git-gui: add missing close bracket 5897e5ac96 Merge branch 'cs/german-translation' cf85a32eb6 git-gui: update German translation 5096e51c54 git-gui: extend translation glossary template with more terms 8b85bb1b70 git-gui: update pot template and German translation to current source code e68e29171c Sync with 2.25.1 c522f061d5 Git 2.25.1 10cdb9f38a rebase: rename the two primary rebase backends 2ac0d6273f rebase: change the default backend from "am" to "merge" 8295ed690b rebase: make the backend configurable via config setting 76340c8107 rebase tests: repeat some tests using the merge backend instead of am 980b482d28 rebase tests: mark tests specific to the am-backend with --am c2417d3af7 rebase: drop '-i' from the reflog for interactive-based rebases 6d04ce75c4 git-prompt: change the prompt for interactive-based rebases 52eb738d6b rebase: add an --am option 8af14f0859 rebase: move incompatibility checks between backend options a bit earlier be50c938df git-rebase.txt: add more details about behavioral differences of backends befb89ce7c rebase: allow more types of rebases to fast-forward 9a70f3d4ae t3432: make these tests work with either am or merge backends 93122c985a rebase: fix handling of restrict_revision 55d2b6d785 rebase: make sure to pass along the quiet flag to the sequencer 8a997ed132 rebase, sequencer: remove the broken GIT_QUIET handling 7db00f0b3b t3406: simplify an already simple test e98c4269c8 rebase (interactive-backend): fix handling of commits that become empty d48e5e21da rebase (interactive-backend): make --keep-empty the default e0020b2f82 prefix_path: show gitdir when arg is outside repo cc4f2eb828 doc: move credential helper info into gitcredentials(7) bfdd66e72f Sync with maint 7ae7e234c7 The fifth batch for 2.26 53c3be2c29 Merge branch 'tb/commit-graph-object-dir' 7b029ebaef Merge branch 'jk/index-pack-dupfix' aa21cc97bd Merge branch 'jk/alloc-cleanups' 883326077a Merge branch 'jh/notes-fanout-fix' f2dcfcc21d Merge branch 'pk/status-of-uncloned-submodule' 78e67cda42 Merge branch 'mt/use-passed-repo-more-in-funcs' df04a31617 Merge branch 'jk/diff-honor-wserrhighlight-in-plumbing' 433b8aac2e Merge branch 'ds/sparse-checkout-harden' 4a77434bc8 Merge branch 'ld/p4-cleanup-processes' 8fb3945037 Merge branch 'jt/connectivity-check-optim-in-partial-clone' 09e48400a3 Merge branch 'jk/get-oid-error-message-i18n' 4dbeecba27 Merge branch 'ag/edit-todo-drop-check' f7f43afb19 Merge branch 'dl/test-must-fail-fixes-2' d8b8d59054 Merge branch 'ag/rebase-avoid-unneeded-checkout' 251187084d Merge branch 'js/rebase-i-with-colliding-hash' c9a33e5e5d Merge branch 'kw/fsmonitor-watchman-racefix' 56ceb64eb0 Merge branch 'mt/threaded-grep-in-object-store' 0da63da794 Merge branch 'jn/promote-proto2-to-default' a14aebeac3 Merge branch 'jk/packfile-reuse-cleanup' daef1b300b Merge branch 'hw/advice-add-nothing' 6141e0cc00 Merge branch 'js/convert-typofix' into maint 4e52c1ae27 Merge branch 'js/ci-squelch-doc-warning' into maint 5cee4ffff8 Merge branch 'jb/multi-pack-index-docfix' into maint b907ca76f0 Merge branch 'ma/diff-doc-clarify-regexp-example' into maint 7137d6089b Merge branch 'ms/doc-bundle-format' into maint 52d620fdc6 Merge branch 'es/submodule-fetch-message-fix' into maint 0ecc7d62f4 Merge branch 'jb/parse-options-message-fix' into maint 1ea6edfd55 Merge branch 'ma/filter-branch-doc-caret' into maint cfa25e197d Merge branch 'km/submodule-doc-use-sm-path' into maint 153a1b46f1 Merge branch 'pb/do-not-recurse-grep-no-index' into maint 8857657cc9 Merge branch 'jt/t5616-robustify' into maint 1f7609b520 Merge branch 'en/fill-directory-fixes-more' into maint f468972671 Merge branch 'bc/misconception-doc' into maint 6e69042e26 Merge branch 'bc/author-committer-doc' into maint 650ed395be Merge branch 'ds/refmap-doc' into maint 80b806f1a8 Merge branch 'bc/actualmente' into maint eceff4ba12 Merge branch 'rt/submodule-i18n' into maint 8a17eb7972 Merge branch 'jk/test-fixes' into maint 54bbadaeca Merge branch 'jk/asan-build-fix' into maint 8dbeba198e Merge branch 'ds/sparse-cone' into maint e361f36f61 Merge branch 'nd/switch-and-restore' into maint 4a60c63a75 Merge branch 'jk/no-flush-upon-disconnecting-slrpc-transport' into maint ad9c895463 Merge branch 'hw/tutorial-favor-switch-over-checkout' into maint 5ae057d9a8 Merge branch 'es/unpack-trees-oob-fix' into maint c17cf77e4e Merge branch 'bc/run-command-nullness-after-free-fix' into maint d0ebd645b1 Merge branch 'en/string-list-can-be-custom-sorted' into maint 9eddeaece1 Merge branch 'jt/sha1-file-remove-oi-skip-cached' into maint 3bba763373 Merge branch 'hw/commit-advise-while-rejecting' into maint 3ab3185f99 pack-objects: support filters with bitmaps 84243da129 pack-bitmap: implement BLOB_LIMIT filtering 4f3bd5606a pack-bitmap: implement BLOB_NONE filtering cc4aa28506 bitmap: add bitmap_unset() function 2aaeb9ac41 rev-list: use bitmap filters for traversal 6663ae0a08 pack-bitmap: basic noop bitmap filter infrastructure 4eb707ebd6 rev-list: allow commit-only bitmap traversals ea047a8eb4 t5310: factor out bitmap traversal comparison 608d9c9365 rev-list: allow bitmaps when counting objects 55cb10f9b5 rev-list: make --count work with --objects 792f811998 rev-list: factor out bitmap-optimized routines d90fe06ea7 pack-bitmap: refuse to do a bitmap traversal with pathspecs 08809c09aa mingw: add a helper function to attach GDB to the current process bfe2bbb47f t5580: test cloning without file://, test fetching via UNC paths de26f02db1 t9001, t9116: avoid pipes a2dc43414c MyFirstContribution: rephrase contact info e03f928e2a rev-list: fallback to non-bitmap traversal when filtering acac50dd8c pack-bitmap: fix leak of haves/wants object lists 551cf8b655 pack-bitmap: factor out type iterator initialization d8437c57fa The fourth batch for 2.26 a3dcf84df0 Merge branch 'js/convert-typofix' 0de2d1409b Merge branch 'js/ci-squelch-doc-warning' 0410c2ba31 Merge branch 'jb/multi-pack-index-docfix' 0d114107f5 Merge branch 'ma/diff-doc-clarify-regexp-example' e99c325bb4 Merge branch 'ms/doc-bundle-format' afa34c5cf3 Merge branch 'es/submodule-fetch-message-fix' db72f8c940 Merge branch 'jb/parse-options-message-fix' 3d2471ba85 Merge branch 'ma/filter-branch-doc-caret' b2099ebb12 Merge branch 'km/submodule-doc-use-sm-path' 44cba9c4b3 Merge branch 'jc/skip-prefix' 556ccd4dd2 Merge branch 'pb/do-not-recurse-grep-no-index' 17e4a1b141 Merge branch 'hw/doc-git-dir' 4cf7f48891 Merge branch 'jk/push-default-doc' b783391018 Merge branch 'jk/clang-sanitizer-fixes' a74c387495 Merge branch 'dt/submodule-rm-with-stale-cache' 3f7553acf5 Merge branch 'jt/t5616-robustify' 341f8a6476 Merge branch 'jk/escaped-wildcard-dwim' b486d2ee81 Merge branch 'jn/pretend-object-doc' 076ee3e8a2 tests: fix --write-junit-xml with subshells 2b0f19fa7a convert: fix typo c444f032e4 color.c: alias RGB colors 8-15 to aixterm colors 1751b09a92 color.c: support bright aixterm colors 4a28eb0ae4 color.c: refactor color_output arguments f696a2b1c8 mailinfo: factor out some repeated header handling ffbea1816d mailinfo: be more liberal with header whitespace f447d0293e mailinfo: simplify parsing of header values b6537d83ee mailinfo: treat header values as C strings ef07659926 sparse-checkout: work with Windows paths 2631dc879d sparse-checkout: create 'add' subcommand 4bf0c06c71 sparse-checkout: extract pattern update from 'set' subcommand 6fb705abcb sparse-checkout: extract add_patterns_from_input() b3fd6cbf29 remote rename/remove: gently handle remote.pushDefault config f2a2327a4a config: provide access to the current line number 923d4a5ca4 remote rename/remove: handle branch..pushRemote config values ceff1a1308 remote: clean-up config callback 1a83068c26 remote: clean-up by returning early to avoid one indentation 88f8576eda pull --rebase/remote rename: document and honor single-letter abbreviations rebase types 145d59f482 config: add '--show-scope' to print the scope of a config value 9a83d088ee submodule-config: add subomdule config scope e37efa40e1 config: teach git_config_source to remember its scope 5c105a842e config: preserve scope in do_git_config_sequence 6766e41b8a config: clarify meaning of command line scoping 6dc905d974 config: split repo scope to local and worktree a5cb4204b6 config: make scope_name non-static and rename it 30183894ea ci: ignore rubygems warning in the "Documentation" job 7a9f8ca805 parse-options: simplify parse_options_dup() c84078573e parse-options: const parse_options_concat() parameters f904f9025f parse-options: factor out parse_options_count() a277d0a67f parse-options: use COPY_ARRAY in parse_options_concat() 517b60564e mailinfo: don't insert header prefix for handle_content_type() a91cc7fad0 strbuf: add and use strbuf_insertstr() eb31044ff7 pack-format: correct multi-pack-index description 9299f84921 diff-options.txt: avoid "regex" overload in example 7378ec90e1 doc: describe Git bundle format f3037657e8 t6024: update for SHA-256 edf04243b2 t6006: make hash size independent 5db24dcffd t6000: abstract away SHA-1-specific constants d341e0805d t5703: make test work with SHA-256 88ed241a7e t5607: make hash size independent 48c10cc0e6 t5318: update for SHA-256 f7ae8e69b6 t5515: make test hash independent e70649bb66 t5321: make test hash independent a30f93b143 t5313: make test hash independent a79eec220b t5309: make test hash independent 796d1383a3 t5302: make hash size independent 417e45e5e3 t4060: make test work with SHA-256 dfa5f53e78 t4211: add test cases for SHA-256 f743e8f5b3 t4211: move SHA-1-specific test cases into a directory 72f936b120 t4013: make test hash independent 5df0f11f07 t3311: make test work with SHA-256 07877f393c t3310: make test work with SHA-256 6025e898d6 t3309: make test work with SHA-256 7b1a1822fe t3308: make test work with SHA-256 94db7e3e93 t3206: make hash size independent db12505c2c t/lib-pack: support SHA-256 303b3c1c46 submodule: add newline on invalid submodule error 887a0fd573 add: change advice config variables used by the add API de93cc14ab The third batch for 2.26 ea46d9097b Merge branch 'mt/sparse-checkout-doc-update' ff5134b2ff Merge branch 'pb/recurse-submodule-in-worktree-fix' b5c71cc33d Merge branch 'es/fetch-show-failed-submodules-atend' 7ab963e122 Merge branch 'en/fill-directory-fixes-more' f52ab33616 Merge branch 'bc/hash-independent-tests-part-7' 25794d6ce9 Merge branch 'km/submodule-add-errmsg' d0e70cd32e Merge branch 'am/checkout-file-and-ref-ref-ambiguity' 76c57fedfa Merge branch 'js/add-p-leftover-bits' 9a5315edfd Merge branch 'js/patch-mode-in-others-in-c' 381e8e9de1 Merge branch 'dl/test-must-fail-fixes' 395518cf7a parse-options: lose an unnecessary space in an error message 079f970971 name-rev: sort tip names before applying 2d53975488 name-rev: release unused name strings 977dc1912b name-rev: generate name strings only if they are better 1c56fc2084 name-rev: pre-size buffer in get_parent_name() ddc42ec786 name-rev: factor out get_parent_name() f13ca7cef5 name-rev: put struct rev_name into commit slab d689d6d82f name-rev: don't _peek() in create_or_update_name() 15a4205d96 name-rev: don't leak path copy in name_ref() 36d2419c9a name-rev: respect const qualifier 71620ca86c name-rev: remove unused typedef 3e2feb0d64 name-rev: rewrite create_or_update_name() a21781011f index-pack: downgrade twice-resolved REF_DELTA to die() dbc27477ff notes.c: fix off-by-one error when decreasing notes fanout e1c5253951 t3305: check notes fanout more carefully and robustly e469afe158 git-filter-branch.txt: wrap "maths" notation in backticks a7df60cac8 commit-graph.h: use odb in 'load_commit_graph_one_fd_st' ad2dd5bb63 commit-graph.c: remove path normalization, comparison 13c2499249 commit-graph.h: store object directory in 'struct commit_graph' 0bd52e27e3 commit-graph.h: store an odb in 'struct write_commit_graph_context' f38c92452d t7400: testcase for submodule status on unregistered inner git repos 5290d45134 tree-walk.c: break circular dependency with unpack-trees f998a3f1e5 sparse-checkout: fix cone mode behavior mismatch d2e65f4c90 sparse-checkout: improve docs around 'set' in cone mode e53ffe2704 sparse-checkout: escape all glob characters on write e55682ea26 sparse-checkout: use C-style quotes in 'list' subcommand bd64de42de sparse-checkout: unquote C-style strings over --stdin d585f0e799 sparse-checkout: write escaped patterns in cone mode 4f52c2ce6c sparse-checkout: properly match escaped characters 9abc60f801 sparse-checkout: warn on globs in cone patterns 145136a95a C: use skip_prefix() to avoid hardcoded string length 04e5b3f0b4 submodule foreach: replace $path with $sm_path in example 1793280e91 t5318: don't pass non-object directory to '--object-dir' da8063522f diff: move diff.wsErrorHighlight to "basic" config b98d188581 sha1-file: allow check_object_signature() to handle any repo 2dcde20e1c sha1-file: pass git_hash_algo to hash_object_file() 7ad5c44d9c sha1-file: pass git_hash_algo to write_object_file_prepare() c8123e72f6 streaming: allow open_istream() to handle any repo 5ec9b8accd pack-check: use given repo's hash_algo at verify_packfile() a651946730 cache-tree: use given repo's hash_algo at verify_one() eb999b3295 diff: make diff_populate_filespec() honor its repo argument 5b0ca878e0 Sync with maint 344ee18728 The second batch 53a83299c7 Merge branch 'bc/misconception-doc' c9ccf9d09b Merge branch 'bc/author-committer-doc' 0d0fa20c40 Merge branch 'ss/t6025-modernize' 7050624abc Merge branch 'lh/bool-to-type-bool' 4b69f29271 Merge branch 'ds/refmap-doc' aff812ce3c Merge branch 'bc/actualmente' 38fb56e92a Merge branch 'rt/submodule-i18n' f0940743fa Merge branch 'js/builtin-add-i-cmds' 0afeb3fdf4 Merge branch 'jk/test-fixes' 808dab2b58 Merge branch 'jk/asan-build-fix' fec1ff97c2 Merge branch 'sg/completion-worktree' c7372c9e2c Merge branch 'jn/test-lint-one-shot-export-to-shell-function' 11ad30b887 Merge branch 'hi/gpg-mintrustlevel' 96aef8f684 Merge branch 'am/test-pathspec-f-f-error-cases' d52adee779 Merge branch 'ds/graph-horizontal-edges' 6909474491 Merge branch 'am/update-pathspec-f-f-tests' 043426c8fd Merge branch 'ds/sparse-cone' 34246a1a3c Merge branch 'hi/indent-text-with-tabs-in-editorconfig' 8dd40c0472 traverse_trees(): use stack array for name entries 667b76ec58 walker_fetch(): avoid raw array length computation 9734b74a8f normalize_path_copy(): document "dst" size expectations 43f33e492a git-p4: avoid leak of file handle when cloning 19fa5ac333 git-p4: check for access to remote host earlier 6026aff5bb git-p4: cleanup better on error exit ca5b5cce62 git-p4: create helper function importRevisions() 4c1d58675d git-p4: disable some pylint warnings, to get pylint output to something manageable 5c3d5020e6 git-p4: add P4CommandException to report errors talking to Perforce 837b3a6376 git-p4: make closeStreams() idempotent b0418303b1 sha1-name: mark get_oid() error messages for translation 2df1aa239c fetch: forgo full connectivity check if --filter 50033772d5 connected: verify promisor-ness of partial clone d82ad54945 git: update documentation for --git-dir 0ad7144999 .mailmap: map Yi-Jyun Pan's email c56c48dd07 grep: ignore --recurse-submodules if --no-index is given 8b2a1928f0 doc: drop "explicitly given" from push.default description cf82bff73f obstack: avoid computing offsets from NULL pointer 3cd309c16f xdiff: avoid computing non-zero offset from NULL pointer d20bc01a51 avoid computing zero offsets from NULL pointer 7edee32985 git rm submodule: succeed if .gitmodules index stat info is zero bc3f657f71 t1506: drop space after redirection operator e5d7b2f65c t1400: avoid "test" string comparisons 5a5445d878 rebase-interactive: warn if commit is dropped with `rebase --edit-todo' 1da5874c1b sequencer: move check_todo_list_from_file() to rebase-interactive.c c7a6207591 Sync with maint 7210ca4ee5 .mailmap: fix GGG authoship screwup 37a63faae5 t4124: only mark git command with test_must_fail a8c663cf65 t3507: use test_path_is_missing() 2def7f017c t3507: fix indentation e8a1c686ae t3504: do check for conflict marker after failed cherry-pick 1c9fd32fd2 t3419: stop losing return code of git command c232ffa83c t3415: increase granularity of test_auto_{fixup,squash}() a781cd6fef t3415: stop losing return codes of git commands 86ce6e0dd1 t3310: extract common notes_merge_files_gone() 245b9ba0ba t3030: use test_path_is_missing() 4a6f11fd7b t2018: replace "sha" with "oid" 62e80fcb48 t2018: don't lose return code of git commands 30c0367668 t2018: teach do_checkout() to accept `!` arg 40caa5366a t2018: be more discerning when checking for expected exit codes b54128bb0b t5616: make robust to delta base change 4c616c2ba1 merge-recursive: use subtraction to flip stage ee798742bd merge-recursive: silence -Wxor-used-as-pow warning 39e21c6ef5 verify_filename(): handle backslashes in "wildcards are pathspecs" rule a0ba80001a .mailmap: fix erroneous authorship for Johannes Schindelin 3b2885ec9b submodule: fix status of initialized but not cloned submodules ace912bfb8 t7400: add a testcase for submodule status on empty dirs 4bb4fd4290 MyFirstContribution: add avenues for getting help 9e6d3e6417 sparse-checkout: detect short patterns 41de0c6fbc sparse-checkout: cone mode does not recognize "**" 7aa9ef2fca sparse-checkout: fix documentation typo for core.sparseCheckoutCone 47dbf10d8a clone: fix --sparse option with URLs 3c754067a1 sparse-checkout: create leading directories d622c34396 t1091: improve here-docs 522e641748 t1091: use check_files to reduce boilerplate 417be08d02 t1300: create custom config file without special characters 3de7ee369b t1300: fix over-indented HERE-DOCs 329e6ec397 config: fix typo in variable name 767a9c417e rebase -i: stop checking out the tip of the branch to rebase dfaed02862 fsmonitor: update documentation for hook version and watchman hooks e4e1e8342a fsmonitor: add fsmonitor hook scripts for version 2 d031049da3 completion: add support for sparse-checkout a402723e48 doc: sparse-checkout: mention --cone option 26027625dd rebase -i: also avoid SHA-1 collisions with missingCommitsCheck b6992261de rebase -i: re-fix short SHA-1 collision d859dcad94 parse_insn_line(): improve error message when parsing failed d2ea031046 pack-bitmap: don't rely on bitmap_git->reuse_objects 92fb0db94c pack-objects: add checks for duplicate objects bb514de356 pack-objects: improve partial packfile reuse ff483026a9 builtin/pack-objects: introduce obj_is_packed() e704fc7978 pack-objects: introduce pack.allowPackReuse 2f4af77699 csum-file: introduce hashfile_total() 8ebf529661 pack-bitmap: simplify bitmap_has_oid_in_uninteresting() 59b2829ec5 pack-bitmap: uninteresting oid can be outside bitmapped packfile 40d18ff8c6 pack-bitmap: introduce bitmap_walk_contains() 14fbd26044 ewah/bitmap: introduce bitmap_word_alloc() bc7a3d4dc0 The first batch post 2.25 cycle 09e393d913 Merge branch 'nd/switch-and-restore' 45f47ff01d Merge branch 'jk/no-flush-upon-disconnecting-slrpc-transport' 0f501545a3 Merge branch 'hw/tutorial-favor-switch-over-checkout' 36da2a8635 Merge branch 'es/unpack-trees-oob-fix' 42096c778d Merge branch 'bc/run-command-nullness-after-free-fix' 1f10b84e43 Merge branch 'en/string-list-can-be-custom-sorted' a3648c02a2 Merge branch 'en/simplify-check-updates-in-unpack-trees' e26bd14c8d Merge branch 'jt/sha1-file-remove-oi-skip-cached' 9403e5dcdd Merge branch 'hw/commit-advise-while-rejecting' 237a83a943 Merge branch 'dl/credential-netrc' a9472afb63 submodule.c: use get_git_dir() instead of get_git_common_dir() 129510a067 t2405: clarify test descriptions and simplify test 4eaadc8493 t2405: use git -C and test_commit -C instead of subshells 773c60a45e t7410: rename to t2405-worktree-submodule.sh 7a2dc95cbc docs: mention when increasing http.postBuffer is valuable 1b13e9032f doc: dissuade users from trying to ignore tracked files 69e104d70e doc: provide guidance on user.name format 813f6025a5 docs: expand on possible and recommended user config options bc94e5862a doc: move author and committer information to git-commit(1) 7979dfe1d4 l10n: Update Catalan translation 81e3db42f3 templates: fix deprecated type option `--bool` c513a958b6 t6025: use helpers to replace test -f 70789843bd t6025: modernize style 6a7aca6f01 doc: rm: synchronize description 856249c62a docs: use "currently" for the present time b40a50264a fetch: document and test --refmap="" a9ae8fde2e t3404: directly test the behavior of interest 22a69fda19 git-rebase.txt: update description of --allow-empty-message f1928f04b2 grep: use no. of cores as the default no. of threads 70a9fef240 grep: move driver pre-load out of critical section 1184a95ea2 grep: re-enable threads in non-worktree case 6c307626f1 grep: protect packed_git [re-]initialization c441ea4edc grep: allow submodule functions to run in parallel d7992421e1 submodule-config: add skip_if_read option to repo_read_gitmodules() 1d1729caeb grep: replace grep_read_mutex by internal obj read lock 31877c9aec object-store: allow threaded access to object reading b1fc9da1c8 replace-object: make replace operations thread-safe d5b0bac528 grep: fix racy calls in grep_objects() faf123c730 grep: fix race conditions at grep_submodule() c3a5bb31c1 grep: fix race conditions on userdiff calls 0222540827 fetch: emphasize failure during submodule fetch 232378479e Sync with maint e4837b4406 t7800: don't rely on reuse_worktree_file() fbce03d329 t4018: drop "debugging" cat from hunk-header tests f65d07fffa Makefile: use compat regex with SANITIZE=address 849e43cc18 built-in add -i: accept open-ended ranges again d660a30ceb built-in add -i: do not try to `patch`/`diff` an empty list of files a4ffbbbb99 submodule.c: mark more strings for translation 0cbb60574e dir: point treat_leading_path() warning to the right place ad6f2157f9 dir: restructure in a way to avoid passing around a struct dirent 22705334b9 dir: treat_leading_path() and read_directory_recursive(), round 2 f365bf40a0 clean: demonstrate a bug with pathspecs b6d4d82bd5 msvc: accommodate for vcpkg's upgrade to OpenSSL v1.1.x 277eb5af7c t5604: make hash independent 44b6c05b43 t5601: switch into repository to hash object 7a868c51c2 t5562: use $ZERO_OID 1b8f39fb0d t5540: make hash size independent a8c17e3bd6 t5537: make hash size independent 832072219c t5530: compute results based on object length 74ad99b1d8 t5512: abstract away SHA-1-specific constants ba1be1ab45 t5510: make hash size independent cba472d3ad t5504: make hash algorithm independent 82d5aeb1e6 t5324: make hash size independent 3c5e65cac1 t5319: make test work with SHA-256 235d3cddb8 t5319: change invalid offset for SHA-256 compatibility 1d86c8f0ce t5318: update for SHA-256 525a7f1769 t4300: abstract away SHA-1-specific constants 7a1bcb251b t4204: make hash size independent cb78f4f0fe t4202: abstract away SHA-1-specific constants 717c939d8f t4200: make hash size independent 08a9dd891c t4134: compute appropriate length constant 215b60bf07 t4066: compute index line in diffs 194264c185 t4054: make hash-size independent 7d5ecd775d completion: list paths and refs for 'git worktree add' 3027e4f9a8 completion: list existing working trees for 'git worktree' subcommands 3c86f6cde8 completion: simplify completing 'git worktree' subcommands and options 367efd54b3 completion: return the index of found word from __git_find_on_cmdline() d447fe2bfe completion: clean up the __git_find_on_cmdline() helper function 2712e91564 t9902-completion: add tests for the __git_find_on_cmdline() helper 54887b4689 gpg-interface: add minTrustLevel as a configuration option 684ceae32d fetch: default to protocol version 2 33166f3a1f protocol test: let protocol.version override GIT_TEST_PROTOCOL_VERSION 8a1b0978ab test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate b9ab170752 config doc: protocol.version is not experimental 07ef3c6604 fetch test: use more robust test for filtered objects d6509da620 fetch test: mark test of "skipping" haves as v0-only a7fbf12f2f t/check-non-portable-shell: detect "FOO= shell_func", too c7973f249e fetch test: avoid use of "VAR= cmd" with a shell function bf66db37f1 add: use advise function to display hints c958d3bd0a graph: fix collapse of multiple edges 8588932e20 graph: add test to demonstrate horizontal line bug d0d0a357a1 t: directly test parse_pathspec_file() 568cabb2fe t: fix quotes tests for --pathspec-from-file f94f7bd00d t: add tests for error conditions with --pathspec-from-file b2627cc3d4 ci: include the built-in `git add -i` in the `linux-gcc` job 12acdf573a built-in add -p: handle Escape sequences more efficiently e118f06396 built-in add -p: handle Escape sequences in interactive.singlekey mode 04f816b125 built-in add -p: respect the `interactive.singlekey` config setting a5e46e6b01 terminal: add a new function to read a single keystroke 9ea416cb51 terminal: accommodate Git for Windows' default terminal 94ac3c31f7 terminal: make the code of disable_echo() reusable 08b1ea4c39 built-in add -p: handle diff.algorithm 180f48df69 built-in add -p: support interactive.diffFilter 1e4ffc765d t3701: adjust difffilter test c81638541c submodule add: show 'add --dry-run' stderr when aborting 8da2c57629 fsmonitor: handle version 2 of the hooks that will use opaque token 56c6910028 fsmonitor: change last update timestamp on the index_state to opaque token d0654dc308 Git 2.25 b4615e40a8 Merge tag 'l10n-2.25.0-rnd1' of git://github.com/git-l10n/git-po 4d924528d8 Revert "Merge branch 'ra/rebase-i-more-options'" ddc12c429b l10n: zh_CN: for git v2.25.0 l10n round 1 e23b95e75b Merge branch 'master' of github.com:Softcatala/git-po into git-po-master 1cf4836865 Merge branch 'js/mingw-loosen-overstrict-tree-entry-checks' d78a1968c5 Merge branch 'ma/config-advice-markup-fix' a20ae3ee29 l10n: Update Catalan translation 49e268e23e mingw: safeguard better against backslashes in file names 4c6c7971e0 unpack-trees: correctly compute result count 63a5650a49 l10n: de.po: Update German translation v2.25.0 round 1 75449c1b39 l10n: de.po: Reword generation numbers 6b6a9803fb l10n: bg.po: Updated Bulgarian translation (4800t) 3901d2c6bd config/advice.txt: fix description list separator 7a6a90c6ec Git 2.25-rc2 1f5f3ffe5c Merge branch 'ds/graph-assert-fix' a4e4140ac9 Merge branch 'tm/doc-submodule-absorb-fix' 202f68b252 Merge branch 'pm/am-in-body-header-doc-update' 7e65f8638e Merge branch 'jb/doc-multi-pack-idx-fix' c5dc20638b Merge branch 'do/gitweb-typofix-in-comments' fe47c9cb5f Merge https://github.com/prati0100/git-gui a1087c9367 graph: fix lack of color in horizontal lines 0d251c3291 graph: drop assert() for merge with two collapsing parents 4d8cab95cc transport: don't flush when disconnecting stateless-rpc helper 573117dfa5 unpack-trees: watch for out-of-range index position e701bab3e9 restore: invalidate cache-tree when removing entries with --staged 1a7e454dd6 doc/gitcore-tutorial: fix prose to match example command fa74180d08 checkout: don't revert file on ambiguous tracking branches 2957709bd4 parse_branchname_arg(): extract part as new function 5020f6806a t2018: improve style of if-statement 7ffb54618b t2018: add space between function name and () 63ab08fb99 run-command: avoid undefined behavior in exists_in_PATH 065027ee1a string-list: note in docs that callers can specify sorting function 26f924d50e unpack-trees: exit check_updates() early if updates are not wanted 042ed3e048 The final batch before -rc2 0f1930cd1b Merge branch 'ds/sparse-cone' 037f067587 Merge branch 'ds/commit-graph-set-size-mult' f25f04edca Merge branch 'en/merge-recursive-oid-eq-simplify' c20d4fd44a Merge branch 'ds/sparse-list-in-cone-mode' a578ef9e63 Merge branch 'js/mingw-loosen-overstrict-tree-entry-checks' c4117fcb97 Merge branch 'pb/clarify-line-log-doc' 556f0258df Merge branch 'ew/packfile-syscall-optim' 5814d44d9b doc: submodule: fix typo for command absorbgitdirs 7047f75f22 editorconfig: indent text files with tabs 60440d72db sha1-file: document how to use pretend_object_file 7fdc5f296f l10n: es: 2.25.0 round #1 f8740c586b am: document that Date: can appear as an in-body header 4e2c4c0d4f gitweb: fix a couple spelling errors in comments 421c0ffb02 multi-pack-index: correct configuration in documentation 757ff352bd Documentation/git-sparse-checkout.txt: fix a typo 0d2116c644 Merge branch 'zs/open-current-file' 9d48668cd5 l10n: sv.po: Update Swedish translation (4800t0f0u) 3a05aacddd Merge branch 'fr_v2.25.0_rnd1' of github.com:jnavila/git into master 4c5081614c l10n: fr.po v2.25.0 rnd 1 5bb457409c l10n: vi(4800t): Updated Vietnamese translation v2.25.0 63020f175f commit-graph: prefer default size_mult when given zero 224c7d70fa mingw: only test index entries for backslashes, not tree entries 9c8a294a1a sha1-file: remove OBJECT_INFO_SKIP_CACHED 8679ef24ed Git 2.25-rc1 a82027e9e6 Merge branch 'js/use-test-tool-on-path' 13432fc6dd Merge branch 'js/mingw-reserved-filenames' e0e1ac5db0 Merge branch 'en/rebase-signoff-fix' b76a244c9d Merge branch 'em/freebsd-cirrus-ci' bc855232bc Merge branch 'bk/p4-misc-usability' 763a59e71c merge-recursive: remove unnecessary oid_eq function 44143583b7 sparse-checkout: use extern for global variables d6a6263f5f Merge branch 'translation_191231' of github.com:l10n-tw/git-po into git-po-master 13185fd241 l10n: zh_TW.po: update translation for v2.25.0 round 1 786f4d2405 git-gui: allow opening currently selected file in default app 4fd683b6a3 sparse-checkout: document interactions with submodules de11951b03 sparse-checkout: list directories in cone mode 0d3ce942b0 l10n: it.po: update the Italian translation for Git 2.25.0 578c793731 l10n: git.pot: v2.25.0 round 1 (119 new, 13 removed) 173fff68da Merge tag 'v2.25.0-rc0' into git-po-master f1842ff531 t2018: remove trailing space from test description 20a67e8ce9 t3008: find test-tool through path lookup 9e341f62ca l10n: Update Catalan translation 4e61b2214d packfile: replace lseek+read with pread ace0f86c7f doc: log, gitk: line-log arguments must exist in starting revision 2be45868a8 doc: log, gitk: document accepted line-log diff formats 280738c36e packfile: remove redundant fcntl F_GETFD/F_SETFD 0a76bd7381 mailmap: mask accentless variant for Công Danh 99c33bed56 Git 2.25-rc0 d2189a721c Merge branch 'en/fill-directory-fixes' 8be0a428d6 Merge branch 'rs/test-cleanup' 65099bd775 Merge branch 'mr/bisect-save-pointer-to-const-string' c0c6a74594 Merge branch 'rs/xdiff-ignore-ws-w-func-context' 45b96a6fa1 Merge branch 'js/add-p-in-c' ccc292e862 Merge branch 'jc/drop-gen-hdrs' dfee504bee Merge branch 'ja/doc-markup-cleanup' 87cbb1ca66 Merge branch 'rs/ref-read-cleanup' 20aa6d88b7 Merge branch 'rb/p4-lfs' fcd5b55f56 Merge branch 'pb/submodule-doc-xref' 4bfc9ccfb6 Merge branch 'mr/bisect-use-after-free' ba6b66281e Merge branch 'ln/userdiff-elixir' bd72a08d6c Merge branch 'ds/sparse-cone' f3c520e17f Merge branch 'sg/name-rev-wo-recursion' 6514ad40a1 Merge branch 'ra/t5150-depends-on-perl' 17066bea38 Merge branch 'dl/format-patch-notes-config-fixup' 135365dd99 Merge branch 'am/pathspec-f-f-checkout' ff0cb70d45 Merge branch 'am/pathspec-from-file' 4dc42c6c18 mingw: refuse paths containing reserved names 98d9b23e90 mingw: short-circuit the conversion of `/dev/null` to UTF-16 c480eeb574 commit --interactive: make it work with the built-in `add -i` cee6cb7300 built-in add -p: implement the "worktree" patch modes 52628f94fc built-in add -p: implement the "checkout" patch modes 6610e4628a built-in stash: use the built-in `git add -p` if so configured 90a6bb98d1 legacy stash -p: respect the add.interactive.usebuiltin setting 36bae1dc0e built-in add -p: implement the "stash" and "reset" patch modes d2a233cb8b built-in add -p: prepare for patch modes other than "stage" 761e3d26bb sparse-checkout: improve OS ls compatibility 6579d93a97 contrib/credential/netrc: work outside a repo 1c78c78d25 contrib/credential/netrc: make PERL_PATH configurable b5a9d7afcd CI: add FreeBSD CI support via Cirrus-CI b441717256 t1507: inline full_name() 9291e6329e t1507: run commands within test_expect_success 5236fce6b4 t1507: stop losing return codes of git commands 10812c2337 t1501: remove use of `test_might_fail cp` 62d58cda69 t1409: use test_path_is_missing() b87b02cfe6 t1409: let sed open its own input file 9b92070e52 t1307: reorder `nongit test_must_fail` 3595d10c26 t1306: convert `test_might_fail rm` to `rm -f` f511bc02ed t0020: use ! check_packed_refs_marked f6041abdcd t0020: don't use `test_must_fail has_cr` f46c243e66 t0003: don't use `test_must_fail attr_check` 99c049bc4c t0003: use test_must_be_empty() 3738439c77 t0003: use named parameters in attr_check() 7717242014 t0000: replace test_must_fail with run_sub_test_lib_test_err() b8afb908c2 t/lib-git-p4: use test_path_is_missing() 4fe7e43c53 rebase: fix saving of --signoff state for am-based rebases 6836d2fe06 dir.c: use st_add3() for allocation size c847dfafee dir: consolidate similar code in treat_directory() 777b420347 dir: synchronize treat_leading_path() and read_directory_recursive() b9670c1f5e dir: fix checks on common prefix directory 5c4f55f1f6 commit: honor advice.statusHints when rejecting an empty commit 23cbe427c4 Merge branch 'py/console-close-esc' 124a895811 t4015: improve coverage of function context test 509efef789 commit: forbid --pathspec-from-file --all 12029dc57d t3434: mark successful test as such e0f9095aaa notes.h: fix typos in comment 675ef6bab8 t6030: don't create unused file 01ed17dc8c t5580: don't create unused file f670adb49b t3501: don't create unused file 1e1ccbfdd3 git-gui: allow closing console window with Escape 7c5cea7242 bisect--helper: convert `*_warning` char pointers to char arrays. b02fd2acca The sixth batch 59d0b3be45 Merge branch 'rs/patch-id-use-oid-to-hex' e3b72391d1 Merge branch 'rs/commit-export-env-simplify' 43bf44e23a Merge branch 'rs/archive-zip-code-cleanup' 4438a1a59f Merge branch 'js/t3404-indent-fix' 3a44db2ed2 Merge branch 'dr/branch-usage-casefix' 8bc481f4f6 Merge branch 'sg/t9300-robustify' 011fc2e88e Merge branch 'js/add-i-a-bit-more-tests' d1c0fe8d9b Merge branch 'dl/range-diff-with-notes' 26c816a67d Merge branch 'hw/doc-in-header' f0070a7df9 Merge branch 'rs/xdiff-ignore-ws-w-func-context' 71a7de7a99 Merge branch 'dl/rebase-with-autobase' c9f5fc9114 Merge branch 'dl/test-cleanup' 6d831b8a3e Merge branch 'cs/store-packfiles-in-hashmap' 3beff388b2 Merge branch 'js/builtin-add-i-cmds' 4755a34c47 Merge branch 'dd/time-reentrancy' 37c2619d91 Merge branch 'ag/sequencer-todo-updates' 608e380502 git-p4: show detailed help when parsing options fail e2aed5fd5b git-p4: yes/no prompts should sanitize user text 571fb96573 fix-typo: consecutive-word duplications f371984613 Makefile: drop GEN_HDRS 2e4083198d built-in add -p: show helpful hint when nothing can be staged 54d9d9b2ee built-in add -p: only show the applicable parts of the help text ade246efed built-in add -p: implement the 'q' ("quit") command d6cf873340 built-in add -p: implement the '/' ("search regex") command 9254bdfb4f built-in add -p: implement the 'g' ("goto") command bcdd297b78 built-in add -p: implement hunk editing b38dd9e715 strbuf: add a helper function to call the editor "on an strbuf" 11f2c0dae8 built-in add -p: coalesce hunks after splitting them 510aeca199 built-in add -p: implement the hunk splitting feature 0ecd9d27fc built-in add -p: show different prompts for mode changes and deletions 5906d5de77 built-in app -p: allow selecting a mode change as a "hunk" 47dc4fd5eb built-in add -p: handle deleted empty files 80399aec5a built-in add -p: support multi-file diffs 7584dd3c66 built-in add -p: offer a helpful error message when hunk navigation failed 12c24cf850 built-in add -p: color the prompt and the help text 25ea47af49 built-in add -p: adjust hunk headers as needed e3bd11b4eb built-in add -p: show colored hunks by default 1942ee44e8 built-in add -i: wire up the new C code for the `patch` command f6aa7ecc34 built-in add -i: start implementing the `patch` functionality in C d1b1384d61 userdiff: remove empty subexpression from elixir regex df5be01669 doc: indent multi-line items in list fd5041e127 doc: remove non pure ASCII characters 190a65f9db sparse-checkout: respect core.ignoreCase in cone mode 1d7297513d notes: break set_display_notes() into smaller functions 66f79ee23d config/format.txt: clarify behavior of multiple format.notes cc2bd5c45d gitmodules: link to gitsubmodules guide 99f86bde83 remote: pass NULL to read_ref_full() because object ID is not needed e0ae2447d6 refs: pass NULL to refs_read_ref_full() because object ID is not needed 8c02fe6060 t7004: don't create unused file cb05d6a5ed t4256: don't create unused file c5c4eddd56 dir: break part of read_directory_recursive() out for reuse 072a231016 dir: exit before wildcard fall-through if there is no wildcard 2f5d3847d4 dir: remove stray quote character in comment a2b13367fe Revert "dir.c: make 'git-status --ignored' work within leading directories" 452efd11fb t3011: demonstrate directory traversal failures ea94b16fb8 git-p4: honor lfs.storage configuration variable 51a0a4ed95 bisect--helper: avoid use-after-free d32e065a91 Merge branch 'kk/branch-name-encoding' ad05a3d8e5 The fifth batch 7cc5f89088 Merge branch 'ag/sequencer-continue-leakfix' b089e5e6cb Merge branch 'em/test-skip-regex-illseq' 930078ba39 Merge branch 'hi/gpg-use-check-signature' 08d2f46d0c Merge branch 'bc/t9001-zsh-in-posix-emulation-mode' 7aba2b7fd6 Merge branch 'sg/test-squelch-noise-in-commit-bulk' 55c37d12d3 Merge branch 'jk/perf-wo-git-dot-pm' 41dac79c2f Merge branch 'ds/commit-graph-delay-gen-progress' 5dd1d59d35 Merge branch 'jt/clone-recursesub-ref-advise' dac30e7b5d Merge branch 'as/t7812-missing-redirects-fix' d37cfe3b5c Merge branch 'dl/pretty-reference' 99c4ff1bda Merge branch 'dl/submodule-set-url' 55d607d85b Merge branch 'js/mingw-inherit-only-std-handles' c58ae96fc4 Merge branch 'am/pathspec-from-file' 7c88714262 Merge branch 'po/bundle-doc-clonable' 5d9324e0f4 Merge branch 'ra/rebase-i-more-options' 7034cd094b Sync with Git 2.24.1 09ac67a183 format-patch: move git_config() before repo_init_revisions() 8164c961e1 format-patch: use --notes behavior for format.notes 452538c358 notes: extract logic into set_display_notes() e6e230eeae notes: create init_display_notes() helper 1e6ed5441a notes: rename to load_display_notes() 2866fd284c name-rev: cleanup name_ref() 49f7a2fde9 name-rev: eliminate recursion in name_rev() fee984bcab name-rev: use 'name->tip_name' instead of 'tip_name' e05e8cf074 archive-zip: use enum for compression method 39acfa3d22 git gui: fix branch name encoding error 11de8dd7ef l10n: minor case fix in 'git branch' '--unset-upstream' description 8cf8f9b4aa t3404: fix indentation 4507ecc771 patch-id: use oid_to_hex() to print multiple object IDs 147ee35558 commit: use strbuf_add() to add a length-limited string 559c6fc317 The fourth batch 56e6c16394 Merge branch 'dl/lore-is-the-archive' 3b3d9ea6a8 Merge branch 'jk/lore-is-the-archive' 7cb0d37f6d Merge branch 'tg/perf-remove-stale-result' 403ac1381c Merge branch 'jk/send-pack-check-negative-with-quick' f0cf2fee5d Merge branch 'hi/grep-do-not-return-void' 391fb22ac7 Merge branch 'rs/use-skip-prefix-more' 92b52e1bd6 Merge branch 'rs/simplify-prepare-cmd' 4ba74ca901 Merge branch 'rs/test-cleanup' f233c9f455 Merge branch 'sg/assume-no-todo-update-in-cherry-pick' ef3ce7c4b9 Merge branch 'sg/osx-force-gcc-9' 8c5724c585 name-rev: drop name_rev()'s 'generation' and 'distance' parameters 3a52150301 name-rev: restructure creating/updating 'struct rev_name' instances dd432a6ecf name-rev: restructure parsing commits and applying date cutoff dd090a8a37 name-rev: pull out deref handling from the recursion 766f9e39c0 name-rev: extract creating/updating a 'struct name_rev' into a helper d59fc83697 t6120: add a test to cover inner conditions in 'git name-rev's name_rev() bf43abc6e6 name-rev: use sizeof(*ptr) instead of sizeof(type) in allocation e0c4da6f2a name-rev: avoid unnecessary cast in name_ref() c3794d4ccb name-rev: use strbuf_strip_suffix() in get_rev_name() c593a26348 t6120-describe: modernize the 'check_describe' helper abcf857300 range-diff: clear `other_arg` at end of function f8675343d7 range-diff: mark pointers as const 828765dfe0 t3206: fix incorrect test name 0d9b0d7885 t9300-fast-import: don't hang if background fast-import exits too early 21f57620b2 t9300-fast-import: store the PID in a variable instead of pidfile b4bbbbd5a2 apply --allow-overlap: fix a corner case 89c8559367 git add -p: use non-zero exit code when the diff generation failed e91162be9c t3701: verify that the diff.algorithm config setting is handled 0c3222c4f3 t3701: verify the shown messages when nothing can be added 24be352d52 t3701: add a test for the different `add -p` prompts 8539b46534 t3701: avoid depending on the TTY prerequisite 0f0fba2cc8 t3701: add a test for advanced split-hunk editing 53a06cf39b Git 2.24.1 67af91c47a Sync with 2.23.1 a7312d1a28 Git 2.23.1 7fd9fd94fb Sync with 2.22.2 d9589d4051 Git 2.22.2 5421ddd8d0 Sync with 2.21.1 367f12b7e9 Git 2.21.1 20c71bcf67 Merge branch 'fix-msys2-quoting-bugs' 7d8b676992 mingw: sh arguments need quoting in more circumstances d9061ed9da t7415: drop v2.20.x-specific work-around 04522edbd4 mingw: fix quoting of empty arguments for `sh` 49f7a76d57 mingw: use MSYS2 quoting even when spawning shell scripts e2ba3d6f6d mingw: detect when MSYS2's sh is to be spawned more robustly fc346cb292 Sync with 2.20.2 4cd1cf31ef Git 2.20.2 c154745074 submodule: defend against submodule.update = !command in .gitmodules 4cfc47de25 t7415: adjust test for dubiously-nested submodule gitdirs for v2.20.x d851d94151 Sync with 2.19.3 caccc527ca Git 2.19.3 7c9fbda6e2 Sync with 2.18.2 9877106b01 Git 2.18.2 14af7ed5a9 Sync with 2.17.3 a5ab8d0317 Git 2.17.3 bb92255ebe fsck: reject submodule.update = !command in .gitmodules bdfef0492c Sync with 2.16.6 eb288bc455 Git 2.16.6 68440496c7 test-drop-caches: use `has_dos_drive_prefix()` 9ac92fed5b Sync with 2.15.4 7cdafcaacf Git 2.15.4 e904deb89d submodule: reject submodule.update = !command in .gitmodules d3ac8c3f27 Sync with 2.14.6 66d2a6159f Git 2.14.6 083378cc35 The third batch 88bd37a2d0 Merge branch 'js/pkt-line-h-typofix' 473b431410 Merge branch 'us/unpack-trees-fsmonitor' e0f9ec9027 Merge branch 'sg/test-bool-env' fd952307ec Merge branch 'mh/clear-topo-walk-upon-reset' e547e5a89e Merge branch 'hv/assume-priumax-is-available-anywhere' 88cf80949e Merge branch 'mg/submodule-status-from-a-subdirectory' 8feb47e882 Merge branch 'dl/t5520-cleanup' 6b3cb32f43 Merge branch 'nl/reset-patch-takes-a-tree' 57d46bc602 Merge branch 'mg/doc-submodule-status-cached' 75bd003c7b Merge branch 'js/git-svn-use-rebase-merges' f06dff7b7c Merge branch 'hi/gpg-optional-pkfp-fix' c9208597a9 Merge branch 'pw/sequencer-compare-with-right-parent-to-check-empty-commits' 36fd304d81 Merge branch 'jk/fail-show-toplevel-outside-working-tree' cf91c31688 Merge branch 'sg/unpack-progress-throughput' ef6104581d Merge branch 'pb/submodule-update-fetches' 7fd7a8ab29 Merge branch 'jc/azure-ci-osx-fix-fix' f3c7bfdde2 Merge branch 'dl/range-diff-with-notes' 9502b616f1 Merge branch 'jh/userdiff-python-async' 76c68246c6 Merge branch 'ec/fetch-mark-common-refs-trace2' 995b1b1411 Merge branch 'dd/rebase-merge-reserves-onto-label' f7998d9793 Merge branch 'js/builtin-add-i' 917d0d6234 Merge branch 'js/rebase-r-safer-label' 56d3ce82b0 Merge branch 'ep/guard-kset-tar-headers' 2763530048 Merge branch 'jg/revert-untracked' fa38ab68b0 git-gui: revert untracked files by deleting them d9c6469f38 git-gui: update status bar to track operations 29a9366052 git-gui: consolidate naming conventions 0bb313a552 xdiff: unignore changes in function context 2ddcccf97a Merge branch 'win32-accommodate-funny-drive-names' 65d30a19de Merge branch 'win32-filenames-cannot-have-trailing-spaces-or-periods' 5532ebdeb7 Merge branch 'fix-mingw-quoting-bug' 76a681ce9c Merge branch 'dubiously-nested-submodules' dd53ea7220 Merge branch 'turn-on-protectntfs-by-default' f82a97eb91 mingw: handle `subst`-ed "DOS drives" 7f3551dd68 Merge branch 'disallow-dotgit-via-ntfs-alternate-data-streams' d2c84dad1c mingw: refuse to access paths with trailing spaces or periods 379e51d1ae quote-stress-test: offer to test quoting arguments for MSYS2 sh 817ddd64c2 mingw: refuse to access paths with illegal characters cc756edda6 unpack-trees: let merged_entry() pass through do_add_entry()'s errors 7530a6287e quote-stress-test: allow skipping some trials 35edce2056 t6130/t9350: prepare for stringent Win32 path validation 55953c77c0 quote-stress-test: accept arguments to test via the command-line ad15592529 tests: add a helper to stress test argument quoting a8dee3ca61 Disallow dubiously-nested submodule git directories 9102f958ee protect_ntfs: turn on NTFS protection by default 91bd46588e path: also guard `.gitmodules` against NTFS Alternate Data Streams 6d8684161e mingw: fix quoting of arguments 3a85dc7d53 is_ntfs_dotgit(): speed it up 7c3745fc61 path: safeguard `.git` against NTFS Alternate Streams Accesses 288a74bcd2 is_ntfs_dotgit(): only verify the leading segment a62f9d1ace test-path-utils: offer to run a protectNTFS/protectHFS benchmark cae0bc09ab rebase: fix format.useAutoBase breakage 945dc55dda format-patch: teach --no-base 700e006c5d t4014: use test_config() a749d01e1d format-patch: fix indentation 0c47e06176 t3400: demonstrate failure with format.useAutoBase d9b31db2c4 t7700: stop losing return codes of git commands 3699d69df0 t7700: make references to SHA-1 generic dcf9a748ca t7700: replace egrep with grep cfe5eda02a t7700: consolidate code into test_has_duplicate_object() ae475afc0f t7700: consolidate code into test_no_missing_in_packs() 14b7664df8 doc: replace LKML link with lore.kernel.org d23f9c8e04 RelNotes: replace Gmane with real Message-IDs dcee037228 doc: replace MARC links with lore.kernel.org a9aecc7abb checkout, restore: support the --pathspec-from-file option cfd9376c1d doc: restore: synchronize description 8ea1189eac doc: checkout: synchronize description 6fdc9ad259 doc: checkout: fix broken text reference 1d022bb43f doc: checkout: remove duplicate synopsis bebb5d6d6b add: support the --pathspec-from-file option 21bb3083c3 cmd_add: prepare for next patch 4778452597 Merge branch 'prevent-name-squatting-on-windows' a7b1ad3b05 Merge branch 'jk/fast-import-unsafe' 525e7fba78 path.c: document the purpose of `is_ntfs_dotgit()` e1d911dd4c mingw: disallow backslash characters in tree objects' file names 0060fd1511 clone --recurse-submodules: prevent name squatting on Windows a52ed76142 fast-import: disallow "feature import-marks" by default 68061e3470 fast-import: disallow "feature export-marks" by default 019683025f fast-import: delay creating leading directories for export-marks e075dba372 fast-import: stop creating leading directories for import-marks 11e934d56e fast-import: tighten parsing of boolean command line options 816f806786 t9300: create marks files for double-import-marks test f94804c1f2 t9300: drop some useless uses of cat 4f3e57ef13 submodule--helper: advise on fatal alternate error 10c64a0b3c Doc: explain submodule.alternateErrorStrategy ec48540fe8 packfile.c: speed up loading lots of packfiles 3ba3720b3f mingw: forbid translating ERROR_SUCCESS to an errno value a4fb016ba1 pkt-line: fix a typo 0109d676f9 mingw: use {gm,local}time_s as backend for {gm,local}time_r e714b898c6 t7812: expect failure for grep -i with invalid UTF-8 data 228f53135a The second batch 6c630f237e Merge branch 'jk/gitweb-anti-xss' 3288d99c92 Merge branch 'ar/install-doc-update-cmds-needing-the-shell' 4775e02a5c Merge branch 'ma/t7004' a6c6f8d02a Merge branch 'js/complete-svn-recursive' 3ae8defaf9 Merge branch 'jk/send-pack-remote-failure' aec3b2e24f Merge branch 'jc/fsmonitor-sanity-fix' 4ab9616c76 Merge branch 'sg/skip-skipped-prereq' 723a8adba5 Merge branch 'ds/test-read-graph' 9da3948781 Merge branch 'rs/use-copy-array-in-mingw-shell-command-preparation' 406ca29e0d Merge branch 'rs/parse-options-dup-null-fix' fce9e836d3 Merge branch 'jt/fetch-remove-lazy-fetch-plugging' 8faff3899e Merge branch 'jk/optim-in-pack-idx-conversion' ef8f621045 Merge branch 'dl/complete-rebase-onto' 3c3e5d0ea2 Merge branch 'tg/stash-refresh-index' 43c5fe1c1d Merge branch 'nn/doc-rebase-merges' 6511cb33c9 Merge branch 'dd/sequencer-utf8' f165457618 Merge branch 'jk/remove-sha1-to-hex' a774064fb0 Merge branch 'dj/typofix-merge-strat' ca5c8aa8e1 Merge branch 'rj/bundle-ui-updates' d2489ce92c Merge branch 'rs/skip-iprefix' 376e7309e1 Merge branch 'ln/userdiff-elixir' 9a5d34c6dc Merge branch 'py/shortlog-list-options-for-log' d3096d2ba6 Merge branch 'en/doc-typofix' 26f20fa3fc Merge branch 'ns/test-desc-typofix' ffd130a363 Merge branch 'en/t6024-style' 5149902ff9 Merge branch 'en/misc-doc-fixes' bcb06e204c Merge branch 'js/fetch-multi-lockfix' d08daec001 Merge branch 'rs/trace2-dots' fc7b26c907 Merge branch 'kw/fsmonitor-watchman-fix' bad5ed39cd Merge branch 'cb/curl-use-xmalloc' 7ab2088255 Merge branch 'rt/fetch-message-fix' f089ddd56a Merge branch 'es/myfirstcontrib-updates' 3c90710c0c Merge branch 'hw/config-doc-in-header' d4924ea7c3 Merge branch 'dl/doc-diff-no-index-implies-exit-code' 5444d52866 Merge branch 'js/vreportf-wo-buffering' 05fc6471e3 Merge branch 'pb/no-recursive-reset-hard-in-worktree-add' ecbddd16bb Merge branch 'pb/help-list-gitsubmodules-among-guides' 532d983823 Merge branch 'sg/blame-indent-heuristics-is-now-the-default' dfc03e48ec Merge branch 'mr/clone-dir-exists-to-path-exists' fac9ab1419 Merge branch 'ma/bisect-doc-sample-update' a2b0451434 Merge branch 'js/git-path-head-dot-lock-fix' 0be5caf97c Merge branch 'jc/log-graph-simplify' 0e07c1cd83 Merge branch 'jk/cleanup-object-parsing-and-fsck' 2e697ced9d built-in add -i: offer the `quit` command d7633578b5 built-in add -i: re-implement the `diff` command 8746e07277 built-in add -i: implement the `patch` command ab1e1cccaf built-in add -i: re-implement `add-untracked` in C c54ef5e424 built-in add -i: re-implement `revert` in C a8c45be939 built-in add -i: implement the `update` command f37c226454 built-in add -i: prepare for multi-selection commands c08171d156 built-in add -i: allow filtering the modified files list 0c3944a628 add-interactive: make sure to release `rev.prune_data` 4d0375ca24 mingw: do set `errno` correctly when trying to restrict handle inheritance 867fc7f310 grep: don't return an expression from pcre2_free() c64368e3a2 t9001: avoid including non-trailing NUL bytes in variables 72b006f4bf gpg-interface: prefer check_signature() for GPG verification 7187c7bbb8 t4210: skip i18n tests that don't work on FreeBSD b5ab03bcb6 archive-zip.c: switch to reentrant localtime_r ccd469450a date.c: switch to reentrant {gm,local}time_r 271c351b2f t7811: don't create unused file 65efb42862 t9300: don't create unused file f6b9413baf sequencer: fix a memory leak in sequencer_continue() 3eae30e464 doc: replace public-inbox links with lore.kernel.org 46c67492aa doc: recommend lore.kernel.org over public-inbox.org 5cf7a17dfb send-pack: use OBJECT_INFO_QUICK to check negative objects 17a4ae92ea t7700: s/test -f/test_path_is_file/ d2eee32a89 t7700: move keywords onto their own line 7a1c8c2346 t7700: remove spaces after redirect operators 09279086e8 t7700: drop redirections to /dev/null 756ee7fc9f t7501: stop losing return codes of git commands 38c1aa01de t7501: remove spaces after redirect operators 763b47bafa t5703: stop losing return codes of git commands eacaa1c180 t5703: simplify one-time-sed generation logic a29b2429e5 t5317: use ! grep to check for no matching lines 6c37f3ec1b t5317: stop losing return codes of git commands b66e0a1773 t4138: stop losing return codes of git commands afd43c9905 t4015: use test_write_lines() 946d2353a3 t4015: stop losing return codes of git commands 50cd31c652 t3600: comment on inducing SIGPIPE in `git rm` 3b737381d8 t3600: stop losing return codes of git commands 0d913dfa7e t3600: use test_line_count() where possible 29a40b5a67 t3301: stop losing return codes of git commands 9b5a9fa60a t0090: stop losing return codes of git commands 17aa9d9c1a t0014: remove git command upstream of pipe 77a946be98 apply-one-time-sed.sh: modernize style 176441bfb5 ci: build Git with GCC 9 in the 'osx-gcc' build job ed254710ee test: use test_must_be_empty F instead of test_cmp empty F c74b3cbb83 t7812: add missing redirects 213dabf49d test: use test_must_be_empty F instead of test -z $(cat F) c93a5aaec8 t1400: use test_must_be_empty 6e4826ea75 t1410: use test_line_count a5d04a3ef9 t1512: use test_line_count 54a7a64613 run-command: use prepare_git_cmd() in prepare_cmd() 2059e79c0d name-rev: use skip_prefix() instead of starts_with() 1768aaf01d push: use skip_prefix() instead of starts_with() ec6ee0c07a shell: use skip_prefix() instead of starts_with() 7e412e8a34 fmt-merge-msg: use skip_prefix() instead of starts_with() a6293f5d28 fetch: use skip_prefix() instead of starts_with() 13ca8fb79e t5150: skip request-pull test if Perl is disabled ecc0869080 commit-graph: use start_delayed_progress() 44a4693bfc progress: create GIT_PROGRESS_DELAY 528d9e6d01 t/perf: don't depend on Git.pm b8dcc45387 perf-lib: use a single filename for all measurement types fc42f20e24 test-lib-functions: suppress a 'git rev-parse' error in 'test_commit_bulk' d82dfa7f5b rebase -i: finishing touches to --reset-author-date 1f3aea22c7 submodule: fix 'submodule status' when called from a subdirectory 393adf7a6f sequencer: directly call pick_commits() from complete_action() a2dd67f105 rebase: fill `squash_onto' in get_replay_opts() 3f34f2d8a4 sequencer: move the code writing total_nr on the disk to a new function 34065541e3 sequencer: update `done_nr' when skipping commands in a todo list 8638114e06 sequencer: update `total_nr' when adding an item to a todo list 0aa0c2b2ec revision: free topo_walk_info before creating a new one in init_topo_walk ffa1f28fea revision: clear the topo-walk flags in reset_revision_walk ebc3278665 git-compat-util.h: drop the `PRIuMAX` and other fallback definitions 9917eca794 l10n: zh_TW: add translation for v2.24.0 0a8e3036a3 reset: parse rev as tree-ish in patch mode f0e58b3fe8 doc: mention that 'git submodule update' fetches missing commits 8d483c8408 doc: document 'git submodule status --cached' befd4f6a81 sequencer: don't re-read todo for revert and cherry-pick ac33519ddf mingw: restrict file handle inheritance only on Windows 7 and later 9a780a384d mingw: spawned processes need to inherit only standard handles c5a03b1e29 mingw: work around incorrect standard handles eea4a7f4b3 mingw: demonstrate that all file handles are inherited by child processes a85efb5985 t5608-clone-2gb.sh: turn GIT_TEST_CLONE_2GB into a bool 43a2afee82 tests: add 'test_bool_env' to catch non-bool GIT_TEST_* values 2d05ef2778 sequencer: fix empty commit check when amending ea8b7be147 git svn: stop using `rebase --preserve-merges` 67a6ea6300 gpg-interface: limit search for primary key fingerprint 392b862e9a gpg-interface: refactor the free-and-xmemdupz pattern cff4e9138d sparse-checkout: check for dirty status 416adc8711 sparse-checkout: update working directory in-process for 'init' f75a69f880 sparse-checkout: cone mode should not interact with .gitignore fb10ca5b54 sparse-checkout: write using lockfile 99dfa6f970 sparse-checkout: use in-process update for disable subcommand e091228e17 sparse-checkout: update working directory in-process e9de487aa3 sparse-checkout: sanitize for nested folders 4dcd4def3c unpack-trees: add progress to clear_ce_flags() eb42feca97 unpack-trees: hash less in cone mode af09ce24a9 sparse-checkout: init and set in cone mode 96cc8ab531 sparse-checkout: use hashmaps for cone patterns 879321eb0b sparse-checkout: add 'cone' mode e6152e35ff trace2: add region in clear_ce_flags 72918c1ad9 sparse-checkout: create 'disable' subcommand 7bffca95ea sparse-checkout: add '--stdin' option to set subcommand f6039a9423 sparse-checkout: 'set' subcommand d89f09c828 clone: add --sparse mode bab3c35908 sparse-checkout: create 'init' subcommand 94c0956b60 sparse-checkout: create builtin with 'list' subcommand 679f2f9fdd unpack-trees: skip stat on fsmonitor-valid files df6d3d6802 lib-bash.sh: move `then` onto its own line 2a02262078 t5520: replace `! git` with `test_must_fail git` c245e58bb6 t5520: remove redundant lines in test cases a1a64fdd0a t5520: replace $(cat ...) comparison with test_cmp e959a18ee7 t5520: don't put git in upstream of pipe 5540ed27bc t5520: test single-line files by git with test_cmp dd0f1e767b t5520: use test_cmp_rev where possible 979f8891cc t5520: replace test -{n,z} with test-lib functions 3037d3db90 t5520: use test_line_count where possible 93a9bf876b t5520: remove spaces after redirect operator ceeef863de t5520: replace test -f with test-lib functions 4c8b046f82 t5520: let sed open its own input 53c62b9810 t5520: use sq for test case names e8d1eaf9b4 t5520: improve test style 2c9e125b27 t: teach test_cmp_rev to accept ! for not-equals 8cb7980382 t0000: test multiple local assignment 5b583e6a09 format-patch: pass notes configuration to range-diff bd36191886 range-diff: pass through --notes to `git log` 9f726e1b87 range-diff: output `## Notes ##` header 3bdbdfb7a5 t3206: range-diff compares logs with commit notes 75c5aa0701 t3206: s/expected/expect/ 79f3950d02 t3206: disable parameter substitution in heredoc 3a6e48e9f7 t3206: remove spaces after redirect operators 26d94853f0 pretty-options.txt: --notes accepts a ref instead of treeish 077a1fda82 userdiff: support Python async functions 3798149a74 SubmittingPatches: use `--pretty=reference` 1f0fc1db85 pretty: implement 'reference' format 618a855083 pretty: add struct cmt_fmt_map::default_date_mode_type 0df621172d pretty: provide short date format ac52d9410e t4205: cover `git log --reflog -z` blindspot 3e8ed3b93e pretty.c: inline initalize format_context 4982516451 revision: make get_revision_mark() return const pointer f0f9de2bd7 completion: complete `tformat:` pretty format fb2ffa77a6 SubmittingPatches: remove dq from commit reference bae74c9dfb pretty-formats.txt: use generic terms for hash bd00717eab SubmittingPatches: use generic terms for hash 9d45ac4cbf rev-list-options.txt: remove reference to --show-notes 828e829b9e argv-array: add space after `while` e440fc5888 commit: support the --pathspec-from-file option 66a25a7242 doc: commit: synchronize description 64bac8df97 reset: support the `--pathspec-from-file` option d137b50756 doc: reset: synchronize description 24e4750c96 pathspec: add new function to parse file 0dbc4a0edf ci(osx): update homebrew-cask repository with less noise e02058a729 sequencer: handle rebase-merges for "onto" message bae60ba7e9 builtin/unpack-objects.c: show throughput progress 2d92ab32fd rev-parse: make --show-toplevel without a worktree an error 9e5afdf997 fetch: add trace2 instrumentation 4c4066d95d run-command: move doc to run-command.h 6c51cb525d trace2: move doc to trace2.h 7db0305438 parse-options: add link to doc file in parse-options.h d95a77d059 submodule-config: move doc to submodule-config.h f3b9055624 credential: move doc to credential.h bbcfa3002a tree-walk: move doc to tree-walk.h 971b1f24a2 argv-array: move doc to argv-array.h f1ecbe0f53 trace: move doc to trace.h 13aa9c8b70 cache: move doc to cache.h c0be43f898 sigchain: move doc to sigchain.h 19ef3ddd36 pathspec: move doc to pathspec.h 301d595e72 revision: move doc to revision.h 3a1b3415d9 attr: move doc to attr.h 126c1ccefb refs: move doc to refs.h d27eb356bf remote: move doc to remote.h and refspec.h 405c6b1fbc sha1-array: move doc to sha1-array.h d3d7172e40 merge: move doc to ll-merge.h 3f1480b745 graph: move doc to graph.h and graph.c 266f03eccd dir: move doc to dir.h 13c4d7eb22 diff: move doc to diff.h and diffcore.h cd5522271f rebase -r: let `label` generate safer labels 867bc1d236 rebase-merges: move labels' whitespace mangling into `label_oid()` 8c15904462 built-in add -i: implement the `help` command 3d965c7674 built-in add -i: use color in the main loop 68db1cbf8e built-in add -i: support `?` (prompt help) 76b743234c built-in add -i: show unique prefixes of the commands 6348bfba58 built-in add -i: implement the main loop a376e37b2c gitweb: escape URLs generated by href() b178c207d7 t/gitweb-lib.sh: set $REQUEST_URI f28bceca75 t/gitweb-lib.sh: drop confusing quotes 0eba60c9b7 t9502: pass along all arguments in xss helper 932757b0cc INSTALL: use existing shell scripts as example b018719927 t7004: check existence of correct tag 1daaebcaa5 built-in add -i: color the header in the `status` command 5e82b9e4d2 built-in add -i: implement the `status` command e4cb659ebd diff: export diffstat interface f83dff60a7 Start to implement a built-in version of `git add --interactive` df53c80822 stash: make sure we have a valid index before writing it ad7a403268 send-pack: check remote ref status on pack-objects failure d91ce887c9 t6120-describe: correct test repo history graph in comment 1f9247a3bd completion: tab-complete "git svn --recursive" 603960b50e promisor-remote: remove fetch_if_missing=0 e362fadcd0 clone: remove fetch_if_missing=0 169bed7421 parse-options: avoid arithmetic on pointer that's potentially NULL 51bd6be32d mingw: use COPY_ARRAY for copying array 4bd0593e0f test-tool: use 'read-graph' helper e0316695ec test-lib: don't check prereqs of test cases that won't be run anyway d784d978f6 t4215: use helper function to check output 61eea521fe fsmonitor: do not compare bitmap size with size of split index b19f3fe9dd hex: drop sha1_to_hex() c1ce9c06d0 completion: learn to complete `git rebase --onto=` f66e0401ab pack-objects: avoid pointless oe_map_new_pack() calls d3a8caebf3 doc: improve readability of --rebase-merges in git-rebase aa6d7f93ed hex: drop sha1_to_hex_r() 52f52e5ae4 sequencer: reencode commit message for am/rebase --show-current-patch 5772b0c745 sequencer: reencode old merge-commit message e0eba649e8 bundle-verify: add --quiet 79862b6b77 bundle-create: progress output control 73c3253d75 bundle: framework for options before bundle file 68d40f30c4 merge-strategies: fix typo "reflected to" to "reflected in" b375744274 sequencer: reencode squashing commit's message 019a9d8362 sequencer: reencode revert/cherry-pick's todo list 0798d16fe3 sequencer: reencode to utf-8 before arrange rebase's todo list e4b95b3b5f t3900: demonstrate git-rebase problem with multi encoding 1ba6e7aecd configure.ac: define ICONV_OMITS_BOM if necessary d9f6f3b619 The first batch post 2.24 cycle 28014c1084 Merge branch 'bc/hash-independent-tests-part-6' 57b530125e Merge branch 'js/update-index-ignore-removal-for-skip-worktree' c22f63c40f Merge branch 'pb/pretty-email-without-domain-part' 5731ca3657 Merge branch 'hw/remove-api-docs-placeholder' 14b58c62bc Merge branch 'sg/commit-graph-usage-fix' eff313f8a7 Merge branch 'dl/apply-3way-diff3' db806d7064 Merge branch 'sg/dir-trie-fixes' f1e2666b33 Merge branch 'jc/am-show-current-patch-docfix' 8f1119b988 Merge branch 'wb/midx-progress' d9800351d3 Merge branch 'en/merge-recursive-directory-rename-fixes' 0c51181ffb Merge branch 'js/rebase-deprecate-preserve-merges' 8f40d89783 Merge branch 'hv/bitshift-constants-in-blame' d4a98e701f Merge branch 'dd/notes-copy-default-dst-to-head' 5c8c0a0d78 Merge branch 'pw/post-commit-from-sequencer' b75ba9bbd1 Merge branch 'dl/format-patch-cover-from-desc' 15d9f3dc66 Merge branch 'es/walken-tutorial' 026587c793 Merge branch 'jt/fetch-pack-record-refs-in-the-dot-promisor' ed28358833 convert: use skip_iprefix() in validate_encoding() 89f8cabaf3 utf8: use skip_iprefix() in same_utf_encoding() 03670c8b23 Fix spelling errors in no-longer-updated-from-upstream modules ae821ffe83 multimail: fix a few simple spelling errors 557c5895c2 sha1dc: fix trivial comment spelling error aa74be316a Fix spelling errors in test commands 96c0caf5e3 Fix spelling errors in messages shown to users 4dc8b1c114 Fix spelling errors in names of tests 7a40cf1553 Fix spelling errors in comments of testcases 15beaaa3d1 Fix spelling errors in code comments a807200f67 userdiff: add Elixir to supported userdiff languages 461caf3e8a git-shortlog.txt: include commit limiting options 6462d5eb9a fetch: remove fetch_if_missing=0 46efd28be1 kset.h, tar.h: add missing header guard to prevent multiple inclusion 99b2ba35f5 t0028: eliminate non-standard usage of printf add97702ed parse-options.h: add new options `--pathspec-from-file`, `--pathspec-file-nul` 14c4776d75 t: fix typo in test descriptions 270de6acbe t6024: modernize style 77363a51fb name-hash.c: remove duplicate word in comment c92faa4d22 hashmap: fix documentation misuses of -> versus . a6d39f2efb git-filter-branch.txt: correct argument name typo 4d17fd253f remote-curl: unbreak http.extraHeader with custom allocators 8915297925 Fix spelling errors in documentation outside of Documentation/ 031fd4b93b Documentation: fix a bunch of typos, both old and new dd0b61f577 fsmonitor: fix watchman integration 5c34d2f03e trace2: add dots directly to strbuf in perf_fmt_prepare() 7d8e72b970 fetch: avoid locking issues between fetch.jobs/fetch.writeCommitGraph c14e6e7903 fetch: add the command-line option `--write-commit-graph` da72936f54 Git 2.24 1d34d425d4 Merge branch 'bc/doc-use-docbook-5' dac1d83c91 Merge branch 'ds/commit-graph-on-fetch' c32ca691c2 Merge branch 'jt/delay-fetch-if-missing' ab6b50e4c8 Merge https://github.com/prati0100/git-gui 93bf7423dd Merge tag 'l10n-2.24.0-rnd2' of https://github.com/git-l10n/git-po a5cd71ca4a l10n: zh_CN: for git v2.24.0 l10n round 1~2 fe28ad8520 rebase: add --reset-author-date 08187b4cba rebase -i: support --ignore-date 0185c683c9 sequencer: rename amend_author to author_to_rename cbd8db17ac rebase -i: support --committer-date-is-author-date c068bcc59b sequencer: allow callers of read_author_script() to ignore fields ba51d2fb24 rebase -i: add --ignore-whitespace flag 3c8d754c4b myfirstcontrib: hint to find gitgitgadget allower 3ada78de3f myfirstcontrib: add dependency installation step 4ed5562925 myfirstcontrib: add 'psuh' to command-list.txt 4a58c3d7f7 stash: handle staged changes in skip-worktree files correctly 8dfb04ae96 update-index: optionally leave skip-worktree entries alone 116d1fa6c6 vreportf(): avoid relying on stdio buffering efd5444238 RelNotes/2.24.0: fix self-contradictory note 391c7e40b5 fetch.c: fix typo in a warning message 55aca515eb manpage-bold-literal.xsl: match for namespaced "d:literal" in template 849e43680d RelNotes/2.24.0: typofix 0115e5d929 git-diff.txt: document return code of `--no-index` 798d66e35d l10n: de.po: Update German translation c1d0038746 l10n: sv.po: Update Swedish translation (4695t0f0u) f21f8f5d35 Git 2.24-rc2 8dc28ee438 Merge branch 'wb/fsmonitor-bitmap-fix' 0d6799e563 Merge branch 'rl/gitweb-blame-prev-fix' f2db52c46b Merge branch 'js/mingw-needs-hiding-fix' 5b7594abdc Merge branch 'master' of github.com:vnwildman/git 034d33653a Merge branch 'next' of github.com:ChrisADR/git-po 26b061007c submodule: teach set-url subcommand 460782b7be t7519-status-fsmonitor: improve comments d8b8217c8a pretty: add "%aL" etc. to show local-part of email addresses 4782cf2ab6 worktree: teach "add" to ignore submodule.recurse config 1294a85b7c l10n: bg.po: Updated Bulgarian translation (4694) f126a1fb0f l10n: vi(4694t): Updated translation for v2.24.0 762d5b4f46 help: add gitsubmodules to the list of guides 76a53d640f git_path(): handle `.lock` files correctly 3ce47211a6 t1400: wrap setup code in test case 44ae131e38 builtin/blame.c: remove '--indent-heuristic' from usage string 6c02042139 clone: rename static function `dir_exists()`. 8dd327b246 Documentation/git-bisect.txt: add --no-ff to merge command 77200e9332 l10n: es: 2.24.0 round 2 e42df36b42 Merge branch 'l10n/it/update-italian-translation' 5e196e8ae0 l10n: it.po: update the Italian translation for Git 2.24.0 round #2 51728480fe l10n: fr v2.24.0 rnd2 045a548698 l10n: git.pot: v2.24.0 round 2 (1 new) 468d356a81 Merge tag 'v2.24.0-rc1' of github.com:git/git into master b2f2039c2b fsck: accept an oid instead of a "struct tree" for fsck_tree() c5b4269b57 fsck: accept an oid instead of a "struct commit" for fsck_commit() 103fb6d43b fsck: accept an oid instead of a "struct tag" for fsck_tag() f648ee7088 fsck: rename vague "oid" local variables cc579000bf fsck: don't require an object struct in verify_headers() 7854399366 fsck: don't require an object struct for fsck_ident() b8b00f1693 fsck: drop blob struct from fsck_finish() 6da40b22ca fsck: accept an oid instead of a "struct blob" for fsck_blob() 38370253fd fsck: don't require an object struct for report() f59793763d fsck: only require an oid for skiplist functions 5afc4b1dc6 fsck: only provide oid/type in fsck_error callback 82ef89b318 fsck: don't require object structs for display functions 733902905d fsck: use oids rather than objects for object_name API d40bbc109b fsck_describe_object(): build on our get_object_name() primitive a59cfb3230 fsck: unify object-name code 23a173a761 fsck: require an actual buffer for non-blobs 2175a0c601 fsck: stop checking tag->tagged ec65231571 fsck: stop checking commit->parent counts 1de6007d85 fsck: stop checking commit->tree value 228c78fbd4 commit, tag: don't set parsed bit for parse failures 60e6569a12 mingw: avoid a buffer overrun in `needs_hiding()` 8b656572ca builtin/commit-graph.c: remove subcommand-less usage string fa26d5ede6 t4048: abstract away SHA-1-specific constants cf02be8486 t4045: make hash-size independent 38ee26b2a3 t4044: update test to work with SHA-256 37ab8ebef1 t4039: abstract away SHA-1-specific constants 0370b35414 t4038: abstract away SHA-1 specific constants 0253e126a2 t4034: abstract away SHA-1-specific constants 45e2ef2b1d t4027: make hash-size independent 79b0edc1a0 t4015: abstract away SHA-1-specific constants 840624ff55 t4011: abstract away SHA-1-specific constants 32a6707267 t4010: abstract away SHA-1-specific constants 440bf91dfa t3429: remove SHA1 annotation 0b408ca2bd t1305: avoid comparing extensions 2eabd38313 rev-parse: add a --show-object-format option 52bd3e4657 gitweb: correctly store previous rev in javascript-actions mode 45e206f0d8 t4203: use test-lib.sh definitions 2ae4944aac t6006: use test-lib.sh definitions cb99a34e23 commit-graph: fix writing first commit-graph during fetch e88aab917e t5510-fetch.sh: demonstrate fetch.writeCommitGraph bug 7b4fb434b4 documentation: remove empty doc files 566a1439f6 Git 2.24-rc1 04b1f4f768 Merge branch 'sg/ci-osx-gcc8-fix' 4d6fb2beeb Merge branch 'ds/feature-macros' 5f0b6ed907 Merge branch 'js/azure-ci-osx-fix' c555caab7a Merge branch 'bw/format-patch-o-create-leading-dirs' 1b4f85285f Merge branch 'dl/submodule-set-branch' c7aadccba0 fetch: delay fetch_if_missing=0 until after config c11e9966cb repo-settings: read an int for index.version 091489d068 apply: respect merge.conflictStyle in --3way aa76ae4905 t4108: demonstrate bug in apply 95806205cd t4108: use `test_config` instead of `git config` b0069684d4 t4108: remove git command upstream of pipe fa87b81385 t4108: replace create_file with test_write_lines 7d4733c501 ci: fix GCC install in the Travis CI GCC OSX job 6c96630cb0 config: move documentation to config.h d81542e6f3 Eleventh batch e0ff2d4c7e Merge branch 'cb/pcre2-chartables-leakfix' d45d771978 Merge branch 'bc/smart-http-atomic-push' 22dd22dce0 Merge branch 'wb/fsmonitor-bitmap-fix' 2e215b7959 Merge branch 'sb/userdiff-dts' e3cf08361a Merge branch 'sg/progress-fix' b895e8dea6 Merge branch 'nr/diff-highlight-indent-fix' c1ec35dd48 Merge branch 'mb/clarify-zsh-completion-doc' f45f88b2e4 path.c: don't call the match function without value in trie_find() c72fc40d09 path.c: clarify two field names in 'struct common_dir' 8a64881b44 path.c: mark 'logs/HEAD' in 'common_list' as file 7cb8c929d7 path.c: clarify trie_find()'s in-code comment e536b1fedf Documentation: mention more worktree-specific exceptions 680cba2c2b multi-pack-index: add [--[no-]progress] option. 64d80e7d52 midx: honor the MIDX_PROGRESS flag in midx_repack ad60096d1c midx: honor the MIDX_PROGRESS flag in verify_midx_file 8dc18f8937 midx: add progress to expire_midx_packs 840cef0c70 midx: add progress to write_midx_file efbc3aee08 midx: add MIDX_PROGRESS flag 0eb3671ed9 ci(osx): use new location of the `perforce` cask da1e295e00 t604[236]: do not run setup in separate tests 49b8133a9e merge-recursive: fix merging a subdirectory into the root directory d3eebaad5e merge-recursive: clean up get_renamed_dir_portion() 80736d7c5e doc: am --show-current-patch gives an entire e-mail message a8e2c0eadc t7419: change test_must_fail to ! for grep 19c29e538e t4014: make output-directory tests self-contained 12a4aeaad8 Merge branch 'js/azure-pipelines-msvc' 399c23c046 ci(visual-studio): actually run the tests in parallel 711cd6d15c ci(visual-studio): use strict compile flags, and optimization 370784e0e6 l10n: it.po: update the Italian translation for Git 2.24.0 cc73c68603 Merge branch 'master' of github.com:jnavila/git into git-po-master 907843be3b Merge branch 'master' of github.com:alshopov/git-po into git-po-master 13bcea8c7f l10n: fr 2.24.0 rnd 1 135480a616 Merge remote-tracking branch 'git-po/master' into git-po-master 3d0a05b464 l10n: git.pot: v2.24.0 round 1 (35 new, 16 removed) 8da56a4848 userdiff: fix some corner cases in dts regex 86795774bb builtin/blame.c: constants into bit shift format feebd2d256 rebase: hide --preserve-merges option 0e40a73a4c Doc: Bundle file usage 78d50148b9 parse_tag_buffer(): treat NULL tag pointer as parse error 12736d2f02 parse_commit_buffer(): treat lookup_tree() failure as parse error c78fe00459 parse_commit_buffer(): treat lookup_commit() failure as parse error 2b6f6ea1bd test-progress: fix test failures on big-endian systems f757409e36 l10n: bg.po: Updated Bulgarian translation (4693) 176f5adfdb completion: clarify installation instruction for zsh d966095db0 Git 2.24-rc0 90e0d167c6 Merge branch 'rs/remote-curl-use-argv-array' 3def8ae9a4 Merge branch 'rs/column-use-utf8-strnwidth' d0258d0944 Merge branch 'rs/http-push-simplify' bb52def6da Merge branch 'jj/stash-reset-only-toplevel' f1afbb063f Merge branch 'bw/format-patch-o-create-leading-dirs' e5fca6b573 Merge branch 'bb/compat-util-comment-fix' 43400b4222 Merge branch 'bb/utf8-wcwidth-cleanup' 07ff6dd0ea Merge branch 'dl/allow-running-cocci-verbosely' 2d74d28ee0 Merge branch 'dl/compat-cleanup' 9b83a94829 Merge branch 'ta/t1308-typofix' 376012c919 Merge branch 'js/doc-stash-save' 10da030ab7 grep: avoid leak of chartables in PCRE2 513f2b0bbd grep: make PCRE2 aware of custom allocator 57d4660468 grep: make PCRE1 aware of custom allocator d58deb9c4e notes: fix minimum number of parameters to "copy" subcommand 8af69cf3e2 t3301: test diagnose messages for too few/many paramters 6f1194246a remote-curl: pass on atomic capability to remote side bbb13e8188 graph: fix coloring of octopus dashes 92beecc136 graph: flatten edges that fuse with their right neighbor 479db18bc0 graph: smooth appearance of collapsing edges on commit lines 0195285b95 graph: rename `new_mapping` to `old_mapping` d62893ecc1 graph: commit and post-merge lines for left-skewed merges 0f0f389f12 graph: tidy up display of left-skewed merges 458152cce1 graph: example of graph output that can be simplified ee7abb5ffa graph: extract logic for moving to GRAPH_PRE_COMMIT state 46ba2abdfa graph: remove `mapping_idx` and `graph_update_width()` a551fd5efd graph: reduce duplication in `graph_insert_into_new_columns()` 9157a2a032 graph: reuse `find_new_column_by_commit()` 210179a20d graph: handle line padding in `graph_next_line()` fbccf255f9 graph: automatically track display width of graph lines 5374a290aa fetch-pack: write fetched refs to .promisor 4627bc777e sequencer: run post-commit hook 49697cb721 move run_commit_hook() to libgit and use it there 12bb7a540a sequencer.h fix placement of #endif 6a619ca03c t3404: remove uneeded calls to set_fake_editor b2dbacbddf t3404: set $EDITOR in subshell 88a92b6c73 t3404: remove unnecessary subshell bf8e65b30b format-patch: teach --cover-from-description option a92331df18 format-patch: use enum variables 46273df7bf format-patch: replace erroneous and condition 3b3c79f6c9 diff-highlight: fix a whitespace nit 108b97dc37 Ninth batch cbe8cdd3a0 Merge branch 'jk/coc' 3b9ec27919 Merge branch 'js/trace2-fetch-push' c7d2cedec2 Merge branch 'jt/push-avoid-lazy-fetch' 1ef3bd362a Merge branch 'dl/format-patch-doc-test-cleanup' eb3de5b823 Merge branch 'js/xdiffi-comment-updates' 4e8371ec26 Merge branch 'dl/t0000-skip-test-test' b6d712fa4e Merge branch 'tg/range-diff-output-update' 77458870a5 Merge branch 'gs/sq-quote-buf-pretty' 5efabc7ed9 Merge branch 'ew/hashmap' d0ce4d9024 Merge branch 'js/trace2-cap-max-output-files' 6ed610b968 Merge branch 'am/t0028-utf16-tests' 5b900fb812 Merge branch 'dl/octopus-graph-bug' 16d9d7184b Merge branch 'en/fast-imexport-nested-tags' 6d5291be45 Merge branch 'js/azure-pipelines-msvc' ccc289915a Merge branch 'gs/commit-graph-trace-with-cmd' d96e31e390 Merge branch 'js/fetch-jobs' 280bd44551 Merge branch 'en/merge-recursive-cleanup' 062a309d36 remote-curl: use argv_array in parse_push() a81e42d235 column: use utf8_strnwidth() to strip out ANSI color escapes 5cc6a4be11 http-push: simplify deleting a list item 556895d0c8 stash: avoid recursive hard reset on submodules b524f6b399 Merge branch 'ka/japanese-translation' f6f3824b4e git-gui: improve Japanese translation 61f4b407d3 Merge branch 'py/readme' 1e6880fd06 git-gui: add a readme edefc31873 format-patch: create leading components of output directory 68b69211b2 git-compat-util: fix documentation syntax fa364ad790 utf8: use ARRAY_SIZE() in git_wcwidth() e0479fa073 documentation: add tutorial for object walking 3444ec2eb2 fsmonitor: don't fill bitmap with entries to be removed 4f3c1dc5d6 Makefile: respect $(V) in %.cocci.patch target 9cad1c4488 pthread.h: manually align parameter lists 8c1cfd58e3 t1308-config-set: fix a test that has a typo 57d8f4b4c7 doc(stash): clarify the description of `save` 08da6496b6 Eighth batch 07f25ad8b2 Merge branch 'dl/rev-list-doc-cleanup' f0d407e6ae Merge branch 'kt/add-i-progress' 66102cfad8 Merge branch 'js/stash-apply-in-secondary-worktree' a4c5d9f66e Merge branch 'rs/dedup-includes' 159cdabd87 Merge branch 'js/range-diff-noprefix' 93424f1f7d Merge branch 'cb/pcre1-cleanup' a73f91774c Merge branch 'ab/pcre-jit-fixes' 4608a029b4 Merge branch 'pw/rebase-i-show-HEAD-to-reword' 020011f2cb Merge branch 'tk/git-svn-trim-author-name' 676278f8ea Merge branch 'bc/object-id-part17' aafb75452b Merge branch 'en/clean-nested-with-ignored' 3f9ef874a7 CODE_OF_CONDUCT: mention individual project-leader emails 5cdf2301d4 add a Code of Conduct document 70bf0b755a Seventh batch 9b3995cee0 Merge branch 'rs/test-remove-useless-debugging-cat' 2e956f7fb3 Merge branch 'pm/p4-auto-delete-named-temporary' d17f54947d Merge branch 'rs/convert-fix-utf-without-dash' 82c80f98e6 Merge branch 'py/git-gui-has-maintainer' 6e12570822 Merge branch 'ah/cleanups' 772cad0afb Merge branch 'js/diff-rename-force-stable-sort' 424663d9c8 Merge branch 'js/mingw-spawn-with-spaces-in-path' 678a9ca629 Merge branch 'as/shallow-slab-use-fix' 0b4fae553c Merge branch 'sg/name-rev-cutoff-underflow-fix' 042a54d251 Merge branch 'am/visual-studio-config-fix' 03d3b1297c xdiffi: fix typos and touch up comments b05b40930e t0000: cover GIT_SKIP_TESTS blindspots d8bc1a518a send-pack: never fetch when checking exclusions 756fb0dedb t4014: treat rev-list output as the expected value 2b6a9b13ca range-diff: don't segfault with mode-only changes 360c7ba330 transport: push codepath can take arbitrary repository ce2d7ed2fd sq_quote_buf_pretty: don't drop empty arguments b657047719 merge-recursive: fix the fix to the diff3 common ancestor label b744c3af07 Sixth batch 417056578a Merge branch 'bw/submodule-helper-usage-fix' 9728ab488a Merge branch 'dl/honor-cflags-in-hdr-check' 1f314d5223 Merge branch 'cb/do-not-use-test-cmp-with-a' 59b19bcd9f Merge branch 'cc/multi-promisor' 1f4485b219 Merge branch 'jt/merge-recursive-symlink-is-not-a-dir-in-way' 5ecdbfafd6 Merge branch 'ps/my-first-contribution-alphasort' eb35c18e42 Merge branch 'sg/travis-help-debug' cabb145fe3 Merge branch 'rs/alias-use-copy-array' 56c7ab0f4e Merge branch 'sg/t-helper-gitignore' e5ce62b1ac Merge branch 'cc/svn-fe-py-shebang' 583cf6232a Merge branch 'ah/doc-submodule-ignore-submodules' 337e3f2b49 Merge branch 'rs/nth-switch-code-simplification' 8f53fe1733 Merge branch 'hb/hg-to-git-py3' ef93bfbd45 Merge branch 'sg/progress-fix' 980351d1ac Merge branch 'js/doc-patch-text' 80693e3f09 Merge branch 'tb/commit-graph-harden' ae203ba414 Merge branch 'jt/cache-tree-avoid-lazy-fetch-during-merge' 3f84633563 Merge branch 'dl/cocci-everywhere' caf150ce7d Merge branch 'gs/commit-graph-progress' 1d8b0dfa8a Merge branch 'ms/fetch-follow-tag-optim' 1398171378 Merge branch 'rs/commit-graph-use-list-count' 773521df26 Merge branch 'rs/nth-parent-parse' 7f17913161 Merge branch 'dl/submodule-set-branch' cb3ec6f4ef Merge branch 'cs/pretty-formats-doc-typofix' bbfe5f2241 Merge branch 'jk/list-objects-optim-wo-trees' 098e8c6716 Merge branch 'jk/disable-commit-graph-during-upload-pack' 37ab7cb0a8 Merge branch 'mr/complete-more-for-log-etc' e392382f95 Merge branch 'dl/complete-rebase-and-archive' cda8faa37e Merge branch 'jk/commit-graph-cleanup' 36d2fca82b Merge branch 'ss/get-time-cleanup' ed6822896b Merge branch 'rs/simplify-by-deco-with-deco-refs-exclude' ad8f0368b4 Merge branch 'jk/partial-clone-sparse-blob' ba2d451122 Merge branch 'tg/stash-refresh-index' e2b5038d87 hashmap_entry: remove first member requirement from docs 404ab78e39 hashmap: remove type arg from hashmap_{get,put,remove}_entry 23dee69f53 OFFSETOF_VAR macro to simplify hashmap iterators c8e424c9c9 hashmap: introduce hashmap_free_entries 8a973d0bb3 hashmap: hashmap_{put,remove} return hashmap_entry * 87571c3f71 hashmap: use *_entry APIs for iteration 939af16eac hashmap_cmp_fn takes hashmap_entry params f23a465132 hashmap_get{,_from_hash} return "struct hashmap_entry *" f0e63c4113 hashmap: use *_entry APIs to wrap container_of 6bcbdfb277 hashmap_get_next returns "struct hashmap_entry *" 973d5eea74 introduce container_of macro 26b455f21e hashmap_put takes "struct hashmap_entry *" 28ee794128 hashmap_remove takes "const struct hashmap_entry *" b6c5241606 hashmap_get takes "const struct hashmap_entry *" b94e5c1df6 hashmap_add takes "struct hashmap_entry *" f6eb6bdcf2 hashmap_get_next takes "const struct hashmap_entry *" d22245a2e3 hashmap_entry_init takes "struct hashmap_entry *" d0a48a0a1d packfile: use hashmap_entry in delta_base_cache_entry 12878c8351 coccicheck: detect hashmap_entry.hash assignment e010a41216 diff: use hashmap_entry_init on moved_entry.ent f537485fa5 tests: remove "cat foo" before "test_i18ngrep bar foo" de5abb5f7a git-p4: auto-delete named temporary file c90b652afd Fifth batch f00b57e5bc Merge branch 'cb/skip-utf8-check-with-pcre1' b0f8aed48f Merge branch 'ma/user-manual-markup-update' faf5576a8d Merge branch 'bc/doc-use-docbook-5' 314fcd32d7 Merge branch 'ma/asciidoctor-more-fixes' 70c1cbf515 Merge branch 'ma/asciidoctor-refmiscinfo' 847650798b Merge branch 'am/mailmap-andrey-mazo' 1a155f2e66 Merge branch 'jc/git-gui-has-maintainer' 1bcef51204 t/oid-info: add empty tree and empty blob values ecde49bb8a t/oid-info: allow looking up hash algorithm name 11a3d3aadd git-rev-list.txt: prune options in synopsis 7d2f003ee4 Documentation: update the location of the git-gui repo b181676ce9 convert: fix handling of dashless UTF prefix in validate_encoding() 46689317ac ci: also build and test with MS Visual Studio on Azure Pipelines b35304bf95 ci: really use shallow clones on Azure Pipelines ab7d854aba tests: let --immediate and --write-junit-xml play well together be5d88e112 test-tool run-command: learn to run (parts of) the testsuite 5d65ad17a9 vcxproj: include more generated files 030a628b81 vcxproj: only copy `git-remote-http.exe` once it was built 61d1d92aa4 msvc: work around a bug in GetEnvironmentVariable() e4347c9434 msvc: handle DEVELOPER=1 ed712ef8d5 msvc: ignore some libraries when linking 5b8f9e2417 compat/win32/path-utils.h: add #include guards 41616ef618 winansi: use FLEX_ARRAY to avoid compiler warning c097b95a26 msvc: avoid using minus operator on unsigned types dfd557c978 stash apply: report status correctly even in a worktree's subdirectory d54dea77db fetch: let --jobs= parallelize --multiple, too 87db61a436 trace2: write discard message to sentinel files 83e57b04e6 trace2: discard new traces if target directory has too many files 11c21f22de t4214: demonstrate octopus graph coloring failure 25eb905e14 t4214: explicitly list tags in log 63be8c8dd7 t4214: generate expect in their own test cases a7a5590c6e t4214: use test_merge 94ba151300 test-lib: let test_merge() perform octopus merges 22541013d0 docs: clarify trace2 version invariants 3d4548e7e2 docs: mention trace2 target-dir mode in git-config 2fe44394c8 treewide: remove duplicate #include directives dbcd970c27 push: do not pretend to return `int` from `die_push_simple()` 941790d7de fast-export: handle nested tags 8d7d33c1ce t9350: add tests for tags of things other than a commit a1638cfe12 fast-export: allow user to request tags be marked with --mark-tags 208d69246e fast-export: add support for --import-marks-if-exists b8f50e5b60 fast-import: add support for new 'alias' command f73b2aba05 fast-import: allow tags to be identified by mark labels 3164e6bd24 fast-import: fix handling of deleted tags 8085050ab4 add -i: show progress counter in the prompt 69fdb922ad Merge branch 'bw/diff3-conflict-style' b436825b9b git-gui: support for diff3 conflict style 937b76ed49 range-diff: internally force `diff.noprefix=true` 411e4f4735 ci: run `hdr-check` as part of the `Static Analysis` job 25e4b8099c push: add trace2 instrumentation 5fc31180d8 fetch: add trace2 instrumentation 53d687bf5f git_mkstemps_mode(): replace magic numbers with computed value c3b57dc2a0 git-gui: use existing interface to query a path's attribute 45ab460d4a Merge branch 'js/git-bash-if-available' 0bd7f578b2 commit-graph: emit trace2 cmd_mode for each sub-command 71f4960b91 t0061: fix test for argv[0] with spaces (MINGW only) 54a80a9ad8 wrapper: use a loop instead of repetitive statements baed6bbb5b diffcore-break: use a goto instead of a redundant if statement 8da02ce62a commit-graph: remove a duplicate assignment ddb3c856f3 shallow.c: don't free unallocated slabs 8e4ec3376e merge-recursive: fix the diff3 common ancestor label for virtual commits 65904b8b2b promisor-remote: skip move_to_tail when no-op 2049b8dc65 diffcore_rename(): use a stable sort 97fff61012 Move git_sort(), a stable sort, into into libgit.a 69f272b922 dir: special case check for the possibility that pathspec is NULL 6a72d44fc2 git-gui (Windows): use git-bash.exe if it is available bc12974a89 Fourth batch 5a5350940b Merge branch 'ds/commit-graph-on-fetch' 974bdb0205 Merge branch 'bw/rebase-autostash-keep-current-branch' 9755f70fe6 Merge branch 'ds/include-exclude' 93fc8760e7 Merge branch 'jh/trace2-pretty-output' 640f9cd599 Merge branch 'dl/rebase-i-keep-base' 026428c35e Merge branch 'sg/clean-nested-repo-with-ignored' 21db12c9ea Merge branch 'dl/complete-cherry-pick-revert-skip' d693345518 Merge branch 'dl/use-sq-from-test-lib' d8ce144e11 Merge branch 'jk/misc-uninitialized-fixes' 2be6ccc01a Merge branch 'sg/git-test-boolean' cf861cd7a0 Merge branch 'rs/get-tagged-oid' 91243b019d Merge branch 'en/filter-branch-deprecation' 9bc67b6658 Merge branch 'en/merge-options-ff-and-friends' fe048e4fd9 Merge branch 'tg/push-all-in-mirror-forbidden' cab037cd4b Merge branch 'dt/remote-helper-doc-re-lock-option' 8e111e487b Merge branch 'rs/help-unknown-ref-does-not-return' 3ff6af7753 Merge branch 'nd/switch-and-restore' aadac067aa Merge branch 'tb/file-url-to-unc-path' b57a88a5f1 Merge branch 'js/gitdir-at-unc-root' 6f21347f11 Merge branch 'ar/mingw-run-external-with-non-ascii-path' 430439536b Merge branch 'rs/parse-tree-indirect' 991fd97b9a Merge branch 'jk/fast-import-history-bugfix' 74a39b9bcc Merge branch 'mh/notes-duplicate-entries' 37801f0665 Merge branch 'tb/banned-vsprintf-namefix' 21ce0b48f3 Merge branch 'mh/release-commit-memory-fix' f0fcab6deb Merge branch 'mh/http-urlmatch-cleanup' bf6136cab8 Merge branch 'rs/strbuf-detach' a2e22bb3ad Merge branch 'rs/trace2-dst-warning' 1c6fc941c7 Merge branch 'dl/format-patch-doc-test-cleanup' 0281733483 Merge branch 'bc/hash-independent-tests-part-5' f06fb376ed Merge branch 'jc/test-cleanup' 00bb74453d Merge branch 'dl/compat-cleanup' 59438be06c Merge branch 'js/visual-studio' cda0d497e3 builtin/submodule--helper: fix usage string for 'update-clone' af2abd870b fast-export: fix exporting a tag and nothing else c4d2f6143a user-manual.txt: render ASCII art correctly under Asciidoctor dba3734103 asciidoctor-extensions.rb: handle "book" doctype in linkgit fd5b820d9c user-manual.txt: change header notation e79b34533a user-manual.txt: add missing section label b503a2d515 Makefile: emulate compile in $(HCO) target better af26e2a9d2 pack-bitmap.h: remove magic number b06fdead04 promisor-remote.h: include missing header 97b989ee3a apply.h: include missing header 4ddd4bddb1 git-svn: trim leading and trailing whitespaces in author name d928a8388a t0028: add more tests 0b63fd6965 t0028: fix test for UTF-16-LE-BOM fe0ed5d5e9 contrib/buildsystems: fix Visual Studio Debug configuration 2e09c01232 name-rev: avoid cutoff timestamp underflow 8464f94aeb promisor-remote.h: drop extern from function declaration 75b2c15435 t4038: Remove non-portable '-a' option passed to test_cmp 24c681794f doc: MyFirstContribution: fix cmd placement instructions c46ebc2496 travis-ci: do not skip successfully tested trees in debug mode 60c60b627e Merge branch 'py/git-git-extra-stuff' faf420e05a treewide: correct several "up-to-date" to "up to date" b71c6c3b64 Fix build with core.autocrlf=true 16d7601e17 Merge branches 'js/msgfmt-on-windows', 'tz/fsf-address-update', 'jn/reproducible-build', 'ls/no-double-utf8-author-name', 'js/misc-git-gui-stuff', 'bb/ssh-key-files', 'bp/bind-kp-enter', 'cb/ttk-style' and 'py/call-do-quit-before-exit' of ../git into py/git-git-extra-stuff 26e3d1cbea .mailmap: update email address of Andrey Mazo 27ea41c0b4 t/helper: ignore only executable files 7bd97d6dff git: use COPY_ARRAY and MOVE_ARRAY in handle_alias() 83e3ad3b12 merge-recursive: symlink's descendants not in way 34933d0eff stash: make sure to write refreshed cache e080b34540 merge: use refresh_and_write_cache 22184497a3 factor out refresh_and_write_cache function 7371612255 commit-graph: add --[no-]progress to write and verify 47b27c96fa test_date.c: remove reference to GIT_TEST_DATE_NOW 253bfe49bd SubmittingPatches: git-gui has a new maintainer d17ae00c97 hg-to-git: make it compatible with both python3 and python2 4c86140027 Third batch f67bf53300 Merge branch 'jt/avoid-ls-refs-with-http' 627b826834 Merge branch 'md/list-objects-filter-combo' b9ac6c59b8 Merge branch 'cc/multi-promisor' de67293e74 Merge branch 'sg/line-log-tree-diff-optim' 95486229e3 Merge branch 'sg/complete-configuration-variables' f76bd8c6b1 Merge branch 'js/pre-merge-commit-hook' a2e524ecf3 Merge branch 'cb/curl-use-xmalloc' 128666753b Merge branch 'jk/drop-release-pack-memory' 917a319ea5 Merge branch 'js/rebase-r-strategy' 7e1976e210 Merge branch 'master' of https://github.com/prati0100/git-gui 4b3aa170d1 sha1_name: simplify strbuf handling in interpret_nth_prior_checkout() 0d4304c124 doc: fix reference to --ignore-submodules af78249463 contrib/svn-fe: fix shebang for svnrdump_sim.py 8a3a6817e2 Merge gitk to pick up emergency build fix 2a4ac71ffb gitk: rename zh_CN.po to zh_cn.po 9027af58e2 Makefile: run coccicheck on more source files 43f8c890fd Makefile: strip leading ./ in $(FIND_SOURCE_FILES) 5dedf7de53 Makefile: define THIRD_PARTY_SOURCES 902b90cf42 clean: fix theoretical path corruption ca8b5390db clean: rewrap overly long line 09487f2cba clean: avoid removing untracked files in a nested git repository e86bbcf987 clean: disambiguate the definition of -d 3aca58045f git-clean.txt: do not claim we will delete files with -n/--dry-run 29b577b960 dir: add commentary explaining match_pathspec_item's return value 89a1f4aaf7 dir: if our pathspec might match files under a dir, recurse into it a3d89d8f76 dir: make the DO_MATCH_SUBMODULE code reusable for a non-submodule case 404ebceda0 dir: also check directories for matching pathspecs a5e916c745 dir: fix off-by-one error in match_pathspec_item bbbb6b0b89 dir: fix typo in comment 7541cc5302 t7300: add testcases showing failure to clean specified pathspecs 0eb7c37a8a diff, log doc: small grammer, format, and language fixes 6fae6bd518 diff, log doc: say "patch text" instead of "patches" 2bb74b53a4 Test the progress display bbf47568ad Revert "progress: use term_clear_line()" cf6a2d2557 Makefile: strip leading ./ in $(LIB_H) b7e2d8bca5 fetch: use oidset to keep the want OIDs for faster lookup 689a146c91 commit-graph: use commit_list_count() 59fa5f5a25 sha1-name: check for overflow of N in "foo^N" and "foo~N" a678df1bf9 rev-parse: demonstrate overflow of N for "foo^N" and "foo~N" a4cafc7379 list-objects-filter: use empty string instead of NULL for sparse "base" cf34337f98 list-objects-filter: give a more specific error sparse parsing error 4c96a77594 list-objects-filter: delay parsing of sparse oid 72de5895ed t5616: test cloning/fetching with sparse:oid= filter 83b0b8953e doc-diff: replace --cut-header-footer with --cut-footer 7a30134358 asciidoctor-extensions: provide `` 226daba280 Doc/Makefile: give mansource/-version/-manual attributes 40e747e89d git-submodule.txt: fix AsciiDoc formatting error f6461b82b9 Documentation: fix build with Asciidoctor 2 3cb8921f74 Merge branch 'master' of git://ozlabs.org/~paulus/gitk f7a8834ba4 Merge branch 'bp/amend-toggle-bind' ec7424e1a6 git-gui: add hotkey to toggle "Amend Last Commit" 9ea831a2a6 gitk: Do not mistake unchanged lines for submodule changes d7cc4fb001 gitk: Use right colour for remote refs in the "Tags and heads" dialog beffae768a gitk: Add Chinese (zh_CN) translation 56d9cbe68b packfile: expose get_delta_base() bab28d9f97 builtin/pack-objects: report reused packfile objects 6c8ec8c30a Merge branch 'bw/commit-scrollbuffer' acfa495519 Merge branch 'bw/amend-checkbutton' da08d559b7 git-gui: add horizontal scrollbar to commit buffer ba41b5b335 git-gui: convert new/amend commit radiobutton to checkbutton aeeb978ba6 completion: teach archive to use __gitcomp_builtin 2b9bd488ae completion: teach rebase to use __gitcomp_builtin d49dffde9a completion: add missing completions for log, diff, show 6abada1880 upload-pack: disable commit graph more gently for shallow traversal fbab552a53 commit-graph: bump DIE_ON_LOAD check to actual load-time 72ed80c784 list-objects: don't queue root trees unless revs->tree_objects is set 4fd39c76e6 doc: minor formatting fix 29f4332e66 Quit passing 'now' to date code c77abf0460 Merge branch 'py/revert-hunks-lines' 5a2bb62180 Merge branch 'bp/widget-focus-hotkeys' e07446ed5f git-gui: add hotkeys to set widget focus f981ec18cf cache-tree: do not lazy-fetch tentative tree f1d4a28250 Second batch c8ada15456 Merge branch 'bc/reread-attributes-during-rebase' 8f3ba423e7 Merge branch 'tg/t0021-racefix' a477abe9e4 Merge branch 'mp/for-each-ref-missing-name-or-email' d49c2c3466 Merge branch 'sb/userdiff-dts' 2743b61bc6 Merge branch 'rs/sort-oid-array-thread-safe' 4c49dd042d Merge branch 'nd/diff-parseopt' d8b1ce7972 Merge branch 'jt/diff-lazy-fetch-submodule-fix' 8ce8a63b46 Merge branch 'ds/midx-expire-repack' 9437394661 Merge branch 'cb/fetch-set-upstream' af2b8faf49 Merge branch 'rs/pax-extended-header-length-fix' fa9e7934c7 Merge branch 'bm/repository-layout-typofix' d1a251a1fa Merge branch 'en/checkout-mismerge-fix' e1151704f2 Merge branch 'sg/diff-indent-heuristic-non-experimental' f4f8dfe127 Merge branch 'ds/feature-macros' 4a12f89865 Merge branch 'jk/eoo' b4a1eec332 Merge branch 'jk/repo-init-cleanup' 70336bd50a Merge branch 'py/git-gui-do-quit' ad7c543e3b grep: skip UTF8 checks explicitly 0cc7380d88 log-tree: call load_ref_decorations() in get_name_decoration() b4ecbcf6a2 log: test --decorate-refs-exclude with --simplify-by-decoration 4414e837fc gitweb.conf.txt: switch pluses to backticks to help Asciidoctor b7e1ba5649 git-merge-index.txt: wrap shell listing in "----" 38cadf9e47 git-receive-pack.txt: wrap shell [script] listing in "----" 5371813768 git-ls-remote.txt: wrap shell listing in "----" 1925fe0c8a Documentation: wrap config listings in "----" 922a2c93f5 git-merge-base.txt: render indentations correctly under Asciidoctor 2017956a19 Documentation: wrap blocks with "--" dd2e50a84e commit-graph: turn off save_commit_buffer 67fa6aac5a commit-graph: don't show progress percentages while expanding reachable commits 806278dead commit-graph.c: handle corrupt/missing trees 16749b8dd2 commit-graph.c: handle commit parsing errors 23424ea759 t/t5318: introduce failing 'git commit-graph write' tests bf1e28e0ad builtin/rebase.c: Remove pointless message d2172ef02d builtin/rebase.c: make sure the active branch isn't moved when autostashing bd482d6e33 t: use common $SQ variable 3a37876b5d pack-objects: drop packlist index_pos optimization 7e6b96c73b test-read-cache: drop namelen variable e4b369069e diff-delta: set size out-parameter to 0 for NULL delta 7140414d8b bulk-checkin: zero-initialize hashfile_checkpoint f1cbd033e2 pack-objects: use object_id in packlist_alloc() 0dfed92dfd git-am: handle missing "author" when parsing commit 3960290675 ci: restore running httpd tests 6a20b62d7e t/lib-git-svn.sh: check GIT_TEST_SVN_HTTPD when running SVN HTTP tests c77722b3ea use get_tagged_oid() dad3f0607b tag: factor out get_tagged_oid() 468ce99b77 unpack-trees: rename 'is_excluded_from_list()' 65edd96aec treewide: rename 'exclude' methods to 'pattern' 4ff89ee52c treewide: rename 'EXCL_FLAG_' to 'PATTERN_FLAG_' caa3d55444 treewide: rename 'struct exclude_list' to 'struct pattern_list' ab8db61390 treewide: rename 'struct exclude' to 'struct path_pattern' 483e861111 t9902: use a non-deprecated command for testing 9df53c5de6 Recommend git-filter-repo instead of git-filter-branch 7b6ad97939 t6006: simplify, fix, and optimize empty message test 50094ca45f config/format.txt: specify default value of format.coverLetter c1a6f21cd4 Doc: add more detail for git-format-patch 854b5cb46a t4014: stop losing return codes of git commands dd2b6b6860 t4014: remove confusing pipe in check_threading() 6bd26f58ea t4014: use test_line_count() where possible c6ec6dadba t4014: let sed open its own files f2e2fa8f60 t4014: drop redirections to /dev/null 460609cbd5 t4014: use indentable here-docs 92014b69bb t4014: remove spaces after redirect operators 0ab74e979c t4014: use sq for test case names cb46c40662 t4014: move closing sq onto its own line b562a54c01 t4014: s/expected/expect/ e770fbfeff t3005: remove unused variable da280f5f1a t: use LF variable defined in the test harness 7027f508c7 compat/*.[ch]: remove extern from function declarations using spatch 552fc5016f mingw: apply array.cocci rule 476998d05b t3427: accelerate this test by using fast-export and fast-import aac6ff7b5b .gitignore: stop ignoring `.manifest` files 2c65d90f75 am: reload .gitattributes after patching it 1577dc0f7c tree: simplify parse_tree_indirect() 50f26bd035 fetch: add fetch.writeCommitGraph config setting 8e4c8af058 push: disallow --all and refspecs when remote..mirror is set 27fd1e4ea7 merge-options.txt: clarify meaning of various ff-related options 0a8bc7068f clarify documentation for remote helpers 80e3658647 help: make help_unknown_ref() NORETURN 313677627a checkout: add simple check for 'git checkout -b' 3441de5b9c gitk: Make web links clickable a4fa2f0a4c git-gui: allow undoing last revert 414d924beb rebase: teach rebase --keep-base 6330209d7d rebase tests: test linear branch topology 4effc5bc96 rebase: fast-forward --fork-point in more cases c0efb4c1dd rebase: fast-forward --onto in more cases 2b318aa6c3 rebase: refactor can_fast_forward into goto tower c9efc21683 t3432: test for --no-ff's interaction with fast-forward 1ebec8dfc1 fast-import: duplicate into history rather than passing ownership 9756082b3c fast-import: duplicate parsed encoding string 86ae43da6a status: mention --skip for revert and cherry-pick b1b16bba96 completion: add --skip for cherry-pick and revert deaa65a754 completion: merge options for cherry-pick and revert 4336d36512 t3432: distinguish "noop-same" v.s. "work-same" in "same head" tests 793ac7e309 t3432: test rebase fast-forward behavior 359ecebc34 t3431: add rebase --fork-point tests 502c386ff9 t7300-clean: demonstrate deleting nested repo with an ignored file breakage ff61681b46 grep: refactor and simplify PCRE1 support 8991da6a38 grep: make sure NO_LIBPCRE1_JIT disable JIT in PCRE1 1fd881d404 trace2: use warning() directly in tr2_dst_malformed_warning() fd99c2dd9b grep: use return value of strbuf_detach() 82f51af345 log-tree: always use return value of strbuf_detach() 7e92756751 http: don't leak urlmatch_config.vars 9784f97321 commit: free the right buffer in release_commit_memory ce17feb1b3 path: add a function to check for path suffix 60d198d022 banned.h: fix vsprintf()'s ban message 60fe477a0b notes: avoid potential use-after-free during insertion 779ad6641b notes: avoid leaking duplicate entries 4e1a641ee3 mingw: fix launching of externals from Unicode paths 5cf7b3b1ac setup_git_directory(): handle UNC root paths correctly e2683d51d9 Fix .git/ discovery at the root of UNC shares d17f2124a7 setup_git_directory(): handle UNC paths correctly ebb8d2c90f mingw: support UNC in git clone file://server/share/repo 0c37c41d13 t4009: make hash size independent c1f3dfcc23 t4002: make hash independent 8cc5ff83c3 t4000: make hash size independent c784815073 t3903: abstract away SHA-1-specific constants 2ccdfb1c78 git-gui: return early when patch fails to apply 62bd99934b git-gui: allow reverting selected hunk 5f0a516de9 git-gui: allow reverting selected lines fddf2ebe38 transport: teach all vtables to allow fetch first ac3fda82bf transport-helper: skip ls-refs if unnecessary 745f681289 First batch after Git 2.23 d4b12b9e07 Merge branch 'sg/worktree-remove-errormsg' 22e86e85cb Merge branch 'en/fast-import-merge-doc' 9c7573581c Merge branch 'jk/perf-no-dups' 4336fdb2ef Merge branch 'rs/nedalloc-fixlets' 8ae7a46c4d Merge branch 'sg/show-failed-test-names' 6ba06b582b Merge branch 'sg/commit-graph-validate' 072735ea58 Merge branch 'vn/restore-empty-ita-corner-case-fix' 207ad3cb20 Merge branch 'sc/pack-refs-deletion-racefix' 77067b6ce8 Merge branch 'sg/do-not-skip-non-httpd-tests' 1b01cdbf2e Merge branch 'jk/tree-walk-overflow' 8aa76abba5 Merge branch 'sg/t5510-test-i18ngrep-fix' 307179732d Merge branch 'mt/grep-submodules-working-tree' 58166c2e9d t0021: make sure clean filter runs 8b3f33ef11 ref-filter: initialize empty name or email fields 3c81760bc6 userdiff: add a builtin pattern for dts files fe49814409 t4014: drop unnecessary blank lines from test cases a2bb801f6a line-log: avoid unnecessary full tree diffs eef5204190 line-log: extract pathspec parsing from line ranges into a helper function a63694f523 diff: skip GITLINK when lazy fetching missing objs 7cfcb16b0e sha1-name: make sort_ambiguous_oid_array() thread-safe 19800bdc3f parseopt: move definition of enum parse_opt_result up 415b770b88 packfile.h: drop extern from function declaration acb49d1cc8 t3800: make hash-size independent ca6ba94200 t3600: make hash size independent 19ce5496c2 t3506: make hash independent 9a6738c061 t3430: avoid hard-coded object IDs 4dd1b5f90f t3404: abstract away SHA-1-specific constants b99bfc7a6c t3306: abstract away SHA-1-specific constants e3e9d02e35 t3305: make hash size independent b408cf8cf6 t3301: abstract away SHA-1-specific constants b561edd213 t3206: abstract away hash size constants a5f61c7d13 t3201: abstract away SHA-1-specific constants 1c24a54ea4 repository-layout.txt: correct pluralization of 'object' b0a3186140 sequencer: simplify root commit creation a47ba3c777 rebase -i: check for updated todo after squash and reword 450efe2d53 rebase -i: always update HEAD before rewording c581e4a749 grep: under --debug, show whether PCRE JIT is enabled aaa95dfa05 midx: switch to using the_hash_algo be8e172e9f builtin/show-index: replace sha1_to_hex 3f34d70d40 rerere: replace sha1_to_hex fc06be3b7f builtin/receive-pack: replace sha1_to_hex 69fa337060 builtin/index-pack: replace sha1_to_hex 3a4d7aa5ae packfile: replace sha1_to_hex e0cb7cdb89 wt-status: convert struct wt_status to object_id 8d4d86b0f0 cache: remove null_sha1 f6ca67d673 builtin/worktree: switch null_sha1 to null_oid dd336a5511 builtin/repack: write object IDs of the proper length 894c0f66bb pack-write: use hash_to_hex when writing checksums 4439c7a360 sequencer: convert to use the_hash_algo 95518faac1 bisect: switch to using the_hash_algo e84f3572bd sha1-lookup: switch hard-coded constants to the_hash_algo fe9fec45f6 config: use the_hash_algo in abbrev comparison 976ff7e49d combine-diff: replace GIT_SHA1_HEXSZ with the_hash_algo 703d2d4193 bundle: switch to use the_hash_algo 9d958cc041 connected: switch GIT_SHA1_HEXSZ to the_hash_algo 7962e046ff show-index: switch hard-coded constants to the_hash_algo fee49308a1 blame: remove needless comparison with GIT_SHA1_HEXSZ 7e0d029f18 builtin/rev-parse: switch to use the_hash_algo 319009642c builtin/blame: switch uses of GIT_SHA1_HEXSZ to the_hash_algo fabec2c5c3 builtin/receive-pack: switch to use the_hash_algo f6af19a9ad fetch-pack: use parse_oid_hex 36261e42ec patch-id: convert to use the_hash_algo 28ba1830d0 builtin/replace: make hash size independent 24bc1a1292 pull, fetch: add --set-upstream option 71d41ff651 archive-tar: turn length miscalculation warning into BUG 17e9ef00d2 archive-tar: use size_t in strbuf_append_ext_header() 82a46af13e archive-tar: fix pax extended header length calculation 4060c1990a archive-tar: report wrong pax extended header length 4615a8cb5b merge-recursive: alphabetize include list 45ef16f77a merge-recursive: add sanity checks for relevant merge_options f3081dae01 merge-recursive: rename MERGE_RECURSIVE_* to MERGE_VARIANT_* 5bf7e5779e merge-recursive: split internal fields into a separate struct e95e481f9e merge-recursive: avoid losing output and leaking memory holding that output a779fb829b merge-recursive: comment and reorder the merge_options fields 8599ab4574 merge-recursive: consolidate unnecessary fields in merge_options 7c0a6c8e47 merge-recursive: move some definitions around to clean up the header c749ab1da8 merge-recursive: rename merge_options argument to opt in header bab56877e0 merge-recursive: rename 'mrtree' to 'result_tree', for clarity ff1bfa2cd5 merge-recursive: use common name for ancestors/common/base_list 4d7101e25c merge-recursive: fix some overly long lines 724dd767b2 cache-tree: share code between functions writing an index as a tree 345480d1ed merge-recursive: don't force external callers to do our logging b4db8a2b76 merge-recursive: remove useless parameter in merge_trees() 98a1d3d888 merge-recursive: exit early if index != head 9822175d2b Ensure index matches head before invoking merge machinery, round N 10f751c06b merge-recursive: remove another implicit dependency on the_repository f836bf3937 merge-recursive: future-proof update_file_flags() against memory leaks 8e01251694 merge-recursive: introduce an enum for detect_directory_renames values 743474cbfa merge-recursive: provide a better label for diff3 common ancestor 51eeaf4aa7 l10n: sv.po: Update Swedish translation (4674t0f0u) 5bace62582 l10n: Update Catalan translation 139ef37a2f merge-recursive: enforce opt->ancestor != NULL when calling merge_trees() 65c01c6442 checkout: provide better conflict hunk description with detached HEAD d8523ca1b9 merge-recursive: be consistent with assert acb7da05ac checkout: remove duplicate code 93b980e58f http: use xmalloc with cURL 64e5e1fba1 diff: 'diff.indentHeuristic' is no longer experimental aaf633c2ad repo-settings: create feature.experimental setting c6cc4c5afd repo-settings: create feature.manyFiles setting ad0fb65999 repo-settings: parse core.untrackedCache 31b1de6a09 commit-graph: turn on commit-graph by default b068d9a250 t6501: use 'git gc' in quiet mode 7211b9e753 repo-settings: consolidate some config settings 507e5470a0 worktree remove: clarify error message on dirty worktree 5af9d5f6c8 completion: complete config variables and values for 'git clone --config=' 88cd790d6a completion: complete config variables names and values for 'git clone -c' dd33472831 completion: complete values of configuration variables after 'git -c var=' e1e00089da completion: complete configuration sections and variable names for 'git -c' 42d0efec59 completion: split _git_config() d9ee1e0617 completion: simplify inner 'case' pattern in __gitcomp() 2675ea1cc0 completion: use 'sort -u' to deduplicate config variable names d9438873c4 completion: deduplicate configuration sections 7a09a8f093 completion: add tests for 'git config' completion 840d7e5b3c completion: complete more values of more 'color.*' configuration variables 08a12175d8 completion: fix a typo in a comment 9827d4c185 packfile: drop release_pack_memory() d1387d3895 git-fast-import.txt: clarify that multiple merge commits are allowed 362f8b280c t/perf: rename duplicate-numbered test script 742ed63345 trace2: cleanup whitespace in perf format e34430556c trace2: cleanup whitespace in normal format c2b890aca5 quote: add sq_append_quote_argv_pretty() ad43e37839 trace2: trim trailing whitespace in normal format error message 04f10d332f trace2: remove dead code in maybe_add_string_va() da4589ce7e trace2: trim whitespace in region messages in perf target format 0d88f3d2c5 Merge branch 'py/call-do-quit-before-exit' of github.com:gitster/git-gui into py/git-gui-do-quit 5440eb0ea2 git-gui: call do_quit before destroying the main window bc40ce4de6 merge: --no-verify to bypass pre-merge-commit hook 6098817fd7 git-merge: honor pre-merge-commit hook a1f3dd7eb3 merge: do no-verify like commit f78f6c7e0c t7503: verify proper hook execution 70597e8386 nedmalloc: avoid compiler warning about unused value c9b9c09dae nedmalloc: do assignments only after the declaration section 22932d9169 config: stop checking whether the_repository is NULL 5732f2b1ef common-main: delay trace2 initialization 58ebccb478 t1309: use short branch name in includeIf.onbranch test 67feca3b1c gitcli: document --end-of-options 51b4594b40 parse-options: allow --end-of-options as a synonym for "--" 19e8789b23 revision: allow --end-of-options to end option parsing ffe1afe67c tests: show the test name and number at the start of verbose output 96f3ccc2ab t0000-basic: use realistic test script names in the verbose tests 7c5c9b9c57 commit-graph: error out on invalid commit oids in 'write --stdin-commits' 39d8831856 commit-graph: turn a group of write-related macro flags into an enum 9916073be5 t5318-commit-graph: use 'test_expect_code' 620c09e1b6 restore: add test for deleted ita files ecd72042de checkout.c: unstage empty deleted ita files a613d4f817 pack-refs: always refresh after taking the lock file decfe05bb6 t: warn against adding non-httpd-specific tests after sourcing 'lib-httpd' 371df1bea9 trace2: cleanup column alignment in perf target format 5aa02f9868 tree-walk: harden make_traverse_path() length computations c43ab06259 tree-walk: add a strbuf wrapper for make_traverse_path() b3b3cbcbf2 tree-walk: accept a raw length for traverse_path_len() 37806080d7 tree-walk: use size_t consistently 7f005b0f48 t5703: run all non-httpd-specific tests before sourcing 'lib-httpd.sh' 12b1826609 t5510-fetch: run non-httpd-specific test before sourcing 'lib-httpd.sh' 9055384710 tree-walk: drop oid from traverse_info 947208b725 setup_traverse_info(): stop copying oid e1fac531ea rebase -r: do not (re-)generate root commits with `--root` *and* `--onto` a63f990d92 t3418: test `rebase -r` with merge strategies 5dcdd7409a t/lib-rebase: prepare for testing `git rebase --rebase-merges` e145d99347 rebase -r: support merge strategies other than `recursive` 4e6023b13a t3427: fix another incorrect assumption f67336dabf t3427: accommodate for the `rebase --merge` backend having been replaced a9c71073da t3427: fix erroneous assumption b8c6f24255 t3427: condense the unnecessarily repetitive test cases into three d51b771dc0 t3427: move the `filter-branch` invocation into the `setup` case c248d32cdb t3427: simplify the `setup` test case significantly 8c1e24048a t3427: add a clarifying comment 5efed0ecf9 rebase: fold git-rebase--common into the -p backend 68b54f669d sequencer: the `am` and `rebase--interactive` scripts are gone 2e7bbac6be .gitignore: there is no longer a built-in `git-rebase--interactive` 6180b20239 t3400: stop referring to the scripted rebase d5b581f228 Drop unused git-rebase--am.sh 814291cf3f t5510-fetch: fix negated 'test_i18ngrep' invocation 6a289d45c0 grep: fix worktree case in submodules 870eea8166 grep: do not enter PCRE2_UTF mode on fixed matching 8a5999838e grep: stess test PCRE v2 on invalid UTF-8 data 09872f6418 grep: create a "is_fixed" member in "grep_pat" 8a35b540a9 grep: consistently use "p->fixed" in compile_regexp() 685668faaa grep: stop using a custom JIT stack with PCRE v1 34489239d0 grep: stop "using" a custom JIT stack with PCRE v2 04bef50c01 grep: remove overly paranoid BUG(...) code b65abcafc7 grep: use PCRE v2 for optimized fixed-string search 48de2a768c grep: remove the kwset optimization 45d1f37ccc grep: drop support for \0 in --fixed-strings 25754125ce grep: make the behavior for NUL-byte in patterns sane d316af059d grep tests: move binary pattern tests into their own file 471dac5d2c grep tests: move "grep binary" alongside the rest f463beb805 grep: inline the return value of a function call used only once b14cf112e2 t4210: skip more command-line encoding tests on MinGW 44570188a0 grep: don't use PCRE2?_UTF8 with "log --encoding=" 4e2443b181 log tests: test regex backends in "--encode=" tests 90d21f9ebf list-objects-filter-options: make parser void 5a133e8a7f list-objects-filter-options: clean up use of ALLOC_GROW 489fc9ee71 list-objects-filter-options: allow mult. --filter c2694952e3 strbuf: give URL-encoding API a char predicate fn cf9ceb5a12 list-objects-filter-options: make filter_spec a string_list f56f764279 list-objects-filter-options: move error check up e987df5fe6 list-objects-filter: implement composite filters 842b00516a list-objects-filter-options: always supply *errbuf 7a7c7f4a6d list-objects-filter: put omits set in filter struct 9430147ca0 list-objects-filter: encapsulate filter components 4ca9474efa Move core_partial_clone_filter_default to promisor-remote.c 60b7a92d84 Move repository_format_partial_clone to promisor-remote.c db27dca5cf Remove fetch-object.{c,h} in favor of promisor-remote.{c,h} 75de085211 remote: add promisor and partial clone config to the doc 7e154badc0 partial-clone: add multiple remotes in the doc 9a4c507886 t0410: test fetching from many promisor remotes 5e46139376 builtin/fetch: remove unique promisor remote limitation fa3d1b63e8 promisor-remote: parse remote.*.partialclonefilter b14ed5adaf Use promisor_remote_get_direct() and has_promisor_remote() faf2abf496 promisor-remote: use repository_format_partial_clone 9cfebc1f3b promisor-remote: add promisor_remote_reinit() 9e27beaa23 promisor-remote: implement promisor_remote_get_direct() 48de315817 Add initial support for many promisor remotes 2e860675b6 fetch-object: make functions return an error code c59c7c879e t0410: remove pipes after git commands git-subtree-dir: third_party/git git-subtree-split: ef7aa56f965a794d96fb0b1385f94634e7cea06f --- t/README | 17 +- t/check-non-portable-shell.pl | 2 +- t/gitweb-lib.sh | 7 +- t/helper/.gitignore | 9 +- t/helper/test-config.c | 18 +- t/helper/test-date.c | 27 +- t/helper/test-drop-caches.c | 11 +- t/helper/test-dump-fsmonitor.c | 2 +- t/helper/test-hashmap.c | 50 +- t/helper/test-lazy-init-name-hash.c | 12 +- t/helper/test-parse-options.c | 2 + t/helper/test-parse-pathspec-file.c | 33 + t/helper/test-path-utils.c | 113 +++ t/helper/test-progress.c | 81 ++ t/helper/test-read-cache.c | 5 +- t/helper/test-read-graph.c | 53 + t/helper/test-run-command.c | 335 ++++++- t/helper/test-tool.c | 3 + t/helper/test-tool.h | 3 + t/helper/test-windows-named-pipe.c | 2 +- t/lib-bash.sh | 6 +- t/lib-credential.sh | 2 +- t/lib-git-daemon.sh | 2 +- t/lib-git-p4.sh | 2 +- t/lib-git-svn.sh | 4 +- t/lib-httpd.sh | 4 +- t/lib-httpd/apache.conf | 6 +- t/lib-httpd/apply-one-time-perl.sh | 27 + t/lib-httpd/apply-one-time-sed.sh | 22 - t/lib-log-graph.sh | 28 + t/lib-pack.sh | 35 +- t/lib-rebase.sh | 37 +- t/oid-info/hash-info | 9 + t/perf/aggregate.perl | 21 +- t/perf/bisect_regression | 2 +- t/perf/p5303-many-packs.sh | 19 + t/perf/p5310-pack-bitmaps.sh | 22 + t/perf/p5600-clone-reference.sh | 27 - t/perf/p5601-clone-reference.sh | 27 + t/perf/perf-lib.sh | 4 +- t/t0000-basic.sh | 123 ++- t/t0003-attributes.sh | 47 +- t/t0008-ignores.sh | 39 +- t/t0014-alias.sh | 7 + t/t0020-crlf.sh | 18 +- t/t0021-conversion.sh | 8 +- t/t0027-auto-crlf.sh | 2 +- t/t0028-working-tree-encoding.sh | 45 +- t/t0040-parse-options.sh | 29 +- t/t0050-filesystem.sh | 20 + t/t0060-path-utils.sh | 45 +- t/t0061-run-command.sh | 25 +- t/t0067-parse_pathspec_file.sh | 108 ++ t/t0090-cache-tree.sh | 5 +- t/t0211-trace2-perf.sh | 4 +- t/t0212-trace2-event.sh | 19 + t/t0300-credentials.sh | 279 +++++- t/t0410-partial-clone.sh | 93 +- t/t0500-progress-display.sh | 286 ++++++ t/t1011-read-tree-sparse-checkout.sh | 3 +- t/t1014-read-tree-confusing.sh | 1 + t/t1050-large.sh | 16 +- t/t1091-sparse-checkout-builtin.sh | 524 ++++++++++ t/t1300-config.sh | 255 +++-- t/t1305-config-include.sh | 2 +- t/t1306-xdg-files.sh | 8 +- t/t1307-config-blob.sh | 2 +- t/t1308-config-set.sh | 26 +- t/t1309-early-config.sh | 9 +- t/t1400-update-ref.sh | 62 +- t/t1404-update-ref-errors.sh | 64 +- t/t1406-submodule-ref-store.sh | 2 +- t/t1409-avoid-packing-refs.sh | 16 +- t/t1410-reflog.sh | 4 +- t/t1414-reflog-walk.sh | 3 +- t/t1450-fsck.sh | 20 +- t/t1500-rev-parse.sh | 25 + t/t1501-work-tree.sh | 2 +- t/t1506-rev-parse-diagnosis.sh | 79 +- t/t1507-rev-parse-upstream.sh | 116 ++- t/t1512-rev-parse-disambiguation.sh | 4 +- t/t1600-index.sh | 35 +- t/t2018-checkout-branch.sh | 75 +- t/t2022-checkout-paths.sh | 11 + t/t2024-checkout-dwim.sh | 28 +- t/t2026-checkout-pathspec-file.sh | 163 +++ t/t2070-restore.sh | 28 + t/t2072-restore-pathspec-file.sh | 164 +++ t/t2107-update-index-basic.sh | 1 - t/t2400-worktree-add.sh | 37 +- t/t2402-worktree-list.sh | 6 + t/t2405-worktree-submodule.sh | 90 ++ t/t3005-ls-files-relative.sh | 12 +- t/t3007-ls-files-recurse-submodules.sh | 1 - t/t3008-ls-files-lazy-init-name-hash.sh | 2 +- t/t3011-common-prefixes-and-directory-traversal.sh | 209 ++++ t/t3030-merge-recursive.sh | 39 +- t/t3035-merge-sparse.sh | 4 +- t/t3060-ls-files-with-tree.sh | 4 +- t/t3201-branch-contains.sh | 8 +- t/t3206-range-diff.sh | 537 ++++++++-- t/t3206/history.export | 31 +- t/t3210-pack-refs.sh | 2 +- t/t3301-notes.sh | 400 +++++--- t/t3305-notes-fanout.sh | 117 ++- t/t3306-notes-prune.sh | 45 +- t/t3308-notes-merge.sh | 83 +- t/t3309-notes-merge-auto-resolve.sh | 228 +++-- t/t3310-notes-merge-manual-resolve.sh | 106 +- t/t3311-notes-merge-fanout.sh | 60 +- t/t3400-rebase.sh | 102 +- t/t3401-rebase-and-am-rename.sh | 4 +- t/t3403-rebase-skip.sh | 32 + t/t3404-rebase-interactive.sh | 790 ++++++++++----- t/t3406-rebase-message.sh | 19 +- t/t3407-rebase-abort.sh | 6 +- t/t3415-rebase-autosquash.sh | 153 ++- t/t3416-rebase-onto-threedots.sh | 57 ++ t/t3418-rebase-continue.sh | 14 + t/t3419-rebase-patch-id.sh | 5 +- t/t3420-rebase-autostash.sh | 34 +- t/t3421-rebase-topology-linear.sh | 79 +- t/t3422-rebase-incompatible-options.sh | 10 - t/t3424-rebase-empty.sh | 134 +++ t/t3425-rebase-topology-merges.sh | 8 +- t/t3427-rebase-subtree.sh | 160 ++- t/t3429-rebase-edit-todo.sh | 53 +- t/t3430-rebase-merges.sh | 81 +- t/t3431-rebase-fork-point.sh | 57 ++ t/t3432-rebase-fast-forward.sh | 123 +++ t/t3433-rebase-across-mode-change.sh | 48 + t/t3434-rebase-i18n.sh | 84 ++ t/t3434/ISO8859-1.txt | 3 + t/t3434/eucJP.txt | 4 + t/t3501-revert-cherry-pick.sh | 4 +- t/t3504-cherry-pick-rerere.sh | 6 +- t/t3506-cherry-pick-ff.sh | 8 +- t/t3507-cherry-pick-conflict.sh | 28 +- t/t3508-cherry-pick-many-commits.sh | 2 +- t/t3600-rm.sh | 25 +- t/t3601-rm-pathspec-file.sh | 79 ++ t/t3700-add.sh | 4 +- t/t3701-add-interactive.sh | 181 +++- t/t3704-add-pathspec-file.sh | 159 +++ t/t3800-mktag.sh | 49 +- t/t3900-i18n-commit.sh | 37 + t/t3903-stash.sh | 71 +- t/t3905-stash-include-untracked.sh | 4 +- t/t3906-stash-submodule.sh | 42 +- t/t3908-stash-in-worktree.sh | 27 + t/t3909-stash-pathspec-file.sh | 100 ++ t/t4000-diff-format.sh | 2 +- t/t4002-diff-basic.sh | 367 +++++-- t/t4009-diff-rename-4.sh | 19 +- t/t4010-diff-pathspec.sh | 20 +- t/t4011-diff-symlink.sh | 40 +- t/t4013-diff-various.sh | 47 +- t/t4014-format-patch.sh | 1059 ++++++++++++-------- t/t4015-diff-whitespace.sh | 213 ++-- t/t4018-diff-funcname.sh | 3 +- t/t4018/dts-labels | 9 + t/t4018/dts-node-unitless | 8 + t/t4018/dts-nodes | 8 + t/t4018/dts-nodes-boolean-prop | 9 + t/t4018/dts-nodes-comment1 | 8 + t/t4018/dts-nodes-comment2 | 8 + t/t4018/dts-nodes-multiline-prop | 13 + t/t4018/dts-reference | 9 + t/t4018/dts-root | 5 + t/t4018/dts-root-comment | 8 + t/t4018/elixir-do-not-pick-end | 5 + t/t4018/elixir-ex-unit-test | 6 + t/t4018/elixir-function | 5 + t/t4018/elixir-macro | 5 + t/t4018/elixir-module | 9 + t/t4018/elixir-module-func | 8 + t/t4018/elixir-nested-module | 9 + t/t4018/elixir-private-function | 5 + t/t4018/elixir-protocol | 6 + t/t4018/elixir-protocol-implementation | 5 + t/t4018/python-async-def | 4 + t/t4018/python-class | 4 + t/t4018/python-def | 4 + t/t4018/python-indented-async-def | 7 + t/t4018/python-indented-class | 5 + t/t4018/python-indented-def | 7 + t/t4026-color.sh | 12 + t/t4027-diff-submodule.sh | 16 +- t/t4034-diff-words.sh | 94 +- t/t4034/dts/expect | 37 + t/t4034/dts/post | 32 + t/t4034/dts/pre | 32 + t/t4038-diff-combined.sh | 23 +- t/t4039-diff-assume-unchanged.sh | 3 +- t/t4041-diff-submodule-option.sh | 20 +- t/t4044-diff-index-unique-abbrev.sh | 46 +- t/t4045-diff-relative.sh | 2 +- t/t4048-diff-combined-binary.sh | 58 +- t/t4054-diff-bogus-tree.sh | 3 +- t/t4057-diff-combined-paths.sh | 2 +- t/t4060-diff-submodule-option-diff-format.sh | 126 +-- t/t4066-diff-emit-delay.sh | 10 +- t/t4067-diff-partial-clone.sh | 31 + t/t4100/t-apply-1.patch | 4 +- t/t4100/t-apply-3.patch | 2 +- t/t4100/t-apply-5.patch | 4 +- t/t4100/t-apply-7.patch | 2 +- t/t4108-apply-threeway.sh | 55 +- t/t4117-apply-reject.sh | 6 +- t/t4124-apply-ws-rule.sh | 10 +- t/t4134-apply-submodule.sh | 5 +- t/t4138-apply-ws-expansion.sh | 16 +- t/t4150-am.sh | 72 ++ t/t4200-rerere.sh | 3 +- t/t4202-log.sh | 244 +++-- t/t4203-mailmap.sh | 122 ++- t/t4204-patch-id.sh | 2 +- t/t4205-log-pretty-formats.sh | 81 +- t/t4210-log-i18n.sh | 41 +- t/t4211-line-log.sh | 85 +- t/t4211/expect.beginning-of-file | 43 - t/t4211/expect.end-of-file | 62 -- t/t4211/expect.move-support-f | 80 -- t/t4211/expect.multiple | 104 -- t/t4211/expect.multiple-overlapping | 187 ---- t/t4211/expect.multiple-superset | 187 ---- t/t4211/expect.parallel-change-f-to-main | 160 --- t/t4211/expect.simple-f | 59 -- t/t4211/expect.simple-f-to-main | 100 -- t/t4211/expect.simple-main | 68 -- t/t4211/expect.simple-main-to-end | 70 -- t/t4211/expect.two-ranges | 102 -- t/t4211/expect.vanishes-early | 39 - t/t4211/sha1/expect.beginning-of-file | 43 + t/t4211/sha1/expect.end-of-file | 62 ++ t/t4211/sha1/expect.move-support-f | 80 ++ t/t4211/sha1/expect.multiple | 104 ++ t/t4211/sha1/expect.multiple-overlapping | 187 ++++ t/t4211/sha1/expect.multiple-superset | 187 ++++ t/t4211/sha1/expect.parallel-change-f-to-main | 160 +++ t/t4211/sha1/expect.simple-f | 59 ++ t/t4211/sha1/expect.simple-f-to-main | 100 ++ t/t4211/sha1/expect.simple-main | 68 ++ t/t4211/sha1/expect.simple-main-to-end | 70 ++ t/t4211/sha1/expect.two-ranges | 102 ++ t/t4211/sha1/expect.vanishes-early | 39 + t/t4211/sha256/expect.beginning-of-file | 43 + t/t4211/sha256/expect.end-of-file | 62 ++ t/t4211/sha256/expect.move-support-f | 80 ++ t/t4211/sha256/expect.multiple | 104 ++ t/t4211/sha256/expect.multiple-overlapping | 187 ++++ t/t4211/sha256/expect.multiple-superset | 187 ++++ t/t4211/sha256/expect.parallel-change-f-to-main | 160 +++ t/t4211/sha256/expect.simple-f | 59 ++ t/t4211/sha256/expect.simple-f-to-main | 100 ++ t/t4211/sha256/expect.simple-main | 68 ++ t/t4211/sha256/expect.simple-main-to-end | 70 ++ t/t4211/sha256/expect.two-ranges | 102 ++ t/t4211/sha256/expect.vanishes-early | 39 + t/t4213-log-tabexpand.sh | 2 +- t/t4214-log-graph-octopus.sh | 339 ++++++- t/t4215-log-skewed-merges.sh | 373 +++++++ t/t4256-am-format-flowed.sh | 2 +- t/t4300-merge-tree.sh | 188 ++-- t/t5004-archive-corner-cases.sh | 19 + t/t5100-mailinfo.sh | 15 + t/t5150-request-pull.sh | 8 +- t/t5302-pack-index.sh | 21 +- t/t5307-pack-missing-commit.sh | 4 +- t/t5309-pack-delta-cycles.sh | 18 +- t/t5310-pack-bitmaps.sh | 36 +- t/t5313-pack-bounds-checks.sh | 19 +- t/t5314-pack-cycle-detection.sh | 2 +- t/t5317-pack-objects-filter-objects.sh | 34 +- t/t5318-commit-graph.sh | 101 +- t/t5319-multi-pack-index.sh | 95 +- t/t5321-pack-large-objects.sh | 4 +- t/t5324-split-commit-graph.sh | 19 +- t/t5400-send-pack.sh | 2 +- t/t5407-post-rewrite-hook.sh | 16 +- t/t5409-colorize-remote-messages.sh | 3 +- t/t5500-fetch-pack.sh | 77 +- t/t5504-fetch-receive-strict.sh | 17 +- t/t5505-remote.sh | 88 +- t/t5509-fetch-push-namespaces.sh | 13 +- t/t5510-fetch.sh | 110 +- t/t5512-ls-remote.sh | 29 +- t/t5514-fetch-multiple.sh | 11 + t/t5515-fetch-merge-logic.sh | 63 +- t/t5516-fetch-push.sh | 23 +- t/t5517-push-mirror.sh | 10 + t/t5520-pull.sh | 366 ++++--- t/t5528-push-default.sh | 2 +- t/t5530-upload-pack-error.sh | 26 +- t/t5535-fetch-push-symref.sh | 2 +- t/t5537-fetch-shallow.sh | 21 +- t/t5539-fetch-http-shallow.sh | 2 +- t/t5540-http-push-webdav.sh | 6 +- t/t5541-http-push-smart.sh | 50 +- t/t5545-push-options.sh | 5 +- t/t5550-http-fetch-dumb.sh | 16 +- t/t5551-http-fetch-smart.sh | 12 +- t/t5552-skipping-fetch-negotiator.sh | 41 +- t/t5553-set-upstream.sh | 178 ++++ t/t5562-http-backend-content-length.sh | 2 +- t/t5573-pull-verify-signatures.sh | 64 ++ t/t5580-clone-push-unc.sh | 77 -- t/t5580-unc-paths.sh | 89 ++ t/t5601-clone.sh | 11 +- t/t5604-clone-reference.sh | 5 +- t/t5607-clone-bundle.sh | 13 +- t/t5608-clone-2gb.sh | 2 +- t/t5616-partial-clone.sh | 219 +++- t/t5617-clone-submodules-remote.sh | 13 +- t/t5700-protocol-v1.sh | 6 +- t/t5702-protocol-v2.sh | 50 +- t/t5703-upload-pack-ref-in-want.sh | 250 ++--- t/t5801-remote-helpers.sh | 1 - t/t6000-rev-list-misc.sh | 33 +- t/t6006-rev-list-format.sh | 37 +- t/t6011-rev-list-with-bad-commit.sh | 2 +- t/t6016-rev-list-graph-simplify-history.sh | 30 +- t/t6019-rev-list-ancestry-path.sh | 4 +- t/t6020-merge-df.sh | 55 +- t/t6021-merge-criss-cross.sh | 137 +-- t/t6022-merge-rename.sh | 393 ++++---- t/t6023-merge-file.sh | 568 ++++++----- t/t6024-recursive-merge.sh | 135 +-- t/t6025-merge-symlinks.sh | 95 +- t/t6026-merge-attr.sh | 46 +- t/t6030-bisect-porcelain.sh | 2 +- t/t6034-merge-rename-nocruft.sh | 122 ++- t/t6035-merge-dir-to-symlink.sh | 28 +- t/t6036-recursive-corner-cases.sh | 51 +- t/t6042-merge-rename-corner-cases.sh | 111 +- t/t6043-merge-rename-directories.sh | 574 +++++++---- t/t6046-merge-skip-unneeded-updates.sh | 217 ++-- t/t6047-diff3-conflict-markers.sh | 211 ++++ t/t6102-rev-list-unexpected-objects.sh | 2 +- t/t6112-rev-list-filters-objects.sh | 194 +++- t/t6113-rev-list-bitmap-filters.sh | 56 ++ t/t6120-describe.sh | 138 ++- t/t6130-pathspec-noglob.sh | 1 + t/t6136-pathspec-in-bare.sh | 38 + t/t6300-for-each-ref.sh | 19 + t/t6500-gc.sh | 6 +- t/t6501-freshen-objects.sh | 6 +- t/t7004-tag.sh | 9 +- t/t7008-filter-branch-null-sha1.sh | 55 + t/t7008-grep-binary.sh | 249 ----- t/t7009-filter-branch-null-sha1.sh | 55 - t/t7012-skip-worktree-writing.sh | 15 + t/t7030-verify-tag.sh | 38 +- t/t7061-wtstatus-ignore.sh | 9 +- t/t7105-reset-patch.sh | 21 + t/t7107-reset-pathspec-file.sh | 173 ++++ t/t7300-clean.sh | 73 +- t/t7400-submodule-basic.sh | 64 +- t/t7406-submodule-update.sh | 33 +- t/t7410-submodule-checkout-to.sh | 77 -- t/t7415-submodule-names.sh | 57 ++ t/t7416-submodule-dash-url.sh | 157 ++- t/t7417-submodule-path-url.sh | 17 + t/t7419-submodule-set-branch.sh | 6 +- t/t7420-submodule-set-url.sh | 55 + t/t7500-commit-template-squash-signoff.sh | 9 + t/t7501-commit-basic-functionality.sh | 83 +- t/t7503-pre-commit-and-pre-merge-commit-hooks.sh | 281 ++++++ t/t7503-pre-commit-hook.sh | 139 --- t/t7505-prepare-commit-msg-hook.sh | 8 +- t/t7505/expected-rebase-i | 3 +- t/t7508-status.sh | 2 +- t/t7510-signed-commit.sh | 39 + t/t7512-status-help.sh | 18 +- t/t7513-interpret-trailers.sh | 2 +- t/t7519-status-fsmonitor.sh | 37 +- t/t7519/fsmonitor-all | 1 - t/t7519/fsmonitor-all-v2 | 21 + t/t7519/fsmonitor-env | 24 + t/t7519/fsmonitor-watchman | 16 +- t/t7519/fsmonitor-watchman-v2 | 173 ++++ t/t7526-commit-pathspec-file.sh | 164 +++ t/t7612-merge-verify-signatures.sh | 22 + t/t7700-repack.sh | 172 ++-- t/t7800-difftool.sh | 5 +- t/t7811-grep-open.sh | 1 - t/t7812-grep-icase-non-ascii.sh | 31 + t/t7814-grep-recurse-submodules.sh | 32 +- t/t7815-grep-binary.sh | 148 +++ t/t7816-grep-binary-pattern.sh | 127 +++ t/t8003-blame-corner-cases.sh | 1 - t/t9001-send-email.sh | 8 +- t/t9010-svn-fe.sh | 4 +- t/t9106-git-svn-commit-diff-clobber.sh | 3 +- t/t9116-git-svn-log.sh | 12 +- t/t9300-fast-import.sh | 132 ++- t/t9301-fast-import-notes.sh | 2 +- t/t9350-fast-export.sh | 71 +- t/t9502-gitweb-standalone-parse-output.sh | 7 +- t/t9800-git-p4-basic.sh | 1 - t/t9809-git-p4-client-view.sh | 2 +- t/t9810-git-p4-rcs.sh | 1 - t/t9902-completion.sh | 145 ++- t/t9903-bash-prompt.sh | 8 +- t/test-lib-functions.sh | 88 +- t/test-lib.sh | 82 +- 406 files changed, 19187 insertions(+), 6683 deletions(-) create mode 100644 t/helper/test-parse-pathspec-file.c create mode 100644 t/helper/test-progress.c create mode 100644 t/helper/test-read-graph.c create mode 100644 t/lib-httpd/apply-one-time-perl.sh delete mode 100644 t/lib-httpd/apply-one-time-sed.sh create mode 100755 t/lib-log-graph.sh delete mode 100755 t/perf/p5600-clone-reference.sh create mode 100755 t/perf/p5601-clone-reference.sh create mode 100755 t/t0067-parse_pathspec_file.sh create mode 100755 t/t0500-progress-display.sh create mode 100755 t/t1091-sparse-checkout-builtin.sh create mode 100755 t/t2026-checkout-pathspec-file.sh create mode 100755 t/t2072-restore-pathspec-file.sh create mode 100755 t/t2405-worktree-submodule.sh create mode 100755 t/t3011-common-prefixes-and-directory-traversal.sh create mode 100755 t/t3424-rebase-empty.sh create mode 100755 t/t3431-rebase-fork-point.sh create mode 100755 t/t3432-rebase-fast-forward.sh create mode 100755 t/t3433-rebase-across-mode-change.sh create mode 100755 t/t3434-rebase-i18n.sh create mode 100644 t/t3434/ISO8859-1.txt create mode 100644 t/t3434/eucJP.txt create mode 100755 t/t3601-rm-pathspec-file.sh create mode 100755 t/t3704-add-pathspec-file.sh create mode 100755 t/t3908-stash-in-worktree.sh create mode 100755 t/t3909-stash-pathspec-file.sh create mode 100644 t/t4018/dts-labels create mode 100644 t/t4018/dts-node-unitless create mode 100644 t/t4018/dts-nodes create mode 100644 t/t4018/dts-nodes-boolean-prop create mode 100644 t/t4018/dts-nodes-comment1 create mode 100644 t/t4018/dts-nodes-comment2 create mode 100644 t/t4018/dts-nodes-multiline-prop create mode 100644 t/t4018/dts-reference create mode 100644 t/t4018/dts-root create mode 100644 t/t4018/dts-root-comment create mode 100644 t/t4018/elixir-do-not-pick-end create mode 100644 t/t4018/elixir-ex-unit-test create mode 100644 t/t4018/elixir-function create mode 100644 t/t4018/elixir-macro create mode 100644 t/t4018/elixir-module create mode 100644 t/t4018/elixir-module-func create mode 100644 t/t4018/elixir-nested-module create mode 100644 t/t4018/elixir-private-function create mode 100644 t/t4018/elixir-protocol create mode 100644 t/t4018/elixir-protocol-implementation create mode 100644 t/t4018/python-async-def create mode 100644 t/t4018/python-class create mode 100644 t/t4018/python-def create mode 100644 t/t4018/python-indented-async-def create mode 100644 t/t4018/python-indented-class create mode 100644 t/t4018/python-indented-def create mode 100644 t/t4034/dts/expect create mode 100644 t/t4034/dts/post create mode 100644 t/t4034/dts/pre delete mode 100644 t/t4211/expect.beginning-of-file delete mode 100644 t/t4211/expect.end-of-file delete mode 100644 t/t4211/expect.move-support-f delete mode 100644 t/t4211/expect.multiple delete mode 100644 t/t4211/expect.multiple-overlapping delete mode 100644 t/t4211/expect.multiple-superset delete mode 100644 t/t4211/expect.parallel-change-f-to-main delete mode 100644 t/t4211/expect.simple-f delete mode 100644 t/t4211/expect.simple-f-to-main delete mode 100644 t/t4211/expect.simple-main delete mode 100644 t/t4211/expect.simple-main-to-end delete mode 100644 t/t4211/expect.two-ranges delete mode 100644 t/t4211/expect.vanishes-early create mode 100644 t/t4211/sha1/expect.beginning-of-file create mode 100644 t/t4211/sha1/expect.end-of-file create mode 100644 t/t4211/sha1/expect.move-support-f create mode 100644 t/t4211/sha1/expect.multiple create mode 100644 t/t4211/sha1/expect.multiple-overlapping create mode 100644 t/t4211/sha1/expect.multiple-superset create mode 100644 t/t4211/sha1/expect.parallel-change-f-to-main create mode 100644 t/t4211/sha1/expect.simple-f create mode 100644 t/t4211/sha1/expect.simple-f-to-main create mode 100644 t/t4211/sha1/expect.simple-main create mode 100644 t/t4211/sha1/expect.simple-main-to-end create mode 100644 t/t4211/sha1/expect.two-ranges create mode 100644 t/t4211/sha1/expect.vanishes-early create mode 100644 t/t4211/sha256/expect.beginning-of-file create mode 100644 t/t4211/sha256/expect.end-of-file create mode 100644 t/t4211/sha256/expect.move-support-f create mode 100644 t/t4211/sha256/expect.multiple create mode 100644 t/t4211/sha256/expect.multiple-overlapping create mode 100644 t/t4211/sha256/expect.multiple-superset create mode 100644 t/t4211/sha256/expect.parallel-change-f-to-main create mode 100644 t/t4211/sha256/expect.simple-f create mode 100644 t/t4211/sha256/expect.simple-f-to-main create mode 100644 t/t4211/sha256/expect.simple-main create mode 100644 t/t4211/sha256/expect.simple-main-to-end create mode 100644 t/t4211/sha256/expect.two-ranges create mode 100644 t/t4211/sha256/expect.vanishes-early create mode 100755 t/t4215-log-skewed-merges.sh create mode 100755 t/t5553-set-upstream.sh delete mode 100755 t/t5580-clone-push-unc.sh create mode 100755 t/t5580-unc-paths.sh create mode 100755 t/t6047-diff3-conflict-markers.sh create mode 100755 t/t6113-rev-list-bitmap-filters.sh create mode 100755 t/t6136-pathspec-in-bare.sh create mode 100755 t/t7008-filter-branch-null-sha1.sh delete mode 100755 t/t7008-grep-binary.sh delete mode 100755 t/t7009-filter-branch-null-sha1.sh create mode 100755 t/t7107-reset-pathspec-file.sh delete mode 100755 t/t7410-submodule-checkout-to.sh create mode 100755 t/t7420-submodule-set-url.sh create mode 100755 t/t7503-pre-commit-and-pre-merge-commit-hooks.sh delete mode 100755 t/t7503-pre-commit-hook.sh create mode 100755 t/t7519/fsmonitor-all-v2 create mode 100755 t/t7519/fsmonitor-env create mode 100755 t/t7519/fsmonitor-watchman-v2 create mode 100755 t/t7526-commit-pathspec-file.sh create mode 100755 t/t7815-grep-binary.sh create mode 100755 t/t7816-grep-binary-pattern.sh (limited to 't') diff --git a/t/README b/t/README index 60d5b77bccd9..9afd61e3ca0d 100644 --- a/t/README +++ b/t/README @@ -352,8 +352,8 @@ details. GIT_TEST_SPLIT_INDEX= forces split-index mode on the whole test suite. Accept any boolean values that are accepted by git-config. -GIT_TEST_PROTOCOL_VERSION=, when set, overrides the -'protocol.version' setting to n if it is less than n. +GIT_TEST_PROTOCOL_VERSION=, when set, makes 'protocol.version' +default to n. GIT_TEST_FULL_IN_PACK_ARRAY= exercises the uncommon pack-objects code path where there are more than 1024 packs even if @@ -397,6 +397,10 @@ GIT_TEST_STASH_USE_BUILTIN=, when false, disables the built-in version of git-stash. See 'stash.useBuiltin' in git-config(1). +GIT_TEST_ADD_I_USE_BUILTIN=, when true, enables the +built-in version of git add -i. See 'add.interactive.useBuiltin' in +git-config(1). + GIT_TEST_INDEX_THREADS= enables exercising the multi-threaded loading of the index for the whole test suite by bypassing the default number of cache entries and thread minimums. Setting this to 1 will make the @@ -978,6 +982,15 @@ library for your script to use. output to the downstream---unlike the real version, it generates only up to 99 lines. + - test_bool_env + + Given the name of an environment variable with a bool value, + normalize its value to a 0 (true) or 1 (false or empty string) + return code. Return with code corresponding to the given default + value if the variable is unset. + Abort the test script if either the value of the variable or the + default are not valid bool values. + Prerequisites ------------- diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index 38bfeebd881a..fd3303552bec 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -46,7 +46,7 @@ while (<>) { /(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)'; /\bgrep\b.*--file\b/ and err 'grep --file FILE is not portable (use grep -f FILE)'; /\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)'; - /^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and + /^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and err '"FOO=bar shell_func" assignment extends beyond "shell_func"'; $line = ''; # this resets our $. for each file diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh index 006d2a8152dc..1f32ca66ea51 100644 --- a/t/gitweb-lib.sh +++ b/t/gitweb-lib.sh @@ -58,10 +58,11 @@ gitweb_run () { GATEWAY_INTERFACE='CGI/1.1' HTTP_ACCEPT='*/*' REQUEST_METHOD='GET' - QUERY_STRING=""$1"" - PATH_INFO=""$2"" + QUERY_STRING=$1 + PATH_INFO=$2 + REQUEST_URI=/gitweb.cgi$PATH_INFO export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD \ - QUERY_STRING PATH_INFO + QUERY_STRING PATH_INFO REQUEST_URI GITWEB_CONFIG=$(pwd)/gitweb_config.perl export GITWEB_CONFIG diff --git a/t/helper/.gitignore b/t/helper/.gitignore index 2bad28af9241..48c7bb0bbb1d 100644 --- a/t/helper/.gitignore +++ b/t/helper/.gitignore @@ -1,5 +1,4 @@ -* -!*.sh -!*.[ch] -!*.gitignore - +/test-tool +/test-fake-ssh +/test-line-buffer +/test-svn-fe diff --git a/t/helper/test-config.c b/t/helper/test-config.c index 214003d5b2f9..234c722b485e 100644 --- a/t/helper/test-config.c +++ b/t/helper/test-config.c @@ -37,21 +37,6 @@ * */ -static const char *scope_name(enum config_scope scope) -{ - switch (scope) { - case CONFIG_SCOPE_SYSTEM: - return "system"; - case CONFIG_SCOPE_GLOBAL: - return "global"; - case CONFIG_SCOPE_REPO: - return "repo"; - case CONFIG_SCOPE_CMDLINE: - return "cmdline"; - default: - return "unknown"; - } -} static int iterate_cb(const char *var, const char *value, void *data) { static int nr; @@ -63,7 +48,8 @@ static int iterate_cb(const char *var, const char *value, void *data) printf("value=%s\n", value ? value : "(null)"); printf("origin=%s\n", current_config_origin_type()); printf("name=%s\n", current_config_name()); - printf("scope=%s\n", scope_name(current_config_scope())); + printf("lno=%d\n", current_config_line()); + printf("scope=%s\n", config_scope_name(current_config_scope())); return 0; } diff --git a/t/helper/test-date.c b/t/helper/test-date.c index 585347ea487a..099eff4f0fc8 100644 --- a/t/helper/test-date.c +++ b/t/helper/test-date.c @@ -12,13 +12,13 @@ static const char *usage_msg = "\n" " test-tool date is64bit\n" " test-tool date time_t-is64bit\n"; -static void show_relative_dates(const char **argv, struct timeval *now) +static void show_relative_dates(const char **argv) { struct strbuf buf = STRBUF_INIT; for (; *argv; argv++) { time_t t = atoi(*argv); - show_date_relative(t, now, &buf); + show_date_relative(t, &buf); printf("%s -> %s\n", *argv, buf.buf); } strbuf_release(&buf); @@ -74,20 +74,20 @@ static void parse_dates(const char **argv) strbuf_release(&result); } -static void parse_approxidate(const char **argv, struct timeval *now) +static void parse_approxidate(const char **argv) { for (; *argv; argv++) { timestamp_t t; - t = approxidate_relative(*argv, now); + t = approxidate_relative(*argv); printf("%s -> %s\n", *argv, show_date(t, 0, DATE_MODE(ISO8601))); } } -static void parse_approx_timestamp(const char **argv, struct timeval *now) +static void parse_approx_timestamp(const char **argv) { for (; *argv; argv++) { timestamp_t t; - t = approxidate_relative(*argv, now); + t = approxidate_relative(*argv); printf("%s -> %"PRItime"\n", *argv, t); } } @@ -103,22 +103,13 @@ static void getnanos(const char **argv) int cmd__date(int argc, const char **argv) { - struct timeval now; const char *x; - x = getenv("GIT_TEST_DATE_NOW"); - if (x) { - now.tv_sec = atoi(x); - now.tv_usec = 0; - } - else - gettimeofday(&now, NULL); - argv++; if (!*argv) usage(usage_msg); if (!strcmp(*argv, "relative")) - show_relative_dates(argv+1, &now); + show_relative_dates(argv+1); else if (!strcmp(*argv, "human")) show_human_dates(argv+1); else if (skip_prefix(*argv, "show:", &x)) @@ -126,9 +117,9 @@ int cmd__date(int argc, const char **argv) else if (!strcmp(*argv, "parse")) parse_dates(argv+1); else if (!strcmp(*argv, "approxidate")) - parse_approxidate(argv+1, &now); + parse_approxidate(argv+1); else if (!strcmp(*argv, "timestamp")) - parse_approx_timestamp(argv+1, &now); + parse_approx_timestamp(argv+1); else if (!strcmp(*argv, "getnanos")) getnanos(argv+1); else if (!strcmp(*argv, "is64bit")) diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c index f65e301f9ddc..7b4278462bb7 100644 --- a/t/helper/test-drop-caches.c +++ b/t/helper/test-drop-caches.c @@ -8,18 +8,21 @@ static int cmd_sync(void) { char Buffer[MAX_PATH]; DWORD dwRet; - char szVolumeAccessPath[] = "\\\\.\\X:"; + char szVolumeAccessPath[] = "\\\\.\\XXXX:"; HANDLE hVolWrite; - int success = 0; + int success = 0, dos_drive_prefix; dwRet = GetCurrentDirectory(MAX_PATH, Buffer); if ((0 == dwRet) || (dwRet > MAX_PATH)) return error("Error getting current directory"); - if (!has_dos_drive_prefix(Buffer)) + dos_drive_prefix = has_dos_drive_prefix(Buffer); + if (!dos_drive_prefix) return error("'%s': invalid drive letter", Buffer); - szVolumeAccessPath[4] = Buffer[0]; + memcpy(szVolumeAccessPath, Buffer, dos_drive_prefix); + szVolumeAccessPath[dos_drive_prefix] = '\0'; + hVolWrite = CreateFile(szVolumeAccessPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (INVALID_HANDLE_VALUE == hVolWrite) diff --git a/t/helper/test-dump-fsmonitor.c b/t/helper/test-dump-fsmonitor.c index 2786f47088e9..975f0ac89051 100644 --- a/t/helper/test-dump-fsmonitor.c +++ b/t/helper/test-dump-fsmonitor.c @@ -13,7 +13,7 @@ int cmd__dump_fsmonitor(int ac, const char **av) printf("no fsmonitor\n"); return 0; } - printf("fsmonitor last update %"PRIuMAX"\n", (uintmax_t)istate->fsmonitor_last_update); + printf("fsmonitor last update %s\n", istate->fsmonitor_last_update); for (i = 0; i < istate->cache_nr; i++) printf((istate->cache[i]->ce_flags & CE_FSMONITOR_VALID) ? "+" : "-"); diff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c index aaf17b0ddf9e..f38706216f44 100644 --- a/t/helper/test-hashmap.c +++ b/t/helper/test-hashmap.c @@ -5,6 +5,7 @@ struct test_entry { + int padding; /* hashmap entry no longer needs to be the first member */ struct hashmap_entry ent; /* key and value as two \0-terminated strings */ char key[FLEX_ARRAY]; @@ -16,15 +17,17 @@ static const char *get_value(const struct test_entry *e) } static int test_entry_cmp(const void *cmp_data, - const void *entry, - const void *entry_or_key, + const struct hashmap_entry *eptr, + const struct hashmap_entry *entry_or_key, const void *keydata) { const int ignore_case = cmp_data ? *((int *)cmp_data) : 0; - const struct test_entry *e1 = entry; - const struct test_entry *e2 = entry_or_key; + const struct test_entry *e1, *e2; const char *key = keydata; + e1 = container_of(eptr, const struct test_entry, ent); + e2 = container_of(entry_or_key, const struct test_entry, ent); + if (ignore_case) return strcasecmp(e1->key, key ? key : e2->key); else @@ -37,7 +40,7 @@ static struct test_entry *alloc_test_entry(unsigned int hash, size_t klen = strlen(key); size_t vlen = strlen(value); struct test_entry *entry = xmalloc(st_add4(sizeof(*entry), klen, vlen, 2)); - hashmap_entry_init(entry, hash); + hashmap_entry_init(&entry->ent, hash); memcpy(entry->key, key, klen + 1); memcpy(entry->key + klen + 1, value, vlen + 1); return entry; @@ -103,11 +106,11 @@ static void perf_hashmap(unsigned int method, unsigned int rounds) /* add entries */ for (i = 0; i < TEST_SIZE; i++) { - hashmap_entry_init(entries[i], hashes[i]); - hashmap_add(&map, entries[i]); + hashmap_entry_init(&entries[i]->ent, hashes[i]); + hashmap_add(&map, &entries[i]->ent); } - hashmap_free(&map, 0); + hashmap_free(&map); } } else { /* test map lookups */ @@ -116,8 +119,8 @@ static void perf_hashmap(unsigned int method, unsigned int rounds) /* fill the map (sparsely if specified) */ j = (method & TEST_SPARSE) ? TEST_SIZE / 10 : TEST_SIZE; for (i = 0; i < j; i++) { - hashmap_entry_init(entries[i], hashes[i]); - hashmap_add(&map, entries[i]); + hashmap_entry_init(&entries[i]->ent, hashes[i]); + hashmap_add(&map, &entries[i]->ent); } for (j = 0; j < rounds; j++) { @@ -127,7 +130,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds) } } - hashmap_free(&map, 0); + hashmap_free(&map); } } @@ -179,7 +182,7 @@ int cmd__hashmap(int argc, const char **argv) entry = alloc_test_entry(hash, p1, p2); /* add to hashmap */ - hashmap_add(&map, entry); + hashmap_add(&map, &entry->ent); } else if (!strcmp("put", cmd) && p1 && p2) { @@ -187,43 +190,44 @@ int cmd__hashmap(int argc, const char **argv) entry = alloc_test_entry(hash, p1, p2); /* add / replace entry */ - entry = hashmap_put(&map, entry); + entry = hashmap_put_entry(&map, entry, ent); /* print and free replaced entry, if any */ puts(entry ? get_value(entry) : "NULL"); free(entry); } else if (!strcmp("get", cmd) && p1) { - /* lookup entry in hashmap */ - entry = hashmap_get_from_hash(&map, hash, p1); + entry = hashmap_get_entry_from_hash(&map, hash, p1, + struct test_entry, ent); /* print result */ if (!entry) puts("NULL"); - while (entry) { + hashmap_for_each_entry_from(&map, entry, ent) puts(get_value(entry)); - entry = hashmap_get_next(&map, entry); - } } else if (!strcmp("remove", cmd) && p1) { /* setup static key */ struct hashmap_entry key; + struct hashmap_entry *rm; hashmap_entry_init(&key, hash); /* remove entry from hashmap */ - entry = hashmap_remove(&map, &key, p1); + rm = hashmap_remove(&map, &key, p1); + entry = rm ? container_of(rm, struct test_entry, ent) + : NULL; /* print result and free entry*/ puts(entry ? get_value(entry) : "NULL"); free(entry); } else if (!strcmp("iterate", cmd)) { - struct hashmap_iter iter; - hashmap_iter_init(&map, &iter); - while ((entry = hashmap_iter_next(&iter))) + + hashmap_for_each_entry(&map, &iter, entry, + ent /* member name */) printf("%s %s\n", entry->key, get_value(entry)); } else if (!strcmp("size", cmd)) { @@ -258,6 +262,6 @@ int cmd__hashmap(int argc, const char **argv) } strbuf_release(&line); - hashmap_free(&map, 1); + hashmap_free_entries(&map, struct test_entry, ent); return 0; } diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c index b99a37080d93..cd1b4c9736ef 100644 --- a/t/helper/test-lazy-init-name-hash.c +++ b/t/helper/test-lazy-init-name-hash.c @@ -41,17 +41,13 @@ static void dump_run(void) die("non-threaded code path used"); } - dir = hashmap_iter_first(&the_index.dir_hash, &iter_dir); - while (dir) { + hashmap_for_each_entry(&the_index.dir_hash, &iter_dir, dir, + ent /* member name */) printf("dir %08x %7d %s\n", dir->ent.hash, dir->nr, dir->name); - dir = hashmap_iter_next(&iter_dir); - } - ce = hashmap_iter_first(&the_index.name_hash, &iter_cache); - while (ce) { + hashmap_for_each_entry(&the_index.name_hash, &iter_cache, ce, + ent /* member name */) printf("name %08x %s\n", ce->ent.hash, ce->name); - ce = hashmap_iter_next(&iter_cache); - } discard_cache(); } diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c index af82db06ac59..2051ce57db73 100644 --- a/t/helper/test-parse-options.c +++ b/t/helper/test-parse-options.c @@ -121,6 +121,8 @@ int cmd__parse_options(int argc, const char **argv) OPT_INTEGER('j', NULL, &integer, "get a integer, too"), OPT_MAGNITUDE('m', "magnitude", &magnitude, "get a magnitude"), OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23), + OPT_CMDMODE(0, "mode1", &integer, "set integer to 1 (cmdmode option)", 1), + OPT_CMDMODE(0, "mode2", &integer, "set integer to 2 (cmdmode option)", 2), OPT_CALLBACK('L', "length", &integer, "str", "get length of ", length_callback), OPT_FILENAME('F', "file", &file, "set file to "), diff --git a/t/helper/test-parse-pathspec-file.c b/t/helper/test-parse-pathspec-file.c new file mode 100644 index 000000000000..02f4ccfd2a2d --- /dev/null +++ b/t/helper/test-parse-pathspec-file.c @@ -0,0 +1,33 @@ +#include "test-tool.h" +#include "parse-options.h" +#include "pathspec.h" +#include "gettext.h" + +int cmd__parse_pathspec_file(int argc, const char **argv) +{ + struct pathspec pathspec; + const char *pathspec_from_file = 0; + int pathspec_file_nul = 0, i; + + static const char *const usage[] = { + "test-tool parse-pathspec-file --pathspec-from-file [--pathspec-file-nul]", + NULL + }; + + struct option options[] = { + OPT_PATHSPEC_FROM_FILE(&pathspec_from_file), + OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul), + OPT_END() + }; + + parse_options(argc, argv, 0, options, usage, 0); + + parse_pathspec_file(&pathspec, 0, 0, 0, pathspec_from_file, + pathspec_file_nul); + + for (i = 0; i < pathspec.nr; i++) + printf("%s\n", pathspec.items[i].original); + + clear_pathspec(&pathspec); + return 0; +} diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c index 5d543ad21f89..409034cf4eef 100644 --- a/t/helper/test-path-utils.c +++ b/t/helper/test-path-utils.c @@ -185,6 +185,99 @@ static int cmp_by_st_size(const void *a, const void *b) return x > y ? -1 : (x < y ? +1 : 0); } +/* + * A very simple, reproducible pseudo-random generator. Copied from + * `test-genrandom.c`. + */ +static uint64_t my_random_value = 1234; + +static uint64_t my_random(void) +{ + my_random_value = my_random_value * 1103515245 + 12345; + return my_random_value; +} + +/* + * A fast approximation of the square root, without requiring math.h. + * + * It uses Newton's method to approximate the solution of 0 = x^2 - value. + */ +static double my_sqrt(double value) +{ + const double epsilon = 1e-6; + double x = value; + + if (value == 0) + return 0; + + for (;;) { + double delta = (value / x - x) / 2; + if (delta < epsilon && delta > -epsilon) + return x + delta; + x += delta; + } +} + +static int protect_ntfs_hfs_benchmark(int argc, const char **argv) +{ + size_t i, j, nr, min_len = 3, max_len = 20; + char **names; + int repetitions = 15, file_mode = 0100644; + uint64_t begin, end; + double m[3][2], v[3][2]; + uint64_t cumul; + double cumul2; + + if (argc > 1 && !strcmp(argv[1], "--with-symlink-mode")) { + file_mode = 0120000; + argc--; + argv++; + } + + nr = argc > 1 ? strtoul(argv[1], NULL, 0) : 1000000; + ALLOC_ARRAY(names, nr); + + if (argc > 2) { + min_len = strtoul(argv[2], NULL, 0); + if (argc > 3) + max_len = strtoul(argv[3], NULL, 0); + if (min_len > max_len) + die("min_len > max_len"); + } + + for (i = 0; i < nr; i++) { + size_t len = min_len + (my_random() % (max_len + 1 - min_len)); + + names[i] = xmallocz(len); + while (len > 0) + names[i][--len] = (char)(' ' + (my_random() % ('\x7f' - ' '))); + } + + for (protect_ntfs = 0; protect_ntfs < 2; protect_ntfs++) + for (protect_hfs = 0; protect_hfs < 2; protect_hfs++) { + cumul = 0; + cumul2 = 0; + for (i = 0; i < repetitions; i++) { + begin = getnanotime(); + for (j = 0; j < nr; j++) + verify_path(names[j], file_mode); + end = getnanotime(); + printf("protect_ntfs = %d, protect_hfs = %d: %lfms\n", protect_ntfs, protect_hfs, (end-begin) / (double)1e6); + cumul += end - begin; + cumul2 += (end - begin) * (end - begin); + } + m[protect_ntfs][protect_hfs] = cumul / (double)repetitions; + v[protect_ntfs][protect_hfs] = my_sqrt(cumul2 / (double)repetitions - m[protect_ntfs][protect_hfs] * m[protect_ntfs][protect_hfs]); + printf("mean: %lfms, stddev: %lfms\n", m[protect_ntfs][protect_hfs] / (double)1e6, v[protect_ntfs][protect_hfs] / (double)1e6); + } + + for (protect_ntfs = 0; protect_ntfs < 2; protect_ntfs++) + for (protect_hfs = 0; protect_hfs < 2; protect_hfs++) + printf("ntfs=%d/hfs=%d: %lf%% slower\n", protect_ntfs, protect_hfs, (m[protect_ntfs][protect_hfs] - m[0][0]) * 100 / m[0][0]); + + return 0; +} + int cmd__path_utils(int argc, const char **argv) { if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) { @@ -355,6 +448,26 @@ int cmd__path_utils(int argc, const char **argv) return !!res; } + if (argc > 1 && !strcmp(argv[1], "protect_ntfs_hfs")) + return !!protect_ntfs_hfs_benchmark(argc - 1, argv + 1); + + if (argc > 1 && !strcmp(argv[1], "is_valid_path")) { + int res = 0, expect = 1, i; + + for (i = 2; i < argc; i++) + if (!strcmp("--not", argv[i])) + expect = 0; + else if (expect != is_valid_path(argv[i])) + res = error("'%s' is%s a valid path", + argv[i], expect ? " not" : ""); + else + fprintf(stderr, + "'%s' is%s a valid path\n", + argv[i], expect ? "" : " not"); + + return !!res; + } + fprintf(stderr, "%s: unknown function name: %s\n", argv[0], argv[1] ? argv[1] : "(there was none)"); return 1; diff --git a/t/helper/test-progress.c b/t/helper/test-progress.c new file mode 100644 index 000000000000..42b96cb103c6 --- /dev/null +++ b/t/helper/test-progress.c @@ -0,0 +1,81 @@ +/* + * A test helper to exercise the progress display. + * + * Reads instructions from standard input, one instruction per line: + * + * "progress " - Call display_progress() with the given item count + * as parameter. + * "throughput - Call display_throughput() with the given + * byte count as parameter. The 'millis' + * specify the time elapsed since the + * start_progress() call. + * "update" - Set the 'progress_update' flag. + * + * See 't0500-progress-display.sh' for examples. + */ +#include "test-tool.h" +#include "gettext.h" +#include "parse-options.h" +#include "progress.h" +#include "strbuf.h" + +/* + * These are defined in 'progress.c', but are not exposed in 'progress.h', + * because they are exclusively for testing. + */ +extern int progress_testing; +extern uint64_t progress_test_ns; +void progress_test_force_update(void); + +int cmd__progress(int argc, const char **argv) +{ + int total = 0; + const char *title; + struct strbuf line = STRBUF_INIT; + struct progress *progress; + + const char *usage[] = { + "test-tool progress [--total=] ", + NULL + }; + struct option options[] = { + OPT_INTEGER(0, "total", &total, "total number of items"), + OPT_END(), + }; + + argc = parse_options(argc, argv, NULL, options, usage, 0); + if (argc != 1) + die("need a title for the progress output"); + title = argv[0]; + + progress_testing = 1; + progress = start_progress(title, total); + while (strbuf_getline(&line, stdin) != EOF) { + char *end; + + if (skip_prefix(line.buf, "progress ", (const char **) &end)) { + uint64_t item_count = strtoull(end, &end, 10); + if (*end != '\0') + die("invalid input: '%s'\n", line.buf); + display_progress(progress, item_count); + } else if (skip_prefix(line.buf, "throughput ", + (const char **) &end)) { + uint64_t byte_count, test_ms; + + byte_count = strtoull(end, &end, 10); + if (*end != ' ') + die("invalid input: '%s'\n", line.buf); + test_ms = strtoull(end + 1, &end, 10); + if (*end != '\0') + die("invalid input: '%s'\n", line.buf); + progress_test_ns = test_ms * 1000 * 1000; + display_throughput(progress, byte_count); + } else if (!strcmp(line.buf, "update")) + progress_test_force_update(); + else + die("invalid input: '%s'\n", line.buf); + } + stop_progress(&progress); + + return 0; +} diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c index 7e79b555de80..244977a29bdf 100644 --- a/t/helper/test-read-cache.c +++ b/t/helper/test-read-cache.c @@ -4,11 +4,10 @@ int cmd__read_cache(int argc, const char **argv) { - int i, cnt = 1, namelen; + int i, cnt = 1; const char *name = NULL; if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) { - namelen = strlen(name); argc--; argv++; } @@ -24,7 +23,7 @@ int cmd__read_cache(int argc, const char **argv) refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL); - pos = index_name_pos(&the_index, name, namelen); + pos = index_name_pos(&the_index, name, strlen(name)); if (pos < 0) die("%s not in index", name); printf("%s is%s up to date\n", name, diff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c new file mode 100644 index 000000000000..f8a461767ca4 --- /dev/null +++ b/t/helper/test-read-graph.c @@ -0,0 +1,53 @@ +#include "test-tool.h" +#include "cache.h" +#include "commit-graph.h" +#include "repository.h" +#include "object-store.h" + +int cmd__read_graph(int argc, const char **argv) +{ + struct commit_graph *graph = NULL; + char *graph_name; + int open_ok; + int fd; + struct stat st; + struct object_directory *odb; + + setup_git_directory(); + odb = the_repository->objects->odb; + + graph_name = get_commit_graph_filename(odb); + + open_ok = open_commit_graph(graph_name, &fd, &st); + if (!open_ok) + die_errno(_("Could not open commit-graph '%s'"), graph_name); + + graph = load_commit_graph_one_fd_st(fd, &st, odb); + if (!graph) + return 1; + + FREE_AND_NULL(graph_name); + + printf("header: %08x %d %d %d %d\n", + ntohl(*(uint32_t*)graph->data), + *(unsigned char*)(graph->data + 4), + *(unsigned char*)(graph->data + 5), + *(unsigned char*)(graph->data + 6), + *(unsigned char*)(graph->data + 7)); + printf("num_commits: %u\n", graph->num_commits); + printf("chunks:"); + + if (graph->chunk_oid_fanout) + printf(" oid_fanout"); + if (graph->chunk_oid_lookup) + printf(" oid_lookup"); + if (graph->chunk_commit_data) + printf(" commit_metadata"); + if (graph->chunk_extra_edges) + printf(" extra_edges"); + printf("\n"); + + UNLEAK(graph); + + return 0; +} diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c index 2cc93bb69c52..1646aa25d82f 100644 --- a/t/helper/test-run-command.c +++ b/t/helper/test-run-command.c @@ -10,11 +10,16 @@ #include "test-tool.h" #include "git-compat-util.h" +#include "cache.h" #include "run-command.h" #include "argv-array.h" #include "strbuf.h" -#include -#include +#include "parse-options.h" +#include "string-list.h" +#include "thread-utils.h" +#include "wildmatch.h" +#include "gettext.h" +#include "parse-options.h" static int number_callbacks; static int parallel_next(struct child_process *cp, @@ -50,11 +55,337 @@ static int task_finished(int result, return 1; } +struct testsuite { + struct string_list tests, failed; + int next; + int quiet, immediate, verbose, verbose_log, trace, write_junit_xml; +}; +#define TESTSUITE_INIT \ + { STRING_LIST_INIT_DUP, STRING_LIST_INIT_DUP, -1, 0, 0, 0, 0, 0, 0 } + +static int next_test(struct child_process *cp, struct strbuf *err, void *cb, + void **task_cb) +{ + struct testsuite *suite = cb; + const char *test; + if (suite->next >= suite->tests.nr) + return 0; + + test = suite->tests.items[suite->next++].string; + argv_array_pushl(&cp->args, "sh", test, NULL); + if (suite->quiet) + argv_array_push(&cp->args, "--quiet"); + if (suite->immediate) + argv_array_push(&cp->args, "-i"); + if (suite->verbose) + argv_array_push(&cp->args, "-v"); + if (suite->verbose_log) + argv_array_push(&cp->args, "-V"); + if (suite->trace) + argv_array_push(&cp->args, "-x"); + if (suite->write_junit_xml) + argv_array_push(&cp->args, "--write-junit-xml"); + + strbuf_addf(err, "Output of '%s':\n", test); + *task_cb = (void *)test; + + return 1; +} + +static int test_finished(int result, struct strbuf *err, void *cb, + void *task_cb) +{ + struct testsuite *suite = cb; + const char *name = (const char *)task_cb; + + if (result) + string_list_append(&suite->failed, name); + + strbuf_addf(err, "%s: '%s'\n", result ? "FAIL" : "SUCCESS", name); + + return 0; +} + +static int test_failed(struct strbuf *out, void *cb, void *task_cb) +{ + struct testsuite *suite = cb; + const char *name = (const char *)task_cb; + + string_list_append(&suite->failed, name); + strbuf_addf(out, "FAILED TO START: '%s'\n", name); + + return 0; +} + +static const char * const testsuite_usage[] = { + "test-run-command testsuite [] [...]", + NULL +}; + +static int testsuite(int argc, const char **argv) +{ + struct testsuite suite = TESTSUITE_INIT; + int max_jobs = 1, i, ret; + DIR *dir; + struct dirent *d; + struct option options[] = { + OPT_BOOL('i', "immediate", &suite.immediate, + "stop at first failed test case(s)"), + OPT_INTEGER('j', "jobs", &max_jobs, "run jobs in parallel"), + OPT_BOOL('q', "quiet", &suite.quiet, "be terse"), + OPT_BOOL('v', "verbose", &suite.verbose, "be verbose"), + OPT_BOOL('V', "verbose-log", &suite.verbose_log, + "be verbose, redirected to a file"), + OPT_BOOL('x', "trace", &suite.trace, "trace shell commands"), + OPT_BOOL(0, "write-junit-xml", &suite.write_junit_xml, + "write JUnit-style XML files"), + OPT_END() + }; + + memset(&suite, 0, sizeof(suite)); + suite.tests.strdup_strings = suite.failed.strdup_strings = 1; + + argc = parse_options(argc, argv, NULL, options, + testsuite_usage, PARSE_OPT_STOP_AT_NON_OPTION); + + if (max_jobs <= 0) + max_jobs = online_cpus(); + + dir = opendir("."); + if (!dir) + die("Could not open the current directory"); + while ((d = readdir(dir))) { + const char *p = d->d_name; + + if (*p != 't' || !isdigit(p[1]) || !isdigit(p[2]) || + !isdigit(p[3]) || !isdigit(p[4]) || p[5] != '-' || + !ends_with(p, ".sh")) + continue; + + /* No pattern: match all */ + if (!argc) { + string_list_append(&suite.tests, p); + continue; + } + + for (i = 0; i < argc; i++) + if (!wildmatch(argv[i], p, 0)) { + string_list_append(&suite.tests, p); + break; + } + } + closedir(dir); + + if (!suite.tests.nr) + die("No tests match!"); + if (max_jobs > suite.tests.nr) + max_jobs = suite.tests.nr; + + fprintf(stderr, "Running %d tests (%d at a time)\n", + suite.tests.nr, max_jobs); + + ret = run_processes_parallel(max_jobs, next_test, test_failed, + test_finished, &suite); + + if (suite.failed.nr > 0) { + ret = 1; + fprintf(stderr, "%d tests failed:\n\n", suite.failed.nr); + for (i = 0; i < suite.failed.nr; i++) + fprintf(stderr, "\t%s\n", suite.failed.items[i].string); + } + + string_list_clear(&suite.tests, 0); + string_list_clear(&suite.failed, 0); + + return !!ret; +} + +static uint64_t my_random_next = 1234; + +static uint64_t my_random(void) +{ + uint64_t res = my_random_next; + my_random_next = my_random_next * 1103515245 + 12345; + return res; +} + +static int quote_stress_test(int argc, const char **argv) +{ + /* + * We are running a quote-stress test. + * spawn a subprocess that runs quote-stress with a + * special option that echoes back the arguments that + * were passed in. + */ + char special[] = ".?*\\^_\"'`{}()[]<>@~&+:;$%"; // \t\r\n\a"; + int i, j, k, trials = 100, skip = 0, msys2 = 0; + struct strbuf out = STRBUF_INIT; + struct argv_array args = ARGV_ARRAY_INIT; + struct option options[] = { + OPT_INTEGER('n', "trials", &trials, "Number of trials"), + OPT_INTEGER('s', "skip", &skip, "Skip trials"), + OPT_BOOL('m', "msys2", &msys2, "Test quoting for MSYS2's sh"), + OPT_END() + }; + const char * const usage[] = { + "test-tool run-command quote-stress-test ", + NULL + }; + + argc = parse_options(argc, argv, NULL, options, usage, 0); + + setenv("MSYS_NO_PATHCONV", "1", 0); + + for (i = 0; i < trials; i++) { + struct child_process cp = CHILD_PROCESS_INIT; + size_t arg_count, arg_offset; + int ret = 0; + + argv_array_clear(&args); + if (msys2) + argv_array_pushl(&args, "sh", "-c", + "printf %s\\\\0 \"$@\"", "skip", NULL); + else + argv_array_pushl(&args, "test-tool", "run-command", + "quote-echo", NULL); + arg_offset = args.argc; + + if (argc > 0) { + trials = 1; + arg_count = argc; + for (j = 0; j < arg_count; j++) + argv_array_push(&args, argv[j]); + } else { + arg_count = 1 + (my_random() % 5); + for (j = 0; j < arg_count; j++) { + char buf[20]; + size_t min_len = 1; + size_t arg_len = min_len + + (my_random() % (ARRAY_SIZE(buf) - min_len)); + + for (k = 0; k < arg_len; k++) + buf[k] = special[my_random() % + ARRAY_SIZE(special)]; + buf[arg_len] = '\0'; + + argv_array_push(&args, buf); + } + } + + if (i < skip) + continue; + + cp.argv = args.argv; + strbuf_reset(&out); + if (pipe_command(&cp, NULL, 0, &out, 0, NULL, 0) < 0) + return error("Failed to spawn child process"); + + for (j = 0, k = 0; j < arg_count; j++) { + const char *arg = args.argv[j + arg_offset]; + + if (strcmp(arg, out.buf + k)) + ret = error("incorrectly quoted arg: '%s', " + "echoed back as '%s'", + arg, out.buf + k); + k += strlen(out.buf + k) + 1; + } + + if (k != out.len) + ret = error("got %d bytes, but consumed only %d", + (int)out.len, (int)k); + + if (ret) { + fprintf(stderr, "Trial #%d failed. Arguments:\n", i); + for (j = 0; j < arg_count; j++) + fprintf(stderr, "arg #%d: '%s'\n", + (int)j, args.argv[j + arg_offset]); + + strbuf_release(&out); + argv_array_clear(&args); + + return ret; + } + + if (i && (i % 100) == 0) + fprintf(stderr, "Trials completed: %d\n", (int)i); + } + + strbuf_release(&out); + argv_array_clear(&args); + + return 0; +} + +static int quote_echo(int argc, const char **argv) +{ + while (argc > 1) { + fwrite(argv[1], strlen(argv[1]), 1, stdout); + fputc('\0', stdout); + argv++; + argc--; + } + + return 0; +} + +static int inherit_handle(const char *argv0) +{ + struct child_process cp = CHILD_PROCESS_INIT; + char path[PATH_MAX]; + int tmp; + + /* First, open an inheritable handle */ + xsnprintf(path, sizeof(path), "out-XXXXXX"); + tmp = xmkstemp(path); + + argv_array_pushl(&cp.args, + "test-tool", argv0, "inherited-handle-child", NULL); + cp.in = -1; + cp.no_stdout = cp.no_stderr = 1; + if (start_command(&cp) < 0) + die("Could not start child process"); + + /* Then close it, and try to delete it. */ + close(tmp); + if (unlink(path)) + die("Could not delete '%s'", path); + + if (close(cp.in) < 0 || finish_command(&cp) < 0) + die("Child did not finish"); + + return 0; +} + +static int inherit_handle_child(void) +{ + struct strbuf buf = STRBUF_INIT; + + if (strbuf_read(&buf, 0, 0) < 0) + die("Could not read stdin"); + printf("Received %s\n", buf.buf); + strbuf_release(&buf); + + return 0; +} + int cmd__run_command(int argc, const char **argv) { struct child_process proc = CHILD_PROCESS_INIT; int jobs; + if (argc > 1 && !strcmp(argv[1], "testsuite")) + exit(testsuite(argc - 1, argv + 1)); + if (!strcmp(argv[1], "inherited-handle")) + exit(inherit_handle(argv[0])); + if (!strcmp(argv[1], "inherited-handle-child")) + exit(inherit_handle_child()); + + if (argc >= 2 && !strcmp(argv[1], "quote-stress-test")) + return !!quote_stress_test(argc - 1, argv + 1); + + if (argc >= 2 && !strcmp(argv[1], "quote-echo")) + return !!quote_echo(argc - 1, argv + 1); + if (argc < 3) return 1; while (!strcmp(argv[1], "env")) { diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index ce7e89028c4a..c9a232d23897 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -39,11 +39,14 @@ static struct test_cmd cmds[] = { { "oidmap", cmd__oidmap }, { "online-cpus", cmd__online_cpus }, { "parse-options", cmd__parse_options }, + { "parse-pathspec-file", cmd__parse_pathspec_file }, { "path-utils", cmd__path_utils }, { "pkt-line", cmd__pkt_line }, { "prio-queue", cmd__prio_queue }, + { "progress", cmd__progress }, { "reach", cmd__reach }, { "read-cache", cmd__read_cache }, + { "read-graph", cmd__read_graph }, { "read-midx", cmd__read_midx }, { "ref-store", cmd__ref_store }, { "regex", cmd__regex }, diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index f805bb39ae9e..c8549fd87f23 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -29,11 +29,14 @@ int cmd__mktemp(int argc, const char **argv); int cmd__oidmap(int argc, const char **argv); int cmd__online_cpus(int argc, const char **argv); int cmd__parse_options(int argc, const char **argv); +int cmd__parse_pathspec_file(int argc, const char** argv); int cmd__path_utils(int argc, const char **argv); int cmd__pkt_line(int argc, const char **argv); int cmd__prio_queue(int argc, const char **argv); +int cmd__progress(int argc, const char **argv); int cmd__reach(int argc, const char **argv); int cmd__read_cache(int argc, const char **argv); +int cmd__read_graph(int argc, const char **argv); int cmd__read_midx(int argc, const char **argv); int cmd__ref_store(int argc, const char **argv); int cmd__regex(int argc, const char **argv); diff --git a/t/helper/test-windows-named-pipe.c b/t/helper/test-windows-named-pipe.c index b4b752b01aaf..ae52183e6344 100644 --- a/t/helper/test-windows-named-pipe.c +++ b/t/helper/test-windows-named-pipe.c @@ -19,7 +19,7 @@ int cmd__windows_named_pipe(int argc, const char **argv) if (argc < 2) goto print_usage; filename = argv[1]; - if (strchr(filename, '/') || strchr(filename, '\\')) + if (strpbrk(filename, "/\\")) goto print_usage; strbuf_addf(&pathname, "//./pipe/%s", filename); diff --git a/t/lib-bash.sh b/t/lib-bash.sh index 2be955fafba6..b0b6060929ce 100644 --- a/t/lib-bash.sh +++ b/t/lib-bash.sh @@ -2,10 +2,12 @@ # to run under Bash; primarily intended for tests of the completion # script. -if test -n "$BASH" && test -z "$POSIXLY_CORRECT"; then +if test -n "$BASH" && test -z "$POSIXLY_CORRECT" +then # we are in full-on bash mode true -elif type bash >/dev/null 2>&1; then +elif type bash >/dev/null 2>&1 +then # execute in full-on bash mode unset POSIXLY_CORRECT exec bash "$0" "$@" diff --git a/t/lib-credential.sh b/t/lib-credential.sh index 937b831ea675..bb88cc01087b 100755 --- a/t/lib-credential.sh +++ b/t/lib-credential.sh @@ -19,7 +19,7 @@ check() { false fi && test_cmp expect-stdout stdout && - test_cmp expect-stderr stderr + test_i18ncmp expect-stderr stderr } read_chunk() { diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh index fb8f8870801e..e62569222b55 100644 --- a/t/lib-git-daemon.sh +++ b/t/lib-git-daemon.sh @@ -15,7 +15,7 @@ # # test_done -if ! git env--helper --type=bool --default=true --exit-code GIT_TEST_GIT_DAEMON +if ! test_bool_env GIT_TEST_GIT_DAEMON true then skip_all="git-daemon testing disabled (unset GIT_TEST_GIT_DAEMON to enable)" test_done diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh index 547b9f88e123..5aff2abe8b54 100644 --- a/t/lib-git-p4.sh +++ b/t/lib-git-p4.sh @@ -175,7 +175,7 @@ stop_and_cleanup_p4d () { cleanup_git () { retry_until_success rm -r "$git" - test_must_fail test -d "$git" && + test_path_is_missing "$git" && retry_until_success mkdir "$git" } diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index 5d4ae629e14e..7d248e658806 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -69,7 +69,7 @@ svn_cmd () { maybe_start_httpd () { loc=${1-svn} - if git env--helper --type=bool --default=false --exit-code GIT_TEST_HTTPD + if test_bool_env GIT_TEST_SVN_HTTPD false then . "$TEST_DIRECTORY"/lib-httpd.sh LIB_HTTPD_SVN="$loc" @@ -104,7 +104,7 @@ EOF } require_svnserve () { - if ! git env--helper --type=bool --default=false --exit-code GIT_TEST_SVNSERVE + if ! test_bool_env GIT_TEST_SVNSERVE false then skip_all='skipping svnserve test. (set $GIT_TEST_SVNSERVE to enable)' test_done diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index 0d985758c6dd..1449ee95e9ea 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -41,7 +41,7 @@ then test_done fi -if ! git env--helper --type=bool --default=true --exit-code GIT_TEST_HTTPD +if ! test_bool_env GIT_TEST_HTTPD true then skip_all="Network testing disabled (unset GIT_TEST_HTTPD to enable)" test_done @@ -132,7 +132,7 @@ prepare_httpd() { install_script broken-smart-http.sh install_script error-smart-http.sh install_script error.sh - install_script apply-one-time-sed.sh + install_script apply-one-time-perl.sh ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules" diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf index 5c1c86c193ab..994e5290d63b 100644 --- a/t/lib-httpd/apache.conf +++ b/t/lib-httpd/apache.conf @@ -113,7 +113,7 @@ Alias /auth/dumb/ www/auth/dumb/ SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} SetEnv GIT_HTTP_EXPORT_ALL - + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} SetEnv GIT_HTTP_EXPORT_ALL @@ -122,7 +122,7 @@ ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1 ScriptAlias /broken_smart/ broken-smart-http.sh/ ScriptAlias /error_smart/ error-smart-http.sh/ ScriptAlias /error/ error.sh/ -ScriptAliasMatch /one_time_sed/(.*) apply-one-time-sed.sh/$1 +ScriptAliasMatch /one_time_perl/(.*) apply-one-time-perl.sh/$1 Options FollowSymlinks @@ -135,7 +135,7 @@ ScriptAliasMatch /one_time_sed/(.*) apply-one-time-sed.sh/$1 Options ExecCGI - + Options ExecCGI diff --git a/t/lib-httpd/apply-one-time-perl.sh b/t/lib-httpd/apply-one-time-perl.sh new file mode 100644 index 000000000000..09a0abdff7c4 --- /dev/null +++ b/t/lib-httpd/apply-one-time-perl.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# If "one-time-perl" exists in $HTTPD_ROOT_PATH, run perl on the HTTP response, +# using the contents of "one-time-perl" as the perl command to be run. If the +# response was modified as a result, delete "one-time-perl" so that subsequent +# HTTP responses are no longer modified. +# +# This can be used to simulate the effects of the repository changing in +# between HTTP request-response pairs. +if test -f one-time-perl +then + LC_ALL=C + export LC_ALL + + "$GIT_EXEC_PATH/git-http-backend" >out + perl -pe "$(cat one-time-perl)" out >out_modified + + if cmp -s out out_modified + then + cat out + else + cat out_modified + rm one-time-perl + fi +else + "$GIT_EXEC_PATH/git-http-backend" +fi diff --git a/t/lib-httpd/apply-one-time-sed.sh b/t/lib-httpd/apply-one-time-sed.sh deleted file mode 100644 index fcef72892547..000000000000 --- a/t/lib-httpd/apply-one-time-sed.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# If "one-time-sed" exists in $HTTPD_ROOT_PATH, run sed on the HTTP response, -# using the contents of "one-time-sed" as the sed command to be run. If the -# response was modified as a result, delete "one-time-sed" so that subsequent -# HTTP responses are no longer modified. -# -# This can be used to simulate the effects of the repository changing in -# between HTTP request-response pairs. -if [ -e one-time-sed ]; then - "$GIT_EXEC_PATH/git-http-backend" >out - sed "$(cat one-time-sed)" out_modified - - if diff out out_modified >/dev/null; then - cat out - else - cat out_modified - rm one-time-sed - fi -else - "$GIT_EXEC_PATH/git-http-backend" -fi diff --git a/t/lib-log-graph.sh b/t/lib-log-graph.sh new file mode 100755 index 000000000000..1184cceef262 --- /dev/null +++ b/t/lib-log-graph.sh @@ -0,0 +1,28 @@ +# Helps shared by the test scripts for comparing log graphs. + +sanitize_log_output () { + sed -e 's/ *$//' \ + -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \ + -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \ + -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \ + -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \ + -e 's/index [0-9a-f]*\.\.[0-9a-f]*/index BEFORE..AFTER/' +} + +lib_test_cmp_graph () { + git log --graph "$@" >output && + sed 's/ *$//' >output.sanitized output && + sanitize_log_output >output.sanitized output.colors.raw && + test_decode_color output.colors && + test_cmp expect.colors output.colors +} diff --git a/t/lib-pack.sh b/t/lib-pack.sh index c4d907a450a7..f3463170b39f 100644 --- a/t/lib-pack.sh +++ b/t/lib-pack.sh @@ -35,9 +35,11 @@ pack_header () { # have hardcoded some well-known objects. See the case statements below for the # complete list. pack_obj () { + test_oid_init + case "$1" in # empty blob - e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) + $EMPTY_BLOB) case "$2" in '') printf '\060\170\234\003\0\0\0\0\1' @@ -47,7 +49,7 @@ pack_obj () { ;; # blob containing "\7\76" - e68fe8129b546b101aee9510c5328e7f21ca1d18) + $(test_oid packlib_7_76)) case "$2" in '') printf '\062\170\234\143\267\3\0\0\116\0\106' @@ -59,11 +61,18 @@ pack_obj () { printf '\234\143\142\142\142\267\003\0\0\151\0\114' return ;; + 37c8e2c15bb22b912e59b43fd51a4f7e9465ed0b5084c5a1411d991cbe630683) + printf '\165\67\310\342\301\133\262\53\221\56\131' && + printf '\264\77\325\32\117\176\224\145\355\13\120' && + printf '\204\305\241\101\35\231\34\276\143\6\203\170' && + printf '\234\143\142\142\142\267\003\0\0\151\0\114' + return + ;; esac ;; # blob containing "\7\0" - 01d7713666f4de822776c7622c10f1b07de280dc) + $(test_oid packlib_7_0)) case "$2" in '') printf '\062\170\234\143\147\0\0\0\20\0\10' @@ -75,6 +84,13 @@ pack_obj () { printf '\143\142\142\142\147\0\0\0\53\0\16' return ;; + 5d8e6fc40f2dab00e6983a48523fe57e621f46434cb58dbd4422fba03380d886) + printf '\165\135\216\157\304\17\55\253\0\346\230\72' && + printf '\110\122\77\345\176\142\37\106\103\114\265' && + printf '\215\275\104\42\373\240\63\200\330\206\170\234' && + printf '\143\142\142\142\147\0\0\0\53\0\16' + return + ;; esac ;; esac @@ -86,7 +102,7 @@ pack_obj () { then echo "$1" | git pack-objects --stdout >pack_obj.tmp && size=$(wc -c trailer.tmp && + test_oid_init && + test-tool $(test_oid algo) -b <"$1" >trailer.tmp && cat trailer.tmp >>"$1" && rm -f trailer.tmp } @@ -108,3 +125,11 @@ pack_trailer () { clear_packs () { rm -f .git/objects/pack/* } + +test_oid_cache <<-EOF +packlib_7_0 sha1:01d7713666f4de822776c7622c10f1b07de280dc +packlib_7_0 sha256:37c8e2c15bb22b912e59b43fd51a4f7e9465ed0b5084c5a1411d991cbe630683 + +packlib_7_76 sha1:e68fe8129b546b101aee9510c5328e7f21ca1d18 +packlib_7_76 sha256:5d8e6fc40f2dab00e6983a48523fe57e621f46434cb58dbd4422fba03380d886 +EOF diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 7ea30e50068b..b72c051f4761 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -44,10 +44,10 @@ set_fake_editor () { rm -f "$1" echo 'rebase -i script before editing:' cat "$1".tmp - action=pick + action=\& for line in $FAKE_LINES; do case $line in - pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d) + pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d|label|l|reset|r|merge|m) action="$line";; exec_*|x_*|break|b) echo "$line" | sed 's/_/ /g' >> "$1";; @@ -58,11 +58,12 @@ set_fake_editor () { bad) action="badcmd";; fakesha) + test \& != "$action" || action=pick echo "$action XXXXXXX False commit" >> "$1" action=pick;; *) - sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1" - action=pick;; + sed -n "${line}s/^[a-z][a-z]*/$action/p" < "$1".tmp >> "$1" + action=\&;; esac done echo 'rebase -i script after editing:' @@ -118,3 +119,31 @@ make_empty () { git commit --allow-empty -m "$1" && git tag "$1" } + +# Call this (inside test_expect_success) at the end of a test file to +# check that no tests have changed editor related environment +# variables or config settings +test_editor_unchanged () { + # We're only interested in exported variables hence 'sh -c' + sh -c 'cat >actual <<-EOF + EDITOR=$EDITOR + FAKE_COMMIT_AMEND=$FAKE_COMMIT_AMEND + FAKE_COMMIT_MESSAGE=$FAKE_COMMIT_MESSAGE + FAKE_LINES=$FAKE_LINES + GIT_EDITOR=$GIT_EDITOR + GIT_SEQUENCE_EDITOR=$GIT_SEQUENCE_EDITOR + core.editor=$(git config core.editor) + sequence.editor=$(git config sequence.editor) + EOF' + cat >expect <<-\EOF + EDITOR=: + FAKE_COMMIT_AMEND= + FAKE_COMMIT_MESSAGE= + FAKE_LINES= + GIT_EDITOR= + GIT_SEQUENCE_EDITOR= + core.editor= + sequence.editor= + EOF + test_cmp expect actual +} diff --git a/t/oid-info/hash-info b/t/oid-info/hash-info index ccdbfdf9743d..d0736dd1a00d 100644 --- a/t/oid-info/hash-info +++ b/t/oid-info/hash-info @@ -6,3 +6,12 @@ hexsz sha256:64 zero sha1:0000000000000000000000000000000000000000 zero sha256:0000000000000000000000000000000000000000000000000000000000000000 + +algo sha1:sha1 +algo sha256:sha256 + +empty_blob sha1:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 +empty_blob sha256:473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813 + +empty_tree sha1:4b825dc642cb6eb9a060e54bf8d69288fbee4904 +empty_tree sha256:6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321 diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl index 66554d216122..14e4cda287d7 100755 --- a/t/perf/aggregate.perl +++ b/t/perf/aggregate.perl @@ -4,7 +4,6 @@ use lib '../../perl/build/lib'; use strict; use warnings; use Getopt::Long; -use Git; use Cwd qw(realpath); sub get_times { @@ -85,6 +84,11 @@ sub format_size { return $out; } +sub sane_backticks { + open(my $fh, '-|', @_); + return <$fh>; +} + my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests, $codespeed, $sortby, $subsection, $reponame); @@ -102,7 +106,8 @@ while (scalar @ARGV) { my $prefix = ''; last if -f $arg or $arg eq "--"; if (! -d $arg) { - my $rev = Git::command_oneline(qw(rev-parse --verify), $arg); + my $rev = sane_backticks(qw(git rev-parse --verify), $arg); + chomp $rev; $dir = "build/".$rev; } elsif ($arg eq '.') { $dir = '.'; @@ -219,13 +224,7 @@ sub print_default_results { for my $i (0..$#dirs) { my $d = $dirs[$i]; my $base = "$resultsdir/$prefixes{$d}$t"; - $times{$prefixes{$d}.$t} = []; - foreach my $type (qw(times size)) { - if (-e "$base.$type") { - $times{$prefixes{$d}.$t} = [get_times("$base.$type")]; - last; - } - } + $times{$prefixes{$d}.$t} = [get_times("$base.result")]; my ($r,$u,$s) = @{$times{$prefixes{$d}.$t}}; my $w = length format_times($r,$u,$s,$firstr); $colwidth[$i] = $w if $w > $colwidth[$i]; @@ -267,7 +266,7 @@ sub print_sorted_results { my ($prevr, $prevu, $prevs, $prevrev); for my $i (0..$#dirs) { my $d = $dirs[$i]; - my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times"); + my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result"); if ($i > 0 and defined $r and defined $prevr and $prevr > 0) { my $percent = 100.0 * ($r - $prevr) / $prevr; push @evolutions, { "percent" => $percent, @@ -327,7 +326,7 @@ sub print_codespeed_results { my $commitid = $prefixes{$d}; $commitid =~ s/^build_//; $commitid =~ s/\.$//; - my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times"); + my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result"); my %vals = ( "commitid" => $commitid, diff --git a/t/perf/bisect_regression b/t/perf/bisect_regression index a94d9955d012..ce47e1662a92 100755 --- a/t/perf/bisect_regression +++ b/t/perf/bisect_regression @@ -51,7 +51,7 @@ oldtime=$(echo "$oldtime" | sed -e 's/^\([0-9]\+\.[0-9]\+\).*$/\1/') newtime=$(echo "$newtime" | sed -e 's/^\([0-9]\+\.[0-9]\+\).*$/\1/') test $(echo "$newtime" "$oldtime" | awk '{ print ($1 > $2) }') = 1 || - die "New time '$newtime' shoud be greater than old time '$oldtime'" + die "New time '$newtime' should be greater than old time '$oldtime'" tmpdir=$(mktemp -d -t bisect_regression_XXXXXX) || die "Failed to create temp directory" echo "$oldtime" >"$tmpdir/oldtime" || die "Failed to write to '$tmpdir/oldtime'" diff --git a/t/perf/p5303-many-packs.sh b/t/perf/p5303-many-packs.sh index 377985194116..7ee791669a15 100755 --- a/t/perf/p5303-many-packs.sh +++ b/t/perf/p5303-many-packs.sh @@ -77,6 +77,7 @@ do # actual pack generation, without smudging the on-disk setup # between trials. test_perf "repack ($nr_packs)" ' + GIT_TEST_FULL_IN_PACK_ARRAY=1 \ git pack-objects --keep-true-parents \ --honor-pack-keep --non-empty --all \ --reflog --indexed-objects --delta-base-offset \ @@ -84,4 +85,22 @@ do ' done +# Measure pack loading with 10,000 packs. +test_expect_success 'generate lots of packs' ' + for i in $(test_seq 10000); do + echo "blob" + echo "data </dev/null ' +test_perf 'rev-list (commits)' ' + git rev-list --all --use-bitmap-index >/dev/null +' + +test_perf 'rev-list (objects)' ' + git rev-list --all --use-bitmap-index --objects >/dev/null +' + +test_perf 'rev-list count with blob:none' ' + git rev-list --use-bitmap-index --count --objects --all \ + --filter=blob:none >/dev/null +' + +test_perf 'rev-list count with blob:limit=1k' ' + git rev-list --use-bitmap-index --count --objects --all \ + --filter=blob:limit=1k >/dev/null +' + +test_perf 'simulated partial clone' ' + git pack-objects --stdout --all --filter=blob:none /dev/null +' + test_expect_success 'create partial bitmap state' ' # pick a commit to represent the repo tip in the past cutoff=$(git rev-list HEAD~100 -1) && diff --git a/t/perf/p5600-clone-reference.sh b/t/perf/p5600-clone-reference.sh deleted file mode 100755 index 68fed663479d..000000000000 --- a/t/perf/p5600-clone-reference.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -test_description='speed of clone --reference' -. ./perf-lib.sh - -test_perf_default_repo - -test_expect_success 'create shareable repository' ' - git clone --bare . shared.git -' - -test_expect_success 'advance base repository' ' - # Do not use test_commit here; its test_tick will - # use some ancient hard-coded date. The resulting clock - # skew will cause pack-objects to traverse in a very - # sub-optimal order, skewing the results. - echo content >new-file-that-does-not-exist && - git add new-file-that-does-not-exist && - git commit -m "new commit" -' - -test_perf 'clone --reference' ' - rm -rf dst.git && - git clone --no-local --bare --reference shared.git . dst.git -' - -test_done diff --git a/t/perf/p5601-clone-reference.sh b/t/perf/p5601-clone-reference.sh new file mode 100755 index 000000000000..68fed663479d --- /dev/null +++ b/t/perf/p5601-clone-reference.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +test_description='speed of clone --reference' +. ./perf-lib.sh + +test_perf_default_repo + +test_expect_success 'create shareable repository' ' + git clone --bare . shared.git +' + +test_expect_success 'advance base repository' ' + # Do not use test_commit here; its test_tick will + # use some ancient hard-coded date. The resulting clock + # skew will cause pack-objects to traverse in a very + # sub-optimal order, skewing the results. + echo content >new-file-that-does-not-exist && + git add new-file-that-does-not-exist && + git commit -m "new commit" +' + +test_perf 'clone --reference' ' + rm -rf dst.git && + git clone --no-local --bare --reference shared.git . dst.git +' + +test_done diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh index b58a43ea4364..13e389367a4e 100644 --- a/t/perf/perf-lib.sh +++ b/t/perf/perf-lib.sh @@ -214,7 +214,7 @@ test_perf_ () { else test_ok_ "$1" fi - "$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".times + "$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".result } test_perf () { @@ -223,7 +223,7 @@ test_perf () { test_size_ () { say >&3 "running: $2" - if test_eval_ "$2" 3>"$base".size; then + if test_eval_ "$2" 3>"$base".result; then test_ok_ "$1" else test_failure_ "$@" diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 9ca0818cbe4c..3e440c078d57 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -20,9 +20,9 @@ modification *should* take notice and update the test vectors here. . ./test-lib.sh -try_local_x () { - local x="local" && - echo "$x" +try_local_xy () { + local x="local" y="alsolocal" && + echo "$x $y" } # Check whether the shell supports the "local" keyword. "local" is not @@ -35,11 +35,12 @@ try_local_x () { # relying on "local". test_expect_success 'verify that the running shell supports "local"' ' x="notlocal" && - echo "local" >expected1 && - try_local_x >actual1 && + y="alsonotlocal" && + echo "local alsolocal" >expected1 && + try_local_xy >actual1 && test_cmp expected1 actual1 && - echo "notlocal" >expected2 && - echo "$x" >actual2 && + echo "notlocal alsonotlocal" >expected2 && + echo "$x $y" >actual2 && test_cmp expected2 actual2 ' @@ -126,7 +127,7 @@ check_sub_test_lib_test () { check_sub_test_lib_test_err () { name="$1" # stdin is the expected output from the test - # expected error output is in descriptior 3 + # expected error output is in descriptor 3 ( cd "$name" && sed -e 's/^> //' -e 's/Z$//' >expect.out && @@ -154,7 +155,7 @@ test_expect_success 'pretend we have a fully passing test suite' " " test_expect_success 'pretend we have a partially passing test suite' " - test_must_fail run_sub_test_lib_test \ + run_sub_test_lib_test_err \ partial-pass '2/3 tests passing' <<-\\EOF && test_expect_success 'passing test #1' 'true' test_expect_success 'failing test #2' 'false' @@ -218,7 +219,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su " test_expect_success 'pretend we have a pass, fail, and known breakage' " - test_must_fail run_sub_test_lib_test \ + run_sub_test_lib_test_err \ mixed-results1 'mixed results #1' <<-\\EOF && test_expect_success 'passing test' 'true' test_expect_success 'failing test' 'false' @@ -237,7 +238,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' " " test_expect_success 'pretend we have a mix of all possible results' " - test_must_fail run_sub_test_lib_test \ + run_sub_test_lib_test_err \ mixed-results2 'mixed results #2' <<-\\EOF && test_expect_success 'passing test' 'true' test_expect_success 'passing test' 'true' @@ -273,24 +274,24 @@ test_expect_success 'pretend we have a mix of all possible results' " " test_expect_success C_LOCALE_OUTPUT 'test --verbose' ' - test_must_fail run_sub_test_lib_test \ - test-verbose "test verbose" --verbose <<-\EOF && + run_sub_test_lib_test_err \ + t1234-verbose "test verbose" --verbose <<-\EOF && test_expect_success "passing test" true test_expect_success "test with output" "echo foo" test_expect_success "failing test" false test_done EOF - mv test-verbose/out test-verbose/out+ && - grep -v "^Initialized empty" test-verbose/out+ >test-verbose/out && - check_sub_test_lib_test test-verbose <<-\EOF - > expecting success: true + mv t1234-verbose/out t1234-verbose/out+ && + grep -v "^Initialized empty" t1234-verbose/out+ >t1234-verbose/out && + check_sub_test_lib_test t1234-verbose <<-\EOF + > expecting success of 1234.1 '\''passing test'\'': true > ok 1 - passing test > Z - > expecting success: echo foo + > expecting success of 1234.2 '\''test with output'\'': echo foo > foo > ok 2 - test with output > Z - > expecting success: false + > expecting success of 1234.3 '\''failing test'\'': false > not ok 3 - failing test > # false > Z @@ -300,18 +301,18 @@ test_expect_success C_LOCALE_OUTPUT 'test --verbose' ' ' test_expect_success 'test --verbose-only' ' - test_must_fail run_sub_test_lib_test \ - test-verbose-only-2 "test verbose-only=2" \ + run_sub_test_lib_test_err \ + t2345-verbose-only-2 "test verbose-only=2" \ --verbose-only=2 <<-\EOF && test_expect_success "passing test" true test_expect_success "test with output" "echo foo" test_expect_success "failing test" false test_done EOF - check_sub_test_lib_test test-verbose-only-2 <<-\EOF + check_sub_test_lib_test t2345-verbose-only-2 <<-\EOF > ok 1 - passing test > Z - > expecting success: echo foo + > expecting success of 2345.2 '\''test with output'\'': echo foo > foo > ok 2 - test with output > Z @@ -391,6 +392,44 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' " ) " +test_expect_success 'GIT_SKIP_TESTS entire suite' " + ( + GIT_SKIP_TESTS='git' && export GIT_SKIP_TESTS && + run_sub_test_lib_test git-skip-tests-entire-suite \ + 'GIT_SKIP_TESTS entire suite' <<-\\EOF && + for i in 1 2 3 + do + test_expect_success \"passing test #\$i\" 'true' + done + test_done + EOF + check_sub_test_lib_test git-skip-tests-entire-suite <<-\\EOF + > 1..0 # SKIP skip all tests in git + EOF + ) +" + +test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' " + ( + GIT_SKIP_TESTS='notgit' && export GIT_SKIP_TESTS && + run_sub_test_lib_test git-skip-tests-unmatched-suite \ + 'GIT_SKIP_TESTS does not skip unmatched suite' <<-\\EOF && + for i in 1 2 3 + do + test_expect_success \"passing test #\$i\" 'true' + done + test_done + EOF + check_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\EOF + > ok 1 - passing test #1 + > ok 2 - passing test #2 + > ok 3 - passing test #3 + > # passed all 3 test(s) + > 1..3 + EOF + ) +" + test_expect_success '--run basic' " run_sub_test_lib_test run-basic \ '--run basic' --run='1 3 5' <<-\\EOF && @@ -795,7 +834,7 @@ then fi test_expect_success 'tests clean up even on failures' " - test_must_fail run_sub_test_lib_test \ + run_sub_test_lib_test_err \ failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF && test_expect_success 'tests clean up even after a failure' ' touch clean-after-failure && @@ -824,7 +863,7 @@ test_expect_success 'tests clean up even on failures' " " test_expect_success 'test_atexit is run' " - test_must_fail run_sub_test_lib_test \ + run_sub_test_lib_test_err \ atexit-cleanup 'Run atexit commands' -i <<-\\EOF && test_expect_success 'tests clean up even after a failure' ' > ../../clean-atexit && @@ -878,6 +917,40 @@ test_expect_success 'test_oid can look up data for SHA-256' ' test "$hexsz" -eq 64 ' +test_expect_success 'test_bool_env' ' + ( + sane_unset envvar && + + test_bool_env envvar true && + ! test_bool_env envvar false && + + envvar= && + export envvar && + ! test_bool_env envvar true && + ! test_bool_env envvar false && + + envvar=true && + test_bool_env envvar true && + test_bool_env envvar false && + + envvar=false && + ! test_bool_env envvar true && + ! test_bool_env envvar false && + + envvar=invalid && + # When encountering an invalid bool value, test_bool_env + # prints its error message to the original stderr of the + # test script, hence the redirection of fd 7, and aborts + # with "exit 1", hence the subshell. + ! ( test_bool_env envvar true ) 7>err && + grep "error: test_bool_env requires bool values" err && + + envvar=true && + ! ( test_bool_env envvar invalid ) 7>err && + grep "error: test_bool_env requires bool values" err + ) +' + ################################################################ # Basics of the basics diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index 71e63d8b509d..b660593c20f8 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -5,19 +5,16 @@ test_description=gitattributes . ./test-lib.sh attr_check () { - path="$1" expect="$2" + path="$1" expect="$2" git_opts="$3" && - git $3 check-attr test -- "$path" >actual 2>err && - echo "$path: test: $2" >expect && + git $git_opts check-attr test -- "$path" >actual 2>err && + echo "$path: test: $expect" >expect && test_cmp expect actual && - test_line_count = 0 err + test_must_be_empty err } attr_check_quote () { - - path="$1" - quoted_path="$2" - expect="$3" + path="$1" quoted_path="$2" expect="$3" && git check-attr test -- "$path" >actual && echo "\"$quoted_path\": test: $expect" >expect && @@ -27,7 +24,7 @@ attr_check_quote () { test_expect_success 'open-quoted pathname' ' echo "\"a test=a" >.gitattributes && - test_must_fail attr_check a a + attr_check a unspecified ' @@ -112,20 +109,20 @@ test_expect_success 'attribute test' ' test_expect_success 'attribute matching is case sensitive when core.ignorecase=0' ' - test_must_fail attr_check F f "-c core.ignorecase=0" && - test_must_fail attr_check a/F f "-c core.ignorecase=0" && - test_must_fail attr_check a/c/F f "-c core.ignorecase=0" && - test_must_fail attr_check a/G a/g "-c core.ignorecase=0" && - test_must_fail attr_check a/B/g a/b/g "-c core.ignorecase=0" && - test_must_fail attr_check a/b/G a/b/g "-c core.ignorecase=0" && - test_must_fail attr_check a/b/H a/b/h "-c core.ignorecase=0" && - test_must_fail attr_check a/b/D/g "a/b/d/*" "-c core.ignorecase=0" && - test_must_fail attr_check oNoFf unset "-c core.ignorecase=0" && - test_must_fail attr_check oFfOn set "-c core.ignorecase=0" && + attr_check F unspecified "-c core.ignorecase=0" && + attr_check a/F unspecified "-c core.ignorecase=0" && + attr_check a/c/F unspecified "-c core.ignorecase=0" && + attr_check a/G unspecified "-c core.ignorecase=0" && + attr_check a/B/g a/g "-c core.ignorecase=0" && + attr_check a/b/G unspecified "-c core.ignorecase=0" && + attr_check a/b/H unspecified "-c core.ignorecase=0" && + attr_check a/b/D/g a/g "-c core.ignorecase=0" && + attr_check oNoFf unspecified "-c core.ignorecase=0" && + attr_check oFfOn unspecified "-c core.ignorecase=0" && attr_check NO unspecified "-c core.ignorecase=0" && - test_must_fail attr_check a/b/D/NO "a/b/d/*" "-c core.ignorecase=0" && + attr_check a/b/D/NO unspecified "-c core.ignorecase=0" && attr_check a/b/d/YES a/b/d/* "-c core.ignorecase=0" && - test_must_fail attr_check a/E/f "A/e/F" "-c core.ignorecase=0" + attr_check a/E/f f "-c core.ignorecase=0" ' @@ -149,8 +146,8 @@ test_expect_success 'attribute matching is case insensitive when core.ignorecase ' test_expect_success CASE_INSENSITIVE_FS 'additional case insensitivity tests' ' - test_must_fail attr_check a/B/D/g "a/b/d/*" "-c core.ignorecase=0" && - test_must_fail attr_check A/B/D/NO "a/b/d/*" "-c core.ignorecase=0" && + attr_check a/B/D/g a/g "-c core.ignorecase=0" && + attr_check A/B/D/NO unspecified "-c core.ignorecase=0" && attr_check A/b/h a/b/h "-c core.ignorecase=1" && attr_check a/B/D/g "a/b/d/*" "-c core.ignorecase=1" && attr_check A/B/D/NO "a/b/d/*" "-c core.ignorecase=1" @@ -244,7 +241,7 @@ EOF git check-attr foo -- "a/b/f" >>actual 2>>err && git check-attr foo -- "a/b/c/f" >>actual 2>>err && test_cmp expect actual && - test_line_count = 0 err + test_must_be_empty err ' test_expect_success '"**" with no slashes test' ' @@ -265,7 +262,7 @@ EOF git check-attr foo -- "a/b/f" >>actual 2>>err && git check-attr foo -- "a/b/c/f" >>actual 2>>err && test_cmp expect actual && - test_line_count = 0 err + test_must_be_empty err ' test_expect_success 'using --git-dir and --work-tree' ' diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh index 1744cee5e996..370a389e5c5c 100755 --- a/t/t0008-ignores.sh +++ b/t/t0008-ignores.sh @@ -424,9 +424,24 @@ test_expect_success 'local ignore inside a sub-directory with --verbose' ' ) ' -test_expect_success_multi 'nested include' \ - 'a/b/.gitignore:8:!on* a/b/one' ' - test_check_ignore "a/b/one" +test_expect_success 'nested include of negated pattern' ' + expect "" && + test_check_ignore "a/b/one" 1 +' + +test_expect_success 'nested include of negated pattern with -q' ' + expect "" && + test_check_ignore "-q a/b/one" 1 +' + +test_expect_success 'nested include of negated pattern with -v' ' + expect "a/b/.gitignore:8:!on* a/b/one" && + test_check_ignore "-v a/b/one" 0 +' + +test_expect_success 'nested include of negated pattern with -v -n' ' + expect "a/b/.gitignore:8:!on* a/b/one" && + test_check_ignore "-v -n a/b/one" 0 ' ############################################################################ @@ -460,7 +475,6 @@ test_expect_success 'cd to ignored sub-directory' ' expect_from_stdin <<-\EOF && foo twoooo - ../one seven ../../one EOF @@ -543,7 +557,6 @@ test_expect_success 'global ignore' ' globalthree a/globalthree a/per-repo - globaltwo EOF test_check_ignore "globalone per-repo globalthree a/globalthree a/per-repo not-ignored globaltwo" ' @@ -586,17 +599,7 @@ EOF cat <<-\EOF >expected-default one a/one - a/b/on - a/b/one - a/b/one one - a/b/one two - "a/b/one\"three" - a/b/two a/b/twooo - globaltwo - a/globaltwo - a/b/globaltwo - b/globaltwo EOF cat <<-EOF >expected-verbose .gitignore:1:one one @@ -696,8 +699,12 @@ cat <<-EOF >expected-all $global_excludes:2:!globaltwo ../b/globaltwo :: c/not-ignored EOF +cat <<-EOF >expected-default +../one +one +b/twooo +EOF grep -v '^:: ' expected-all >expected-verbose -sed -e 's/.* //' expected-verbose >expected-default broken_c_unquote stdin >stdin0 diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh index a070e645d7fb..8d3d9144c06d 100755 --- a/t/t0014-alias.sh +++ b/t/t0014-alias.sh @@ -37,4 +37,11 @@ test_expect_success 'looping aliases - internal execution' ' # test_i18ngrep "^fatal: alias loop detected: expansion of" output #' +test_expect_success 'run-command formats empty args properly' ' + test_must_fail env GIT_TRACE=1 git frotz a "" b " " c 2>actual.raw && + sed -ne "/run_command:/s/.*trace: run_command: //p" actual.raw >actual && + echo "git-frotz a '\'''\'' b '\'' '\'' c" >expect && + test_cmp expect actual +' + test_done diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh index 854da0ae16f8..b63ba62e5db4 100755 --- a/t/t0020-crlf.sh +++ b/t/t0020-crlf.sh @@ -159,8 +159,8 @@ test_expect_success 'checkout with autocrlf=input' ' rm -f tmp one dir/two three && git config core.autocrlf input && git read-tree --reset -u HEAD && - test_must_fail has_cr one && - test_must_fail has_cr dir/two && + ! has_cr one && + ! has_cr dir/two && git update-index -- one dir/two && test "$one" = $(git hash-object --stdin .gitattributes && git read-tree --reset -u HEAD && - test_must_fail has_cr dir/two + ! has_cr dir/two ' test_expect_success '.gitattributes says two and three are text' ' @@ -270,7 +270,7 @@ test_expect_success 'in-tree .gitattributes (1)' ' rm -rf tmp one dir .gitattributes patch.file three && git read-tree --reset -u HEAD && - test_must_fail has_cr one && + ! has_cr one && verbose has_cr three ' @@ -280,7 +280,7 @@ test_expect_success 'in-tree .gitattributes (2)' ' git read-tree --reset HEAD && git checkout-index -f -q -u -a && - test_must_fail has_cr one && + ! has_cr one && verbose has_cr three ' @@ -291,7 +291,7 @@ test_expect_success 'in-tree .gitattributes (3)' ' git checkout-index -u .gitattributes && git checkout-index -u one dir/two three && - test_must_fail has_cr one && + ! has_cr one && verbose has_cr three ' @@ -302,7 +302,7 @@ test_expect_success 'in-tree .gitattributes (4)' ' git checkout-index -u one dir/two three && git checkout-index -u .gitattributes && - test_must_fail has_cr one && + ! has_cr one && verbose has_cr three ' diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index e10f5f787fca..dc664da551a3 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -35,7 +35,7 @@ filter_git () { # Compare two files and ensure that `clean` and `smudge` respectively are # called at least once if specified in the `expect` file. The actual # invocation count is not relevant because their number can vary. -# c.f. http://public-inbox.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/ +# c.f. http://lore.kernel.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/ test_cmp_count () { expect=$1 actual=$2 @@ -50,7 +50,7 @@ test_cmp_count () { # Compare two files but exclude all `clean` invocations because Git can # call `clean` zero or more times. -# c.f. http://public-inbox.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/ +# c.f. http://lore.kernel.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/ test_cmp_exclude_clean () { expect=$1 actual=$2 @@ -390,6 +390,9 @@ test_expect_success PERL 'required process filter should filter data' ' EOF test_cmp_exclude_clean expected.log debug.log && + # Make sure that the file appears dirty, so checkout below has to + # run the configured filter. + touch test.r && filter_git checkout --quiet --no-progress empty-branch && cat >expected.log <<-EOF && START @@ -792,7 +795,6 @@ test_expect_success PERL 'missing file in delayed checkout' ' rm -rf repo-cloned && test_must_fail git clone repo repo-cloned 2>git-stderr.log && - cat git-stderr.log && grep "error: .missing-delay\.a. was not filtered properly" git-stderr.log ' diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh index 959b6da44900..9fcd56fab373 100755 --- a/t/t0027-auto-crlf.sh +++ b/t/t0027-auto-crlf.sh @@ -215,7 +215,7 @@ stats_ascii () { } -# contruct the attr/ returned by git ls-files --eol +# construct the attr/ returned by git ls-files --eol # Take none (=empty), one or two args # convert.c: eol=XX overrides text=auto attr_ascii () { diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh index 1090e650edb7..bfc4fb9af5f2 100755 --- a/t/t0028-working-tree-encoding.sh +++ b/t/t0028-working-tree-encoding.sh @@ -17,7 +17,7 @@ test_lazy_prereq NO_UTF32_BOM ' write_utf16 () { if test_have_prereq NO_UTF16_BOM then - printf '\xfe\xff' + printf '\376\377' fi && iconv -f UTF-8 -t UTF-16 } @@ -25,7 +25,7 @@ write_utf16 () { write_utf32 () { if test_have_prereq NO_UTF32_BOM then - printf '\x00\x00\xfe\xff' + printf '\0\0\376\377' fi && iconv -f UTF-8 -t UTF-32 } @@ -40,7 +40,7 @@ test_expect_success 'setup test files' ' printf "$text" | write_utf16 >test.utf16.raw && printf "$text" | write_utf32 >test.utf32.raw && printf "\377\376" >test.utf16lebom.raw && - printf "$text" | iconv -f UTF-8 -t UTF-32LE >>test.utf16lebom.raw && + printf "$text" | iconv -f UTF-8 -t UTF-16LE >>test.utf16lebom.raw && # Line ending tests printf "one\ntwo\nthree\n" >lf.utf8.raw && @@ -280,4 +280,43 @@ test_expect_success ICONV_SHIFT_JIS 'check roundtrip encoding' ' git reset ' +# $1: checkout encoding +# $2: test string +# $3: binary test string in checkout encoding +test_commit_utf8_checkout_other () { + encoding="$1" + orig_string="$2" + expect_bytes="$3" + + test_expect_success "Commit UTF-8, checkout $encoding" ' + test_when_finished "git checkout HEAD -- .gitattributes" && + + test_ext="commit_utf8_checkout_$encoding" && + test_file="test.$test_ext" && + + # Commit as UTF-8 + echo "*.$test_ext text working-tree-encoding=UTF-8" >.gitattributes && + printf "$orig_string" >$test_file && + git add $test_file && + git commit -m "Test data" && + + # Checkout in tested encoding + rm $test_file && + echo "*.$test_ext text working-tree-encoding=$encoding" >.gitattributes && + git checkout HEAD -- $test_file && + + # Test + printf $expect_bytes >$test_file.raw && + test_cmp_bin $test_file.raw $test_file + ' +} + +test_commit_utf8_checkout_other "UTF-8" "Test Тест" "\124\145\163\164\040\320\242\320\265\321\201\321\202" +test_commit_utf8_checkout_other "UTF-16LE" "Test Тест" "\124\000\145\000\163\000\164\000\040\000\042\004\065\004\101\004\102\004" +test_commit_utf8_checkout_other "UTF-16BE" "Test Тест" "\000\124\000\145\000\163\000\164\000\040\004\042\004\065\004\101\004\102" +test_commit_utf8_checkout_other "UTF-16LE-BOM" "Test Тест" "\377\376\124\000\145\000\163\000\164\000\040\000\042\004\065\004\101\004\102\004" +test_commit_utf8_checkout_other "UTF-16BE-BOM" "Test Тест" "\376\377\000\124\000\145\000\163\000\164\000\040\004\042\004\065\004\101\004\102" +test_commit_utf8_checkout_other "UTF-32LE" "Test Тест" "\124\000\000\000\145\000\000\000\163\000\000\000\164\000\000\000\040\000\000\000\042\004\000\000\065\004\000\000\101\004\000\000\102\004\000\000" +test_commit_utf8_checkout_other "UTF-32BE" "Test Тест" "\000\000\000\124\000\000\000\145\000\000\000\163\000\000\000\164\000\000\000\040\000\000\004\042\000\000\004\065\000\000\004\101\000\000\004\102" + test_done diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index cebc77fab0b2..3483b72db42a 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -23,6 +23,8 @@ usage: test-tool parse-options -j get a integer, too -m, --magnitude get a magnitude --set23 set integer to 23 + --mode1 set integer to 1 (cmdmode option) + --mode2 set integer to 2 (cmdmode option) -L, --length get length of -F, --file set file to @@ -242,7 +244,7 @@ test_expect_success 'Alias options do not contribute to abbreviation' ' ' cat >typo.err <<\EOF -error: did you mean `--boolean` (with two dashes ?) +error: did you mean `--boolean` (with two dashes)? EOF test_expect_success 'detect possible typos' ' @@ -252,7 +254,7 @@ test_expect_success 'detect possible typos' ' ' cat >typo.err <<\EOF -error: did you mean `--ambiguous` (with two dashes ?) +error: did you mean `--ambiguous` (with two dashes)? EOF test_expect_success 'detect possible typos' ' @@ -324,6 +326,22 @@ test_expect_success 'OPT_NEGBIT() works' ' test-tool parse-options --expect="boolean: 6" -bb --no-neg-or4 ' +test_expect_success 'OPT_CMDMODE() works' ' + test-tool parse-options --expect="integer: 1" --mode1 +' + +test_expect_success 'OPT_CMDMODE() detects incompatibility' ' + test_must_fail test-tool parse-options --mode1 --mode2 >output 2>output.err && + test_must_be_empty output && + test_i18ngrep "incompatible with --mode" output.err +' + +test_expect_success 'OPT_CMDMODE() detects incompatibility with something else' ' + test_must_fail test-tool parse-options --set23 --mode2 >output 2>output.err && + test_must_be_empty output && + test_i18ngrep "incompatible with something else" output.err +' + test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' ' test-tool parse-options --expect="boolean: 6" + + + + + + ' @@ -399,4 +417,11 @@ test_expect_success 'GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS works' ' test-tool parse-options --ye ' +test_expect_success '--end-of-options treats remainder as args' ' + test-tool parse-options \ + --expect="verbose: -1" \ + --expect="arg 00: --verbose" \ + --end-of-options --verbose +' + test_done diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 192c94eccd13..608673fb775d 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -131,4 +131,24 @@ $test_unicode 'merge (silent unicode normalization)' ' git merge topic ' +test_expect_success CASE_INSENSITIVE_FS 'checkout with no pathspec and a case insensitive fs' ' + git init repo && + ( + cd repo && + + >Gitweb && + git add Gitweb && + git commit -m "add Gitweb" && + + git checkout --orphan todo && + git reset --hard && + mkdir -p gitweb/subdir && + >gitweb/subdir/file && + git add gitweb && + git commit -m "add gitweb/subdir/file" && + + git checkout master + ) +' + test_done diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index c7b53e494ba4..2ea2d00c39a6 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -165,6 +165,15 @@ test_expect_success 'absolute path rejects the empty string' ' test_must_fail test-tool path-utils absolute_path "" ' +test_expect_success MINGW ':\\abc is an absolute path' ' + for letter in : \" C Z 1 ä + do + path=$letter:\\abc && + absolute="$(test-tool path-utils absolute_path "$path")" && + test "$path" = "$absolute" || return 1 + done +' + test_expect_success 'real path rejects the empty string' ' test_must_fail test-tool path-utils real_path "" ' @@ -285,9 +294,13 @@ test_git_path GIT_OBJECT_DIRECTORY=foo objects/foo foo/foo test_git_path GIT_OBJECT_DIRECTORY=foo objects2 .git/objects2 test_expect_success 'setup common repository' 'git --git-dir=bar init' test_git_path GIT_COMMON_DIR=bar index .git/index +test_git_path GIT_COMMON_DIR=bar index.lock .git/index.lock test_git_path GIT_COMMON_DIR=bar HEAD .git/HEAD test_git_path GIT_COMMON_DIR=bar logs/HEAD .git/logs/HEAD +test_git_path GIT_COMMON_DIR=bar logs/HEAD.lock .git/logs/HEAD.lock test_git_path GIT_COMMON_DIR=bar logs/refs/bisect/foo .git/logs/refs/bisect/foo +test_git_path GIT_COMMON_DIR=bar logs/refs bar/logs/refs +test_git_path GIT_COMMON_DIR=bar logs/refs/ bar/logs/refs/ test_git_path GIT_COMMON_DIR=bar logs/refs/bisec/foo bar/logs/refs/bisec/foo test_git_path GIT_COMMON_DIR=bar logs/refs/bisec bar/logs/refs/bisec test_git_path GIT_COMMON_DIR=bar logs/refs/bisectfoo bar/logs/refs/bisectfoo @@ -423,6 +436,9 @@ test_expect_success 'match .gitmodules' ' ~1000000 \ ~9999999 \ \ + .gitmodules:\$DATA \ + "gitmod~4 . :\$DATA" \ + \ --not \ ".gitmodules x" \ ".gitmodules .x" \ @@ -447,7 +463,34 @@ test_expect_success 'match .gitmodules' ' \ GI7EB~1 \ GI7EB~01 \ - GI7EB~1X + GI7EB~1X \ + \ + .gitmodules,:\$DATA +' + +test_expect_success MINGW 'is_valid_path() on Windows' ' + test-tool path-utils is_valid_path \ + win32 \ + "win32 x" \ + ../hello.txt \ + C:\\git \ + comm \ + conout.c \ + lptN \ + \ + --not \ + "win32 " \ + "win32 /x " \ + "win32." \ + "win32 . ." \ + .../hello.txt \ + colon:test \ + "AUX.c" \ + "abc/conOut\$ .xyz/test" \ + lpt8 \ + "lpt*" \ + Nul \ + "PRN./abc" ' test_done diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh index 015fac8b5d07..7d599675e35a 100755 --- a/t/t0061-run-command.sh +++ b/t/t0061-run-command.sh @@ -12,6 +12,10 @@ cat >hello-script <<-EOF cat hello-script EOF +test_expect_success MINGW 'subprocess inherits only std handles' ' + test-tool run-command inherited-handle +' + test_expect_success 'start_command reports ENOENT (slash)' ' test-tool run-command start-command-ENOENT ./does-not-exist 2>err && test_i18ngrep "\./does-not-exist" err @@ -210,10 +214,23 @@ test_expect_success MINGW 'verify curlies are quoted properly' ' test_cmp expect actual ' -test_expect_success MINGW 'can spawn with argv[0] containing spaces' ' - cp "$GIT_BUILD_DIR/t/helper/test-fake-ssh$X" ./ && - test_must_fail "$PWD/test-fake-ssh$X" 2>err && - grep TRASH_DIRECTORY err +test_expect_success MINGW 'can spawn .bat with argv[0] containing spaces' ' + bat="$TRASH_DIRECTORY/bat with spaces in name.bat" && + + # Every .bat invocation will log its arguments to file "out" + rm -f out && + echo "echo %* >>out" >"$bat" && + + # Ask git to invoke .bat; clone will fail due to fake SSH helper + test_must_fail env GIT_SSH="$bat" git clone myhost:src ssh-clone && + + # Spawning .bat can fail if there are two quoted cmd.exe arguments. + # .bat itself is first (due to spaces in name), so just one more is + # needed to verify. GIT_SSH will invoke .bat multiple times: + # 1) -G myhost + # 2) myhost "git-upload-pack src" + # First invocation will always succeed. Test the second one. + grep "git-upload-pack" out ' test_done diff --git a/t/t0067-parse_pathspec_file.sh b/t/t0067-parse_pathspec_file.sh new file mode 100755 index 000000000000..7bab49f361a9 --- /dev/null +++ b/t/t0067-parse_pathspec_file.sh @@ -0,0 +1,108 @@ +#!/bin/sh + +test_description='Test parse_pathspec_file()' + +. ./test-lib.sh + +test_expect_success 'one item from stdin' ' + cat >expect <<-\EOF && + fileA.t + EOF + + echo fileA.t | + test-tool parse-pathspec-file --pathspec-from-file=- >actual && + + test_cmp expect actual +' + +test_expect_success 'one item from file' ' + cat >expect <<-\EOF && + fileA.t + EOF + + echo fileA.t >list && + test-tool parse-pathspec-file --pathspec-from-file=list >actual && + + test_cmp expect actual +' + +test_expect_success 'NUL delimiters' ' + cat >expect <<-\EOF && + fileA.t + fileB.t + EOF + + printf "fileA.t\0fileB.t\0" | + test-tool parse-pathspec-file --pathspec-from-file=- --pathspec-file-nul >actual && + + test_cmp expect actual +' + +test_expect_success 'LF delimiters' ' + cat >expect <<-\EOF && + fileA.t + fileB.t + EOF + + printf "fileA.t\nfileB.t\n" | + test-tool parse-pathspec-file --pathspec-from-file=- >actual && + + test_cmp expect actual +' + +test_expect_success 'no trailing delimiter' ' + cat >expect <<-\EOF && + fileA.t + fileB.t + EOF + + printf "fileA.t\nfileB.t" | + test-tool parse-pathspec-file --pathspec-from-file=- >actual && + + test_cmp expect actual +' + +test_expect_success 'CRLF delimiters' ' + cat >expect <<-\EOF && + fileA.t + fileB.t + EOF + + printf "fileA.t\r\nfileB.t\r\n" | + test-tool parse-pathspec-file --pathspec-from-file=- >actual && + + test_cmp expect actual +' + +test_expect_success 'quotes' ' + cat >expect <<-\EOF && + fileA.t + EOF + + cat >list <<-\EOF && + "file\101.t" + EOF + + test-tool parse-pathspec-file --pathspec-from-file=list >actual && + + test_cmp expect actual +' + +test_expect_success '--pathspec-file-nul takes quotes literally' ' + # Note: there is an extra newline because --pathspec-file-nul takes + # input \n literally, too + cat >expect <<-\EOF && + "file\101.t" + + EOF + + cat >list <<-\EOF && + "file\101.t" + EOF + + test-tool parse-pathspec-file --pathspec-from-file=list --pathspec-file-nul >actual && + + test_cmp expect actual +' + +test_done diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index ce9a4a5f324b..5a633690bffc 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -21,9 +21,10 @@ generate_expected_cache_tree_rec () { parent="$2" && # ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux # We want to count only foo because it's the only direct child - subtrees=$(git ls-files|grep /|cut -d / -f 1|uniq) && + git ls-files >files && + subtrees=$(grep / files|cut -d / -f 1|uniq) && subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 != "" {++c} END {print c}') && - entries=$(git ls-files|wc -l) && + entries=$(wc -l ../expected_filenames.txt && + xargs touch <../expected_filenames.txt && + cd .. && + GIT_TRACE2_EVENT="$(pwd)/trace_target_dir" test-tool trace2 001return 0 + ) && + echo git-trace2-discard >>expected_filenames.txt && + ls trace_target_dir >ls_output.txt && + test_cmp expected_filenames.txt ls_output.txt && + head -n1 trace_target_dir/git-trace2-discard | grep \"event\":\"version\" && + head -n2 trace_target_dir/git-trace2-discard | tail -n1 | grep \"event\":\"too_many_files\" +' + test_done diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh index 82eaaea0f495..5555a1524f1d 100755 --- a/t/t0300-credentials.sh +++ b/t/t0300-credentials.sh @@ -22,6 +22,11 @@ test_expect_success 'setup helper scripts' ' exit 0 EOF + write_script git-credential-quit <<-\EOF && + . ./dump + echo quit=1 + EOF + write_script git-credential-verbatim <<-\EOF && user=$1; shift pass=$1; shift @@ -35,43 +40,71 @@ test_expect_success 'setup helper scripts' ' test_expect_success 'credential_fill invokes helper' ' check fill "verbatim foo bar" <<-\EOF + protocol=http + host=example.com -- + protocol=http + host=example.com username=foo password=bar -- verbatim: get + verbatim: protocol=http + verbatim: host=example.com EOF ' test_expect_success 'credential_fill invokes multiple helpers' ' check fill useless "verbatim foo bar" <<-\EOF + protocol=http + host=example.com -- + protocol=http + host=example.com username=foo password=bar -- useless: get + useless: protocol=http + useless: host=example.com verbatim: get + verbatim: protocol=http + verbatim: host=example.com EOF ' test_expect_success 'credential_fill stops when we get a full response' ' check fill "verbatim one two" "verbatim three four" <<-\EOF + protocol=http + host=example.com -- + protocol=http + host=example.com username=one password=two -- verbatim: get + verbatim: protocol=http + verbatim: host=example.com EOF ' test_expect_success 'credential_fill continues through partial response' ' check fill "verbatim one \"\"" "verbatim two three" <<-\EOF + protocol=http + host=example.com -- + protocol=http + host=example.com username=two password=three -- verbatim: get + verbatim: protocol=http + verbatim: host=example.com verbatim: get + verbatim: protocol=http + verbatim: host=example.com verbatim: username=one EOF ' @@ -97,14 +130,20 @@ test_expect_success 'credential_fill passes along metadata' ' test_expect_success 'credential_approve calls all helpers' ' check approve useless "verbatim one two" <<-\EOF + protocol=http + host=example.com username=foo password=bar -- -- useless: store + useless: protocol=http + useless: host=example.com useless: username=foo useless: password=bar verbatim: store + verbatim: protocol=http + verbatim: host=example.com verbatim: username=foo verbatim: password=bar EOF @@ -112,6 +151,8 @@ test_expect_success 'credential_approve calls all helpers' ' test_expect_success 'do not bother storing password-less credential' ' check approve useless <<-\EOF + protocol=http + host=example.com username=foo -- -- @@ -121,14 +162,20 @@ test_expect_success 'do not bother storing password-less credential' ' test_expect_success 'credential_reject calls all helpers' ' check reject useless "verbatim one two" <<-\EOF + protocol=http + host=example.com username=foo password=bar -- -- useless: erase + useless: protocol=http + useless: host=example.com useless: username=foo useless: password=bar verbatim: erase + verbatim: protocol=http + verbatim: host=example.com verbatim: username=foo verbatim: password=bar EOF @@ -136,33 +183,49 @@ test_expect_success 'credential_reject calls all helpers' ' test_expect_success 'usernames can be preserved' ' check fill "verbatim \"\" three" <<-\EOF + protocol=http + host=example.com username=one -- + protocol=http + host=example.com username=one password=three -- verbatim: get + verbatim: protocol=http + verbatim: host=example.com verbatim: username=one EOF ' test_expect_success 'usernames can be overridden' ' check fill "verbatim two three" <<-\EOF + protocol=http + host=example.com username=one -- + protocol=http + host=example.com username=two password=three -- verbatim: get + verbatim: protocol=http + verbatim: host=example.com verbatim: username=one EOF ' test_expect_success 'do not bother completing already-full credential' ' check fill "verbatim three four" <<-\EOF + protocol=http + host=example.com username=one password=two -- + protocol=http + host=example.com username=one password=two -- @@ -174,23 +237,31 @@ test_expect_success 'do not bother completing already-full credential' ' # askpass helper is run, we know the internal getpass is working. test_expect_success 'empty helper list falls back to internal getpass' ' check fill <<-\EOF + protocol=http + host=example.com -- + protocol=http + host=example.com username=askpass-username password=askpass-password -- - askpass: Username: - askpass: Password: + askpass: Username for '\''http://example.com'\'': + askpass: Password for '\''http://askpass-username@example.com'\'': EOF ' test_expect_success 'internal getpass does not ask for known username' ' check fill <<-\EOF + protocol=http + host=example.com username=foo -- + protocol=http + host=example.com username=foo password=askpass-password -- - askpass: Password: + askpass: Password for '\''http://foo@example.com'\'': EOF ' @@ -202,7 +273,11 @@ HELPER="!f() { test_expect_success 'respect configured credentials' ' test_config credential.helper "$HELPER" && check fill <<-\EOF + protocol=http + host=example.com -- + protocol=http + host=example.com username=foo password=bar -- @@ -240,6 +315,57 @@ test_expect_success 'do not match configured credential' ' EOF ' +test_expect_success 'match multiple configured helpers' ' + test_config credential.helper "verbatim \"\" \"\"" && + test_config credential.https://example.com.helper "$HELPER" && + check fill <<-\EOF + protocol=https + host=example.com + path=repo.git + -- + protocol=https + host=example.com + username=foo + password=bar + -- + verbatim: get + verbatim: protocol=https + verbatim: host=example.com + EOF +' + +test_expect_success 'match multiple configured helpers with URLs' ' + test_config credential.https://example.com/repo.git.helper "verbatim \"\" \"\"" && + test_config credential.https://example.com.helper "$HELPER" && + check fill <<-\EOF + protocol=https + host=example.com + path=repo.git + -- + protocol=https + host=example.com + username=foo + password=bar + -- + verbatim: get + verbatim: protocol=https + verbatim: host=example.com + EOF +' + +test_expect_success 'match percent-encoded values' ' + test_config credential.https://example.com/%2566.git.helper "$HELPER" && + check fill <<-\EOF + url=https://example.com/%2566.git + -- + protocol=https + host=example.com + username=foo + password=bar + -- + EOF +' + test_expect_success 'pull username from config' ' test_config credential.https://example.com.username foo && check fill <<-\EOF @@ -255,6 +381,63 @@ test_expect_success 'pull username from config' ' EOF ' +test_expect_success 'honors username from URL over helper (URL)' ' + test_config credential.https://example.com.username bob && + test_config credential.https://example.com.helper "verbatim \"\" bar" && + check fill <<-\EOF + url=https://alice@example.com + -- + protocol=https + host=example.com + username=alice + password=bar + -- + verbatim: get + verbatim: protocol=https + verbatim: host=example.com + verbatim: username=alice + EOF +' + +test_expect_success 'honors username from URL over helper (components)' ' + test_config credential.https://example.com.username bob && + test_config credential.https://example.com.helper "verbatim \"\" bar" && + check fill <<-\EOF + protocol=https + host=example.com + username=alice + -- + protocol=https + host=example.com + username=alice + password=bar + -- + verbatim: get + verbatim: protocol=https + verbatim: host=example.com + verbatim: username=alice + EOF +' + +test_expect_success 'last matching username wins' ' + test_config credential.https://example.com/path.git.username bob && + test_config credential.https://example.com.username alice && + test_config credential.https://example.com.helper "verbatim \"\" bar" && + check fill <<-\EOF + url=https://example.com/path.git + -- + protocol=https + host=example.com + username=alice + password=bar + -- + verbatim: get + verbatim: protocol=https + verbatim: host=example.com + verbatim: username=alice + EOF +' + test_expect_success 'http paths can be part of context' ' check fill "verbatim foo bar" <<-\EOF && protocol=https @@ -289,23 +472,107 @@ test_expect_success 'http paths can be part of context' ' EOF ' +test_expect_success 'context uses urlmatch' ' + test_config "credential.https://*.org.useHttpPath" true && + check fill "verbatim foo bar" <<-\EOF + protocol=https + host=example.org + path=foo.git + -- + protocol=https + host=example.org + path=foo.git + username=foo + password=bar + -- + verbatim: get + verbatim: protocol=https + verbatim: host=example.org + verbatim: path=foo.git + EOF +' + test_expect_success 'helpers can abort the process' ' test_must_fail git \ - -c credential.helper="!f() { echo quit=1; }; f" \ + -c credential.helper=quit \ -c credential.helper="verbatim foo bar" \ - credential fill >stdout && - test_must_be_empty stdout + credential fill >stdout 2>stderr <<-\EOF && + protocol=http + host=example.com + EOF + test_must_be_empty stdout && + cat >expect <<-\EOF && + quit: get + quit: protocol=http + quit: host=example.com + fatal: credential helper '\''quit'\'' told us to quit + EOF + test_i18ncmp expect stderr ' test_expect_success 'empty helper spec resets helper list' ' test_config credential.helper "verbatim file file" && check fill "" "verbatim cmdline cmdline" <<-\EOF + protocol=http + host=example.com -- + protocol=http + host=example.com username=cmdline password=cmdline -- verbatim: get + verbatim: protocol=http + verbatim: host=example.com + EOF +' + +test_expect_success 'url parser rejects embedded newlines' ' + test_must_fail git credential fill 2>stderr <<-\EOF && + url=https://one.example.com?%0ahost=two.example.com/ + EOF + cat >expect <<-\EOF && + warning: url contains a newline in its host component: https://one.example.com?%0ahost=two.example.com/ + fatal: credential url cannot be parsed: https://one.example.com?%0ahost=two.example.com/ + EOF + test_i18ncmp expect stderr +' + +test_expect_success 'host-less URLs are parsed as empty host' ' + check fill "verbatim foo bar" <<-\EOF + url=cert:///path/to/cert.pem + -- + protocol=cert + host= + path=path/to/cert.pem + username=foo + password=bar + -- + verbatim: get + verbatim: protocol=cert + verbatim: host= + verbatim: path=path/to/cert.pem + EOF +' + +test_expect_success 'credential system refuses to work with missing host' ' + test_must_fail git credential fill 2>stderr <<-\EOF && + protocol=http + EOF + cat >expect <<-\EOF && + fatal: refusing to work with credential missing host field + EOF + test_i18ncmp expect stderr +' + +test_expect_success 'credential system refuses to work with missing protocol' ' + test_must_fail git credential fill 2>stderr <<-\EOF && + host=example.com + EOF + cat >expect <<-\EOF && + fatal: refusing to work with credential missing protocol field EOF + test_i18ncmp expect stderr ' test_done diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index 5bd892f2f7a9..a3988bd4b8c8 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -26,7 +26,7 @@ promise_and_delete () { test_expect_success 'extensions.partialclone without filter' ' test_create_repo server && git clone --filter="blob:none" "file://$(pwd)/server" client && - git -C client config --unset core.partialclonefilter && + git -C client config --unset remote.origin.partialclonefilter && git -C client fetch origin ' @@ -166,8 +166,9 @@ test_expect_success 'fetching of missing objects' ' # associated packfile contains the object ls repo/.git/objects/pack/pack-*.promisor >promisorlist && test_line_count = 1 promisorlist && - IDX=$(cat promisorlist | sed "s/promisor$/idx/") && - git verify-pack --verbose "$IDX" | grep "$HASH" + IDX=$(sed "s/promisor$/idx/" promisorlist) && + git verify-pack --verbose "$IDX" >out && + grep "$HASH" out ' test_expect_success 'fetching of missing objects works with ref-in-want enabled' ' @@ -182,8 +183,55 @@ test_expect_success 'fetching of missing objects works with ref-in-want enabled' grep "git< fetch=.*ref-in-want" trace ' +test_expect_success 'fetching of missing objects from another promisor remote' ' + git clone "file://$(pwd)/server" server2 && + test_commit -C server2 bar && + git -C server2 repack -a -d --write-bitmap-index && + HASH2=$(git -C server2 rev-parse bar) && + + git -C repo remote add server2 "file://$(pwd)/server2" && + git -C repo config remote.server2.promisor true && + git -C repo cat-file -p "$HASH2" && + + git -C repo fetch server2 && + rm -rf repo/.git/objects/* && + git -C repo cat-file -p "$HASH2" && + + # Ensure that the .promisor file is written, and check that its + # associated packfile contains the object + ls repo/.git/objects/pack/pack-*.promisor >promisorlist && + test_line_count = 1 promisorlist && + IDX=$(sed "s/promisor$/idx/" promisorlist) && + git verify-pack --verbose "$IDX" >out && + grep "$HASH2" out +' + +test_expect_success 'fetching of missing objects configures a promisor remote' ' + git clone "file://$(pwd)/server" server3 && + test_commit -C server3 baz && + git -C server3 repack -a -d --write-bitmap-index && + HASH3=$(git -C server3 rev-parse baz) && + git -C server3 config uploadpack.allowfilter 1 && + + rm repo/.git/objects/pack/pack-*.promisor && + + git -C repo remote add server3 "file://$(pwd)/server3" && + git -C repo fetch --filter="blob:none" server3 $HASH3 && + + test_cmp_config -C repo true remote.server3.promisor && + + # Ensure that the .promisor file is written, and check that its + # associated packfile contains the object + ls repo/.git/objects/pack/pack-*.promisor >promisorlist && + test_line_count = 1 promisorlist && + IDX=$(sed "s/promisor$/idx/" promisorlist) && + git verify-pack --verbose "$IDX" >out && + grep "$HASH3" out +' + test_expect_success 'fetching of missing blobs works' ' - rm -rf server repo && + rm -rf server server2 repo && + rm -rf server server3 repo && test_create_repo server && test_commit -C server foo && git -C server repack -a -d --write-bitmap-index && @@ -234,7 +282,7 @@ test_expect_success 'rev-list stops traversal at missing and promised commit' ' git -C repo config core.repositoryformatversion 1 && git -C repo config extensions.partialclone "arbitrary string" && - GIT_TEST_COMMIT_GRAPH=0 git -C repo rev-list --exclude-promisor-objects --objects bar >out && + GIT_TEST_COMMIT_GRAPH=0 git -C repo -c core.commitGraph=false rev-list --exclude-promisor-objects --objects bar >out && grep $(git -C repo rev-parse bar) out && ! grep $FOO out ' @@ -381,6 +429,19 @@ test_expect_success 'rev-list dies for missing objects on cmd line' ' done ' +test_expect_success 'single promisor remote can be re-initialized gracefully' ' + # ensure one promisor is in the promisors list + rm -rf repo && + test_create_repo repo && + test_create_repo other && + git -C repo remote add foo "file://$(pwd)/other" && + git -C repo config remote.foo.promisor true && + git -C repo config extensions.partialclone foo && + + # reinitialize the promisors list + git -C repo fetch --filter=blob:none foo +' + test_expect_success 'gc repacks promisor objects separately from non-promisor objects' ' rm -rf repo && test_create_repo repo && @@ -492,6 +553,20 @@ test_expect_success 'gc stops traversal when a missing but promised object is re ! grep "$TREE_HASH" out ' +test_expect_success 'do not fetch when checking existence of tree we construct ourselves' ' + rm -rf repo && + test_create_repo repo && + test_commit -C repo base && + test_commit -C repo side1 && + git -C repo checkout base && + test_commit -C repo side2 && + + git -C repo config core.repositoryformatversion 1 && + git -C repo config extensions.partialclone "arbitrary string" && + + git -C repo cherry-pick side1 +' + . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -514,8 +589,12 @@ test_expect_success 'fetching of missing objects from an HTTP server' ' # associated packfile contains the object ls repo/.git/objects/pack/pack-*.promisor >promisorlist && test_line_count = 1 promisorlist && - IDX=$(cat promisorlist | sed "s/promisor$/idx/") && - git verify-pack --verbose "$IDX" | grep "$HASH" + IDX=$(sed "s/promisor$/idx/" promisorlist) && + git verify-pack --verbose "$IDX" >out && + grep "$HASH" out ' +# DO NOT add non-httpd-specific tests here, because the last part of this +# test script is only executed when httpd is available and enabled. + test_done diff --git a/t/t0500-progress-display.sh b/t/t0500-progress-display.sh new file mode 100755 index 000000000000..d2d088d9a0c3 --- /dev/null +++ b/t/t0500-progress-display.sh @@ -0,0 +1,286 @@ +#!/bin/sh + +test_description='progress display' + +. ./test-lib.sh + +show_cr () { + tr '\015' Q | sed -e "s/Q/\\$LF/g" +} + +test_expect_success 'simple progress display' ' + cat >expect <<-\EOF && + Working hard: 1 + Working hard: 2 + Working hard: 5 + Working hard: 5, done. + EOF + + cat >in <<-\EOF && + update + progress 1 + update + progress 2 + progress 3 + progress 4 + update + progress 5 + EOF + test-tool progress "Working hard" stderr && + + show_cr out && + test_i18ncmp expect out +' + +test_expect_success 'progress display with total' ' + cat >expect <<-\EOF && + Working hard: 33% (1/3) + Working hard: 66% (2/3) + Working hard: 100% (3/3) + Working hard: 100% (3/3), done. + EOF + + cat >in <<-\EOF && + progress 1 + progress 2 + progress 3 + EOF + test-tool progress --total=3 "Working hard" stderr && + + show_cr out && + test_i18ncmp expect out +' + +test_expect_success 'progress display breaks long lines #1' ' + sed -e "s/Z$//" >expect <<\EOF && +Working hard.......2.........3.........4.........5.........6: 0% (100/100000) +Working hard.......2.........3.........4.........5.........6: 1% (1000/100000) +Working hard.......2.........3.........4.........5.........6: Z + 10% (10000/100000) + 100% (100000/100000) + 100% (100000/100000), done. +EOF + + cat >in <<-\EOF && + progress 100 + progress 1000 + progress 10000 + progress 100000 + EOF + test-tool progress --total=100000 \ + "Working hard.......2.........3.........4.........5.........6" \ + stderr && + + show_cr out && + test_i18ncmp expect out +' + +test_expect_success 'progress display breaks long lines #2' ' + # Note: we do not need that many spaces after the title to cover up + # the last line before breaking the progress line. + sed -e "s/Z$//" >expect <<\EOF && +Working hard.......2.........3.........4.........5.........6: 0% (1/100000) +Working hard.......2.........3.........4.........5.........6: 0% (2/100000) +Working hard.......2.........3.........4.........5.........6: Z + 10% (10000/100000) + 100% (100000/100000) + 100% (100000/100000), done. +EOF + + cat >in <<-\EOF && + update + progress 1 + update + progress 2 + progress 10000 + progress 100000 + EOF + test-tool progress --total=100000 \ + "Working hard.......2.........3.........4.........5.........6" \ + stderr && + + show_cr out && + test_i18ncmp expect out +' + +test_expect_success 'progress display breaks long lines #3 - even the first is too long' ' + # Note: we do not actually need any spaces at the end of the title + # line, because there is no previous progress line to cover up. + sed -e "s/Z$//" >expect <<\EOF && +Working hard.......2.........3.........4.........5.........6: Z + 25% (25000/100000) + 50% (50000/100000) + 75% (75000/100000) + 100% (100000/100000) + 100% (100000/100000), done. +EOF + + cat >in <<-\EOF && + progress 25000 + progress 50000 + progress 75000 + progress 100000 + EOF + test-tool progress --total=100000 \ + "Working hard.......2.........3.........4.........5.........6" \ + stderr && + + show_cr out && + test_i18ncmp expect out +' + +test_expect_success 'progress display breaks long lines #4 - title line matches terminal width' ' + cat >expect <<\EOF && +Working hard.......2.........3.........4.........5.........6.........7.........: + 25% (25000/100000) + 50% (50000/100000) + 75% (75000/100000) + 100% (100000/100000) + 100% (100000/100000), done. +EOF + + cat >in <<-\EOF && + progress 25000 + progress 50000 + progress 75000 + progress 100000 + EOF + test-tool progress --total=100000 \ + "Working hard.......2.........3.........4.........5.........6.........7........." \ + stderr && + + show_cr out && + test_i18ncmp expect out +' + +# Progress counter goes backwards, this should not happen in practice. +test_expect_success 'progress shortens - crazy caller' ' + cat >expect <<-\EOF && + Working hard: 10% (100/1000) + Working hard: 20% (200/1000) + Working hard: 0% (1/1000) + Working hard: 100% (1000/1000) + Working hard: 100% (1000/1000), done. + EOF + + cat >in <<-\EOF && + progress 100 + progress 200 + progress 1 + progress 1000 + EOF + test-tool progress --total=1000 "Working hard" stderr && + + show_cr out && + test_i18ncmp expect out +' + +test_expect_success 'progress display with throughput' ' + cat >expect <<-\EOF && + Working hard: 10 + Working hard: 20, 200.00 KiB | 100.00 KiB/s + Working hard: 30, 300.00 KiB | 100.00 KiB/s + Working hard: 40, 400.00 KiB | 100.00 KiB/s + Working hard: 40, 400.00 KiB | 100.00 KiB/s, done. + EOF + + cat >in <<-\EOF && + throughput 102400 1000 + update + progress 10 + throughput 204800 2000 + update + progress 20 + throughput 307200 3000 + update + progress 30 + throughput 409600 4000 + update + progress 40 + EOF + test-tool progress "Working hard" stderr && + + show_cr out && + test_i18ncmp expect out +' + +test_expect_success 'progress display with throughput and total' ' + cat >expect <<-\EOF && + Working hard: 25% (10/40) + Working hard: 50% (20/40), 200.00 KiB | 100.00 KiB/s + Working hard: 75% (30/40), 300.00 KiB | 100.00 KiB/s + Working hard: 100% (40/40), 400.00 KiB | 100.00 KiB/s + Working hard: 100% (40/40), 400.00 KiB | 100.00 KiB/s, done. + EOF + + cat >in <<-\EOF && + throughput 102400 1000 + progress 10 + throughput 204800 2000 + progress 20 + throughput 307200 3000 + progress 30 + throughput 409600 4000 + progress 40 + EOF + test-tool progress --total=40 "Working hard" stderr && + + show_cr out && + test_i18ncmp expect out +' + +test_expect_success 'cover up after throughput shortens' ' + cat >expect <<-\EOF && + Working hard: 1 + Working hard: 2, 800.00 KiB | 400.00 KiB/s + Working hard: 3, 1.17 MiB | 400.00 KiB/s + Working hard: 4, 1.56 MiB | 400.00 KiB/s + Working hard: 4, 1.56 MiB | 400.00 KiB/s, done. + EOF + + cat >in <<-\EOF && + throughput 409600 1000 + update + progress 1 + throughput 819200 2000 + update + progress 2 + throughput 1228800 3000 + update + progress 3 + throughput 1638400 4000 + update + progress 4 + EOF + test-tool progress "Working hard" stderr && + + show_cr out && + test_i18ncmp expect out +' + +test_expect_success 'cover up after throughput shortens a lot' ' + cat >expect <<-\EOF && + Working hard: 1 + Working hard: 2, 1000.00 KiB | 1000.00 KiB/s + Working hard: 3, 3.00 MiB | 1.50 MiB/s + Working hard: 3, 3.00 MiB | 1024.00 KiB/s, done. + EOF + + cat >in <<-\EOF && + throughput 1 1000 + update + progress 1 + throughput 1024000 2000 + update + progress 2 + throughput 3145728 3000 + update + progress 3 + EOF + test-tool progress "Working hard" stderr && + + show_cr out && + test_i18ncmp expect out +' + +test_done diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh index ba71b159ba8c..eb44bafb5937 100755 --- a/t/t1011-read-tree-sparse-checkout.sh +++ b/t/t1011-read-tree-sparse-checkout.sh @@ -215,7 +215,6 @@ test_expect_success 'read-tree adds to worktree, dirty case' ' ' test_expect_success 'index removal and worktree narrowing at the same time' ' - >empty && echo init.t >.git/info/sparse-checkout && echo sub/added >>.git/info/sparse-checkout && git checkout -f top && @@ -223,7 +222,7 @@ test_expect_success 'index removal and worktree narrowing at the same time' ' git checkout removed && git ls-files sub/added >result && test ! -f sub/added && - test_cmp empty result + test_must_be_empty result ' test_expect_success 'read-tree --reset removes outside worktree' ' diff --git a/t/t1014-read-tree-confusing.sh b/t/t1014-read-tree-confusing.sh index 2f5a25d50386..da3376b3bb27 100755 --- a/t/t1014-read-tree-confusing.sh +++ b/t/t1014-read-tree-confusing.sh @@ -49,6 +49,7 @@ git~1 .git.SPACE .git.{space} .\\\\.GIT\\\\foobar backslashes .git\\\\foobar backslashes2 +.git...:alternate-stream EOF test_expect_success 'utf-8 paths allowed with core.protectHFS off' ' diff --git a/t/t1050-large.sh b/t/t1050-large.sh index dcb4dbba673e..184b479a2111 100755 --- a/t/t1050-large.sh +++ b/t/t1050-large.sh @@ -53,7 +53,8 @@ test_expect_success 'add a large file or two' ' for p in .git/objects/pack/pack-*.pack do count=$(( $count + 1 )) - if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx" + if test_path_is_file "$p" && + idx=${p%.pack}.idx && test_path_is_file "$idx" then continue fi @@ -65,7 +66,7 @@ test_expect_success 'add a large file or two' ' test $cnt = 2 && for l in .git/objects/??/?????????????????????????????????????? do - test -f "$l" || continue + test_path_is_file "$l" || continue bad=t done && test -z "$bad" && @@ -76,7 +77,8 @@ test_expect_success 'add a large file or two' ' for p in .git/objects/pack/pack-*.pack do count=$(( $count + 1 )) - if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx" + if test_path_is_file "$p" && + idx=${p%.pack}.idx && test_path_is_file "$idx" then continue fi @@ -111,7 +113,7 @@ test_expect_success 'packsize limit' ' count=0 && for pi in .git/objects/pack/pack-*.idx do - test -f "$pi" && count=$(( $count + 1 )) + test_path_is_file "$pi" && count=$(( $count + 1 )) done && test $count = 2 && @@ -194,15 +196,15 @@ test_expect_success 'pack-objects with large loose object' ' test_cmp huge actual ' -test_expect_success 'tar achiving' ' +test_expect_success 'tar archiving' ' git archive --format=tar HEAD >/dev/null ' -test_expect_success 'zip achiving, store only' ' +test_expect_success 'zip archiving, store only' ' git archive --format=zip -0 HEAD >/dev/null ' -test_expect_success 'zip achiving, deflate' ' +test_expect_success 'zip archiving, deflate' ' git archive --format=zip HEAD >/dev/null ' diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh new file mode 100755 index 000000000000..44a91205d600 --- /dev/null +++ b/t/t1091-sparse-checkout-builtin.sh @@ -0,0 +1,524 @@ +#!/bin/sh + +test_description='sparse checkout builtin tests' + +. ./test-lib.sh + +list_files() { + # Do not replace this with 'ls "$1"', as "ls" with BSD-lineage + # enables "-A" by default for root and ends up including ".git" and + # such in its output. (Note, though, that running the test suite as + # root is generally not recommended.) + (cd "$1" && printf '%s\n' *) +} + +check_files() { + list_files "$1" >actual && + shift && + printf "%s\n" $@ >expect && + test_cmp expect actual +} + +test_expect_success 'setup' ' + git init repo && + ( + cd repo && + echo "initial" >a && + mkdir folder1 folder2 deep && + mkdir deep/deeper1 deep/deeper2 && + mkdir deep/deeper1/deepest && + cp a folder1 && + cp a folder2 && + cp a deep && + cp a deep/deeper1 && + cp a deep/deeper2 && + cp a deep/deeper1/deepest && + git add . && + git commit -m "initial commit" + ) +' + +test_expect_success 'git sparse-checkout list (empty)' ' + git -C repo sparse-checkout list >list 2>err && + test_must_be_empty list && + test_i18ngrep "this worktree is not sparse (sparse-checkout file may not exist)" err +' + +test_expect_success 'git sparse-checkout list (populated)' ' + test_when_finished rm -f repo/.git/info/sparse-checkout && + cat >repo/.git/info/sparse-checkout <<-\EOF && + /folder1/* + /deep/ + **/a + !*bin* + EOF + cp repo/.git/info/sparse-checkout expect && + git -C repo sparse-checkout list >list && + test_cmp expect list +' + +test_expect_success 'git sparse-checkout init' ' + git -C repo sparse-checkout init && + cat >expect <<-\EOF && + /* + !/*/ + EOF + test_cmp expect repo/.git/info/sparse-checkout && + test_cmp_config -C repo true core.sparsecheckout && + check_files repo a +' + +test_expect_success 'git sparse-checkout list after init' ' + git -C repo sparse-checkout list >actual && + cat >expect <<-\EOF && + /* + !/*/ + EOF + test_cmp expect actual +' + +test_expect_success 'init with existing sparse-checkout' ' + echo "*folder*" >> repo/.git/info/sparse-checkout && + git -C repo sparse-checkout init && + cat >expect <<-\EOF && + /* + !/*/ + *folder* + EOF + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo a folder1 folder2 +' + +test_expect_success 'clone --sparse' ' + git clone --sparse "file://$(pwd)/repo" clone && + git -C clone sparse-checkout list >actual && + cat >expect <<-\EOF && + /* + !/*/ + EOF + test_cmp expect actual && + check_files clone a +' + +test_expect_success 'set enables config' ' + git init empty-config && + ( + cd empty-config && + test_commit test file && + test_path_is_missing .git/config.worktree && + test_must_fail git sparse-checkout set nothing && + test_path_is_file .git/config.worktree && + test_must_fail git config core.sparseCheckout && + git sparse-checkout set "/*" && + test_cmp_config true core.sparseCheckout + ) +' + +test_expect_success 'set sparse-checkout using builtin' ' + git -C repo sparse-checkout set "/*" "!/*/" "*folder*" && + cat >expect <<-\EOF && + /* + !/*/ + *folder* + EOF + git -C repo sparse-checkout list >actual && + test_cmp expect actual && + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo a folder1 folder2 +' + +test_expect_success 'set sparse-checkout using --stdin' ' + cat >expect <<-\EOF && + /* + !/*/ + /folder1/ + /folder2/ + EOF + git -C repo sparse-checkout set --stdin actual && + test_cmp expect actual && + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo "a folder1 folder2" +' + +test_expect_success 'add to sparse-checkout' ' + cat repo/.git/info/sparse-checkout >expect && + cat >add <<-\EOF && + pattern1 + /folder1/ + pattern2 + EOF + cat add >>expect && + git -C repo sparse-checkout add --stdin actual && + test_cmp expect actual && + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo "a folder1 folder2" +' + +test_expect_success 'cone mode: match patterns' ' + git -C repo config --worktree core.sparseCheckoutCone true && + rm -rf repo/a repo/folder1 repo/folder2 && + git -C repo read-tree -mu HEAD 2>err && + test_i18ngrep ! "disabling cone patterns" err && + git -C repo reset --hard && + check_files repo a folder1 folder2 +' + +test_expect_success 'cone mode: warn on bad pattern' ' + test_when_finished mv sparse-checkout repo/.git/info/ && + cp repo/.git/info/sparse-checkout . && + echo "!/deep/deeper/*" >>repo/.git/info/sparse-checkout && + git -C repo read-tree -mu HEAD 2>err && + test_i18ngrep "unrecognized negative pattern" err +' + +test_expect_success 'sparse-checkout disable' ' + test_when_finished rm -rf repo/.git/info/sparse-checkout && + git -C repo sparse-checkout disable && + test_path_is_file repo/.git/info/sparse-checkout && + git -C repo config --list >config && + test_must_fail git config core.sparseCheckout && + check_files repo a deep folder1 folder2 +' + +test_expect_success 'cone mode: init and set' ' + git -C repo sparse-checkout init --cone && + git -C repo config --list >config && + test_i18ngrep "core.sparsecheckoutcone=true" config && + list_files repo >dir && + echo a >expect && + test_cmp expect dir && + git -C repo sparse-checkout set deep/deeper1/deepest/ 2>err && + test_must_be_empty err && + check_files repo a deep && + check_files repo/deep a deeper1 && + check_files repo/deep/deeper1 a deepest && + cat >expect <<-\EOF && + /* + !/*/ + /deep/ + !/deep/*/ + /deep/deeper1/ + !/deep/deeper1/*/ + /deep/deeper1/deepest/ + EOF + test_cmp expect repo/.git/info/sparse-checkout && + git -C repo sparse-checkout set --stdin 2>err <<-\EOF && + folder1 + folder2 + EOF + test_must_be_empty err && + check_files repo a folder1 folder2 +' + +test_expect_success 'cone mode: list' ' + cat >expect <<-\EOF && + folder1 + folder2 + EOF + git -C repo sparse-checkout set --stdin actual 2>err && + test_must_be_empty err && + test_cmp expect actual +' + +test_expect_success 'cone mode: set with nested folders' ' + git -C repo sparse-checkout set deep deep/deeper1/deepest 2>err && + test_line_count = 0 err && + cat >expect <<-\EOF && + /* + !/*/ + /deep/ + EOF + test_cmp repo/.git/info/sparse-checkout expect +' + +test_expect_success 'cone mode: add independent path' ' + git -C repo sparse-checkout set deep/deeper1 && + git -C repo sparse-checkout add folder1 && + cat >expect <<-\EOF && + /* + !/*/ + /deep/ + !/deep/*/ + /deep/deeper1/ + /folder1/ + EOF + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo a deep folder1 +' + +test_expect_success 'cone mode: add sibling path' ' + git -C repo sparse-checkout set deep/deeper1 && + git -C repo sparse-checkout add deep/deeper2 && + cat >expect <<-\EOF && + /* + !/*/ + /deep/ + !/deep/*/ + /deep/deeper1/ + /deep/deeper2/ + EOF + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo a deep +' + +test_expect_success 'cone mode: add parent path' ' + git -C repo sparse-checkout set deep/deeper1 folder1 && + git -C repo sparse-checkout add deep && + cat >expect <<-\EOF && + /* + !/*/ + /deep/ + /folder1/ + EOF + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo a deep folder1 +' + +test_expect_success 'revert to old sparse-checkout on bad update' ' + test_when_finished git -C repo reset --hard && + git -C repo sparse-checkout set deep && + echo update >repo/deep/deeper2/a && + cp repo/.git/info/sparse-checkout expect && + test_must_fail git -C repo sparse-checkout set deep/deeper1 2>err && + test_i18ngrep "cannot set sparse-checkout patterns" err && + test_cmp repo/.git/info/sparse-checkout expect && + check_files repo/deep a deeper1 deeper2 +' + +test_expect_success 'revert to old sparse-checkout on empty update' ' + git init empty-test && + ( + echo >file && + git add file && + git commit -m "test" && + test_must_fail git sparse-checkout set nothing 2>err && + test_i18ngrep "Sparse checkout leaves no entry on working directory" err && + test_i18ngrep ! ".git/index.lock" err && + git sparse-checkout set file + ) +' + +test_expect_success 'fail when lock is taken' ' + test_when_finished rm -rf repo/.git/info/sparse-checkout.lock && + touch repo/.git/info/sparse-checkout.lock && + test_must_fail git -C repo sparse-checkout set deep 2>err && + test_i18ngrep "Unable to create .*\.lock" err +' + +test_expect_success '.gitignore should not warn about cone mode' ' + git -C repo config --worktree core.sparseCheckoutCone true && + echo "**/bin/*" >repo/.gitignore && + git -C repo reset --hard 2>err && + test_i18ngrep ! "disabling cone patterns" err +' + +test_expect_success 'sparse-checkout (init|set|disable) fails with dirty status' ' + git clone repo dirty && + echo dirty >dirty/folder1/a && + test_must_fail git -C dirty sparse-checkout init && + test_must_fail git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* && + test_must_fail git -C dirty sparse-checkout disable && + git -C dirty reset --hard && + git -C dirty sparse-checkout init && + git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* && + git -C dirty sparse-checkout disable +' + +test_expect_success 'cone mode: set with core.ignoreCase=true' ' + git -C repo sparse-checkout init --cone && + git -C repo -c core.ignoreCase=true sparse-checkout set folder1 && + cat >expect <<-\EOF && + /* + !/*/ + /folder1/ + EOF + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo a folder1 +' + +test_expect_success 'interaction with submodules' ' + git clone repo super && + ( + cd super && + mkdir modules && + git submodule add ../repo modules/child && + git add . && + git commit -m "add submodule" && + git sparse-checkout init --cone && + git sparse-checkout set folder1 + ) && + check_files super a folder1 modules && + check_files super/modules/child a deep folder1 folder2 +' + +test_expect_success 'different sparse-checkouts with worktrees' ' + git -C repo worktree add --detach ../worktree && + check_files worktree "a deep folder1 folder2" && + git -C worktree sparse-checkout init --cone && + git -C repo sparse-checkout set folder1 && + git -C worktree sparse-checkout set deep/deeper1 && + check_files repo a folder1 && + check_files worktree a deep +' + +test_expect_success 'set using filename keeps file on-disk' ' + git -C repo sparse-checkout set a deep && + cat >expect <<-\EOF && + /* + !/*/ + /a/ + /deep/ + EOF + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo a deep +' + +check_read_tree_errors () { + REPO=$1 + FILES=$2 + ERRORS=$3 + git -C $REPO -c core.sparseCheckoutCone=false read-tree -mu HEAD 2>err && + test_must_be_empty err && + check_files $REPO "$FILES" && + git -C $REPO read-tree -mu HEAD 2>err && + if test -z "$ERRORS" + then + test_must_be_empty err + else + test_i18ngrep "$ERRORS" err + fi && + check_files $REPO $FILES +} + +test_expect_success 'pattern-checks: /A/**' ' + cat >repo/.git/info/sparse-checkout <<-\EOF && + /* + !/*/ + /folder1/** + EOF + check_read_tree_errors repo "a folder1" "disabling cone pattern matching" +' + +test_expect_success 'pattern-checks: /A/**/B/' ' + cat >repo/.git/info/sparse-checkout <<-\EOF && + /* + !/*/ + /deep/**/deepest + EOF + check_read_tree_errors repo "a deep" "disabling cone pattern matching" && + check_files repo/deep "deeper1" && + check_files repo/deep/deeper1 "deepest" +' + +test_expect_success 'pattern-checks: too short' ' + cat >repo/.git/info/sparse-checkout <<-\EOF && + /* + !/*/ + / + EOF + check_read_tree_errors repo "a" "disabling cone pattern matching" +' +test_expect_success 'pattern-checks: not too short' ' + cat >repo/.git/info/sparse-checkout <<-\EOF && + /* + !/*/ + /b/ + EOF + git -C repo read-tree -mu HEAD 2>err && + test_must_be_empty err && + check_files repo a +' + +test_expect_success 'pattern-checks: trailing "*"' ' + cat >repo/.git/info/sparse-checkout <<-\EOF && + /* + !/*/ + /a* + EOF + check_read_tree_errors repo "a" "disabling cone pattern matching" +' + +test_expect_success 'pattern-checks: starting "*"' ' + cat >repo/.git/info/sparse-checkout <<-\EOF && + /* + !/*/ + *eep/ + EOF + check_read_tree_errors repo "a deep" "disabling cone pattern matching" +' + +test_expect_success 'pattern-checks: contained glob characters' ' + for c in "[a]" "\\" "?" "*" + do + cat >repo/.git/info/sparse-checkout <<-EOF && + /* + !/*/ + something$c-else/ + EOF + check_read_tree_errors repo "a" "disabling cone pattern matching" + done +' + +test_expect_success BSLASHPSPEC 'pattern-checks: escaped characters' ' + git clone repo escaped && + TREEOID=$(git -C escaped rev-parse HEAD:folder1) && + NEWTREE=$(git -C escaped mktree <<-EOF + $(git -C escaped ls-tree HEAD) + 040000 tree $TREEOID zbad\\dir + 040000 tree $TREEOID zdoes*exist + 040000 tree $TREEOID zglob[!a]? + EOF + ) && + COMMIT=$(git -C escaped commit-tree $NEWTREE -p HEAD) && + git -C escaped reset --hard $COMMIT && + check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" zglob[!a]? && + git -C escaped sparse-checkout init --cone && + git -C escaped sparse-checkout set zbad\\dir/bogus "zdoes*not*exist" "zdoes*exist" "zglob[!a]?" && + cat >expect <<-\EOF && + /* + !/*/ + /zbad\\dir/ + !/zbad\\dir/*/ + /zbad\\dir/bogus/ + /zdoes\*exist/ + /zdoes\*not\*exist/ + /zglob\[!a]\?/ + EOF + test_cmp expect escaped/.git/info/sparse-checkout && + check_read_tree_errors escaped "a zbad\\dir zdoes*exist zglob[!a]?" && + git -C escaped ls-tree -d --name-only HEAD >list-expect && + git -C escaped sparse-checkout set --stdin expect <<-\EOF && + /* + !/*/ + /deep/ + /folder1/ + /folder2/ + /zbad\\dir/ + /zdoes\*exist/ + /zglob\[!a]\?/ + EOF + test_cmp expect escaped/.git/info/sparse-checkout && + check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" zglob[!a]? && + git -C escaped sparse-checkout list >list-actual && + test_cmp list-expect list-actual +' + +test_expect_success MINGW 'cone mode replaces backslashes with slashes' ' + git -C repo sparse-checkout set deep\\deeper1 && + cat >expect <<-\EOF && + /* + !/*/ + /deep/ + !/deep/*/ + /deep/deeper1/ + EOF + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo a deep && + check_files repo/deep a deeper1 +' + +test_done diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 428177c390db..97ebfe1f9d5c 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -1191,47 +1191,47 @@ test_expect_success 'old-fashioned settings are case insensitive' ' test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" && cat >testConfig_actual <<-EOF && - [V.A] - r = value1 + [V.A] + r = value1 EOF q_to_tab >testConfig_expect <<-EOF && - [V.A] - Qr = value2 + [V.A] + Qr = value2 EOF git config -f testConfig_actual "v.a.r" value2 && test_cmp testConfig_expect testConfig_actual && cat >testConfig_actual <<-EOF && - [V.A] - r = value1 + [V.A] + r = value1 EOF q_to_tab >testConfig_expect <<-EOF && - [V.A] - QR = value2 + [V.A] + QR = value2 EOF git config -f testConfig_actual "V.a.R" value2 && test_cmp testConfig_expect testConfig_actual && cat >testConfig_actual <<-EOF && - [V.A] - r = value1 + [V.A] + r = value1 EOF q_to_tab >testConfig_expect <<-EOF && - [V.A] - r = value1 - Qr = value2 + [V.A] + r = value1 + Qr = value2 EOF git config -f testConfig_actual "V.A.r" value2 && test_cmp testConfig_expect testConfig_actual && cat >testConfig_actual <<-EOF && - [V.A] - r = value1 + [V.A] + r = value1 EOF q_to_tab >testConfig_expect <<-EOF && - [V.A] - r = value1 - Qr = value2 + [V.A] + r = value1 + Qr = value2 EOF git config -f testConfig_actual "v.A.r" value2 && test_cmp testConfig_expect testConfig_actual @@ -1241,26 +1241,26 @@ test_expect_success 'setting different case sensitive subsections ' ' test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" && cat >testConfig_actual <<-EOF && - [V "A"] - R = v1 - [K "E"] - Y = v1 - [a "b"] - c = v1 - [d "e"] - f = v1 + [V "A"] + R = v1 + [K "E"] + Y = v1 + [a "b"] + c = v1 + [d "e"] + f = v1 EOF q_to_tab >testConfig_expect <<-EOF && - [V "A"] - Qr = v2 - [K "E"] - Qy = v2 - [a "b"] - Qc = v2 - [d "e"] - f = v1 - [d "E"] - Qf = v2 + [V "A"] + Qr = v2 + [K "E"] + Qy = v2 + [a "b"] + Qc = v2 + [d "e"] + f = v1 + [d "E"] + Qf = v2 EOF # exact match git config -f testConfig_actual a.b.c v2 && @@ -1294,26 +1294,25 @@ test_expect_success 'git -c is not confused by empty environment' ' GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list ' -sq="'" test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' ' cat >expect <<-\EOF && env.one one env.two two EOF - GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq} ${sq}env.two=two${sq}" \ + GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ} ${SQ}env.two=two${SQ}" \ git config --get-regexp "env.*" >actual && test_cmp expect actual && cat >expect <<-EOF && - env.one one${sq} + env.one one${SQ} env.two two EOF - GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq}\\$sq$sq$sq ${sq}env.two=two${sq}" \ + GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ$SQ$SQ ${SQ}env.two=two${SQ}" \ git config --get-regexp "env.*" >actual && test_cmp expect actual && test_must_fail env \ - GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq}\\$sq ${sq}env.two=two${sq}" \ + GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ ${SQ}env.two=two${SQ}" \ git config --get-regexp "env.*" ' @@ -1409,6 +1408,8 @@ test_expect_success 'urlmatch favors more specific URLs' ' cookieFile = /tmp/wildcard.txt [http "https://*.example.com/wildcardwithsubdomain"] cookieFile = /tmp/wildcardwithsubdomain.txt + [http "https://*.example.*"] + cookieFile = /tmp/multiwildcard.txt [http "https://trailing.example.com"] cookieFile = /tmp/trailing.txt [http "https://user@*.example.com/"] @@ -1455,6 +1456,10 @@ test_expect_success 'urlmatch favors more specific URLs' ' echo http.cookiefile /tmp/sub.txt >expect && git config --get-urlmatch HTTP https://user@sub.example.com >actual && + test_cmp expect actual && + + echo http.cookiefile /tmp/multiwildcard.txt >expect && + git config --get-urlmatch HTTP https://wildcard.example.org >actual && test_cmp expect actual ' @@ -1623,40 +1628,40 @@ test_expect_success 'set up --show-origin tests' ' INCLUDE_DIR="$HOME/include" && mkdir -p "$INCLUDE_DIR" && cat >"$INCLUDE_DIR"/absolute.include <<-\EOF && - [user] - absolute = include + [user] + absolute = include EOF cat >"$INCLUDE_DIR"/relative.include <<-\EOF && - [user] - relative = include + [user] + relative = include EOF cat >"$HOME"/.gitconfig <<-EOF && - [user] - global = true - override = global - [include] - path = "$INCLUDE_DIR/absolute.include" + [user] + global = true + override = global + [include] + path = "$INCLUDE_DIR/absolute.include" EOF cat >.git/config <<-\EOF - [user] - local = true - override = local - [include] - path = ../include/relative.include + [user] + local = true + override = local + [include] + path = ../include/relative.include EOF ' test_expect_success '--show-origin with --list' ' cat >expect <<-EOF && - file:$HOME/.gitconfig user.global=true - file:$HOME/.gitconfig user.override=global - file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include - file:$INCLUDE_DIR/absolute.include user.absolute=include - file:.git/config user.local=true - file:.git/config user.override=local - file:.git/config include.path=../include/relative.include - file:.git/../include/relative.include user.relative=include - command line: user.cmdline=true + file:$HOME/.gitconfig user.global=true + file:$HOME/.gitconfig user.override=global + file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include + file:$INCLUDE_DIR/absolute.include user.absolute=include + file:.git/config user.local=true + file:.git/config user.override=local + file:.git/config include.path=../include/relative.include + file:.git/../include/relative.include user.relative=include + command line: user.cmdline=true EOF git -c user.cmdline=true config --list --show-origin >output && test_cmp expect output @@ -1664,16 +1669,16 @@ test_expect_success '--show-origin with --list' ' test_expect_success '--show-origin with --list --null' ' cat >expect <<-EOF && - file:$HOME/.gitconfigQuser.global - trueQfile:$HOME/.gitconfigQuser.override - globalQfile:$HOME/.gitconfigQinclude.path - $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute - includeQfile:.git/configQuser.local - trueQfile:.git/configQuser.override - localQfile:.git/configQinclude.path - ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative - includeQcommand line:Quser.cmdline - trueQ + file:$HOME/.gitconfigQuser.global + trueQfile:$HOME/.gitconfigQuser.override + globalQfile:$HOME/.gitconfigQinclude.path + $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute + includeQfile:.git/configQuser.local + trueQfile:.git/configQuser.override + localQfile:.git/configQinclude.path + ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative + includeQcommand line:Quser.cmdline + trueQ EOF git -c user.cmdline=true config --null --list --show-origin >output.raw && nul_to_q output && @@ -1685,9 +1690,9 @@ test_expect_success '--show-origin with --list --null' ' test_expect_success '--show-origin with single file' ' cat >expect <<-\EOF && - file:.git/config user.local=true - file:.git/config user.override=local - file:.git/config include.path=../include/relative.include + file:.git/config user.local=true + file:.git/config user.override=local + file:.git/config include.path=../include/relative.include EOF git config --local --list --show-origin >output && test_cmp expect output @@ -1695,8 +1700,8 @@ test_expect_success '--show-origin with single file' ' test_expect_success '--show-origin with --get-regexp' ' cat >expect <<-EOF && - file:$HOME/.gitconfig user.global true - file:.git/config user.local true + file:$HOME/.gitconfig user.global true + file:.git/config user.local true EOF git config --show-origin --get-regexp "user\.[g|l].*" >output && test_cmp expect output @@ -1704,31 +1709,36 @@ test_expect_success '--show-origin with --get-regexp' ' test_expect_success '--show-origin getting a single key' ' cat >expect <<-\EOF && - file:.git/config local + file:.git/config local EOF git config --show-origin user.override >output && test_cmp expect output ' test_expect_success 'set up custom config file' ' - CUSTOM_CONFIG_FILE="file\" (dq) and spaces.conf" && + CUSTOM_CONFIG_FILE="custom.conf" && cat >"$CUSTOM_CONFIG_FILE" <<-\EOF - [user] - custom = true + [user] + custom = true EOF ' +test_expect_success !MINGW 'set up custom config file with special name characters' ' + WEIRDLY_NAMED_FILE="file\" (dq) and spaces.conf" && + cp "$CUSTOM_CONFIG_FILE" "$WEIRDLY_NAMED_FILE" +' + test_expect_success !MINGW '--show-origin escape special file name characters' ' cat >expect <<-\EOF && - file:"file\" (dq) and spaces.conf" user.custom=true + file:"file\" (dq) and spaces.conf" user.custom=true EOF - git config --file "$CUSTOM_CONFIG_FILE" --show-origin --list >output && + git config --file "$WEIRDLY_NAMED_FILE" --show-origin --list >output && test_cmp expect output ' test_expect_success '--show-origin stdin' ' cat >expect <<-\EOF && - standard input: user.custom=true + standard input: user.custom=true EOF git config --file - --show-origin --list <"$CUSTOM_CONFIG_FILE" >output && test_cmp expect output @@ -1736,11 +1746,11 @@ test_expect_success '--show-origin stdin' ' test_expect_success '--show-origin stdin with file include' ' cat >"$INCLUDE_DIR"/stdin.include <<-EOF && - [user] - stdin = include + [user] + stdin = include EOF cat >expect <<-EOF && - file:$INCLUDE_DIR/stdin.include include + file:$INCLUDE_DIR/stdin.include include EOF echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" | git config --show-origin --includes --file - user.stdin >output && @@ -1748,18 +1758,18 @@ test_expect_success '--show-origin stdin with file include' ' test_cmp expect output ' -test_expect_success !MINGW '--show-origin blob' ' +test_expect_success '--show-origin blob' ' blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") && cat >expect <<-EOF && - blob:$blob user.custom=true + blob:$blob user.custom=true EOF git config --blob=$blob --show-origin --list >output && test_cmp expect output ' -test_expect_success !MINGW '--show-origin blob ref' ' +test_expect_success '--show-origin blob ref' ' cat >expect <<-\EOF && - blob:"master:file\" (dq) and spaces.conf" user.custom=true + blob:master:custom.conf user.custom=true EOF git add "$CUSTOM_CONFIG_FILE" && git commit -m "new config file" && @@ -1767,6 +1777,65 @@ test_expect_success !MINGW '--show-origin blob ref' ' test_cmp expect output ' +test_expect_success '--show-scope with --list' ' + cat >expect <<-EOF && + global user.global=true + global user.override=global + global include.path=$INCLUDE_DIR/absolute.include + global user.absolute=include + local user.local=true + local user.override=local + local include.path=../include/relative.include + local user.relative=include + command user.cmdline=true + EOF + git -c user.cmdline=true config --list --show-scope >output && + test_cmp expect output +' + +test_expect_success !MINGW '--show-scope with --blob' ' + blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") && + cat >expect <<-EOF && + command user.custom=true + EOF + git config --blob=$blob --show-scope --list >output && + test_cmp expect output +' + +test_expect_success '--show-scope with --local' ' + cat >expect <<-\EOF && + local user.local=true + local user.override=local + local include.path=../include/relative.include + EOF + git config --local --list --show-scope >output && + test_cmp expect output +' + +test_expect_success '--show-scope getting a single value' ' + cat >expect <<-\EOF && + local true + EOF + git config --show-scope --get user.local >output && + test_cmp expect output +' + +test_expect_success '--show-scope with --show-origin' ' + cat >expect <<-EOF && + global file:$HOME/.gitconfig user.global=true + global file:$HOME/.gitconfig user.override=global + global file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include + global file:$INCLUDE_DIR/absolute.include user.absolute=include + local file:.git/config user.local=true + local file:.git/config user.override=local + local file:.git/config include.path=../include/relative.include + local file:.git/../include/relative.include user.relative=include + command command line: user.cmdline=true + EOF + git -c user.cmdline=true config --list --show-origin --show-scope >output && + test_cmp expect output +' + test_expect_success '--local requires a repo' ' # we expect 128 to ensure that we do not simply # fail to find anything and return code "1" diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh index d20b4d150d42..f1e1b289f989 100755 --- a/t/t1305-config-include.sh +++ b/t/t1305-config-include.sh @@ -63,7 +63,7 @@ test_expect_success 'listing includes option and expansion' ' test.one=1 EOF git config --list >actual.full && - grep -v ^core actual.full >actual && + grep -v -e ^core -e ^extensions actual.full >actual && test_cmp expect actual ' diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh index 21e139a313be..dd87b43be1a6 100755 --- a/t/t1306-xdg-files.sh +++ b/t/t1306-xdg-files.sh @@ -153,7 +153,7 @@ test_expect_success 'Checking attributes in both XDG and local attributes files' test_expect_success 'Checking attributes in a non-XDG global attributes file' ' - test_might_fail rm .gitattributes && + rm -f .gitattributes && echo "f attr_f=test" >"$HOME"/my_gitattributes && git config core.attributesfile "$HOME"/my_gitattributes && echo "f: attr_f: test" >expected && @@ -165,7 +165,7 @@ test_expect_success 'Checking attributes in a non-XDG global attributes file' ' test_expect_success 'write: xdg file exists and ~/.gitconfig doesn'\''t' ' mkdir -p "$HOME"/.config/git && >"$HOME"/.config/git/config && - test_might_fail rm "$HOME"/.gitconfig && + rm -f "$HOME"/.gitconfig && git config --global user.name "write_config" && echo "[user]" >expected && echo " name = write_config" >>expected && @@ -183,8 +183,8 @@ test_expect_success 'write: xdg file exists and ~/.gitconfig exists' ' test_expect_success 'write: ~/.config/git/ exists and config file doesn'\''t' ' - test_might_fail rm "$HOME"/.gitconfig && - test_might_fail rm "$HOME"/.config/git/config && + rm -f "$HOME"/.gitconfig && + rm -f "$HOME"/.config/git/config && git config --global user.name "write_gitconfig" && echo "[user]" >expected && echo " name = write_gitconfig" >>expected && diff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh index 37dc689d8c98..002e6d3388e2 100755 --- a/t/t1307-config-blob.sh +++ b/t/t1307-config-blob.sh @@ -74,7 +74,7 @@ test_expect_success 'can parse blob ending with CR' ' ' test_expect_success 'config --blob outside of a repository is an error' ' - test_must_fail nongit git config --blob=foo --list + nongit test_must_fail git config --blob=foo --list ' test_done diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh index d0a2727b850a..3a527e3a8438 100755 --- a/t/t1308-config-set.sh +++ b/t/t1308-config-set.sh @@ -166,14 +166,14 @@ test_expect_success 'find value with highest priority from a configset' ' ' test_expect_success 'find value_list for a key from a configset' ' - cat >except <<-\EOF && + cat >expect <<-\EOF && + lama + ball sam bat hask - lama - ball EOF - test-tool config configset_get_value case.baz config2 .git/config >actual && + test-tool config configset_get_value_multi case.baz config2 .git/config >actual && test_cmp expect actual ' @@ -238,8 +238,8 @@ test_expect_success 'error on modifying repo config without repo' ' cmdline_config="'foo.bar=from-cmdline'" test_expect_success 'iteration shows correct origins' ' - echo "[foo]bar = from-repo" >.git/config && - echo "[foo]bar = from-home" >.gitconfig && + printf "[ignore]\n\tthis = please\n[foo]bar = from-repo\n" >.git/config && + printf "[foo]\n\tbar = from-home\n" >.gitconfig && if test_have_prereq MINGW then # Use Windows path (i.e. *not* $HOME) @@ -253,19 +253,29 @@ test_expect_success 'iteration shows correct origins' ' value=from-home origin=file name=$HOME_GITCONFIG + lno=2 scope=global + key=ignore.this + value=please + origin=file + name=.git/config + lno=2 + scope=local + key=foo.bar value=from-repo origin=file name=.git/config - scope=repo + lno=3 + scope=local key=foo.bar value=from-cmdline origin=command line name= - scope=cmdline + lno=-1 + scope=command EOF GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config iterate >actual && test_cmp expect actual diff --git a/t/t1309-early-config.sh b/t/t1309-early-config.sh index 0c37e7180d1c..ebb8e1aecbf4 100755 --- a/t/t1309-early-config.sh +++ b/t/t1309-early-config.sh @@ -29,7 +29,7 @@ test_expect_success 'ceiling' ' cd sub && test-tool config read_early_config early.config ) >output && - test -z "$(cat output)" + test_must_be_empty output ' test_expect_success 'ceiling #2' ' @@ -91,7 +91,12 @@ test_expect_failure 'ignore .git/ with invalid config' ' test_expect_success 'early config and onbranch' ' echo "[broken" >broken && - test_with_config "[includeif \"onbranch:refs/heads/master\"]path=../broken" + test_with_config "[includeif \"onbranch:master\"]path=../broken" +' + +test_expect_success 'onbranch config outside of git repo' ' + test_config_global includeIf.onbranch:master.path non-existent && + nongit git help ' test_done diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 1fbd94040818..a6224ef65fe9 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -344,14 +344,16 @@ test_expect_success "verifying $m's log (logged by config)" ' test_cmp expect .git/logs/$m ' -git update-ref $m $D -cat >.git/logs/$m < 1117150320 -0500 -$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500 -$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500 -$F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500 -$Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500 -EOF +test_expect_success 'set up for querying the reflog' ' + git update-ref $m $D && + cat >.git/logs/$m <<-EOF + $Z $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500 + $C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500 + $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500 + $F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500 + $Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500 + EOF +' ed="Thu, 26 May 2005 18:32:00 -0500" gd="Thu, 26 May 2005 18:33:00 -0500" @@ -359,55 +361,67 @@ ld="Thu, 26 May 2005 18:43:00 -0500" test_expect_success 'Query "master@{May 25 2005}" (before history)' ' test_when_finished "rm -f o e" && git rev-parse --verify "master@{May 25 2005}" >o 2>e && - test $C = $(cat o) && - test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)" + echo "$C" >expect && + test_cmp expect o && + echo "warning: log for '\''master'\'' only goes back to $ed" >expect && + test_i18ncmp expect e ' test_expect_success 'Query master@{2005-05-25} (before history)' ' test_when_finished "rm -f o e" && git rev-parse --verify master@{2005-05-25} >o 2>e && - test $C = $(cat o) && - test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)" + echo "$C" >expect && + test_cmp expect o && + echo "warning: log for '\''master'\'' only goes back to $ed" >expect && + test_i18ncmp expect e ' test_expect_success 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' ' test_when_finished "rm -f o e" && git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e && - test $C = $(cat o) && - test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)" + echo "$C" >expect && + test_cmp expect o && + echo "warning: log for '\''master'\'' only goes back to $ed" >expect && + test_i18ncmp expect e ' test_expect_success 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' ' test_when_finished "rm -f o e" && git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e && - test $C = $(cat o) && - test "" = "$(cat e)" + echo "$C" >expect && + test_cmp expect o && + test_must_be_empty e ' test_expect_success 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' ' test_when_finished "rm -f o e" && git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e && - test $A = $(cat o) && - test "" = "$(cat e)" + echo "$A" >expect && + test_cmp expect o && + test_must_be_empty e ' test_expect_success 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' ' test_when_finished "rm -f o e" && git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e && - test $B = $(cat o) && + echo "$B" >expect && + test_cmp expect o && test_i18ngrep -F "warning: log for ref $m has gap after $gd" e ' test_expect_success 'Query "master@{2005-05-26 23:38:00}" (middle of history)' ' test_when_finished "rm -f o e" && git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e && - test $Z = $(cat o) && - test "" = "$(cat e)" + echo "$Z" >expect && + test_cmp expect o && + test_must_be_empty e ' test_expect_success 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' ' test_when_finished "rm -f o e" && git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e && - test $E = $(cat o) && - test "" = "$(cat e)" + echo "$E" >expect && + test_cmp expect o && + test_must_be_empty e ' test_expect_success 'Query "master@{2005-05-28}" (past end of history)' ' test_when_finished "rm -f o e" && git rev-parse --verify "master@{2005-05-28}" >o 2>e && - test $D = $(cat o) && + echo "$D" >expect && + test_cmp expect o && test_i18ngrep -F "warning: log for ref $m unexpectedly ended on $ld" e ' diff --git a/t/t1404-update-ref-errors.sh b/t/t1404-update-ref-errors.sh index 970c5c36b9b5..2d142e5535e5 100755 --- a/t/t1404-update-ref-errors.sh +++ b/t/t1404-update-ref-errors.sh @@ -32,8 +32,6 @@ test_update_rejected () { test_cmp unchanged actual } -Q="'" - # Test adding and deleting D/F-conflicting references in a single # transaction. df_test() { @@ -93,7 +91,7 @@ df_test() { delname="$delref" fi && cat >expected-err <<-EOF && - fatal: cannot lock ref $Q$addname$Q: $Q$delref$Q exists; cannot create $Q$addref$Q + fatal: cannot lock ref $SQ$addname$SQ: $SQ$delref$SQ exists; cannot create $SQ$addref$SQ EOF $pack && if $add_del @@ -123,7 +121,7 @@ test_expect_success 'existing loose ref is a simple prefix of new' ' prefix=refs/1l && test_update_rejected "a c e" false "b c/x d" \ - "$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q" + "$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x$SQ" ' @@ -131,7 +129,7 @@ test_expect_success 'existing packed ref is a simple prefix of new' ' prefix=refs/1p && test_update_rejected "a c e" true "b c/x d" \ - "$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q" + "$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x$SQ" ' @@ -139,7 +137,7 @@ test_expect_success 'existing loose ref is a deeper prefix of new' ' prefix=refs/2l && test_update_rejected "a c e" false "b c/x/y d" \ - "$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q" + "$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x/y$SQ" ' @@ -147,7 +145,7 @@ test_expect_success 'existing packed ref is a deeper prefix of new' ' prefix=refs/2p && test_update_rejected "a c e" true "b c/x/y d" \ - "$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q" + "$SQ$prefix/c$SQ exists; cannot create $SQ$prefix/c/x/y$SQ" ' @@ -155,7 +153,7 @@ test_expect_success 'new ref is a simple prefix of existing loose' ' prefix=refs/3l && test_update_rejected "a c/x e" false "b c d" \ - "$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q" + "$SQ$prefix/c/x$SQ exists; cannot create $SQ$prefix/c$SQ" ' @@ -163,7 +161,7 @@ test_expect_success 'new ref is a simple prefix of existing packed' ' prefix=refs/3p && test_update_rejected "a c/x e" true "b c d" \ - "$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q" + "$SQ$prefix/c/x$SQ exists; cannot create $SQ$prefix/c$SQ" ' @@ -171,7 +169,7 @@ test_expect_success 'new ref is a deeper prefix of existing loose' ' prefix=refs/4l && test_update_rejected "a c/x/y e" false "b c d" \ - "$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q" + "$SQ$prefix/c/x/y$SQ exists; cannot create $SQ$prefix/c$SQ" ' @@ -179,7 +177,7 @@ test_expect_success 'new ref is a deeper prefix of existing packed' ' prefix=refs/4p && test_update_rejected "a c/x/y e" true "b c d" \ - "$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q" + "$SQ$prefix/c/x/y$SQ exists; cannot create $SQ$prefix/c$SQ" ' @@ -187,7 +185,7 @@ test_expect_success 'one new ref is a simple prefix of another' ' prefix=refs/5 && test_update_rejected "a e" false "b c c/x d" \ - "cannot process $Q$prefix/c$Q and $Q$prefix/c/x$Q at the same time" + "cannot process $SQ$prefix/c$SQ and $SQ$prefix/c/x$SQ at the same time" ' @@ -334,7 +332,7 @@ test_expect_success 'D/F conflict prevents indirect delete long packed + indirec test_expect_success 'missing old value blocks update' ' prefix=refs/missing-update && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q + fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ EOF printf "%s\n" "update $prefix/foo $E $D" | test_must_fail git update-ref --stdin 2>output.err && @@ -345,7 +343,7 @@ test_expect_success 'incorrect old value blocks update' ' prefix=refs/incorrect-update && git update-ref $prefix/foo $C && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D + fatal: cannot lock ref $SQ$prefix/foo$SQ: is at $C but expected $D EOF printf "%s\n" "update $prefix/foo $E $D" | test_must_fail git update-ref --stdin 2>output.err && @@ -356,7 +354,7 @@ test_expect_success 'existing old value blocks create' ' prefix=refs/existing-create && git update-ref $prefix/foo $C && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/foo$Q: reference already exists + fatal: cannot lock ref $SQ$prefix/foo$SQ: reference already exists EOF printf "%s\n" "create $prefix/foo $E" | test_must_fail git update-ref --stdin 2>output.err && @@ -367,7 +365,7 @@ test_expect_success 'incorrect old value blocks delete' ' prefix=refs/incorrect-delete && git update-ref $prefix/foo $C && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D + fatal: cannot lock ref $SQ$prefix/foo$SQ: is at $C but expected $D EOF printf "%s\n" "delete $prefix/foo $D" | test_must_fail git update-ref --stdin 2>output.err && @@ -378,7 +376,7 @@ test_expect_success 'missing old value blocks indirect update' ' prefix=refs/missing-indirect-update && git symbolic-ref $prefix/symref $prefix/foo && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q + fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ EOF printf "%s\n" "update $prefix/symref $E $D" | test_must_fail git update-ref --stdin 2>output.err && @@ -390,7 +388,7 @@ test_expect_success 'incorrect old value blocks indirect update' ' git symbolic-ref $prefix/symref $prefix/foo && git update-ref $prefix/foo $C && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D + fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D EOF printf "%s\n" "update $prefix/symref $E $D" | test_must_fail git update-ref --stdin 2>output.err && @@ -402,7 +400,7 @@ test_expect_success 'existing old value blocks indirect create' ' git symbolic-ref $prefix/symref $prefix/foo && git update-ref $prefix/foo $C && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: reference already exists + fatal: cannot lock ref $SQ$prefix/symref$SQ: reference already exists EOF printf "%s\n" "create $prefix/symref $E" | test_must_fail git update-ref --stdin 2>output.err && @@ -414,7 +412,7 @@ test_expect_success 'incorrect old value blocks indirect delete' ' git symbolic-ref $prefix/symref $prefix/foo && git update-ref $prefix/foo $C && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D + fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D EOF printf "%s\n" "delete $prefix/symref $D" | test_must_fail git update-ref --stdin 2>output.err && @@ -425,7 +423,7 @@ test_expect_success 'missing old value blocks indirect no-deref update' ' prefix=refs/missing-noderef-update && git symbolic-ref $prefix/symref $prefix/foo && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: reference is missing but expected $D + fatal: cannot lock ref $SQ$prefix/symref$SQ: reference is missing but expected $D EOF printf "%s\n" "option no-deref" "update $prefix/symref $E $D" | test_must_fail git update-ref --stdin 2>output.err && @@ -437,7 +435,7 @@ test_expect_success 'incorrect old value blocks indirect no-deref update' ' git symbolic-ref $prefix/symref $prefix/foo && git update-ref $prefix/foo $C && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D + fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D EOF printf "%s\n" "option no-deref" "update $prefix/symref $E $D" | test_must_fail git update-ref --stdin 2>output.err && @@ -449,7 +447,7 @@ test_expect_success 'existing old value blocks indirect no-deref create' ' git symbolic-ref $prefix/symref $prefix/foo && git update-ref $prefix/foo $C && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: reference already exists + fatal: cannot lock ref $SQ$prefix/symref$SQ: reference already exists EOF printf "%s\n" "option no-deref" "create $prefix/symref $E" | test_must_fail git update-ref --stdin 2>output.err && @@ -461,7 +459,7 @@ test_expect_success 'incorrect old value blocks indirect no-deref delete' ' git symbolic-ref $prefix/symref $prefix/foo && git update-ref $prefix/foo $C && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D + fatal: cannot lock ref $SQ$prefix/symref$SQ: is at $C but expected $D EOF printf "%s\n" "option no-deref" "delete $prefix/symref $D" | test_must_fail git update-ref --stdin 2>output.err && @@ -474,13 +472,13 @@ test_expect_success 'non-empty directory blocks create' ' : >.git/$prefix/foo/bar/baz.lock && test_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/foo$Q: there is a non-empty directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q + fatal: cannot lock ref $SQ$prefix/foo$SQ: there is a non-empty directory $SQ.git/$prefix/foo$SQ blocking reference $SQ$prefix/foo$SQ EOF printf "%s\n" "update $prefix/foo $C" | test_must_fail git update-ref --stdin 2>output.err && test_cmp expected output.err && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q + fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ EOF printf "%s\n" "update $prefix/foo $D $C" | test_must_fail git update-ref --stdin 2>output.err && @@ -493,13 +491,13 @@ test_expect_success 'broken reference blocks create' ' echo "gobbledigook" >.git/$prefix/foo && test_when_finished "rm -f .git/$prefix/foo" && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken + fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken EOF printf "%s\n" "update $prefix/foo $C" | test_must_fail git update-ref --stdin 2>output.err && test_cmp expected output.err && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken + fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken EOF printf "%s\n" "update $prefix/foo $D $C" | test_must_fail git update-ref --stdin 2>output.err && @@ -513,13 +511,13 @@ test_expect_success 'non-empty directory blocks indirect create' ' : >.git/$prefix/foo/bar/baz.lock && test_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: there is a non-empty directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q + fatal: cannot lock ref $SQ$prefix/symref$SQ: there is a non-empty directory $SQ.git/$prefix/foo$SQ blocking reference $SQ$prefix/foo$SQ EOF printf "%s\n" "update $prefix/symref $C" | test_must_fail git update-ref --stdin 2>output.err && test_cmp expected output.err && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q + fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ EOF printf "%s\n" "update $prefix/symref $D $C" | test_must_fail git update-ref --stdin 2>output.err && @@ -532,13 +530,13 @@ test_expect_success 'broken reference blocks indirect create' ' echo "gobbledigook" >.git/$prefix/foo && test_when_finished "rm -f .git/$prefix/foo" && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken + fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken EOF printf "%s\n" "update $prefix/symref $C" | test_must_fail git update-ref --stdin 2>output.err && test_cmp expected output.err && cat >expected <<-EOF && - fatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken + fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken EOF printf "%s\n" "update $prefix/symref $D $C" | test_must_fail git update-ref --stdin 2>output.err && @@ -614,7 +612,7 @@ test_expect_success 'delete fails cleanly if packed-refs file is locked' ' test_when_finished "rm -f .git/packed-refs.lock" && test_must_fail git update-ref -d $prefix/foo >out 2>err && git for-each-ref $prefix >actual && - test_i18ngrep "Unable to create $Q.*packed-refs.lock$Q: " err && + test_i18ngrep "Unable to create $SQ.*packed-refs.lock$SQ: " err && test_cmp unchanged actual ' diff --git a/t/t1406-submodule-ref-store.sh b/t/t1406-submodule-ref-store.sh index d199d872fb19..36b7ef504687 100755 --- a/t/t1406-submodule-ref-store.sh +++ b/t/t1406-submodule-ref-store.sh @@ -75,7 +75,7 @@ test_expect_success 'for_each_reflog()' ' ' test_expect_success 'for_each_reflog_ent()' ' - $RUN for-each-reflog-ent HEAD >actual && cat actual && + $RUN for-each-reflog-ent HEAD >actual && head -n1 actual | grep first && tail -n2 actual | head -n1 | grep master.to.new ' diff --git a/t/t1409-avoid-packing-refs.sh b/t/t1409-avoid-packing-refs.sh index e5cb8a252dd1..be12fb63506e 100755 --- a/t/t1409-avoid-packing-refs.sh +++ b/t/t1409-avoid-packing-refs.sh @@ -8,7 +8,7 @@ test_description='avoid rewriting packed-refs unnecessarily' # shouldn't upset readers, and it should be omitted if the file is # ever rewritten. mark_packed_refs () { - sed -e "s/^\(#.*\)/\1 t1409 /" <.git/packed-refs >.git/packed-refs.new && + sed -e "s/^\(#.*\)/\1 t1409 /" .git/packed-refs >.git/packed-refs.new && mv .git/packed-refs.new .git/packed-refs } @@ -27,15 +27,15 @@ test_expect_success 'setup' ' ' test_expect_success 'do not create packed-refs file gratuitously' ' - test_must_fail test -f .git/packed-refs && + test_path_is_missing .git/packed-refs && git update-ref refs/heads/foo $A && - test_must_fail test -f .git/packed-refs && + test_path_is_missing .git/packed-refs && git update-ref refs/heads/foo $B && - test_must_fail test -f .git/packed-refs && + test_path_is_missing .git/packed-refs && git update-ref refs/heads/foo $C $B && - test_must_fail test -f .git/packed-refs && + test_path_is_missing .git/packed-refs && git update-ref -d refs/heads/foo && - test_must_fail test -f .git/packed-refs + test_path_is_missing .git/packed-refs ' test_expect_success 'check that marking the packed-refs file works' ' @@ -46,7 +46,7 @@ test_expect_success 'check that marking the packed-refs file works' ' git for-each-ref >actual && test_cmp expected actual && git pack-refs --all && - test_must_fail check_packed_refs_marked && + ! check_packed_refs_marked && git for-each-ref >actual2 && test_cmp expected actual2 ' @@ -80,7 +80,7 @@ test_expect_success 'touch packed-refs on delete of packed' ' git pack-refs --all && mark_packed_refs && git update-ref -d refs/heads/packed-delete && - test_must_fail check_packed_refs_marked + ! check_packed_refs_marked ' test_expect_success 'leave packed-refs untouched on update of loose' ' diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index 82950c02825c..76d9b744a64b 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -195,7 +195,7 @@ test_expect_success 'delete' ' git reflog delete master@{1} && git reflog show master > output && - test $(($master_entry_count - 1)) = $(wc -l < output) && + test_line_count = $(($master_entry_count - 1)) output && test $HEAD_entry_count = $(git reflog | wc -l) && ! grep ox < output && @@ -209,7 +209,7 @@ test_expect_success 'delete' ' git reflog delete master@{07.04.2005.15:15:00.-0700} && git reflog show master > output && - test $(($master_entry_count - 1)) = $(wc -l < output) && + test_line_count = $(($master_entry_count - 1)) output && ! grep dragon < output ' diff --git a/t/t1414-reflog-walk.sh b/t/t1414-reflog-walk.sh index feb1efd8ff99..1181a9fb28e3 100755 --- a/t/t1414-reflog-walk.sh +++ b/t/t1414-reflog-walk.sh @@ -18,10 +18,9 @@ do_walk () { git log -g --format="%gd %gs" "$@" } -sq="'" test_expect_success 'set up expected reflog' ' cat >expect.all <<-EOF - HEAD@{0} commit (merge): Merge branch ${sq}master${sq} into side + HEAD@{0} commit (merge): Merge branch ${SQ}master${SQ} into side HEAD@{1} commit: three HEAD@{2} checkout: moving from master to side HEAD@{3} commit: two diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index b36e0528d07b..d09eff503c65 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -70,7 +70,6 @@ test_expect_success 'object with bad sha1' ' test_when_finished "git update-ref -d refs/heads/bogus" && test_must_fail git fsck 2>out && - cat out && test_i18ngrep "$sha.*corrupt" out ' @@ -78,7 +77,6 @@ test_expect_success 'branch pointing to non-commit' ' git rev-parse HEAD^{tree} >.git/refs/heads/invalid && test_when_finished "git update-ref -d refs/heads/invalid" && test_must_fail git fsck 2>out && - cat out && test_i18ngrep "not a commit" out ' @@ -88,7 +86,6 @@ test_expect_success 'HEAD link pointing at a funny object' ' echo $ZERO_OID >.git/HEAD && # avoid corrupt/broken HEAD from interfering with repo discovery test_must_fail env GIT_DIR=.git git fsck 2>out && - cat out && test_i18ngrep "detached HEAD points" out ' @@ -98,7 +95,6 @@ test_expect_success 'HEAD link pointing at a funny place' ' echo "ref: refs/funny/place" >.git/HEAD && # avoid corrupt/broken HEAD from interfering with repo discovery test_must_fail env GIT_DIR=.git git fsck 2>out && - cat out && test_i18ngrep "HEAD points to something strange" out ' @@ -145,7 +141,6 @@ test_expect_success 'email without @ is okay' ' git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && git fsck 2>out && - cat out && ! grep "commit $new" out ' @@ -157,7 +152,6 @@ test_expect_success 'email with embedded > is not okay' ' git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && test_must_fail git fsck 2>out && - cat out && test_i18ngrep "error in commit $new" out ' @@ -169,7 +163,6 @@ test_expect_success 'missing < email delimiter is reported nicely' ' git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && test_must_fail git fsck 2>out && - cat out && test_i18ngrep "error in commit $new.* - bad name" out ' @@ -181,7 +174,6 @@ test_expect_success 'missing email is reported nicely' ' git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && test_must_fail git fsck 2>out && - cat out && test_i18ngrep "error in commit $new.* - missing email" out ' @@ -193,7 +185,6 @@ test_expect_success '> in name is reported' ' git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && test_must_fail git fsck 2>out && - cat out && test_i18ngrep "error in commit $new" out ' @@ -207,7 +198,6 @@ test_expect_success 'integer overflow in timestamps is reported' ' git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && test_must_fail git fsck 2>out && - cat out && test_i18ngrep "error in commit $new.*integer overflow" out ' @@ -219,7 +209,6 @@ test_expect_success 'commit with NUL in header' ' git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && test_must_fail git fsck 2>out && - cat out && test_i18ngrep "error in commit $new.*unterminated header: NUL at offset" out ' @@ -297,7 +286,6 @@ test_expect_success 'tag pointing to nonexistent' ' echo $tag >.git/refs/tags/invalid && test_when_finished "git update-ref -d refs/tags/invalid" && test_must_fail git fsck --tags >out && - cat out && test_i18ngrep "broken link" out ' @@ -378,7 +366,6 @@ test_expect_success 'tag with NUL in header' ' echo $tag >.git/refs/tags/wrong && test_when_finished "git update-ref -d refs/tags/wrong" && test_must_fail git fsck --tags 2>out && - cat out && test_i18ngrep "error in tag $tag.*unterminated header: NUL at offset" out ' @@ -409,7 +396,6 @@ test_expect_success 'rev-list --verify-objects with bad sha1' ' test_when_finished "git update-ref -d refs/heads/bogus" && test_might_fail git rev-list --verify-objects refs/heads/bogus >/dev/null 2>out && - cat out && test_i18ngrep -q "error: hash mismatch $(dirname $new)$(test_oid ff_2)" out ' @@ -433,7 +419,6 @@ test_expect_success 'fsck notices blob entry pointing to null sha1' ' sha=$(printf "100644 file$_bz$_bzoid" | git hash-object -w --stdin -t tree) && git fsck 2>out && - cat out && test_i18ngrep "warning.*null sha1" out ) ' @@ -444,7 +429,6 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' ' sha=$(printf "160000 submodule$_bz$_bzoid" | git hash-object -w --stdin -t tree) && git fsck 2>out && - cat out && test_i18ngrep "warning.*null sha1" out ) ' @@ -456,6 +440,7 @@ while read name path pretty; do ( git init $name-$type && cd $name-$type && + git config core.protectNTFS false && echo content >file && git add file && git commit -m base && @@ -465,7 +450,6 @@ while read name path pretty; do printf "$mode $type %s\t%s" "$value" "$path" >bad && bad_tree=$(git mktree out && - cat out && test_i18ngrep "warning.*tree $bad_tree" out )' done <<-\EOF @@ -632,7 +616,7 @@ test_expect_success 'fsck --name-objects' ' remove_object $(git rev-parse julius:caesar.t) && test_must_fail git fsck --name-objects >out && tree=$(git rev-parse --verify julius:) && - test_i18ngrep -E "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out + test_i18ngrep "$tree (refs/tags/julius:" out ) ' diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 01abee533ded..603019b54167 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -59,6 +59,7 @@ test_rev_parse () { ROOT=$(pwd) test_expect_success 'setup' ' + test_oid_init && mkdir -p sub/dir work && cp -R .git repo.git ' @@ -131,6 +132,30 @@ test_expect_success 'rev-parse --is-shallow-repository in non-shallow repo' ' test_cmp expect actual ' +test_expect_success 'rev-parse --show-object-format in repo' ' + echo "$(test_oid algo)" >expect && + git rev-parse --show-object-format >actual && + test_cmp expect actual && + git rev-parse --show-object-format=storage >actual && + test_cmp expect actual && + git rev-parse --show-object-format=input >actual && + test_cmp expect actual && + git rev-parse --show-object-format=output >actual && + test_cmp expect actual && + test_must_fail git rev-parse --show-object-format=squeamish-ossifrage 2>err && + grep "unknown mode for --show-object-format: squeamish-ossifrage" err +' + +test_expect_success '--show-toplevel from subdir of working tree' ' + pwd >expect && + git -C sub/dir rev-parse --show-toplevel >actual && + test_cmp expect actual +' + +test_expect_success '--show-toplevel from inside .git' ' + test_must_fail git -C .git rev-parse --show-toplevel +' + test_expect_success 'showing the superproject correctly' ' git rev-parse --show-superproject-working-tree >out && test_must_be_empty out && diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh index 3498d3d55e9e..b75558040ffd 100755 --- a/t/t1501-work-tree.sh +++ b/t/t1501-work-tree.sh @@ -350,7 +350,7 @@ test_expect_success 'Multi-worktree setup' ' mkdir work && mkdir -p repo.git/repos/foo && cp repo.git/HEAD repo.git/index repo.git/repos/foo && - test_might_fail cp repo.git/sharedindex.* repo.git/repos/foo && + { cp repo.git/sharedindex.* repo.git/repos/foo || :; } && sane_unset GIT_DIR GIT_CONFIG GIT_WORK_TREE ' diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh index 4ee009da666f..52edcbdcc327 100755 --- a/t/t1506-rev-parse-diagnosis.sh +++ b/t/t1506-rev-parse-diagnosis.sh @@ -8,12 +8,11 @@ exec expected <<-EOF && - fatal: Path '$2$3' $4, but not ${5:-$sq$3$sq}. - Did you mean '$1:$2$3'${2:+ aka $sq$1:./$3$sq}? + fatal: path '$2$3' $4, but not ${5:-$SQ$3$SQ} + hint: Did you mean '$1:$2$3'${2:+ aka $SQ$1:./$3$SQ}? EOF - test_cmp expected error + test_i18ncmp expected error } HASH_file= @@ -104,66 +103,66 @@ test_expect_success 'correct relative file objects (6)' ' test_expect_success 'incorrect revision id' ' test_must_fail git rev-parse foobar:file.txt 2>error && - grep "Invalid object name '"'"'foobar'"'"'." error && - test_must_fail git rev-parse foobar 2> error && + test_i18ngrep "invalid object name .foobar." error && + test_must_fail git rev-parse foobar 2>error && test_i18ngrep "unknown revision or path not in the working tree." error ' test_expect_success 'incorrect file in sha1:path' ' - test_must_fail git rev-parse HEAD:nothing.txt 2> error && - grep "fatal: Path '"'"'nothing.txt'"'"' does not exist in '"'"'HEAD'"'"'" error && - test_must_fail git rev-parse HEAD:index-only.txt 2> error && - grep "fatal: Path '"'"'index-only.txt'"'"' exists on disk, but not in '"'"'HEAD'"'"'." error && + test_must_fail git rev-parse HEAD:nothing.txt 2>error && + test_i18ngrep "path .nothing.txt. does not exist in .HEAD." error && + test_must_fail git rev-parse HEAD:index-only.txt 2>error && + test_i18ngrep "path .index-only.txt. exists on disk, but not in .HEAD." error && (cd subdir && - test_must_fail git rev-parse HEAD:file2.txt 2> error && + test_must_fail git rev-parse HEAD:file2.txt 2>error && test_did_you_mean HEAD subdir/ file2.txt exists ) ' test_expect_success 'incorrect file in :path and :N:path' ' - test_must_fail git rev-parse :nothing.txt 2> error && - grep "fatal: Path '"'"'nothing.txt'"'"' does not exist (neither on disk nor in the index)." error && - test_must_fail git rev-parse :1:nothing.txt 2> error && - grep "Path '"'"'nothing.txt'"'"' does not exist (neither on disk nor in the index)." error && - test_must_fail git rev-parse :1:file.txt 2> error && + test_must_fail git rev-parse :nothing.txt 2>error && + test_i18ngrep "path .nothing.txt. does not exist (neither on disk nor in the index)" error && + test_must_fail git rev-parse :1:nothing.txt 2>error && + test_i18ngrep "path .nothing.txt. does not exist (neither on disk nor in the index)" error && + test_must_fail git rev-parse :1:file.txt 2>error && test_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" && (cd subdir && - test_must_fail git rev-parse :1:file.txt 2> error && + test_must_fail git rev-parse :1:file.txt 2>error && test_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" && - test_must_fail git rev-parse :file2.txt 2> error && + test_must_fail git rev-parse :file2.txt 2>error && test_did_you_mean ":0" subdir/ file2.txt "is in the index" && - test_must_fail git rev-parse :2:file2.txt 2> error && + test_must_fail git rev-parse :2:file2.txt 2>error && test_did_you_mean :0 subdir/ file2.txt "is in the index") && - test_must_fail git rev-parse :disk-only.txt 2> error && - grep "fatal: Path '"'"'disk-only.txt'"'"' exists on disk, but not in the index." error + test_must_fail git rev-parse :disk-only.txt 2>error && + test_i18ngrep "path .disk-only.txt. exists on disk, but not in the index" error ' test_expect_success 'invalid @{n} reference' ' test_must_fail git rev-parse master@{99999} >output 2>error && - test -z "$(cat output)" && - grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error && + test_must_be_empty output && + test_i18ngrep "log for [^ ]* only has [0-9][0-9]* entries" error && test_must_fail git rev-parse --verify master@{99999} >output 2>error && - test -z "$(cat output)" && - grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error + test_must_be_empty output && + test_i18ngrep "log for [^ ]* only has [0-9][0-9]* entries" error ' test_expect_success 'relative path not found' ' ( cd subdir && test_must_fail git rev-parse HEAD:./nonexistent.txt 2>error && - grep subdir/nonexistent.txt error + test_i18ngrep subdir/nonexistent.txt error ) ' test_expect_success 'relative path outside worktree' ' test_must_fail git rev-parse HEAD:../file.txt >output 2>error && - test -z "$(cat output)" && + test_must_be_empty output && test_i18ngrep "outside repository" error ' test_expect_success 'relative path when cwd is outside worktree' ' test_must_fail git --git-dir=.git --work-tree=subdir rev-parse HEAD:./file.txt >output 2>error && - test -z "$(cat output)" && - grep "relative path syntax can.t be used outside working tree." error + test_must_be_empty output && + test_i18ngrep "relative path syntax can.t be used outside working tree" error ' test_expect_success ':file correctly diagnosed after a pathname' ' @@ -215,4 +214,26 @@ test_expect_success 'arg before dashdash must be a revision (ambiguous)' ' test_cmp expect actual ' +test_expect_success 'reject Nth parent if N is too high' ' + test_must_fail git rev-parse HEAD^100000000000000000000000000000000 +' + +test_expect_success 'reject Nth ancestor if N is too high' ' + test_must_fail git rev-parse HEAD~100000000000000000000000000000000 +' + +test_expect_success 'pathspecs with wildcards are not ambiguous' ' + echo "*.c" >expect && + git rev-parse "*.c" >actual && + test_cmp expect actual +' + +test_expect_success 'backslash does not trigger wildcard rule' ' + test_must_fail git rev-parse "foo\\bar" +' + +test_expect_success 'escaped char does not trigger wildcard rule' ' + test_must_fail git rev-parse "foo\\*bar" +' + test_done diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh index fa3e4996418d..dfc0d96d8a8a 100755 --- a/t/t1507-rev-parse-upstream.sh +++ b/t/t1507-rev-parse-upstream.sh @@ -28,16 +28,9 @@ test_expect_success 'setup' ' ) ' -sq="'" - -full_name () { - (cd clone && - git rev-parse --symbolic-full-name "$@") -} - commit_subject () { (cd clone && - git show -s --pretty=format:%s "$@") + git show -s --pretty=tformat:%s "$@") } error_message () { @@ -46,63 +39,78 @@ error_message () { } test_expect_success '@{upstream} resolves to correct full name' ' - test refs/remotes/origin/master = "$(full_name @{upstream})" && - test refs/remotes/origin/master = "$(full_name @{UPSTREAM})" && - test refs/remotes/origin/master = "$(full_name @{UpSTReam})" + echo refs/remotes/origin/master >expect && + git -C clone rev-parse --symbolic-full-name @{upstream} >actual && + test_cmp expect actual && + git -C clone rev-parse --symbolic-full-name @{UPSTREAM} >actual && + test_cmp expect actual && + git -C clone rev-parse --symbolic-full-name @{UpSTReam} >actual && + test_cmp expect actual ' test_expect_success '@{u} resolves to correct full name' ' - test refs/remotes/origin/master = "$(full_name @{u})" && - test refs/remotes/origin/master = "$(full_name @{U})" + echo refs/remotes/origin/master >expect && + git -C clone rev-parse --symbolic-full-name @{u} >actual && + test_cmp expect actual && + git -C clone rev-parse --symbolic-full-name @{U} >actual && + test_cmp expect actual ' test_expect_success 'my-side@{upstream} resolves to correct full name' ' - test refs/remotes/origin/side = "$(full_name my-side@{u})" + echo refs/remotes/origin/side >expect && + git -C clone rev-parse --symbolic-full-name my-side@{u} >actual && + test_cmp expect actual ' test_expect_success 'upstream of branch with @ in middle' ' - full_name fun@ny@{u} >actual && + git -C clone rev-parse --symbolic-full-name fun@ny@{u} >actual && echo refs/remotes/origin/side >expect && test_cmp expect actual && - full_name fun@ny@{U} >actual && + git -C clone rev-parse --symbolic-full-name fun@ny@{U} >actual && test_cmp expect actual ' test_expect_success 'upstream of branch with @ at start' ' - full_name @funny@{u} >actual && + git -C clone rev-parse --symbolic-full-name @funny@{u} >actual && echo refs/remotes/origin/side >expect && test_cmp expect actual ' test_expect_success 'upstream of branch with @ at end' ' - full_name funny@@{u} >actual && + git -C clone rev-parse --symbolic-full-name funny@@{u} >actual && echo refs/remotes/origin/side >expect && test_cmp expect actual ' test_expect_success 'refs/heads/my-side@{upstream} does not resolve to my-side{upstream}' ' - test_must_fail full_name refs/heads/my-side@{upstream} + test_must_fail git -C clone rev-parse --symbolic-full-name refs/heads/my-side@{upstream} ' test_expect_success 'my-side@{u} resolves to correct commit' ' git checkout side && test_commit 5 && (cd clone && git fetch) && - test 2 = "$(commit_subject my-side)" && - test 5 = "$(commit_subject my-side@{u})" + echo 2 >expect && + commit_subject my-side >actual && + test_cmp expect actual && + echo 5 >expect && + commit_subject my-side@{u} >actual ' test_expect_success 'not-tracking@{u} fails' ' - test_must_fail full_name non-tracking@{u} && + test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u} && (cd clone && git checkout --no-track -b non-tracking) && - test_must_fail full_name non-tracking@{u} + test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u} ' test_expect_success '@{u}@{1} resolves correctly' ' test_commit 6 && (cd clone && git fetch) && - test 5 = $(commit_subject my-side@{u}@{1}) && - test 5 = $(commit_subject my-side@{U}@{1}) + echo 5 >expect && + commit_subject my-side@{u}@{1} >actual && + test_cmp expect actual && + commit_subject my-side@{U}@{1} >actual && + test_cmp expect actual ' test_expect_success '@{u} without specifying branch fails on a detached HEAD' ' @@ -129,7 +137,7 @@ test_expect_success 'merge my-side@{u} records the correct name' ' git branch -t new my-side@{u} && git merge -s ours new@{u} && git show -s --pretty=tformat:%s >actual && - echo "Merge remote-tracking branch ${sq}origin/side${sq}" >expect && + echo "Merge remote-tracking branch ${SQ}origin/side${SQ}" >expect && test_cmp expect actual ) ' @@ -151,12 +159,14 @@ test_expect_success 'checkout other@{u}' ' ' test_expect_success 'branch@{u} works when tracking a local branch' ' - test refs/heads/master = "$(full_name local-master@{u})" + echo refs/heads/master >expect && + git -C clone rev-parse --symbolic-full-name local-master@{u} >actual && + test_cmp expect actual ' test_expect_success 'branch@{u} error message when no upstream' ' cat >expect <<-EOF && - fatal: no upstream configured for branch ${sq}non-tracking${sq} + fatal: no upstream configured for branch ${SQ}non-tracking${SQ} EOF error_message non-tracking@{u} && test_i18ncmp expect error @@ -164,7 +174,7 @@ test_expect_success 'branch@{u} error message when no upstream' ' test_expect_success '@{u} error message when no upstream' ' cat >expect <<-EOF && - fatal: no upstream configured for branch ${sq}master${sq} + fatal: no upstream configured for branch ${SQ}master${SQ} EOF test_must_fail git rev-parse --verify @{u} 2>actual && test_i18ncmp expect actual @@ -172,7 +182,7 @@ test_expect_success '@{u} error message when no upstream' ' test_expect_success 'branch@{u} error message with misspelt branch' ' cat >expect <<-EOF && - fatal: no such branch: ${sq}no-such-branch${sq} + fatal: no such branch: ${SQ}no-such-branch${SQ} EOF error_message no-such-branch@{u} && test_i18ncmp expect error @@ -189,7 +199,7 @@ test_expect_success '@{u} error message when not on a branch' ' test_expect_success 'branch@{u} error message if upstream branch not fetched' ' cat >expect <<-EOF && - fatal: upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch + fatal: upstream branch ${SQ}refs/heads/side${SQ} not stored as a remote-tracking branch EOF error_message bad-upstream@{u} && test_i18ncmp expect error @@ -205,35 +215,37 @@ test_expect_success 'pull works when tracking a local branch' ' # makes sense if the previous one succeeded test_expect_success '@{u} works when tracking a local branch' ' - test refs/heads/master = "$(full_name @{u})" + echo refs/heads/master >expect && + git -C clone rev-parse --symbolic-full-name @{u} >actual && + test_cmp expect actual ' -commit=$(git rev-parse HEAD) -cat >expect <) -Reflog message: branch: Created from HEAD -Author: A U Thor -Date: Thu Apr 7 15:15:13 2005 -0700 - - 3 -EOF test_expect_success 'log -g other@{u}' ' + commit=$(git rev-parse HEAD) && + cat >expect <<-EOF && + commit $commit + Reflog: master@{0} (C O Mitter ) + Reflog message: branch: Created from HEAD + Author: A U Thor + Date: Thu Apr 7 15:15:13 2005 -0700 + + 3 + EOF git log -1 -g other@{u} >actual && test_cmp expect actual ' -cat >expect <) -Reflog message: branch: Created from HEAD -Author: A U Thor -Date: Thu Apr 7 15:15:13 2005 -0700 - - 3 -EOF - test_expect_success 'log -g other@{u}@{now}' ' + commit=$(git rev-parse HEAD) && + cat >expect <<-EOF && + commit $commit + Reflog: master@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter ) + Reflog message: branch: Created from HEAD + Author: A U Thor + Date: Thu Apr 7 15:15:13 2005 -0700 + + 3 + EOF git log -1 -g other@{u}@{now} >actual && test_cmp expect actual ' diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh index c19fb500cb22..18fa6cf40d37 100755 --- a/t/t1512-rev-parse-disambiguation.sh +++ b/t/t1512-rev-parse-disambiguation.sh @@ -282,7 +282,7 @@ test_expect_success 'rev-parse --disambiguate' ' # commits created by commit-tree in earlier tests share a # different prefix. git rev-parse --disambiguate=000000000 >actual && - test $(wc -l stderr && grep ^hint: stderr >hints && - # 5 commits, 1 tag (which is a commitish), plus intro line + # 5 commits, 1 tag (which is a committish), plus intro line test_line_count = 7 hints ' diff --git a/t/t1600-index.sh b/t/t1600-index.sh index 42962ed7d46f..b7c31aa86a11 100755 --- a/t/t1600-index.sh +++ b/t/t1600-index.sh @@ -59,17 +59,42 @@ test_expect_success 'out of bounds index.version issues warning' ' ) ' -test_expect_success 'GIT_INDEX_VERSION takes precedence over config' ' +test_index_version () { + INDEX_VERSION_CONFIG=$1 && + FEATURE_MANY_FILES=$2 && + ENV_VAR_VERSION=$3 + EXPECTED_OUTPUT_VERSION=$4 && ( rm -f .git/index && - GIT_INDEX_VERSION=4 && - export GIT_INDEX_VERSION && - git config --add index.version 2 && + rm -f .git/config && + if test "$INDEX_VERSION_CONFIG" -ne 0 + then + git config --add index.version $INDEX_VERSION_CONFIG + fi && + git config --add feature.manyFiles $FEATURE_MANY_FILES + if test "$ENV_VAR_VERSION" -ne 0 + then + GIT_INDEX_VERSION=$ENV_VAR_VERSION && + export GIT_INDEX_VERSION + else + unset GIT_INDEX_VERSION + fi && git add a 2>&1 && - echo 4 >expect && + echo $EXPECTED_OUTPUT_VERSION >expect && test-tool index-version <.git/index >actual && test_cmp expect actual ) +} + +test_expect_success 'index version config precedence' ' + test_index_version 0 false 0 2 && + test_index_version 2 false 0 2 && + test_index_version 3 false 0 2 && + test_index_version 4 false 0 4 && + test_index_version 2 false 4 4 && + test_index_version 2 true 0 2 && + test_index_version 0 true 0 4 && + test_index_version 0 true 2 2 ' test_done diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index 822381dd9df6..bbca7ef8da6d 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -1,50 +1,76 @@ #!/bin/sh -test_description='checkout ' +test_description='checkout' . ./test-lib.sh -# Arguments: [] +# Arguments: [!] [] # # Runs "git checkout" to switch to , testing that # # 1) we are on the specified branch, ; -# 2) HEAD is ; if is not specified, the old HEAD is used. +# 2) HEAD is ; if is not specified, the old HEAD is used. # # If is not specified, "git checkout" is run with -b. -do_checkout() { +# +# If the first argument is `!`, "git checkout" is expected to fail when +# it is run. +do_checkout () { + should_fail= && + if test "x$1" = "x!" + then + should_fail=yes && + shift + fi && exp_branch=$1 && exp_ref="refs/heads/$exp_branch" && - # if is not specified, use HEAD. - exp_sha=${2:-$(git rev-parse --verify HEAD)} && + # if is not specified, use HEAD. + exp_oid=${2:-$(git rev-parse --verify HEAD)} && # default options for git checkout: -b - if [ -z "$3" ]; then + if test -z "$3" + then opts="-b" else opts="$3" fi - git checkout $opts $exp_branch $exp_sha && + if test -n "$should_fail" + then + test_must_fail git checkout $opts $exp_branch $exp_oid + else + git checkout $opts $exp_branch $exp_oid && + echo "$exp_ref" >ref.expect && + git rev-parse --symbolic-full-name HEAD >ref.actual && + test_cmp ref.expect ref.actual && + echo "$exp_oid" >oid.expect && + git rev-parse --verify HEAD >oid.actual && + test_cmp oid.expect oid.actual + fi +} - test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) && - test $exp_sha = $(git rev-parse --verify HEAD) +test_dirty_unmergeable () { + test_expect_code 1 git diff --exit-code } -test_dirty_unmergeable() { - ! git diff --exit-code >/dev/null +test_dirty_unmergeable_discards_changes () { + git diff --exit-code } -setup_dirty_unmergeable() { +setup_dirty_unmergeable () { echo >>file1 change2 } -test_dirty_mergeable() { - ! git diff --cached --exit-code >/dev/null +test_dirty_mergeable () { + test_expect_code 1 git diff --cached --exit-code +} + +test_dirty_mergeable_discards_changes () { + git diff --cached --exit-code } -setup_dirty_mergeable() { +setup_dirty_mergeable () { echo >file2 file2 && git add file2 } @@ -82,7 +108,7 @@ test_expect_success 'checkout -b to a new branch, set to an explicit ref' ' test_expect_success 'checkout -b to a new branch with unmergeable changes fails' ' setup_dirty_unmergeable && - test_must_fail do_checkout branch2 $HEAD1 && + do_checkout ! branch2 $HEAD1 && test_dirty_unmergeable ' @@ -93,7 +119,7 @@ test_expect_success 'checkout -f -b to a new branch with unmergeable changes dis # still dirty and on branch1 do_checkout branch2 $HEAD1 "-f -b" && - test_must_fail test_dirty_unmergeable + test_dirty_unmergeable_discards_changes ' test_expect_success 'checkout -b to a new branch preserves mergeable changes' ' @@ -111,12 +137,12 @@ test_expect_success 'checkout -f -b to a new branch with mergeable changes disca test_when_finished git reset --hard HEAD && setup_dirty_mergeable && do_checkout branch2 $HEAD1 "-f -b" && - test_must_fail test_dirty_mergeable + test_dirty_mergeable_discards_changes ' test_expect_success 'checkout -b to an existing branch fails' ' test_when_finished git reset --hard HEAD && - test_must_fail do_checkout branch2 $HEAD2 + do_checkout ! branch2 $HEAD2 ' test_expect_success 'checkout -b to @{-1} fails with the right branch name' ' @@ -140,7 +166,8 @@ test_expect_success 'checkout -B to a merge base' ' ' test_expect_success 'checkout -B to an existing branch from detached HEAD resets branch to HEAD' ' - git checkout $(git rev-parse --verify HEAD) && + head=$(git rev-parse --verify HEAD) && + git checkout "$head" && do_checkout branch2 "" -B ' @@ -155,14 +182,14 @@ test_expect_success 'checkout -B to an existing branch with unmergeable changes git checkout branch1 && setup_dirty_unmergeable && - test_must_fail do_checkout branch2 $HEAD1 -B && + do_checkout ! branch2 $HEAD1 -B && test_dirty_unmergeable ' test_expect_success 'checkout -f -B to an existing branch with unmergeable changes discards changes' ' # still dirty and on branch1 do_checkout branch2 $HEAD1 "-f -B" && - test_must_fail test_dirty_unmergeable + test_dirty_unmergeable_discards_changes ' test_expect_success 'checkout -B to an existing branch preserves mergeable changes' ' @@ -179,7 +206,7 @@ test_expect_success 'checkout -f -B to an existing branch with mergeable changes setup_dirty_mergeable && do_checkout branch2 $HEAD1 "-f -B" && - test_must_fail test_dirty_mergeable + test_dirty_mergeable_discards_changes ' test_expect_success 'checkout -b ' ' diff --git a/t/t2022-checkout-paths.sh b/t/t2022-checkout-paths.sh index fc3eb43b8909..6844afafc0eb 100755 --- a/t/t2022-checkout-paths.sh +++ b/t/t2022-checkout-paths.sh @@ -78,4 +78,15 @@ test_expect_success 'do not touch files that are already up-to-date' ' test_cmp expect actual ' +test_expect_success 'checkout HEAD adds deleted intent-to-add file back to index' ' + echo "nonempty" >nonempty && + >empty && + git add nonempty empty && + git commit -m "create files to be deleted" && + git rm --cached nonempty empty && + git add -N nonempty empty && + git checkout HEAD nonempty empty && + git diff --cached --exit-code +' + test_done diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh index fa0718c730c3..accfa9aa4bd8 100755 --- a/t/t2024-checkout-dwim.sh +++ b/t/t2024-checkout-dwim.sh @@ -37,7 +37,9 @@ test_expect_success 'setup' ' git checkout -b foo && test_commit a_foo && git checkout -b bar && - test_commit a_bar + test_commit a_bar && + git checkout -b ambiguous_branch_and_file && + test_commit a_ambiguous_branch_and_file ) && git init repo_b && ( @@ -46,7 +48,9 @@ test_expect_success 'setup' ' git checkout -b foo && test_commit b_foo && git checkout -b baz && - test_commit b_baz + test_commit b_baz && + git checkout -b ambiguous_branch_and_file && + test_commit b_ambiguous_branch_and_file ) && git remote add repo_a repo_a && git remote add repo_b repo_b && @@ -75,6 +79,26 @@ test_expect_success 'checkout of branch from multiple remotes fails #1' ' test_branch master ' +test_expect_success 'when arg matches multiple remotes, do not fallback to interpreting as pathspec' ' + # create a file with name matching remote branch name + git checkout -b t_ambiguous_branch_and_file && + >ambiguous_branch_and_file && + git add ambiguous_branch_and_file && + git commit -m "ambiguous_branch_and_file" && + + # modify file to verify that it will not be touched by checkout + test_when_finished "git checkout -- ambiguous_branch_and_file" && + echo "file contents" >ambiguous_branch_and_file && + cp ambiguous_branch_and_file expect && + + test_must_fail git checkout ambiguous_branch_and_file 2>err && + + test_i18ngrep "matched multiple (2) remote tracking branches" err && + + # file must not be altered + test_cmp expect ambiguous_branch_and_file +' + test_expect_success 'checkout of branch from multiple remotes fails with advice' ' git checkout -B master && test_might_fail git branch -D foo && diff --git a/t/t2026-checkout-pathspec-file.sh b/t/t2026-checkout-pathspec-file.sh new file mode 100755 index 000000000000..43d31d794853 --- /dev/null +++ b/t/t2026-checkout-pathspec-file.sh @@ -0,0 +1,163 @@ +#!/bin/sh + +test_description='checkout --pathspec-from-file' + +. ./test-lib.sh + +test_tick + +test_expect_success setup ' + test_commit file0 && + + echo 1 >fileA.t && + echo 1 >fileB.t && + echo 1 >fileC.t && + echo 1 >fileD.t && + git add fileA.t fileB.t fileC.t fileD.t && + git commit -m "files 1" && + + echo 2 >fileA.t && + echo 2 >fileB.t && + echo 2 >fileC.t && + echo 2 >fileD.t && + git add fileA.t fileB.t fileC.t fileD.t && + git commit -m "files 2" && + + git tag checkpoint +' + +restore_checkpoint () { + git reset --hard checkpoint +} + +verify_expect () { + git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual && + test_cmp expect actual +} + +test_expect_success '--pathspec-from-file from stdin' ' + restore_checkpoint && + + echo fileA.t | git checkout --pathspec-from-file=- HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + EOF + verify_expect +' + +test_expect_success '--pathspec-from-file from file' ' + restore_checkpoint && + + echo fileA.t >list && + git checkout --pathspec-from-file=list HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + EOF + verify_expect +' + +test_expect_success 'NUL delimiters' ' + restore_checkpoint && + + printf "fileA.t\0fileB.t\0" | git checkout --pathspec-from-file=- --pathspec-file-nul HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + M fileB.t + EOF + verify_expect +' + +test_expect_success 'LF delimiters' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t\n" | git checkout --pathspec-from-file=- HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + M fileB.t + EOF + verify_expect +' + +test_expect_success 'no trailing delimiter' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t" | git checkout --pathspec-from-file=- HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + M fileB.t + EOF + verify_expect +' + +test_expect_success 'CRLF delimiters' ' + restore_checkpoint && + + printf "fileA.t\r\nfileB.t\r\n" | git checkout --pathspec-from-file=- HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + M fileB.t + EOF + verify_expect +' + +test_expect_success 'quotes' ' + restore_checkpoint && + + cat >list <<-\EOF && + "file\101.t" + EOF + + git checkout --pathspec-from-file=list HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + EOF + verify_expect +' + +test_expect_success 'quotes not compatible with --pathspec-file-nul' ' + restore_checkpoint && + + cat >list <<-\EOF && + "file\101.t" + EOF + + test_must_fail git checkout --pathspec-from-file=list --pathspec-file-nul HEAD^1 +' + +test_expect_success 'only touches what was listed' ' + restore_checkpoint && + + printf "fileB.t\nfileC.t\n" | git checkout --pathspec-from-file=- HEAD^1 && + + cat >expect <<-\EOF && + M fileB.t + M fileC.t + EOF + verify_expect +' + +test_expect_success 'error conditions' ' + restore_checkpoint && + echo fileA.t >list && + + test_must_fail git checkout --pathspec-from-file=list --detach 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with --detach" err && + + test_must_fail git checkout --pathspec-from-file=list --patch 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err && + + test_must_fail git checkout --pathspec-from-file=list -- fileA.t 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err && + + test_must_fail git checkout --pathspec-file-nul 2>err && + test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err +' + +test_done diff --git a/t/t2070-restore.sh b/t/t2070-restore.sh index 2650df196670..076d0df7fc06 100755 --- a/t/t2070-restore.sh +++ b/t/t2070-restore.sh @@ -95,4 +95,32 @@ test_expect_success 'restore --ignore-unmerged ignores unmerged entries' ' ) ' +test_expect_success 'restore --staged adds deleted intent-to-add file back to index' ' + echo "nonempty" >nonempty && + >empty && + git add nonempty empty && + git commit -m "create files to be deleted" && + git rm --cached nonempty empty && + git add -N nonempty empty && + git restore --staged nonempty empty && + git diff --cached --exit-code +' + +test_expect_success 'restore --staged invalidates cache tree for deletions' ' + test_when_finished git reset --hard && + >new1 && + >new2 && + git add new1 new2 && + + # It is important to commit and then reset here, so that the index + # contains a valid cache-tree for the "both" tree. + git commit -m both && + git reset --soft HEAD^ && + + git restore --staged new1 && + git commit -m "just new2" && + git rev-parse HEAD:new2 && + test_must_fail git rev-parse HEAD:new1 +' + test_done diff --git a/t/t2072-restore-pathspec-file.sh b/t/t2072-restore-pathspec-file.sh new file mode 100755 index 000000000000..0d47946e8a9b --- /dev/null +++ b/t/t2072-restore-pathspec-file.sh @@ -0,0 +1,164 @@ +#!/bin/sh + +test_description='restore --pathspec-from-file' + +. ./test-lib.sh + +test_tick + +test_expect_success setup ' + test_commit file0 && + + echo 1 >fileA.t && + echo 1 >fileB.t && + echo 1 >fileC.t && + echo 1 >fileD.t && + git add fileA.t fileB.t fileC.t fileD.t && + git commit -m "files 1" && + + echo 2 >fileA.t && + echo 2 >fileB.t && + echo 2 >fileC.t && + echo 2 >fileD.t && + git add fileA.t fileB.t fileC.t fileD.t && + git commit -m "files 2" && + + git tag checkpoint +' + +restore_checkpoint () { + git reset --hard checkpoint +} + +verify_expect () { + git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual && + test_cmp expect actual +} + +test_expect_success '--pathspec-from-file from stdin' ' + restore_checkpoint && + + echo fileA.t | git restore --pathspec-from-file=- --source=HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + EOF + verify_expect +' + +test_expect_success '--pathspec-from-file from file' ' + restore_checkpoint && + + echo fileA.t >list && + git restore --pathspec-from-file=list --source=HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + EOF + verify_expect +' + +test_expect_success 'NUL delimiters' ' + restore_checkpoint && + + printf "fileA.t\0fileB.t\0" | git restore --pathspec-from-file=- --pathspec-file-nul --source=HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + M fileB.t + EOF + verify_expect +' + +test_expect_success 'LF delimiters' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t\n" | git restore --pathspec-from-file=- --source=HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + M fileB.t + EOF + verify_expect +' + +test_expect_success 'no trailing delimiter' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t" | git restore --pathspec-from-file=- --source=HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + M fileB.t + EOF + verify_expect +' + +test_expect_success 'CRLF delimiters' ' + restore_checkpoint && + + printf "fileA.t\r\nfileB.t\r\n" | git restore --pathspec-from-file=- --source=HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + M fileB.t + EOF + verify_expect +' + +test_expect_success 'quotes' ' + restore_checkpoint && + + cat >list <<-\EOF && + "file\101.t" + EOF + + git restore --pathspec-from-file=list --source=HEAD^1 && + + cat >expect <<-\EOF && + M fileA.t + EOF + verify_expect +' + +test_expect_success 'quotes not compatible with --pathspec-file-nul' ' + restore_checkpoint && + + cat >list <<-\EOF && + "file\101.t" + EOF + + test_must_fail git restore --pathspec-from-file=list --pathspec-file-nul --source=HEAD^1 +' + +test_expect_success 'only touches what was listed' ' + restore_checkpoint && + + printf "fileB.t\nfileC.t\n" | git restore --pathspec-from-file=- --source=HEAD^1 && + + cat >expect <<-\EOF && + M fileB.t + M fileC.t + EOF + verify_expect +' + +test_expect_success 'error conditions' ' + restore_checkpoint && + echo fileA.t >list && + >empty_list && + + test_must_fail git restore --pathspec-from-file=list --patch --source=HEAD^1 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err && + + test_must_fail git restore --pathspec-from-file=list --source=HEAD^1 -- fileA.t 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err && + + test_must_fail git restore --pathspec-file-nul --source=HEAD^1 2>err && + test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err && + + test_must_fail git restore --pathspec-from-file=empty_list --source=HEAD^1 2>err && + test_i18ngrep -e "you must specify path(s) to restore" err +' + +test_done diff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh index 2242cd098ec4..a30b7ca6bc90 100755 --- a/t/t2107-update-index-basic.sh +++ b/t/t2107-update-index-basic.sh @@ -9,7 +9,6 @@ Tests for command-line parsing and basic operation. test_expect_success 'update-index --nonsense fails' ' test_must_fail git update-index --nonsense 2>msg && - cat msg && test -s msg ' diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh index e819ba741ec9..5a7495474aa8 100755 --- a/t/t2400-worktree-add.sh +++ b/t/t2400-worktree-add.sh @@ -438,7 +438,7 @@ test_expect_success 'git worktree add does not match remote' ' cd foo && test_must_fail git config "branch.foo.remote" && test_must_fail git config "branch.foo.merge" && - ! test_cmp_rev refs/remotes/repo_a/foo refs/heads/foo + test_cmp_rev ! refs/remotes/repo_a/foo refs/heads/foo ) ' @@ -483,7 +483,7 @@ test_expect_success 'git worktree --no-guess-remote option overrides config' ' cd foo && test_must_fail git config "branch.foo.remote" && test_must_fail git config "branch.foo.merge" && - ! test_cmp_rev refs/remotes/repo_a/foo refs/heads/foo + test_cmp_rev ! refs/remotes/repo_a/foo refs/heads/foo ) ' @@ -570,6 +570,15 @@ test_expect_success '"add" an existing locked but missing worktree' ' git worktree add --force --force --detach gnoo ' +test_expect_success '"add" not tripped up by magic worktree matching"' ' + # if worktree "sub1/bar" exists, "git worktree add bar" in distinct + # directory `sub2` should not mistakenly complain that `bar` is an + # already-registered worktree + mkdir sub1 sub2 && + git -C sub1 --git-dir=../.git worktree add --detach bozo && + git -C sub2 --git-dir=../.git worktree add --detach bozo +' + test_expect_success FUNNYNAMES 'sanitize generated worktree name' ' git worktree add --detach ". weird*..?.lock.lock" && test -d .git/worktrees/---weird-.- @@ -587,4 +596,28 @@ test_expect_success '"add" should not fail because of another bad worktree' ' ) ' +test_expect_success '"add" with uninitialized submodule, with submodule.recurse unset' ' + test_create_repo submodule && + test_commit -C submodule first && + test_create_repo project && + git -C project submodule add ../submodule && + git -C project add submodule && + test_tick && + git -C project commit -m add_sub && + git clone project project-clone && + git -C project-clone worktree add ../project-2 +' +test_expect_success '"add" with uninitialized submodule, with submodule.recurse set' ' + git -C project-clone -c submodule.recurse worktree add ../project-3 +' + +test_expect_success '"add" with initialized submodule, with submodule.recurse unset' ' + git -C project-clone submodule update --init && + git -C project-clone worktree add ../project-4 +' + +test_expect_success '"add" with initialized submodule, with submodule.recurse set' ' + git -C project-clone -c submodule.recurse worktree add ../project-5 +' + test_done diff --git a/t/t2402-worktree-list.sh b/t/t2402-worktree-list.sh index bb6fb9b12cb7..69ffe865b439 100755 --- a/t/t2402-worktree-list.sh +++ b/t/t2402-worktree-list.sh @@ -151,4 +151,10 @@ test_expect_success 'linked worktrees are sorted' ' test_cmp expected sorted/main/actual ' +test_expect_success 'worktree path when called in .git directory' ' + git worktree list >list1&& + git -C .git worktree list >list2 && + test_cmp list1 list2 +' + test_done diff --git a/t/t2405-worktree-submodule.sh b/t/t2405-worktree-submodule.sh new file mode 100755 index 000000000000..e1b2bfd87e0d --- /dev/null +++ b/t/t2405-worktree-submodule.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +test_description='Combination of submodules and multiple worktrees' + +. ./test-lib.sh + +base_path=$(pwd -P) + +test_expect_success 'setup: create origin repos' ' + git init origin/sub && + test_commit -C origin/sub file1 && + git init origin/main && + test_commit -C origin/main first && + git -C origin/main submodule add ../sub && + git -C origin/main commit -m "add sub" && + test_commit -C origin/sub "file1 updated" file1 file1updated file1updated && + git -C origin/main/sub pull && + git -C origin/main add sub && + git -C origin/main commit -m "sub updated" +' + +test_expect_success 'setup: clone superproject to create main worktree' ' + git clone --recursive "$base_path/origin/main" main +' + +rev1_hash_main=$(git --git-dir=origin/main/.git show --pretty=format:%h -q "HEAD~1") +rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q "HEAD~1") + +test_expect_success 'add superproject worktree' ' + git -C main worktree add "$base_path/worktree" "$rev1_hash_main" +' + +test_expect_failure 'submodule is checked out just after worktree add' ' + git -C worktree diff --submodule master"^!" >out && + grep "file1 updated" out +' + +test_expect_success 'add superproject worktree and initialize submodules' ' + git -C main worktree add "$base_path/worktree-submodule-update" "$rev1_hash_main" && + git -C worktree-submodule-update submodule update +' + +test_expect_success 'submodule is checked out just after submodule update in linked worktree' ' + git -C worktree-submodule-update diff --submodule master"^!" >out && + grep "file1 updated" out +' + +test_expect_success 'add superproject worktree and manually add submodule worktree' ' + git -C main worktree add "$base_path/linked_submodule" "$rev1_hash_main" && + git -C main/sub worktree add "$base_path/linked_submodule/sub" "$rev1_hash_sub" +' + +test_expect_success 'submodule is checked out after manually adding submodule worktree' ' + git -C linked_submodule diff --submodule master"^!" >out && + grep "file1 updated" out +' + +test_expect_success 'checkout --recurse-submodules uses $GIT_DIR for submodules in a linked worktree' ' + git -C main worktree add "$base_path/checkout-recurse" --detach && + git -C checkout-recurse submodule update --init && + echo "gitdir: ../../main/.git/worktrees/checkout-recurse/modules/sub" >expect-gitfile && + cat checkout-recurse/sub/.git >actual-gitfile && + test_cmp expect-gitfile actual-gitfile && + git -C main/sub rev-parse HEAD >expect-head-main && + git -C checkout-recurse checkout --recurse-submodules HEAD~1 && + cat checkout-recurse/sub/.git >actual-gitfile && + git -C main/sub rev-parse HEAD >actual-head-main && + test_cmp expect-gitfile actual-gitfile && + test_cmp expect-head-main actual-head-main +' + +test_expect_success 'core.worktree is removed in $GIT_DIR/modules//config, not in $GIT_COMMON_DIR/modules//config' ' + echo "../../../sub" >expect-main && + git -C main/sub config --get core.worktree >actual-main && + test_cmp expect-main actual-main && + echo "../../../../../../checkout-recurse/sub" >expect-linked && + git -C checkout-recurse/sub config --get core.worktree >actual-linked && + test_cmp expect-linked actual-linked && + git -C checkout-recurse checkout --recurse-submodules first && + test_expect_code 1 git -C main/.git/worktrees/checkout-recurse/modules/sub config --get core.worktree >linked-config && + test_must_be_empty linked-config && + git -C main/sub config --get core.worktree >actual-main && + test_cmp expect-main actual-main +' + +test_expect_success 'unsetting core.worktree does not prevent running commands directly against the submodule repository' ' + git -C main/.git/worktrees/checkout-recurse/modules/sub log +' + +test_done diff --git a/t/t3005-ls-files-relative.sh b/t/t3005-ls-files-relative.sh index 209b4c7cd8c6..2ec69a8a266f 100755 --- a/t/t3005-ls-files-relative.sh +++ b/t/t3005-ls-files-relative.sh @@ -7,10 +7,6 @@ This test runs git ls-files with various relative path arguments. . ./test-lib.sh -new_line=' -' -sq=\' - test_expect_success 'prepare' ' : >never-mind-me && git add never-mind-me && @@ -44,9 +40,9 @@ test_expect_success 'ls-files -c' ' cd top/sub && for f in ../y* do - echo "error: pathspec $sq$f$sq did not match any file(s) known to git" + echo "error: pathspec $SQ$f$SQ did not match any file(s) known to git" done >expect.err && - echo "Did you forget to ${sq}git add${sq}?" >>expect.err && + echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err && ls ../x* >expect.out && test_must_fail git ls-files -c --error-unmatch ../[xy]* >actual.out 2>actual.err && test_cmp expect.out actual.out && @@ -59,9 +55,9 @@ test_expect_success 'ls-files -o' ' cd top/sub && for f in ../x* do - echo "error: pathspec $sq$f$sq did not match any file(s) known to git" + echo "error: pathspec $SQ$f$SQ did not match any file(s) known to git" done >expect.err && - echo "Did you forget to ${sq}git add${sq}?" >>expect.err && + echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err && ls ../y* >expect.out && test_must_fail git ls-files -o --error-unmatch ../[xy]* >actual.out 2>actual.err && test_cmp expect.out actual.out && diff --git a/t/t3007-ls-files-recurse-submodules.sh b/t/t3007-ls-files-recurse-submodules.sh index 318b5bce7ebe..4a0800071379 100755 --- a/t/t3007-ls-files-recurse-submodules.sh +++ b/t/t3007-ls-files-recurse-submodules.sh @@ -130,7 +130,6 @@ test_expect_success '--recurse-submodules and pathspecs setup' ' git ls-files --recurse-submodules >actual && test_cmp expect actual && - cat actual && git ls-files --recurse-submodules "*" >actual && test_cmp expect actual ' diff --git a/t/t3008-ls-files-lazy-init-name-hash.sh b/t/t3008-ls-files-lazy-init-name-hash.sh index 64f047332b51..85f370495876 100755 --- a/t/t3008-ls-files-lazy-init-name-hash.sh +++ b/t/t3008-ls-files-lazy-init-name-hash.sh @@ -4,7 +4,7 @@ test_description='Test the lazy init name hash with various folder structures' . ./test-lib.sh -if test 1 -eq $($GIT_BUILD_DIR/t/helper/test-tool online-cpus) +if test 1 -eq $(test-tool online-cpus) then skip_all='skipping lazy-init tests, single cpu' test_done diff --git a/t/t3011-common-prefixes-and-directory-traversal.sh b/t/t3011-common-prefixes-and-directory-traversal.sh new file mode 100755 index 000000000000..3da5b2b6e795 --- /dev/null +++ b/t/t3011-common-prefixes-and-directory-traversal.sh @@ -0,0 +1,209 @@ +#!/bin/sh + +test_description='directory traversal handling, especially with common prefixes' + +. ./test-lib.sh + +test_expect_success 'setup' ' + test_commit hello && + + >empty && + mkdir untracked_dir && + >untracked_dir/empty && + git init untracked_repo && + >untracked_repo/empty && + + cat <<-EOF >.gitignore && + ignored + an_ignored_dir/ + EOF + mkdir an_ignored_dir && + mkdir an_untracked_dir && + >an_ignored_dir/ignored && + >an_ignored_dir/untracked && + >an_untracked_dir/ignored && + >an_untracked_dir/untracked +' + +test_expect_success 'git ls-files -o shows the right entries' ' + cat <<-EOF >expect && + .gitignore + actual + an_ignored_dir/ignored + an_ignored_dir/untracked + an_untracked_dir/ignored + an_untracked_dir/untracked + empty + expect + untracked_dir/empty + untracked_repo/ + EOF + git ls-files -o >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o --exclude-standard shows the right entries' ' + cat <<-EOF >expect && + .gitignore + actual + an_untracked_dir/untracked + empty + expect + untracked_dir/empty + untracked_repo/ + EOF + git ls-files -o --exclude-standard >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o untracked_dir recurses' ' + echo untracked_dir/empty >expect && + git ls-files -o untracked_dir >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o untracked_dir/ recurses' ' + echo untracked_dir/empty >expect && + git ls-files -o untracked_dir/ >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o --directory untracked_dir does not recurse' ' + echo untracked_dir/ >expect && + git ls-files -o --directory untracked_dir >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o --directory untracked_dir/ does not recurse' ' + echo untracked_dir/ >expect && + git ls-files -o --directory untracked_dir/ >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o untracked_repo does not recurse' ' + echo untracked_repo/ >expect && + git ls-files -o untracked_repo >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o untracked_repo/ does not recurse' ' + echo untracked_repo/ >expect && + git ls-files -o untracked_repo/ >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o untracked_dir untracked_repo recurses into untracked_dir only' ' + cat <<-EOF >expect && + untracked_dir/empty + untracked_repo/ + EOF + git ls-files -o untracked_dir untracked_repo >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o untracked_dir/ untracked_repo/ recurses into untracked_dir only' ' + cat <<-EOF >expect && + untracked_dir/empty + untracked_repo/ + EOF + git ls-files -o untracked_dir/ untracked_repo/ >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o --directory untracked_dir untracked_repo does not recurse' ' + cat <<-EOF >expect && + untracked_dir/ + untracked_repo/ + EOF + git ls-files -o --directory untracked_dir untracked_repo >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o --directory untracked_dir/ untracked_repo/ does not recurse' ' + cat <<-EOF >expect && + untracked_dir/ + untracked_repo/ + EOF + git ls-files -o --directory untracked_dir/ untracked_repo/ >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o .git shows nothing' ' + git ls-files -o .git >actual && + test_must_be_empty actual +' + +test_expect_success 'git ls-files -o .git/ shows nothing' ' + git ls-files -o .git/ >actual && + test_must_be_empty actual +' + +test_expect_success FUNNYNAMES 'git ls-files -o untracked_* recurses appropriately' ' + mkdir "untracked_*" && + >"untracked_*/empty" && + + cat <<-EOF >expect && + untracked_*/empty + untracked_dir/empty + untracked_repo/ + EOF + git ls-files -o "untracked_*" >actual && + test_cmp expect actual +' + +# It turns out fill_directory returns the right paths, but ls-files' post-call +# filtering in show_dir_entry() via calling dir_path_match() which ends up +# in git_fnmatch() has logic for PATHSPEC_ONESTAR that assumes the pathspec +# must match the full path; it doesn't check it for matching a leading +# directory. +test_expect_failure FUNNYNAMES 'git ls-files -o untracked_*/ recurses appropriately' ' + cat <<-EOF >expect && + untracked_*/empty + untracked_dir/empty + untracked_repo/ + EOF + git ls-files -o "untracked_*/" >actual && + test_cmp expect actual +' + +test_expect_success FUNNYNAMES 'git ls-files -o --directory untracked_* does not recurse' ' + cat <<-EOF >expect && + untracked_*/ + untracked_dir/ + untracked_repo/ + EOF + git ls-files -o --directory "untracked_*" >actual && + test_cmp expect actual +' + +test_expect_success FUNNYNAMES 'git ls-files -o --directory untracked_*/ does not recurse' ' + cat <<-EOF >expect && + untracked_*/ + untracked_dir/ + untracked_repo/ + EOF + git ls-files -o --directory "untracked_*/" >actual && + test_cmp expect actual +' + +test_expect_success 'git ls-files -o consistent between one or two dirs' ' + git ls-files -o --exclude-standard an_ignored_dir/ an_untracked_dir/ >tmp && + ! grep ^an_ignored_dir/ tmp >expect && + git ls-files -o --exclude-standard an_ignored_dir/ >actual && + test_cmp expect actual +' + +# ls-files doesn't have a way to request showing both untracked and ignored +# files at the same time, so use `git status --ignored` +test_expect_success 'git status --ignored shows same files under dir with or without pathspec' ' + cat <<-EOF >expect && + ?? an_untracked_dir/ + !! an_untracked_dir/ignored + EOF + git status --porcelain --ignored >output && + grep an_untracked_dir output >expect && + git status --porcelain --ignored an_untracked_dir/ >actual && + test_cmp expect actual +' + +test_done diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index ff641b348a1b..d48d211a9540 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -452,6 +452,34 @@ test_expect_success 'merge-recursive d/f conflict result' ' ' +test_expect_success SYMLINKS 'dir in working tree with symlink ancestor does not produce d/f conflict' ' + git init sym && + ( + cd sym && + ln -s . foo && + mkdir bar && + >bar/file && + git add foo bar/file && + git commit -m "foo symlink" && + + git checkout -b branch1 && + git commit --allow-empty -m "empty commit" && + + git checkout master && + git rm foo && + mkdir foo && + >foo/bar && + git add foo/bar && + git commit -m "replace foo symlink with real foo dir and foo/bar file" && + + git checkout branch1 && + + git cherry-pick master && + test_path_is_dir foo && + test_path_is_file foo/bar + ) +' + test_expect_success 'reset and 3-way merge' ' git reset --hard "$c2" && @@ -576,7 +604,7 @@ test_expect_success 'merge removes empty directories' ' git commit -mremoved-d/e && git checkout master && git merge -s recursive rm && - test_must_fail test -d d + test_path_is_missing d ' test_expect_success 'merge-recursive simple w/submodule' ' @@ -667,15 +695,22 @@ test_expect_success 'merging with triple rename across D/F conflict' ' test_expect_success 'merge-recursive remembers the names of all base trees' ' git reset --hard HEAD && + # make the index match $c1 so that merge-recursive below does not + # fail early + git diff --binary HEAD $c1 -- | git apply --cached && + # more trees than static slots used by oid_to_hex() for commit in $c0 $c2 $c4 $c5 $c6 $c7 do git rev-parse "$commit^{tree}" done >trees && - # ignore the return code -- it only fails because the input is weird + # ignore the return code; it only fails because the input is weird... test_must_fail git -c merge.verbosity=5 merge-recursive $(cat trees) -- $c1 $c3 >out && + # ...but make sure it fails in the expected way + test_i18ngrep CONFLICT.*rename/rename out && + # merge-recursive prints in reverse order, but we do not care sort expect && sed -n "s/^virtual //p" out | sort >actual && diff --git a/t/t3035-merge-sparse.sh b/t/t3035-merge-sparse.sh index c4b4a94324a2..74562e123566 100755 --- a/t/t3035-merge-sparse.sh +++ b/t/t3035-merge-sparse.sh @@ -28,7 +28,7 @@ test_expect_success 'setup' ' git config core.sparseCheckout true && echo "/checked-out" >.git/info/sparse-checkout && git reset --hard && - ! git merge theirs + test_must_fail git merge theirs ' test_expect_success 'reset --hard works after the conflict' ' @@ -42,7 +42,7 @@ test_expect_success 'is reset properly' ' ' test_expect_success 'setup: conflict back' ' - ! git merge theirs + test_must_fail git merge theirs ' test_expect_success 'Merge abort works after the conflict' ' diff --git a/t/t3060-ls-files-with-tree.sh b/t/t3060-ls-files-with-tree.sh index 44f378ce41d2..52ed665fcd2d 100755 --- a/t/t3060-ls-files-with-tree.sh +++ b/t/t3060-ls-files-with-tree.sh @@ -47,7 +47,7 @@ test_expect_success setup ' git add . ' -test_expect_success 'git -ls-files --with-tree should succeed from subdir' ' +test_expect_success 'git ls-files --with-tree should succeed from subdir' ' # We have to run from a sub-directory to trigger prune_path # Then we finally get to run our --with-tree test ( @@ -57,7 +57,7 @@ test_expect_success 'git -ls-files --with-tree should succeed from subdir' ' ' test_expect_success \ - 'git -ls-files --with-tree should add entries from named tree.' \ + 'git ls-files --with-tree should add entries from named tree.' \ 'test_cmp expected output' test_done diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh index 0ea4fc46949d..40251c9f8f68 100755 --- a/t/t3201-branch-contains.sh +++ b/t/t3201-branch-contains.sh @@ -192,10 +192,10 @@ test_expect_success 'branch --merged with --verbose' ' EOF test_cmp expect actual && git branch --verbose --merged topic >actual && - cat >expect <<-\EOF && - master c77a0a9 second on master - * topic 2c939f4 [ahead 1] foo - zzz c77a0a9 second on master + cat >expect <<-EOF && + master $(git rev-parse --short master) second on master + * topic $(git rev-parse --short topic ) [ahead 1] foo + zzz $(git rev-parse --short zzz ) second on master EOF test_i18ncmp expect actual ' diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index ec548654ce1c..bd808f87ed5b 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -8,97 +8,212 @@ test_description='range-diff tests' # harm than good. We need some real history. test_expect_success 'setup' ' - git fast-import < "$TEST_DIRECTORY"/t3206/history.export + git fast-import <"$TEST_DIRECTORY"/t3206/history.export && + test_oid_cache <<-\EOF + # topic + t1 sha1:4de457d + t2 sha1:fccce22 + t3 sha1:147e64e + t4 sha1:a63e992 + t1 sha256:b89f8b9 + t2 sha256:5f12aad + t3 sha256:ea8b273 + t4 sha256:14b7336 + + # unmodified + u1 sha1:35b9b25 + u2 sha1:de345ab + u3 sha1:9af6654 + u4 sha1:2901f77 + u1 sha256:e3731be + u2 sha256:14fadf8 + u3 sha256:736c4bc + u4 sha256:673e77d + + # reordered + r1 sha1:aca177a + r2 sha1:14ad629 + r3 sha1:ee58208 + r4 sha1:307b27a + r1 sha256:f59d3aa + r2 sha256:fb261a8 + r3 sha256:cb2649b + r4 sha256:958577e + + # removed (deleted) + d1 sha1:7657159 + d2 sha1:43d84d3 + d3 sha1:a740396 + d1 sha256:e312513 + d2 sha256:eb19258 + d3 sha256:1ccb3c1 + + # added + a1 sha1:2716022 + a2 sha1:b62accd + a3 sha1:df46cfa + a4 sha1:3e64548 + a5 sha1:12b4063 + a1 sha256:d724f4d + a2 sha256:1de7762 + a3 sha256:e159431 + a4 sha256:b3e483c + a5 sha256:90866a7 + + # rebased + b1 sha1:cc9c443 + b2 sha1:c5d9641 + b3 sha1:28cc2b6 + b4 sha1:5628ab7 + b5 sha1:a31b12e + b1 sha256:a1a8717 + b2 sha256:20a5862 + b3 sha256:587172a + b4 sha256:2721c5d + b5 sha256:7b57864 + + # changed + c1 sha1:a4b3333 + c2 sha1:f51d370 + c3 sha1:0559556 + c4 sha1:d966c5c + c1 sha256:f8c2b9d + c2 sha256:3fb6318 + c3 sha256:168ab68 + c4 sha256:3526539 + + # changed-message + m1 sha1:f686024 + m2 sha1:4ab067d + m3 sha1:b9cb956 + m4 sha1:8add5f1 + m1 sha256:31e6281 + m2 sha256:a06bf1b + m3 sha256:82dc654 + m4 sha256:48470c5 + + # renamed + n1 sha1:f258d75 + n2 sha1:017b62d + n3 sha1:3ce7af6 + n4 sha1:1e6226b + n1 sha256:ad52114 + n2 sha256:3b54c8f + n3 sha256:3b0a644 + n4 sha256:e461653 + + # mode change + o1 sha1:4d39cb3 + o2 sha1:26c107f + o3 sha1:4c1e0f5 + o1 sha256:d0dd598 + o2 sha256:c4a279e + o3 sha256:78459d7 + + # added and removed + s1 sha1:096b1ba + s2 sha1:d92e698 + s3 sha1:9a1db4d + s4 sha1:fea3b5c + s1 sha256:a7f9134 + s2 sha256:b4c2580 + s3 sha256:1d62aa2 + s4 sha256:48160e8 + + # Empty delimiter (included so lines match neatly) + __ sha1:------- + __ sha256:------- + EOF ' test_expect_success 'simple A..B A..C (unmodified)' ' git range-diff --no-color master..topic master..unmodified \ >actual && - cat >expected <<-EOF && - 1: 4de457d = 1: 35b9b25 s/5/A/ - 2: fccce22 = 2: de345ab s/4/A/ - 3: 147e64e = 3: 9af6654 s/11/B/ - 4: a63e992 = 4: 2901f77 s/12/B/ + cat >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ + 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ + 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ + 4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/ EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'simple B...C (unmodified)' ' git range-diff --no-color topic...unmodified >actual && - # same "expected" as above - test_cmp expected actual + # same "expect" as above + test_cmp expect actual ' test_expect_success 'simple A B C (unmodified)' ' git range-diff --no-color master topic unmodified >actual && - # same "expected" as above - test_cmp expected actual + # same "expect" as above + test_cmp expect actual ' test_expect_success 'trivial reordering' ' git range-diff --no-color master topic reordered >actual && - cat >expected <<-EOF && - 1: 4de457d = 1: aca177a s/5/A/ - 3: 147e64e = 2: 14ad629 s/11/B/ - 4: a63e992 = 3: ee58208 s/12/B/ - 2: fccce22 = 4: 307b27a s/4/A/ + cat >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid r1) s/5/A/ + 3: $(test_oid t3) = 2: $(test_oid r2) s/11/B/ + 4: $(test_oid t4) = 3: $(test_oid r3) s/12/B/ + 2: $(test_oid t2) = 4: $(test_oid r4) s/4/A/ EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'removed a commit' ' git range-diff --no-color master topic removed >actual && - cat >expected <<-EOF && - 1: 4de457d = 1: 7657159 s/5/A/ - 2: fccce22 < -: ------- s/4/A/ - 3: 147e64e = 2: 43d84d3 s/11/B/ - 4: a63e992 = 3: a740396 s/12/B/ + cat >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid d1) s/5/A/ + 2: $(test_oid t2) < -: $(test_oid __) s/4/A/ + 3: $(test_oid t3) = 2: $(test_oid d2) s/11/B/ + 4: $(test_oid t4) = 3: $(test_oid d3) s/12/B/ EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'added a commit' ' git range-diff --no-color master topic added >actual && - cat >expected <<-EOF && - 1: 4de457d = 1: 2716022 s/5/A/ - 2: fccce22 = 2: b62accd s/4/A/ - -: ------- > 3: df46cfa s/6/A/ - 3: 147e64e = 4: 3e64548 s/11/B/ - 4: a63e992 = 5: 12b4063 s/12/B/ + cat >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid a1) s/5/A/ + 2: $(test_oid t2) = 2: $(test_oid a2) s/4/A/ + -: $(test_oid __) > 3: $(test_oid a3) s/6/A/ + 3: $(test_oid t3) = 4: $(test_oid a4) s/11/B/ + 4: $(test_oid t4) = 5: $(test_oid a5) s/12/B/ EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'new base, A B C' ' git range-diff --no-color master topic rebased >actual && - cat >expected <<-EOF && - 1: 4de457d = 1: cc9c443 s/5/A/ - 2: fccce22 = 2: c5d9641 s/4/A/ - 3: 147e64e = 3: 28cc2b6 s/11/B/ - 4: a63e992 = 4: 5628ab7 s/12/B/ + cat >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid b1) s/5/A/ + 2: $(test_oid t2) = 2: $(test_oid b2) s/4/A/ + 3: $(test_oid t3) = 3: $(test_oid b3) s/11/B/ + 4: $(test_oid t4) = 4: $(test_oid b4) s/12/B/ EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'new base, B...C' ' # this syntax includes the commits from master! git range-diff --no-color topic...rebased >actual && - cat >expected <<-EOF && - -: ------- > 1: a31b12e unrelated - 1: 4de457d = 2: cc9c443 s/5/A/ - 2: fccce22 = 3: c5d9641 s/4/A/ - 3: 147e64e = 4: 28cc2b6 s/11/B/ - 4: a63e992 = 5: 5628ab7 s/12/B/ + cat >expect <<-EOF && + -: $(test_oid __) > 1: $(test_oid b5) unrelated + 1: $(test_oid t1) = 2: $(test_oid b1) s/5/A/ + 2: $(test_oid t2) = 3: $(test_oid b2) s/4/A/ + 3: $(test_oid t3) = 4: $(test_oid b3) s/11/B/ + 4: $(test_oid t4) = 5: $(test_oid b4) s/12/B/ EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'changed commit' ' git range-diff --no-color topic...changed >actual && - cat >expected <<-EOF && - 1: 4de457d = 1: a4b3333 s/5/A/ - 2: fccce22 = 2: f51d370 s/4/A/ - 3: 147e64e ! 3: 0559556 s/11/B/ + cat >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ + 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ + 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ @@ file: A 9 10 @@ -108,7 +223,7 @@ test_expect_success 'changed commit' ' 12 13 14 - 4: a63e992 ! 4: d966c5c s/12/B/ + 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ @@ file @@ file: A 9 @@ -119,45 +234,45 @@ test_expect_success 'changed commit' ' +B 13 EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'changed commit with --no-patch diff option' ' git range-diff --no-color --no-patch topic...changed >actual && - cat >expected <<-EOF && - 1: 4de457d = 1: a4b3333 s/5/A/ - 2: fccce22 = 2: f51d370 s/4/A/ - 3: 147e64e ! 3: 0559556 s/11/B/ - 4: a63e992 ! 4: d966c5c s/12/B/ + cat >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ + 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ + 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ + 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'changed commit with --stat diff option' ' git range-diff --no-color --stat topic...changed >actual && - cat >expected <<-EOF && - 1: 4de457d = 1: a4b3333 s/5/A/ + cat >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ a => b | 0 1 file changed, 0 insertions(+), 0 deletions(-) - 2: fccce22 = 2: f51d370 s/4/A/ + 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ a => b | 0 1 file changed, 0 insertions(+), 0 deletions(-) - 3: 147e64e ! 3: 0559556 s/11/B/ + 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ a => b | 0 1 file changed, 0 insertions(+), 0 deletions(-) - 4: a63e992 ! 4: d966c5c s/12/B/ + 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ a => b | 0 1 file changed, 0 insertions(+), 0 deletions(-) EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'changed commit with sm config' ' git range-diff --no-color --submodule=log topic...changed >actual && - cat >expected <<-EOF && - 1: 4de457d = 1: a4b3333 s/5/A/ - 2: fccce22 = 2: f51d370 s/4/A/ - 3: 147e64e ! 3: 0559556 s/11/B/ + cat >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ + 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ + 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ @@ file: A 9 10 @@ -167,7 +282,7 @@ test_expect_success 'changed commit with sm config' ' 12 13 14 - 4: a63e992 ! 4: d966c5c s/12/B/ + 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ @@ file @@ file: A 9 @@ -178,14 +293,14 @@ test_expect_success 'changed commit with sm config' ' +B 13 EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'renamed file' ' git range-diff --no-color --submodule=log topic...renamed-file >actual && - sed s/Z/\ /g >expected <<-EOF && - 1: 4de457d = 1: f258d75 s/5/A/ - 2: fccce22 ! 2: 017b62d s/4/A/ + sed s/Z/\ /g >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid n1) s/5/A/ + 2: $(test_oid t2) ! 2: $(test_oid n2) s/4/A/ @@ Metadata ZAuthor: Thomas Rast Z @@ -198,7 +313,7 @@ test_expect_success 'renamed file' ' Z@@ Z 1 Z 2 - 3: 147e64e ! 3: 3ce7af6 s/11/B/ + 3: $(test_oid t3) ! 3: $(test_oid n3) s/11/B/ @@ Metadata Z ## Commit message ## Z s/11/B/ @@ -210,7 +325,7 @@ test_expect_success 'renamed file' ' Z 8 Z 9 Z 10 - 4: a63e992 ! 4: 1e6226b s/12/B/ + 4: $(test_oid t4) ! 4: $(test_oid n4) s/12/B/ @@ Metadata Z ## Commit message ## Z s/12/B/ @@ -223,14 +338,54 @@ test_expect_success 'renamed file' ' Z 10 Z B EOF - test_cmp expected actual + test_cmp expect actual +' + +test_expect_success 'file with mode only change' ' + git range-diff --no-color --submodule=log topic...mode-only-change >actual && + sed s/Z/\ /g >expect <<-EOF && + 1: $(test_oid t2) ! 1: $(test_oid o1) s/4/A/ + @@ Metadata + ZAuthor: Thomas Rast + Z + Z ## Commit message ## + - s/4/A/ + + s/4/A/ + add other-file + Z + Z ## file ## + Z@@ + @@ file + Z A + Z 6 + Z 7 + + + + ## other-file (new) ## + 2: $(test_oid t3) ! 2: $(test_oid o2) s/11/B/ + @@ Metadata + ZAuthor: Thomas Rast + Z + Z ## Commit message ## + - s/11/B/ + + s/11/B/ + mode change other-file + Z + Z ## file ## + Z@@ file: A + @@ file: A + Z 12 + Z 13 + Z 14 + + + + ## other-file (mode change 100644 => 100755) ## + 3: $(test_oid t4) = 3: $(test_oid o3) s/12/B/ + EOF + test_cmp expect actual ' test_expect_success 'file added and later removed' ' git range-diff --no-color --submodule=log topic...added-removed >actual && - sed s/Z/\ /g >expected <<-EOF && - 1: 4de457d = 1: 096b1ba s/5/A/ - 2: fccce22 ! 2: d92e698 s/4/A/ + sed s/Z/\ /g >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid s1) s/5/A/ + 2: $(test_oid t2) ! 2: $(test_oid s2) s/4/A/ @@ Metadata ZAuthor: Thomas Rast Z @@ -246,7 +401,7 @@ test_expect_success 'file added and later removed' ' Z 7 + + ## new-file (new) ## - 3: 147e64e ! 3: 9a1db4d s/11/B/ + 3: $(test_oid t3) ! 3: $(test_oid s3) s/11/B/ @@ Metadata ZAuthor: Thomas Rast Z @@ -262,9 +417,9 @@ test_expect_success 'file added and later removed' ' Z 14 + + ## new-file (deleted) ## - 4: a63e992 = 4: fea3b5c s/12/B/ + 4: $(test_oid t4) = 4: $(test_oid s4) s/12/B/ EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'no commits on one side' ' @@ -274,9 +429,9 @@ test_expect_success 'no commits on one side' ' test_expect_success 'changed message' ' git range-diff --no-color topic...changed-message >actual && - sed s/Z/\ /g >expected <<-EOF && - 1: 4de457d = 1: f686024 s/5/A/ - 2: fccce22 ! 2: 4ab067d s/4/A/ + sed s/Z/\ /g >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid m1) s/5/A/ + 2: $(test_oid t2) ! 2: $(test_oid m2) s/4/A/ @@ Metadata Z ## Commit message ## Z s/4/A/ @@ -286,16 +441,16 @@ test_expect_success 'changed message' ' Z ## file ## Z@@ Z 1 - 3: 147e64e = 3: b9cb956 s/11/B/ - 4: a63e992 = 4: 8add5f1 s/12/B/ + 3: $(test_oid t3) = 3: $(test_oid m3) s/11/B/ + 4: $(test_oid t4) = 4: $(test_oid m4) s/12/B/ EOF - test_cmp expected actual + test_cmp expect actual ' test_expect_success 'dual-coloring' ' - sed -e "s|^:||" >expect <<-\EOF && - :1: a4b3333 = 1: f686024 s/5/A/ - :2: f51d370 ! 2: 4ab067d s/4/A/ + sed -e "s|^:||" >expect <<-EOF && + :1: $(test_oid c1) = 1: $(test_oid m1) s/5/A/ + :2: $(test_oid c2) ! 2: $(test_oid m2) s/4/A/ : @@ Metadata : ## Commit message ## : s/4/A/ @@ -305,7 +460,7 @@ test_expect_success 'dual-coloring' ' : ## file ## : @@ : 1 - :3: 0559556 ! 3: b9cb956 s/11/B/ + :3: $(test_oid c3) ! 3: $(test_oid m3) s/11/B/ : @@ file: A : 9 : 10 @@ -315,7 +470,7 @@ test_expect_success 'dual-coloring' ' : 12 : 13 : 14 - :4: d966c5c ! 4: 8add5f1 s/12/B/ + :4: $(test_oid c4) ! 4: $(test_oid m4) s/12/B/ : @@ file : @@ file: A : 9 @@ -354,4 +509,206 @@ test_expect_success 'format-patch --range-diff as commentary' ' grep "> 1: .* new message" 0001-* ' +test_expect_success 'range-diff overrides diff.noprefix internally' ' + git -c diff.noprefix=true range-diff HEAD^... +' + +test_expect_success 'range-diff compares notes by default' ' + git notes add -m "topic note" topic && + git notes add -m "unmodified note" unmodified && + test_when_finished git notes remove topic unmodified && + git range-diff --no-color master..topic master..unmodified \ + >actual && + sed s/Z/\ /g >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ + 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ + 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ + 4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/ + @@ Commit message + Z + Z + Z ## Notes ## + - topic note + + unmodified note + Z + Z ## file ## + Z@@ file: A + EOF + test_cmp expect actual +' + +test_expect_success 'range-diff with --no-notes' ' + git notes add -m "topic note" topic && + git notes add -m "unmodified note" unmodified && + test_when_finished git notes remove topic unmodified && + git range-diff --no-color --no-notes master..topic master..unmodified \ + >actual && + cat >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ + 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ + 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ + 4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/ + EOF + test_cmp expect actual +' + +test_expect_success 'range-diff with multiple --notes' ' + git notes --ref=note1 add -m "topic note1" topic && + git notes --ref=note1 add -m "unmodified note1" unmodified && + test_when_finished git notes --ref=note1 remove topic unmodified && + git notes --ref=note2 add -m "topic note2" topic && + git notes --ref=note2 add -m "unmodified note2" unmodified && + test_when_finished git notes --ref=note2 remove topic unmodified && + git range-diff --no-color --notes=note1 --notes=note2 master..topic master..unmodified \ + >actual && + sed s/Z/\ /g >expect <<-EOF && + 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ + 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ + 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ + 4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/ + @@ Commit message + Z + Z + Z ## Notes (note1) ## + - topic note1 + + unmodified note1 + Z + Z + Z ## Notes (note2) ## + - topic note2 + + unmodified note2 + Z + Z ## file ## + Z@@ file: A + EOF + test_cmp expect actual +' + +test_expect_success 'format-patch --range-diff does not compare notes by default' ' + git notes add -m "topic note" topic && + git notes add -m "unmodified note" unmodified && + test_when_finished git notes remove topic unmodified && + git format-patch --cover-letter --range-diff=$prev \ + master..unmodified >actual && + test_when_finished "rm 000?-*" && + test_line_count = 5 actual && + test_i18ngrep "^Range-diff:$" 0000-* && + grep "= 1: .* s/5/A" 0000-* && + grep "= 2: .* s/4/A" 0000-* && + grep "= 3: .* s/11/B" 0000-* && + grep "= 4: .* s/12/B" 0000-* && + ! grep "Notes" 0000-* && + ! grep "note" 0000-* +' + +test_expect_success 'format-patch --range-diff with --no-notes' ' + git notes add -m "topic note" topic && + git notes add -m "unmodified note" unmodified && + test_when_finished git notes remove topic unmodified && + git format-patch --no-notes --cover-letter --range-diff=$prev \ + master..unmodified >actual && + test_when_finished "rm 000?-*" && + test_line_count = 5 actual && + test_i18ngrep "^Range-diff:$" 0000-* && + grep "= 1: .* s/5/A" 0000-* && + grep "= 2: .* s/4/A" 0000-* && + grep "= 3: .* s/11/B" 0000-* && + grep "= 4: .* s/12/B" 0000-* && + ! grep "Notes" 0000-* && + ! grep "note" 0000-* +' + +test_expect_success 'format-patch --range-diff with --notes' ' + git notes add -m "topic note" topic && + git notes add -m "unmodified note" unmodified && + test_when_finished git notes remove topic unmodified && + git format-patch --notes --cover-letter --range-diff=$prev \ + master..unmodified >actual && + test_when_finished "rm 000?-*" && + test_line_count = 5 actual && + test_i18ngrep "^Range-diff:$" 0000-* && + grep "= 1: .* s/5/A" 0000-* && + grep "= 2: .* s/4/A" 0000-* && + grep "= 3: .* s/11/B" 0000-* && + grep "! 4: .* s/12/B" 0000-* && + sed s/Z/\ /g >expect <<-EOF && + @@ Commit message + Z + Z + Z ## Notes ## + - topic note + + unmodified note + Z + Z ## file ## + Z@@ file: A + EOF + sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual && + test_cmp expect actual +' + +test_expect_success 'format-patch --range-diff with format.notes config' ' + git notes add -m "topic note" topic && + git notes add -m "unmodified note" unmodified && + test_when_finished git notes remove topic unmodified && + test_config format.notes true && + git format-patch --cover-letter --range-diff=$prev \ + master..unmodified >actual && + test_when_finished "rm 000?-*" && + test_line_count = 5 actual && + test_i18ngrep "^Range-diff:$" 0000-* && + grep "= 1: .* s/5/A" 0000-* && + grep "= 2: .* s/4/A" 0000-* && + grep "= 3: .* s/11/B" 0000-* && + grep "! 4: .* s/12/B" 0000-* && + sed s/Z/\ /g >expect <<-EOF && + @@ Commit message + Z + Z + Z ## Notes ## + - topic note + + unmodified note + Z + Z ## file ## + Z@@ file: A + EOF + sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual && + test_cmp expect actual +' + +test_expect_success 'format-patch --range-diff with multiple notes' ' + git notes --ref=note1 add -m "topic note1" topic && + git notes --ref=note1 add -m "unmodified note1" unmodified && + test_when_finished git notes --ref=note1 remove topic unmodified && + git notes --ref=note2 add -m "topic note2" topic && + git notes --ref=note2 add -m "unmodified note2" unmodified && + test_when_finished git notes --ref=note2 remove topic unmodified && + git format-patch --notes=note1 --notes=note2 --cover-letter --range-diff=$prev \ + master..unmodified >actual && + test_when_finished "rm 000?-*" && + test_line_count = 5 actual && + test_i18ngrep "^Range-diff:$" 0000-* && + grep "= 1: .* s/5/A" 0000-* && + grep "= 2: .* s/4/A" 0000-* && + grep "= 3: .* s/11/B" 0000-* && + grep "! 4: .* s/12/B" 0000-* && + sed s/Z/\ /g >expect <<-EOF && + @@ Commit message + Z + Z + Z ## Notes (note1) ## + - topic note1 + + unmodified note1 + Z + Z + Z ## Notes (note2) ## + - topic note2 + + unmodified note2 + Z + Z ## file ## + Z@@ file: A + EOF + sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual && + test_cmp expect actual +' + test_done diff --git a/t/t3206/history.export b/t/t3206/history.export index 7bb381496227..4c808e5b3b8d 100644 --- a/t/t3206/history.export +++ b/t/t3206/history.export @@ -55,7 +55,7 @@ A 19 20 -commit refs/heads/topic +commit refs/heads/mode-only-change mark :4 author Thomas Rast 1374485014 +0200 committer Thomas Rast 1374485014 +0200 @@ -678,3 +678,32 @@ s/12/B/ from :55 M 100644 :9 renamed-file +commit refs/heads/mode-only-change +mark :57 +author Thomas Rast 1374485024 +0200 +committer Thomas Gummerer 1570473767 +0100 +data 24 +s/4/A/ + add other-file +from :4 +M 100644 :5 file +M 100644 :49 other-file + +commit refs/heads/mode-only-change +mark :58 +author Thomas Rast 1374485036 +0200 +committer Thomas Gummerer 1570473768 +0100 +data 33 +s/11/B/ + mode change other-file +from :57 +M 100644 :7 file +M 100755 :49 other-file + +commit refs/heads/mode-only-change +mark :59 +author Thomas Rast 1374485044 +0200 +committer Thomas Gummerer 1570473768 +0100 +data 8 +s/12/B/ +from :58 +M 100644 :9 file + diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index 9ea5fa4fd246..f41b2afb9964 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -240,7 +240,7 @@ test_expect_success 'retry acquiring packed-refs.lock' ' test_expect_success SYMLINKS 'pack symlinked packed-refs' ' # First make sure that symlinking works when reading: - git update-ref refs/heads/loosy refs/heads/master && + git update-ref refs/heads/lossy refs/heads/master && git for-each-ref >all-refs-before && mv .git/packed-refs .git/my-deviant-packed-refs && ln -s my-deviant-packed-refs .git/packed-refs && diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index 704bbc65419c..8f4330300707 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@ -54,7 +54,9 @@ test_expect_success 'create notes' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b4" = "$(git notes show)" && + echo b4 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' @@ -66,8 +68,9 @@ test_expect_success 'show notes entry with %N' ' ' test_expect_success 'create reflog entry' ' + ref=$(git rev-parse --short refs/notes/commits) && cat <<-EOF >expect && - a1d8fa6 refs/notes/commits@{0}: notes: Notes added by '\''git notes add'\'' + $ref refs/notes/commits@{0}: notes: Notes added by '\''git notes add'\'' EOF git reflog show refs/notes/commits >actual && test_cmp expect actual @@ -78,14 +81,21 @@ test_expect_success 'edit existing notes' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b3" = "$(git notes show)" && + echo b3 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' test_expect_success 'show notes from treeish' ' - test "b3" = "$(git notes --ref commits^{tree} show)" && - test "b4" = "$(git notes --ref commits@{1} show)" + echo b3 >expect && + git notes --ref commits^{tree} show >actual && + test_cmp expect actual && + + echo b4 >expect && + git notes --ref commits@{1} show >actual && + test_cmp expect actual ' test_expect_success 'cannot edit notes from non-ref' ' @@ -98,7 +108,9 @@ test_expect_success 'cannot "git notes add -m" where notes already exists' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b3" = "$(git notes show)" && + echo b3 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' @@ -108,7 +120,9 @@ test_expect_success 'can overwrite existing note with "git notes add -f -m"' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b1" = "$(git notes show)" && + echo b1 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' @@ -118,7 +132,9 @@ test_expect_success 'add w/no options on existing note morphs into edit' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b2" = "$(git notes show)" && + echo b2 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' @@ -128,14 +144,17 @@ test_expect_success 'can overwrite existing note with "git notes add -f"' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b1" = "$(git notes show)" && + echo b1 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' test_expect_success 'show notes' ' + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit 7a4ca6ee52a974a66cbaa78e33214535dff1d691 + commit $commit Author: A U Thor Date: Thu Apr 7 15:14:13 2005 -0700 @@ -144,7 +163,8 @@ test_expect_success 'show notes' ' Notes: ${indent}b1 EOF - ! (git cat-file commit HEAD | grep b1) && + git cat-file commit HEAD >commits && + ! grep b1 commits && git log -1 >actual && test_cmp expect actual ' @@ -152,8 +172,9 @@ test_expect_success 'show notes' ' test_expect_success 'show multi-line notes' ' test_commit 3rd && MSG="b3${LF}c3c3c3c3${LF}d3d3d3" git notes add && + commit=$(git rev-parse HEAD) && cat >expect-multiline <<-EOF && - commit d07d62e5208f22eb5695e7eb47667dc8b9860290 + commit $commit Author: A U Thor Date: Thu Apr 7 15:15:13 2005 -0700 @@ -174,8 +195,9 @@ test_expect_success 'show -F notes' ' test_commit 4th && echo "xyzzy" >note5 && git notes add -F note5 && + commit=$(git rev-parse HEAD) && cat >expect-F <<-EOF && - commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11 + commit $commit Author: A U Thor Date: Thu Apr 7 15:16:13 2005 -0700 @@ -198,10 +220,13 @@ test_expect_success 'Re-adding -F notes without -f fails' ' ' test_expect_success 'git log --pretty=raw does not show notes' ' + commit=$(git rev-parse HEAD) && + tree=$(git rev-parse HEAD^{tree}) && + parent=$(git rev-parse HEAD^) && cat >expect <<-EOF && - commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11 - tree 05ac65288c4c4b3b709a020ae94b2ece2f2201ae - parent d07d62e5208f22eb5695e7eb47667dc8b9860290 + commit $commit + tree $tree + parent $parent author A U Thor 1112912173 -0700 committer C O Mitter 1112912173 -0700 @@ -291,8 +316,9 @@ test_expect_success 'git log --no-notes resets ref list' ' test_expect_success 'show -m notes' ' test_commit 5th && git notes add -m spam -m "foo${LF}bar${LF}baz" && + commit=$(git rev-parse HEAD) && cat >expect-m <<-EOF && - commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + commit $commit Author: A U Thor Date: Thu Apr 7 15:17:13 2005 -0700 @@ -313,8 +339,9 @@ test_expect_success 'show -m notes' ' test_expect_success 'remove note with add -f -F /dev/null' ' git notes add -f -F /dev/null && + commit=$(git rev-parse HEAD) && cat >expect-rm-F <<-EOF && - commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + commit $commit Author: A U Thor Date: Thu Apr 7 15:17:13 2005 -0700 @@ -356,14 +383,16 @@ test_expect_success 'create note with combination of -m and -F' ' test_expect_success 'remove note with "git notes remove"' ' git notes remove HEAD^ && git notes remove && + commit=$(git rev-parse HEAD) && + parent=$(git rev-parse HEAD^) && cat >expect-rm-remove <<-EOF && - commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + commit $commit Author: A U Thor Date: Thu Apr 7 15:17:13 2005 -0700 ${indent}5th - commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11 + commit $parent Author: A U Thor Date: Thu Apr 7 15:16:13 2005 -0700 @@ -459,9 +488,13 @@ test_expect_success 'removing with --stdin --ignore-missing' ' ' test_expect_success 'list notes with "git notes list"' ' - cat >expect <<-EOF && - c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 7a4ca6ee52a974a66cbaa78e33214535dff1d691 - c18dc024e14f08d18d14eea0d747ff692d66d6a3 d07d62e5208f22eb5695e7eb47667dc8b9860290 + commit_2=$(git rev-parse 2nd) && + commit_3=$(git rev-parse 3rd) && + note_2=$(git rev-parse refs/notes/commits:$commit_2) && + note_3=$(git rev-parse refs/notes/commits:$commit_3) && + sort -t" " -k2 >expect <<-EOF && + $note_2 $commit_2 + $note_3 $commit_3 EOF git notes list >actual && test_cmp expect actual @@ -473,9 +506,7 @@ test_expect_success 'list notes with "git notes"' ' ' test_expect_success 'list specific note with "git notes list "' ' - cat >expect <<-EOF && - c18dc024e14f08d18d14eea0d747ff692d66d6a3 - EOF + git rev-parse refs/notes/commits:$commit_3 >expect && git notes list HEAD^^ >actual && test_cmp expect actual ' @@ -498,10 +529,12 @@ test_expect_success 'append to existing note with "git notes append"' ' ' test_expect_success '"git notes list" does not expand to "git notes list HEAD"' ' - cat >expect_list <<-EOF && - c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 7a4ca6ee52a974a66cbaa78e33214535dff1d691 - 4b6ad22357cc8a1296720574b8d2fbc22fab0671 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 - c18dc024e14f08d18d14eea0d747ff692d66d6a3 d07d62e5208f22eb5695e7eb47667dc8b9860290 + commit_5=$(git rev-parse 5th) && + note_5=$(git rev-parse refs/notes/commits:$commit_5) && + sort -t" " -k2 >expect_list <<-EOF && + $note_2 $commit_2 + $note_3 $commit_3 + $note_5 $commit_5 EOF git notes list >actual && test_cmp expect_list actual @@ -531,8 +564,9 @@ test_expect_success 'appending empty string to non-existing note does not create test_expect_success 'create other note on a different notes ref (setup)' ' test_commit 6th && GIT_NOTES_REF="refs/notes/other" git notes add -m "other note" && + commit=$(git rev-parse HEAD) && cat >expect-not-other <<-EOF && - commit 2c125331118caba0ff8238b7f4958ac6e93fe39c + commit $commit Author: A U Thor Date: Thu Apr 7 15:18:13 2005 -0700 @@ -569,8 +603,10 @@ test_expect_success 'Do not show note when core.notesRef is overridden' ' ' test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' ' + commit=$(git rev-parse HEAD) && + parent=$(git rev-parse HEAD^) && cat >expect-both <<-EOF && - commit 2c125331118caba0ff8238b7f4958ac6e93fe39c + commit $commit Author: A U Thor Date: Thu Apr 7 15:18:13 2005 -0700 @@ -582,7 +618,7 @@ test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' ' Notes (other): ${indent}other note - commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + commit $parent Author: A U Thor Date: Thu Apr 7 15:17:13 2005 -0700 @@ -616,8 +652,9 @@ test_expect_success 'notes.displayRef can be given more than once' ' ' test_expect_success 'notes.displayRef respects order' ' + commit=$(git rev-parse HEAD) && cat >expect-both-reversed <<-EOF && - commit 2c125331118caba0ff8238b7f4958ac6e93fe39c + commit $commit Author: A U Thor Date: Thu Apr 7 15:18:13 2005 -0700 @@ -642,14 +679,16 @@ test_expect_success 'GIT_NOTES_DISPLAY_REF works' ' ' test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' ' + commit=$(git rev-parse HEAD) && + parent=$(git rev-parse HEAD^) && cat >expect-none <<-EOF && - commit 2c125331118caba0ff8238b7f4958ac6e93fe39c + commit $commit Author: A U Thor Date: Thu Apr 7 15:18:13 2005 -0700 ${indent}6th - commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361 + commit $parent Author: A U Thor Date: Thu Apr 7 15:17:13 2005 -0700 @@ -666,8 +705,9 @@ test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' ' ' test_expect_success '--no-standard-notes' ' + commit=$(git rev-parse HEAD) && cat >expect-commits <<-EOF && - commit 2c125331118caba0ff8238b7f4958ac6e93fe39c + commit $commit Author: A U Thor Date: Thu Apr 7 15:18:13 2005 -0700 @@ -700,7 +740,8 @@ test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' ' git notes show HEAD: >actual && test_cmp expect actual && echo "Note on a blob" >expect && - filename=$(git ls-tree --name-only HEAD | head -n1) && + git ls-tree --name-only HEAD >files && + filename=$(head -n1 files) && git notes add -m "Note on a blob" HEAD:$filename && git notes show HEAD:$filename >actual && test_cmp expect actual && @@ -712,8 +753,10 @@ test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' ' ' test_expect_success 'create note from other note with "git notes add -C"' ' + test_commit 7th && + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit fb01e0ca8c33b6cc0c6451dde747f97df567cb5c + commit $commit Author: A U Thor Date: Thu Apr 7 15:19:13 2005 -0700 @@ -722,11 +765,13 @@ test_expect_success 'create note from other note with "git notes add -C"' ' Notes: ${indent}order test EOF - test_commit 7th && - git notes add -C $(git notes list HEAD^) && + note=$(git notes list HEAD^) && + git notes add -C $note && git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD^)" + git notes list HEAD^ >expect && + git notes list HEAD >actual && + test_cmp expect actual ' test_expect_success 'create note from non-existing note with "git notes add -C" fails' ' @@ -744,8 +789,9 @@ test_expect_success 'create note from non-blob with "git notes add -C" fails' ' ' test_expect_success 'create note from blob with "git notes add -C" reuses blob id' ' + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit 9a4c31c7f722b5d517e92c64e932dd751e1413bf + commit $commit Author: A U Thor Date: Thu Apr 7 15:20:13 2005 -0700 @@ -754,16 +800,19 @@ test_expect_success 'create note from blob with "git notes add -C" reuses blob i Notes: ${indent}This is a blob object EOF - blob=$(echo "This is a blob object" | git hash-object -w --stdin) && - git notes add -C $blob && + echo "This is a blob object" | git hash-object -w --stdin >blob && + git notes add -C $(cat blob) && git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$blob" + git notes list HEAD >actual && + test_cmp blob actual ' test_expect_success 'create note from other note with "git notes add -c"' ' + test_commit 9th && + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit 2e0db4bc649e174d667a1cde19e725cf897a5bd2 + commit $commit Author: A U Thor Date: Thu Apr 7 15:21:13 2005 -0700 @@ -772,8 +821,8 @@ test_expect_success 'create note from other note with "git notes add -c"' ' Notes: ${indent}yet another note EOF - test_commit 9th && - MSG="yet another note" git notes add -c $(git notes list HEAD^^) && + note=$(git notes list HEAD^^) && + MSG="yet another note" git notes add -c $note && git log -1 >actual && test_cmp expect actual ' @@ -785,8 +834,9 @@ test_expect_success 'create note from non-existing note with "git notes add -c" ' test_expect_success 'append to note from other note with "git notes append -C"' ' + commit=$(git rev-parse HEAD^) && cat >expect <<-EOF && - commit 2e0db4bc649e174d667a1cde19e725cf897a5bd2 + commit $commit Author: A U Thor Date: Thu Apr 7 15:21:13 2005 -0700 @@ -797,14 +847,16 @@ test_expect_success 'append to note from other note with "git notes append -C"' ${indent} ${indent}yet another note EOF - git notes append -C $(git notes list HEAD^) HEAD^ && + note=$(git notes list HEAD^) && + git notes append -C $note HEAD^ && git log -1 HEAD^ >actual && test_cmp expect actual ' test_expect_success 'create note from other note with "git notes append -c"' ' + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit 7c3b87ab368f81e11b1ea87b2ab99a71ccd25406 + commit $commit Author: A U Thor Date: Thu Apr 7 15:22:13 2005 -0700 @@ -813,14 +865,16 @@ test_expect_success 'create note from other note with "git notes append -c"' ' Notes: ${indent}other note EOF - MSG="other note" git notes append -c $(git notes list HEAD^) && + note=$(git notes list HEAD^) && + MSG="other note" git notes append -c $note && git log -1 >actual && test_cmp expect actual ' test_expect_success 'append to note from other note with "git notes append -c"' ' + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit 7c3b87ab368f81e11b1ea87b2ab99a71ccd25406 + commit $commit Author: A U Thor Date: Thu Apr 7 15:22:13 2005 -0700 @@ -831,14 +885,37 @@ test_expect_success 'append to note from other note with "git notes append -c"' ${indent} ${indent}yet another note EOF - MSG="yet another note" git notes append -c $(git notes list HEAD) && + note=$(git notes list HEAD) && + MSG="yet another note" git notes append -c $note && git log -1 >actual && test_cmp expect actual ' test_expect_success 'copy note with "git notes copy"' ' + commit=$(git rev-parse 4th) && cat >expect <<-EOF && - commit a446fff8777efdc6eb8f4b7c8a5ff699484df0d5 + commit $commit + Author: A U Thor + Date: Thu Apr 7 15:16:13 2005 -0700 + + ${indent}4th + + Notes: + ${indent}This is a blob object + EOF + git notes copy 8th 4th && + git log 3rd..4th >actual && + test_cmp expect actual && + git notes list 4th >expect && + git notes list 8th >actual && + test_cmp expect actual +' + +test_expect_success 'copy note with "git notes copy" with default' ' + test_commit 11th && + commit=$(git rev-parse HEAD) && + cat >expect <<-EOF && + commit $commit Author: A U Thor Date: Thu Apr 7 15:23:13 2005 -0700 @@ -849,23 +926,59 @@ test_expect_success 'copy note with "git notes copy"' ' ${indent} ${indent}yet another note EOF - test_commit 11th && - git notes copy HEAD^ HEAD && + git notes copy HEAD^ && git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD^)" + git notes list HEAD^ >expect && + git notes list HEAD >actual && + test_cmp expect actual ' test_expect_success 'prevent overwrite with "git notes copy"' ' test_must_fail git notes copy HEAD~2 HEAD && + cat >expect <<-EOF && + commit $commit + Author: A U Thor + Date: Thu Apr 7 15:23:13 2005 -0700 + + ${indent}11th + + Notes: + ${indent}other note + ${indent} + ${indent}yet another note + EOF git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD^)" + git notes list HEAD^ >expect && + git notes list HEAD >actual && + test_cmp expect actual ' test_expect_success 'allow overwrite with "git notes copy -f"' ' + commit=$(git rev-parse HEAD) && + cat >expect <<-EOF && + commit $commit + Author: A U Thor + Date: Thu Apr 7 15:23:13 2005 -0700 + + ${indent}11th + + Notes: + ${indent}This is a blob object + EOF + git notes copy -f HEAD~3 HEAD && + git log -1 >actual && + test_cmp expect actual && + git notes list HEAD~3 >expect && + git notes list HEAD >actual && + test_cmp expect actual +' + +test_expect_success 'allow overwrite with "git notes copy -f" with default' ' + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit a446fff8777efdc6eb8f4b7c8a5ff699484df0d5 + commit $commit Author: A U Thor Date: Thu Apr 7 15:23:13 2005 -0700 @@ -876,10 +989,12 @@ test_expect_success 'allow overwrite with "git notes copy -f"' ' ${indent} ${indent}yet another note EOF - git notes copy -f HEAD~2 HEAD && + git notes copy -f HEAD~2 && git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" + git notes list HEAD~2 >expect && + git notes list HEAD >actual && + test_cmp expect actual ' test_expect_success 'cannot copy note from object without notes' ' @@ -889,8 +1004,10 @@ test_expect_success 'cannot copy note from object without notes' ' ' test_expect_success 'git notes copy --stdin' ' + commit=$(git rev-parse HEAD) && + parent=$(git rev-parse HEAD^) && cat >expect <<-EOF && - commit e871aa61182b1d95d0a6fb75445d891722863b6b + commit $commit Author: A U Thor Date: Thu Apr 7 15:25:13 2005 -0700 @@ -901,7 +1018,7 @@ test_expect_success 'git notes copy --stdin' ' ${indent} ${indent}yet another note - commit 65e263ded02ae4e8839bc151095113737579dc12 + commit $parent Author: A U Thor Date: Thu Apr 7 15:24:13 2005 -0700 @@ -912,41 +1029,57 @@ test_expect_success 'git notes copy --stdin' ' ${indent} ${indent}yet another note EOF - (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) && - echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | - git notes copy --stdin && + from=$(git rev-parse HEAD~3) && + to=$(git rev-parse HEAD^) && + echo "$from" "$to" >copy && + from=$(git rev-parse HEAD~2) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >>copy && + git notes copy --stdin actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" && - test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)" + git notes list HEAD~2 >expect && + git notes list HEAD >actual && + test_cmp expect actual && + git notes list HEAD~3 >expect && + git notes list HEAD^ >actual && + test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (unconfigured)' ' + test_commit 14th && + test_commit 15th && + commit=$(git rev-parse HEAD) && + parent=$(git rev-parse HEAD^) && cat >expect <<-EOF && - commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + commit $commit Author: A U Thor Date: Thu Apr 7 15:27:13 2005 -0700 ${indent}15th - commit 07c85d77059393ed0154b8c96906547a59dfcddd + commit $parent Author: A U Thor Date: Thu Apr 7 15:26:13 2005 -0700 ${indent}14th EOF - test_commit 14th && - test_commit 15th && - (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) && - echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD~3) && + to=$(git rev-parse HEAD^) && + echo "$from" "$to" >copy && + from=$(git rev-parse HEAD~2) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >>copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (enabled)' ' + commit=$(git rev-parse HEAD) && + parent=$(git rev-parse HEAD^) && cat >expect <<-EOF && - commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + commit $commit Author: A U Thor Date: Thu Apr 7 15:27:13 2005 -0700 @@ -957,7 +1090,7 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' ' ${indent} ${indent}yet another note - commit 07c85d77059393ed0154b8c96906547a59dfcddd + commit $parent Author: A U Thor Date: Thu Apr 7 15:26:13 2005 -0700 @@ -970,24 +1103,31 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' ' EOF test_config notes.rewriteMode overwrite && test_config notes.rewriteRef "refs/notes/*" && - (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) && - echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD~3) && + to=$(git rev-parse HEAD^) && + echo "$from" "$to" >copy && + from=$(git rev-parse HEAD~2) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >>copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (disabled)' ' test_config notes.rewrite.bar false && - echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) | - git notes copy --for-rewrite=bar && + from=$(git rev-parse HEAD~3) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + git notes copy --for-rewrite=bar actual && test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (overwrite)' ' + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + commit $commit Author: A U Thor Date: Thu Apr 7 15:27:13 2005 -0700 @@ -999,8 +1139,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' ' git notes add -f -m"a fresh note" HEAD^ && test_config notes.rewriteMode overwrite && test_config notes.rewriteRef "refs/notes/*" && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1008,15 +1150,18 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' ' test_expect_success 'git notes copy --for-rewrite (ignore)' ' test_config notes.rewriteMode ignore && test_config notes.rewriteRef "refs/notes/*" && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (append)' ' + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + commit $commit Author: A U Thor Date: Thu Apr 7 15:27:13 2005 -0700 @@ -1030,15 +1175,18 @@ test_expect_success 'git notes copy --for-rewrite (append)' ' git notes add -f -m"another fresh note" HEAD^ && test_config notes.rewriteMode concatenate && test_config notes.rewriteRef "refs/notes/*" && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (append two to one)' ' + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + commit $commit Author: A U Thor Date: Thu Apr 7 15:27:13 2005 -0700 @@ -1057,9 +1205,13 @@ test_expect_success 'git notes copy --for-rewrite (append two to one)' ' git notes add -f -m"append 2" HEAD^^ && test_config notes.rewriteMode concatenate && test_config notes.rewriteRef "refs/notes/*" && - (echo $(git rev-parse HEAD^) $(git rev-parse HEAD) && - echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + from=$(git rev-parse HEAD^^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >>copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1068,15 +1220,18 @@ test_expect_success 'git notes copy --for-rewrite (append empty)' ' git notes remove HEAD^ && test_config notes.rewriteMode concatenate && test_config notes.rewriteRef "refs/notes/*" && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' test_expect_success 'GIT_NOTES_REWRITE_MODE works' ' + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + commit $commit Author: A U Thor Date: Thu Apr 7 15:27:13 2005 -0700 @@ -1088,15 +1243,18 @@ test_expect_success 'GIT_NOTES_REWRITE_MODE works' ' test_config notes.rewriteMode concatenate && test_config notes.rewriteRef "refs/notes/*" && git notes add -f -m"replacement note 1" HEAD^ && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | - GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo actual && test_cmp expect actual ' test_expect_success 'GIT_NOTES_REWRITE_REF works' ' + commit=$(git rev-parse HEAD) && cat >expect <<-EOF && - commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89 + commit $commit Author: A U Thor Date: Thu Apr 7 15:27:13 2005 -0700 @@ -1108,9 +1266,11 @@ test_expect_success 'GIT_NOTES_REWRITE_REF works' ' git notes add -f -m"replacement note 2" HEAD^ && test_config notes.rewriteMode overwrite && test_unconfig notes.rewriteRef && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \ - git notes copy --for-rewrite=foo && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1119,41 +1279,55 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' ' git notes add -f -m"replacement note 3" HEAD^ && test_config notes.rewriteMode overwrite && test_config notes.rewriteRef refs/notes/other && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && GIT_NOTES_REWRITE_REF=refs/notes/commits \ - git notes copy --for-rewrite=foo && + git notes copy --for-rewrite=foo actual && grep "replacement note 3" actual ' test_expect_success 'git notes copy diagnoses too many or too few parameters' ' - test_must_fail git notes copy && - test_must_fail git notes copy one two three + test_must_fail git notes copy 2>error && + test_i18ngrep "too few parameters" error && + test_must_fail git notes copy one two three 2>error && + test_i18ngrep "too many parameters" error ' test_expect_success 'git notes get-ref expands refs/heads/master to refs/notes/refs/heads/master' ' test_unconfig core.notesRef && sane_unset GIT_NOTES_REF && - test "$(git notes --ref=refs/heads/master get-ref)" = "refs/notes/refs/heads/master" + echo refs/notes/refs/heads/master >expect && + git notes --ref=refs/heads/master get-ref >actual && + test_cmp expect actual ' test_expect_success 'git notes get-ref (no overrides)' ' test_unconfig core.notesRef && sane_unset GIT_NOTES_REF && - test "$(git notes get-ref)" = "refs/notes/commits" + echo refs/notes/commits >expect && + git notes get-ref >actual && + test_cmp expect actual ' test_expect_success 'git notes get-ref (core.notesRef)' ' test_config core.notesRef refs/notes/foo && - test "$(git notes get-ref)" = "refs/notes/foo" + echo refs/notes/foo >expect && + git notes get-ref >actual && + test_cmp expect actual ' test_expect_success 'git notes get-ref (GIT_NOTES_REF)' ' - test "$(GIT_NOTES_REF=refs/notes/bar git notes get-ref)" = "refs/notes/bar" + echo refs/notes/bar >expect && + GIT_NOTES_REF=refs/notes/bar git notes get-ref >actual && + test_cmp expect actual ' test_expect_success 'git notes get-ref (--ref)' ' - test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz" + echo refs/notes/baz >expect && + GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref >actual && + test_cmp expect actual ' test_expect_success 'setup testing of empty notes' ' diff --git a/t/t3305-notes-fanout.sh b/t/t3305-notes-fanout.sh index 54460beec469..3b4753e1b479 100755 --- a/t/t3305-notes-fanout.sh +++ b/t/t3305-notes-fanout.sh @@ -4,6 +4,38 @@ test_description='Test that adding/removing many notes triggers automatic fanout . ./test-lib.sh +path_has_fanout() { + path=$1 && + fanout=$2 && + after_last_slash=$((40 - $fanout * 2)) && + echo $path | grep -q "^\([0-9a-f]\{2\}/\)\{$fanout\}[0-9a-f]\{$after_last_slash\}$" +} + +touched_one_note_with_fanout() { + notes_commit=$1 && + modification=$2 && # 'A' for addition, 'D' for deletion + fanout=$3 && + diff=$(git diff-tree --no-commit-id --name-status --root -r $notes_commit) && + path=$(echo $diff | sed -e "s/^$modification[\t ]//") && + path_has_fanout "$path" $fanout; +} + +all_notes_have_fanout() { + notes_commit=$1 && + fanout=$2 && + git ls-tree -r --name-only $notes_commit 2>/dev/null | + while read path + do + path_has_fanout $path $fanout || return 1 + done +} + +test_expect_success 'tweak test environment' ' + git checkout -b nondeterminism && + test_commit A && + git checkout --orphan with_notes; +' + test_expect_success 'creating many notes with git-notes' ' num_notes=300 && i=0 && @@ -20,7 +52,7 @@ test_expect_success 'creating many notes with git-notes' ' test_expect_success 'many notes created correctly with git-notes' ' git log | grep "^ " > output && - i=300 && + i=$num_notes && while test $i -gt 0 do echo " commit #$i" && @@ -30,39 +62,46 @@ test_expect_success 'many notes created correctly with git-notes' ' test_cmp expect output ' -test_expect_success 'many notes created with git-notes triggers fanout' ' - # Expect entire notes tree to have a fanout == 1 - git ls-tree -r --name-only refs/notes/commits | - while read path +test_expect_success 'stable fanout 0 is followed by stable fanout 1' ' + i=$num_notes && + fanout=0 && + while test $i -gt 0 do - case "$path" in - ??/??????????????????????????????????????) - : true - ;; - *) - echo "Invalid path \"$path\"" && - return 1 - ;; - esac - done + i=$(($i - 1)) && + if touched_one_note_with_fanout refs/notes/commits~$i A $fanout + then + continue + elif test $fanout -eq 0 + then + fanout=1 && + if all_notes_have_fanout refs/notes/commits~$i $fanout + then + echo "Fanout 0 -> 1 at refs/notes/commits~$i" && + continue + fi + fi && + echo "Failed fanout=$fanout check at refs/notes/commits~$i" && + git ls-tree -r --name-only refs/notes/commits~$i && + return 1 + done && + all_notes_have_fanout refs/notes/commits 1 ' test_expect_success 'deleting most notes with git-notes' ' - num_notes=250 && + remove_notes=285 && i=0 && git rev-list HEAD | - while test $i -lt $num_notes && read sha1 + while test $i -lt $remove_notes && read sha1 do i=$(($i + 1)) && test_tick && - git notes remove "$sha1" || - exit 1 + git notes remove "$sha1" 2>/dev/null || return 1 done ' test_expect_success 'most notes deleted correctly with git-notes' ' - git log HEAD~250 | grep "^ " > output && - i=50 && + git log HEAD~$remove_notes | grep "^ " > output && + i=$(($num_notes - $remove_notes)) && while test $i -gt 0 do echo " commit #$i" && @@ -72,21 +111,29 @@ test_expect_success 'most notes deleted correctly with git-notes' ' test_cmp expect output ' -test_expect_success 'deleting most notes triggers fanout consolidation' ' - # Expect entire notes tree to have a fanout == 0 - git ls-tree -r --name-only refs/notes/commits | - while read path +test_expect_success 'stable fanout 1 is followed by stable fanout 0' ' + i=$remove_notes && + fanout=1 && + while test $i -gt 0 do - case "$path" in - ????????????????????????????????????????) - : true - ;; - *) - echo "Invalid path \"$path\"" && - return 1 - ;; - esac - done + i=$(($i - 1)) && + if touched_one_note_with_fanout refs/notes/commits~$i D $fanout + then + continue + elif test $fanout -eq 1 + then + fanout=0 && + if all_notes_have_fanout refs/notes/commits~$i $fanout + then + echo "Fanout 1 -> 0 at refs/notes/commits~$i" && + continue + fi + fi && + echo "Failed fanout=$fanout check at refs/notes/commits~$i" && + git ls-tree -r --name-only refs/notes/commits~$i && + return 1 + done && + all_notes_have_fanout refs/notes/commits 0 ' test_done diff --git a/t/t3306-notes-prune.sh b/t/t3306-notes-prune.sh index 61748088ebcb..8f4102ff9e44 100755 --- a/t/t3306-notes-prune.sh +++ b/t/t3306-notes-prune.sh @@ -11,23 +11,26 @@ test_expect_success 'setup: create a few commits with notes' ' test_tick && git commit -m 1st && git notes add -m "Note #1" && + first=$(git rev-parse HEAD) && : > file2 && git add file2 && test_tick && git commit -m 2nd && git notes add -m "Note #2" && + second=$(git rev-parse HEAD) && : > file3 && git add file3 && test_tick && git commit -m 3rd && - COMMIT_FILE=.git/objects/5e/e1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && + third=$(git rev-parse HEAD) && + COMMIT_FILE=$(echo $third | sed "s!^..!.git/objects/&/!") && test -f $COMMIT_FILE && test-tool chmtime =+0 $COMMIT_FILE && git notes add -m "Note #3" ' cat > expect < Date: Thu Apr 7 15:15:13 2005 -0700 @@ -36,7 +39,7 @@ Date: Thu Apr 7 15:15:13 2005 -0700 Notes: Note #3 -commit 08341ad9e94faa089d60fd3f523affb25c6da189 +commit $second Author: A U Thor Date: Thu Apr 7 15:14:13 2005 -0700 @@ -45,7 +48,7 @@ Date: Thu Apr 7 15:14:13 2005 -0700 Notes: Note #2 -commit ab5f302035f2e7aaf04265f08b42034c23256e1f +commit $first Author: A U Thor Date: Thu Apr 7 15:13:13 2005 -0700 @@ -70,16 +73,16 @@ test_expect_success 'remove some commits' ' test_expect_success 'verify that commits are gone' ' - test_must_fail git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && - git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 && - git cat-file -p ab5f302035f2e7aaf04265f08b42034c23256e1f + test_must_fail git cat-file -p $third && + git cat-file -p $second && + git cat-file -p $first ' test_expect_success 'verify that notes are still present' ' - git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && - git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 && - git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f + git notes show $third && + git notes show $second && + git notes show $first ' test_expect_success 'prune -n does not remove notes' ' @@ -90,13 +93,10 @@ test_expect_success 'prune -n does not remove notes' ' test_cmp expect actual ' -cat > expect <expect && git notes prune -n > actual && test_cmp expect actual ' @@ -109,9 +109,9 @@ test_expect_success 'prune notes' ' test_expect_success 'verify that notes are gone' ' - test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && - git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 && - git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f + test_must_fail git notes show $third && + git notes show $second && + git notes show $first ' test_expect_success 'remove some commits' ' @@ -121,21 +121,18 @@ test_expect_success 'remove some commits' ' git gc --prune=now ' -cat > expect <expect && git notes prune -v > actual && test_cmp expect actual ' test_expect_success 'verify that notes are gone' ' - test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && - test_must_fail git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 && - git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f + test_must_fail git notes show $third && + test_must_fail git notes show $second && + git notes show $first ' test_done diff --git a/t/t3308-notes-merge.sh b/t/t3308-notes-merge.sh index d60588ec8f00..790e292966b2 100755 --- a/t/t3308-notes-merge.sh +++ b/t/t3308-notes-merge.sh @@ -20,7 +20,34 @@ test_expect_success setup ' git notes add -m "Notes on 3rd commit" 3rd && git notes add -m "Notes on 4th commit" 4th && # Copy notes to remote-notes - git fetch . refs/notes/*:refs/remote-notes/origin/* + git fetch . refs/notes/*:refs/remote-notes/origin/* && + + test_oid_init && + test_oid_cache <<-EOF + hash4a sha1:5e93d24084d32e1cb61f7070505b9d2530cca987 + hash3a sha1:8366731eeee53787d2bdf8fc1eff7d94757e8da0 + hash2a sha1:eede89064cd42441590d6afec6c37b321ada3389 + hash1a sha1:daa55ffad6cb99bf64226532147ffcaf5ce8bdd1 + hash5b sha1:0f2efbd00262f2fd41dfae33df8765618eeacd99 + hash4b sha1:dec2502dac3ea161543f71930044deff93fa945c + hash3b sha1:4069cdb399fd45463ec6eef8e051a16a03592d91 + hash2c sha1:d000d30e6ddcfce3a8122c403226a2ce2fd04d9d + hash1c sha1:43add6bd0c8c0bc871ac7991e0f5573cfba27804 + hash4d sha1:1f257a3a90328557c452f0817d6cc50c89d315d4 + hash3d sha1:05a4927951bcef347f51486575b878b2b60137f2 + + hash4a sha256:eef876be1d32ac2e2e42240e0429325cec116e55e88cb2969899fac695aa762f + hash3a sha256:cf7cd1bc091d7ba4166a86df864110e42087cd893a5ae96bc50d637e0290939d + hash2a sha256:21ddde7ebce2c285213898cb04deca0fd3209610cf7aaf8222e4e2f45262fae2 + hash1a sha256:f9fe0eda16c6027732ed9d4295689a03abd16f893be69b3dcbf4037ddb191921 + hash5b sha256:20046f2244577797a9e3d3f790ea9eca4d8a6bafb2a5570bcb0e03aa02ce100b + hash4b sha256:f90563d134c61a95bb88afbd45d48ccc9e919c62aa6fbfcd483302b3e4d8dbcb + hash3b sha256:988f2aca9f2d87e93e6a73197c2bb99560cc44a2f92d18653968f956f01221e0 + hash2c sha256:84153b777b4d42827a756c6578dcdb59d8ae5d1360b874fb37c430150c825c26 + hash1c sha256:9beb2bc4eef72e4c4087be168a20573e34d993d9ab1883055f23e322afa06567 + hash4d sha256:32de39dc06e679a7abb2d4a55ede7709b3124340a4a90aa305971b1c72ac319d + hash3d sha256:fa73b20e41cbb7541c4c81d1535016131dbfbeb05bf6a71f6115e9cad31c7af5 + EOF ' commit_sha1=$(git rev-parse 1st^{commit}) @@ -40,10 +67,10 @@ verify_notes () { } cat <expect_notes_x -5e93d24084d32e1cb61f7070505b9d2530cca987 $commit_sha4 -8366731eeee53787d2bdf8fc1eff7d94757e8da0 $commit_sha3 -eede89064cd42441590d6afec6c37b321ada3389 $commit_sha2 -daa55ffad6cb99bf64226532147ffcaf5ce8bdd1 $commit_sha1 +$(test_oid hash4a) $commit_sha4 +$(test_oid hash3a) $commit_sha3 +$(test_oid hash2a) $commit_sha2 +$(test_oid hash1a) $commit_sha1 EOF cat >expect_log_x < y) => No-op' ' ' cat <expect_notes_y -0f2efbd00262f2fd41dfae33df8765618eeacd99 $commit_sha5 -dec2502dac3ea161543f71930044deff93fa945c $commit_sha4 -4069cdb399fd45463ec6eef8e051a16a03592d91 $commit_sha3 -daa55ffad6cb99bf64226532147ffcaf5ce8bdd1 $commit_sha1 +$(test_oid hash5b) $commit_sha5 +$(test_oid hash4b) $commit_sha4 +$(test_oid hash3b) $commit_sha3 +$(test_oid hash1a) $commit_sha1 EOF cat >expect_log_y < y)' ' ' cat <expect_notes_y -0f2efbd00262f2fd41dfae33df8765618eeacd99 $commit_sha5 -dec2502dac3ea161543f71930044deff93fa945c $commit_sha4 -4069cdb399fd45463ec6eef8e051a16a03592d91 $commit_sha3 -d000d30e6ddcfce3a8122c403226a2ce2fd04d9d $commit_sha2 -43add6bd0c8c0bc871ac7991e0f5573cfba27804 $commit_sha1 +$(test_oid hash5b) $commit_sha5 +$(test_oid hash4b) $commit_sha4 +$(test_oid hash3b) $commit_sha3 +$(test_oid hash2c) $commit_sha2 +$(test_oid hash1c) $commit_sha1 EOF cat >expect_log_y <expect_notes_x -0f2efbd00262f2fd41dfae33df8765618eeacd99 $commit_sha5 -1f257a3a90328557c452f0817d6cc50c89d315d4 $commit_sha4 -daa55ffad6cb99bf64226532147ffcaf5ce8bdd1 $commit_sha1 +$(test_oid hash5b) $commit_sha5 +$(test_oid hash4d) $commit_sha4 +$(test_oid hash1a) $commit_sha1 EOF cat >expect_log_x <expect_notes_x -0f2efbd00262f2fd41dfae33df8765618eeacd99 $commit_sha5 -1f257a3a90328557c452f0817d6cc50c89d315d4 $commit_sha4 -d000d30e6ddcfce3a8122c403226a2ce2fd04d9d $commit_sha2 -43add6bd0c8c0bc871ac7991e0f5573cfba27804 $commit_sha1 +$(test_oid hash5b) $commit_sha5 +$(test_oid hash4d) $commit_sha4 +$(test_oid hash2c) $commit_sha2 +$(test_oid hash1c) $commit_sha1 EOF cat >expect_log_x < Non-conflicting 3-way merge' ' ' cat <expect_notes_w -05a4927951bcef347f51486575b878b2b60137f2 $commit_sha3 -d000d30e6ddcfce3a8122c403226a2ce2fd04d9d $commit_sha2 +$(test_oid hash3d) $commit_sha3 +$(test_oid hash2c) $commit_sha2 EOF cat >expect_log_w <expect_notes_x -0f2efbd00262f2fd41dfae33df8765618eeacd99 $commit_sha5 -1f257a3a90328557c452f0817d6cc50c89d315d4 $commit_sha4 -05a4927951bcef347f51486575b878b2b60137f2 $commit_sha3 -d000d30e6ddcfce3a8122c403226a2ce2fd04d9d $commit_sha2 -43add6bd0c8c0bc871ac7991e0f5573cfba27804 $commit_sha1 +$(test_oid hash5b) $commit_sha5 +$(test_oid hash4d) $commit_sha4 +$(test_oid hash3d) $commit_sha3 +$(test_oid hash2c) $commit_sha2 +$(test_oid hash1c) $commit_sha1 EOF cat >expect_log_x <expect_notes_x -457a85d6c814ea208550f15fcc48f804ac8dc023 $commit_sha15 -b0c95b954301d69da2bc3723f4cb1680d355937c $commit_sha14 -5d30216a129eeffa97d9694ffe8c74317a560315 $commit_sha13 -dd161bc149470fd890dd4ab52a4cbd79bbd18c36 $commit_sha12 -7abbc45126d680336fb24294f013a7cdfa3ed545 $commit_sha11 -b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10 -20c613c835011c48a5abe29170a2402ca6354910 $commit_sha9 -a3daf8a1e4e5dc3409a303ad8481d57bfea7f5d6 $commit_sha8 -897003322b53bc6ca098e9324ee508362347e734 $commit_sha7 -11d97fdebfa5ceee540a3da07bce6fa0222bc082 $commit_sha6 +$(test_oid hash15a) $commit_sha15 +$(test_oid hash14a) $commit_sha14 +$(test_oid hash13a) $commit_sha13 +$(test_oid hash12a) $commit_sha12 +$(test_oid hash11a) $commit_sha11 +$(test_oid hash10a) $commit_sha10 +$(test_oid hash09a) $commit_sha9 +$(test_oid hash08a) $commit_sha8 +$(test_oid hash07a) $commit_sha7 +$(test_oid hash06a) $commit_sha6 EOF cat >expect_log_x <expect_notes_y -68b8630d25516028bed862719855b3d6768d7833 $commit_sha15 -5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14 -3a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13 -a66055fa82f7a03fe0c02a6aba3287a85abf7c62 $commit_sha12 -7abbc45126d680336fb24294f013a7cdfa3ed545 $commit_sha11 -b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10 -20c613c835011c48a5abe29170a2402ca6354910 $commit_sha9 -154508c7a0bcad82b6fe4b472bc4c26b3bf0825b $commit_sha5 -e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4 -5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3 +$(test_oid hash15b) $commit_sha15 +$(test_oid hash14b) $commit_sha14 +$(test_oid hash13b) $commit_sha13 +$(test_oid hash12b) $commit_sha12 +$(test_oid hash11a) $commit_sha11 +$(test_oid hash10a) $commit_sha10 +$(test_oid hash09a) $commit_sha9 +$(test_oid hash05b) $commit_sha5 +$(test_oid hash04b) $commit_sha4 +$(test_oid hash03b) $commit_sha3 EOF cat >expect_log_y <expect_notes_z -9b4b2c61f0615412da3c10f98ff85b57c04ec765 $commit_sha15 -5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14 -5d30216a129eeffa97d9694ffe8c74317a560315 $commit_sha13 -7e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11 -b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10 -851e1638784a884c7dd26c5d41f3340f6387413a $commit_sha8 -897003322b53bc6ca098e9324ee508362347e734 $commit_sha7 -99fc34adfc400b95c67b013115e37e31aa9a6d23 $commit_sha5 -e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4 -283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2 +$(test_oid hash15c) $commit_sha15 +$(test_oid hash14b) $commit_sha14 +$(test_oid hash13a) $commit_sha13 +$(test_oid hash11c) $commit_sha11 +$(test_oid hash10a) $commit_sha10 +$(test_oid hash08c) $commit_sha8 +$(test_oid hash07a) $commit_sha7 +$(test_oid hash05c) $commit_sha5 +$(test_oid hash04b) $commit_sha4 +$(test_oid hash02c) $commit_sha2 EOF cat >expect_log_z < Fail/No ' cat <expect_notes_ours -68b8630d25516028bed862719855b3d6768d7833 $commit_sha15 -5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14 -3a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13 -a66055fa82f7a03fe0c02a6aba3287a85abf7c62 $commit_sha12 -7e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11 -b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10 -154508c7a0bcad82b6fe4b472bc4c26b3bf0825b $commit_sha5 -e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4 -5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3 -283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2 +$(test_oid hash15b) $commit_sha15 +$(test_oid hash14b) $commit_sha14 +$(test_oid hash13b) $commit_sha13 +$(test_oid hash12b) $commit_sha12 +$(test_oid hash11c) $commit_sha11 +$(test_oid hash10a) $commit_sha10 +$(test_oid hash05b) $commit_sha5 +$(test_oid hash04b) $commit_sha4 +$(test_oid hash03b) $commit_sha3 +$(test_oid hash02c) $commit_sha2 EOF cat >expect_log_ours <expect_notes_theirs -9b4b2c61f0615412da3c10f98ff85b57c04ec765 $commit_sha15 -5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14 -3a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13 -7e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11 -b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10 -851e1638784a884c7dd26c5d41f3340f6387413a $commit_sha8 -99fc34adfc400b95c67b013115e37e31aa9a6d23 $commit_sha5 -e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4 -5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3 -283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2 +$(test_oid hash15c) $commit_sha15 +$(test_oid hash14b) $commit_sha14 +$(test_oid hash13b) $commit_sha13 +$(test_oid hash11c) $commit_sha11 +$(test_oid hash10a) $commit_sha10 +$(test_oid hash08c) $commit_sha8 +$(test_oid hash05c) $commit_sha5 +$(test_oid hash04b) $commit_sha4 +$(test_oid hash03b) $commit_sha3 +$(test_oid hash02c) $commit_sha2 EOF cat >expect_log_theirs <expect_notes_union -7c4e546efd0fe939f876beb262ece02797880b54 $commit_sha15 -5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14 -3a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13 -a66055fa82f7a03fe0c02a6aba3287a85abf7c62 $commit_sha12 -7e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11 -b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10 -851e1638784a884c7dd26c5d41f3340f6387413a $commit_sha8 -6c841cc36ea496027290967ca96bd2bef54dbb47 $commit_sha5 -e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4 -5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3 -283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2 +$(test_oid hash15d) $commit_sha15 +$(test_oid hash14b) $commit_sha14 +$(test_oid hash13b) $commit_sha13 +$(test_oid hash12b) $commit_sha12 +$(test_oid hash11c) $commit_sha11 +$(test_oid hash10a) $commit_sha10 +$(test_oid hash08c) $commit_sha8 +$(test_oid hash05d) $commit_sha5 +$(test_oid hash04b) $commit_sha4 +$(test_oid hash03b) $commit_sha3 +$(test_oid hash02c) $commit_sha2 EOF cat >expect_log_union <expect_notes_union2 -d682107b8bf7a7aea1e537a8d5cb6a12b60135f1 $commit_sha15 -5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14 -3a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13 -a66055fa82f7a03fe0c02a6aba3287a85abf7c62 $commit_sha12 -7e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11 -b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10 -851e1638784a884c7dd26c5d41f3340f6387413a $commit_sha8 -357b6ca14c7afd59b7f8b8aaaa6b8b723771135b $commit_sha5 -e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4 -5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3 -283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2 +$(test_oid hash15e) $commit_sha15 +$(test_oid hash14b) $commit_sha14 +$(test_oid hash13b) $commit_sha13 +$(test_oid hash12b) $commit_sha12 +$(test_oid hash11c) $commit_sha11 +$(test_oid hash10a) $commit_sha10 +$(test_oid hash08c) $commit_sha8 +$(test_oid hash05e) $commit_sha5 +$(test_oid hash04b) $commit_sha4 +$(test_oid hash03b) $commit_sha3 +$(test_oid hash02c) $commit_sha2 EOF cat >expect_log_union2 <expect_notes_cat_sort_uniq -6be90240b5f54594203e25d9f2f64b7567175aee $commit_sha15 -5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14 -3a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13 -a66055fa82f7a03fe0c02a6aba3287a85abf7c62 $commit_sha12 -7e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11 -b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10 -851e1638784a884c7dd26c5d41f3340f6387413a $commit_sha8 -660311d7f78dc53db12ac373a43fca7465381a7e $commit_sha5 -e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4 -5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3 -283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2 +$(test_oid hash15f) $commit_sha15 +$(test_oid hash14b) $commit_sha14 +$(test_oid hash13b) $commit_sha13 +$(test_oid hash12b) $commit_sha12 +$(test_oid hash11c) $commit_sha11 +$(test_oid hash10a) $commit_sha10 +$(test_oid hash08c) $commit_sha8 +$(test_oid hash05f) $commit_sha5 +$(test_oid hash04b) $commit_sha4 +$(test_oid hash03b) $commit_sha3 +$(test_oid hash02c) $commit_sha2 EOF cat >expect_log_cat_sort_uniq <output || :; } && + test_must_be_empty output +} + cat <expect_notes_x -6e8e3febca3c2bb896704335cc4d0c34cb2f8715 $commit_sha4 -e5388c10860456ee60673025345fe2e153eb8cf8 $commit_sha3 -ceefa674873670e7ecd131814d909723cce2b669 $commit_sha2 +$(test_oid hash04a) $commit_sha4 +$(test_oid hash03a) $commit_sha3 +$(test_oid hash02a) $commit_sha2 EOF cat >expect_log_x <expect_notes_y -e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4 -5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3 -b0a6021ec006d07e80e9b20ec9b444cbd9d560d3 $commit_sha1 +$(test_oid hash04b) $commit_sha4 +$(test_oid hash03b) $commit_sha3 +$(test_oid hash01b) $commit_sha1 EOF cat >expect_log_y <expect_notes_z -cff59c793c20bb49a4e01bc06fb06bad642e0d54 $commit_sha4 -283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2 -0a81da8956346e19bcb27a906f04af327e03e31b $commit_sha1 +$(test_oid hash04c) $commit_sha4 +$(test_oid hash02c) $commit_sha2 +$(test_oid hash01c) $commit_sha1 EOF cat >expect_log_z < C ' cat <expect_notes_z -00494adecf2d9635a02fa431308d67993f853968 $commit_sha4 -283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2 -0a81da8956346e19bcb27a906f04af327e03e31b $commit_sha1 +$(test_oid hash04d) $commit_sha4 +$(test_oid hash02c) $commit_sha2 +$(test_oid hash01c) $commit_sha1 EOF cat >expect_log_z <expect_notes_w -ceefa674873670e7ecd131814d909723cce2b669 $commit_sha2 -f75d1df88cbfe4258d49852f26cfc83f2ad4494b $commit_sha1 +$(test_oid hash02a) $commit_sha2 +$(test_oid hash01e) $commit_sha1 EOF cat >expect_log_w <expect_notes_w -6e8e3febca3c2bb896704335cc4d0c34cb2f8715 $commit_sha4 -e5388c10860456ee60673025345fe2e153eb8cf8 $commit_sha3 -ceefa674873670e7ecd131814d909723cce2b669 $commit_sha2 -f75d1df88cbfe4258d49852f26cfc83f2ad4494b $commit_sha1 +$(test_oid hash04a) $commit_sha4 +$(test_oid hash03a) $commit_sha3 +$(test_oid hash02a) $commit_sha2 +$(test_oid hash01e) $commit_sha1 EOF cat >expect_log_w <expect_notes_m -021faa20e931fb48986ffc6282b4bb05553ac946 $commit_sha4 -5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3 -283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2 -0a59e787e6d688aa6309e56e8c1b89431a0fc1c1 $commit_sha1 +$(test_oid hash04f) $commit_sha4 +$(test_oid hash03b) $commit_sha3 +$(test_oid hash02c) $commit_sha2 +$(test_oid hash01f) $commit_sha1 EOF cat >expect_log_m <output 2>/dev/null && - test_must_be_empty output && + notes_merge_files_gone && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" && @@ -397,9 +433,7 @@ test_expect_success 'redo merge of z into m (== y) with default ("manual") resol test_expect_success 'abort notes merge' ' git notes merge --abort && - # No .git/NOTES_MERGE_* files left - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_must_be_empty output && + notes_merge_files_gone && # m has not moved (still == y) test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" && # Verify that other notes refs has not changed (w, x, y and z) @@ -430,9 +464,9 @@ test_expect_success 'redo merge of z into m (== y) with default ("manual") resol ' cat <expect_notes_m -304dfb4325cf243025b9957486eb605a9b51c199 $commit_sha5 -283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2 -0a59e787e6d688aa6309e56e8c1b89431a0fc1c1 $commit_sha1 +$(test_oid hash05g) $commit_sha5 +$(test_oid hash02c) $commit_sha2 +$(test_oid hash01f) $commit_sha1 EOF cat >expect_log_m < .git/NOTES_MERGE_WORKTREE/$commit_sha5 && # Finalize merge git notes merge --commit && - # No .git/NOTES_MERGE_* files left - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_must_be_empty output && + notes_merge_files_gone && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" && @@ -553,9 +585,7 @@ EOF test_expect_success 'resolve situation by aborting the notes merge' ' git notes merge --abort && - # No .git/NOTES_MERGE_* files left - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_must_be_empty output && + notes_merge_files_gone && # m has not moved (still == w) test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" && # Verify that other notes refs has not changed (w, x, y and z) diff --git a/t/t3311-notes-merge-fanout.sh b/t/t3311-notes-merge-fanout.sh index 37151a3adc39..5b675417e9bb 100755 --- a/t/t3311-notes-merge-fanout.sh +++ b/t/t3311-notes-merge-fanout.sh @@ -29,15 +29,10 @@ verify_fanout () { git ls-tree -r --name-only "refs/notes/$notes_ref" | while read path do - case "$path" in - ??/??????????????????????????????????????) - : true - ;; - *) + echo "$path" | grep "^../[0-9a-f]*$" || { echo "Invalid path \"$path\"" && - return 1 - ;; - esac + return 1; + } done } @@ -48,15 +43,10 @@ verify_no_fanout () { git ls-tree -r --name-only "refs/notes/$notes_ref" | while read path do - case "$path" in - ????????????????????????????????????????) - : true - ;; - *) + echo "$path" | grep -v "^../.*" || { echo "Invalid path \"$path\"" && - return 1 - ;; - esac + return 1; + } done } @@ -67,7 +57,27 @@ test_expect_success 'setup a few initial commits with notes (notes ref: x)' ' do test_commit "commit$i" >/dev/null && git notes add -m "notes for commit$i" || return 1 - done + done && + + git log --format=oneline && + + test_oid_cache <<-EOF + hash05a sha1:aed91155c7a72c2188e781fdf40e0f3761b299db + hash04a sha1:99fab268f9d7ee7b011e091a436c78def8eeee69 + hash03a sha1:953c20ae26c7aa0b428c20693fe38bc687f9d1a9 + hash02a sha1:6358796131b8916eaa2dde6902642942a1cb37e1 + hash01a sha1:b02d459c32f0e68f2fe0981033bb34f38776ba47 + hash03b sha1:9f506ee70e20379d7f78204c77b334f43d77410d + hash02b sha1:23a47d6ea7d589895faf800752054818e1e7627b + + hash05a sha256:3aae5d26619d96dba93795f66325716e4cbc486884f95a6adee8fb0615a76d12 + hash04a sha256:07e43dd3d89fe634d3252e253b426aacc7285a995dcdbcf94ac284060a1122cf + hash03a sha256:26fb52eaa7f4866bf735254587be7b31209ec10e525912ffd8e8ba549ba892ff + hash02a sha256:b57ebdf23634e750dcbc4b9a37991d70f90830d568a0e4529ce9de0a3f8d605c + hash01a sha256:377903b1572bd5117087a5518fcb1011b5053cccbc59e3c7c823a8615204173b + hash03b sha256:04e7b392fda7c185bfa17c9179b56db732edc2dc2b3bf887308dcaabb717270d + hash02b sha256:66099aaaec49a485ed990acadd9a9b81232ea592079964113d8f581ff69ef50b + EOF ' commit_sha1=$(git rev-parse commit1^{commit}) @@ -77,11 +87,11 @@ commit_sha4=$(git rev-parse commit4^{commit}) commit_sha5=$(git rev-parse commit5^{commit}) cat <expect_notes_x -aed91155c7a72c2188e781fdf40e0f3761b299db $commit_sha5 -99fab268f9d7ee7b011e091a436c78def8eeee69 $commit_sha4 -953c20ae26c7aa0b428c20693fe38bc687f9d1a9 $commit_sha3 -6358796131b8916eaa2dde6902642942a1cb37e1 $commit_sha2 -b02d459c32f0e68f2fe0981033bb34f38776ba47 $commit_sha1 +$(test_oid hash05a) $commit_sha5 +$(test_oid hash04a) $commit_sha4 +$(test_oid hash03a) $commit_sha3 +$(test_oid hash02a) $commit_sha2 +$(test_oid hash01a) $commit_sha1 EOF cat >expect_log_x < x)' ' ' cat <expect_notes_z -9f506ee70e20379d7f78204c77b334f43d77410d $commit_sha3 -23a47d6ea7d589895faf800752054818e1e7627b $commit_sha2 -b02d459c32f0e68f2fe0981033bb34f38776ba47 $commit_sha1 +$(test_oid hash03b) $commit_sha3 +$(test_oid hash02b) $commit_sha2 +$(test_oid hash01a) $commit_sha1 EOF cat >expect_log_z < and specified as :/quuxery' ' @@ -143,11 +143,11 @@ test_expect_success 'setup: recover' ' test_expect_success 'Show verbose error when HEAD could not be detached' ' >B && + test_when_finished "rm -f B" && test_must_fail git rebase topic 2>output.err >output.out && test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" output.err && test_i18ngrep B output.err ' -rm -f B test_expect_success 'fail when upstream arg is missing and not on branch' ' git checkout topic && @@ -159,19 +159,43 @@ test_expect_success 'fail when upstream arg is missing and not configured' ' test_must_fail git rebase ' -test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg' ' +test_expect_success 'rebase works with format.useAutoBase' ' + test_config format.useAutoBase true && + git checkout topic && + git rebase master +' + +test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg (--merge)' ' git checkout -b default-base master && git checkout -b default topic && git config branch.default.remote . && git config branch.default.merge refs/heads/default-base && - git rebase && + git rebase --merge && git rev-parse --verify default-base >expect && git rev-parse default~1 >actual && test_cmp expect actual && git checkout default-base && git reset --hard HEAD^ && git checkout default && - git rebase && + git rebase --merge && + git rev-parse --verify default-base >expect && + git rev-parse default~1 >actual && + test_cmp expect actual +' + +test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg (--apply)' ' + git checkout -B default-base master && + git checkout -B default topic && + git config branch.default.remote . && + git config branch.default.merge refs/heads/default-base && + git rebase --apply && + git rev-parse --verify default-base >expect && + git rev-parse default~1 >actual && + test_cmp expect actual && + git checkout default-base && + git reset --hard HEAD^ && + git checkout default && + git rebase --apply && git rev-parse --verify default-base >expect && git rev-parse default~1 >actual && test_cmp expect actual @@ -200,9 +224,15 @@ test_expect_success 'cherry-picked commits and fork-point work together' ' test_cmp expect D ' -test_expect_success 'rebase -q is quiet' ' +test_expect_success 'rebase --apply -q is quiet' ' git checkout -b quiet topic && - git rebase -q master >output.out 2>&1 && + git rebase --apply -q master >output.out 2>&1 && + test_must_be_empty output.out +' + +test_expect_success 'rebase --merge -q is quiet' ' + git checkout -B quiet topic && + git rebase --merge -q master >output.out 2>&1 && test_must_be_empty output.out ' @@ -285,7 +315,7 @@ EOF test_cmp From_.msg out ' -test_expect_success 'rebase --am and --show-current-patch' ' +test_expect_success 'rebase --apply and --show-current-patch' ' test_create_repo conflict-apply && ( cd conflict-apply && @@ -295,12 +325,48 @@ test_expect_success 'rebase --am and --show-current-patch' ' echo two >>init.t && git commit -a -m two && git tag two && - test_must_fail git rebase --onto init HEAD^ && + test_must_fail git rebase --apply -f --onto init HEAD^ && GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr && grep "show.*$(git rev-parse two)" stderr ) ' +test_expect_success 'rebase --apply and .gitattributes' ' + test_create_repo attributes && + ( + cd attributes && + test_commit init && + git config filter.test.clean "sed -e '\''s/smudged/clean/g'\''" && + git config filter.test.smudge "sed -e '\''s/clean/smudged/g'\''" && + + test_commit second && + git checkout -b test HEAD^ && + + echo "*.txt filter=test" >.gitattributes && + git add .gitattributes && + test_commit third && + + echo "This text is smudged." >a.txt && + git add a.txt && + test_commit fourth && + + git checkout -b removal HEAD^ && + git rm .gitattributes && + git add -u && + test_commit fifth && + git cherry-pick test && + + git checkout test && + git rebase master && + grep "smudged" a.txt && + + git checkout removal && + git reset --hard && + git rebase master && + grep "clean" a.txt + ) +' + test_expect_success 'rebase--merge.sh and --show-current-patch' ' test_create_repo conflict-merge && ( @@ -335,4 +401,22 @@ test_expect_success 'rebase -c rebase.useBuiltin=false warning' ' test_must_be_empty err ' +test_expect_success 'switch to branch checked out here' ' + git checkout master && + git rebase master master +' + +test_expect_success 'switch to branch not checked out' ' + git checkout master && + git branch other && + git rebase master other +' + +test_expect_success 'refuse to switch to branch checked out elsewhere' ' + git checkout master && + git worktree add wt && + test_must_fail git -C wt rebase master master 2>err && + test_i18ngrep "already checked out" err +' + test_done diff --git a/t/t3401-rebase-and-am-rename.sh b/t/t3401-rebase-and-am-rename.sh index a0b9438b2286..f18bae945075 100755 --- a/t/t3401-rebase-and-am-rename.sh +++ b/t/t3401-rebase-and-am-rename.sh @@ -52,13 +52,13 @@ test_expect_success 'rebase --interactive: directory rename detected' ' ) ' -test_expect_failure 'rebase (am): directory rename detected' ' +test_expect_failure 'rebase --apply: directory rename detected' ' ( cd dir-rename && git checkout B^0 && - git -c merge.directoryRenames=true rebase A && + git -c merge.directoryRenames=true rebase --apply A && git ls-files -s >out && test_line_count = 5 out && diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh index 1f5122b632fb..ee8a8dba5286 100755 --- a/t/t3403-rebase-skip.sh +++ b/t/t3403-rebase-skip.sh @@ -7,6 +7,8 @@ test_description='git rebase --merge --skip tests' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-rebase.sh + # we assume the default git am -3 --skip strategy is tested independently # and always works :) @@ -20,6 +22,13 @@ test_expect_success setup ' git commit -a -m "hello world" && echo goodbye >> hello && git commit -a -m "goodbye" && + git tag goodbye && + + git checkout --detach && + git checkout HEAD^ . && + test_tick && + git commit -m reverted-goodbye && + git tag reverted-goodbye && git checkout -f skip-reference && echo moo > hello && @@ -76,4 +85,27 @@ test_expect_success 'moved back to branch correctly' ' test_debug 'gitk --all & sleep 1' +test_expect_success 'fixup that empties commit fails' ' + test_when_finished "git rebase --abort" && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 fixup 2" git rebase -i \ + goodbye^ reverted-goodbye + ) +' + +test_expect_success 'squash that empties commit fails' ' + test_when_finished "git rebase --abort" && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 squash 2" git rebase -i \ + goodbye^ reverted-goodbye + ) +' + +# Must be the last test in this file +test_expect_success '$EDITOR and friends are unchanged' ' + test_editor_unchanged +' + test_done diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 461dd539ffd4..c5ce3ab760ea 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -29,9 +29,6 @@ Initial setup: . "$TEST_DIRECTORY"/lib-rebase.sh -# WARNING: Modifications to the initial repository can change the SHA ID used -# in the expect2 file for the 'stop on conflicting pick' test. - test_expect_success 'setup' ' test_commit A file1 && test_commit B file1 && @@ -75,12 +72,16 @@ test_expect_success 'rebase --keep-empty' ' test_line_count = 6 actual ' -test_expect_success 'rebase -i with empty HEAD' ' +test_expect_success 'rebase -i with empty todo list' ' cat >expect <<-\EOF && error: nothing to do EOF - set_fake_editor && - test_must_fail env FAKE_LINES="1 exec_true" git rebase -i HEAD^ >actual 2>&1 && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="#" \ + git rebase -i HEAD^ >output 2>&1 + ) && + tail -n 1 output >actual && # Ignore output about changing todo list test_i18ncmp expect actual ' @@ -139,8 +140,11 @@ test_expect_success 'rebase -i sets work tree properly' ' test_expect_success 'rebase -i with the exec command checks tree cleanness' ' git checkout master && - set_fake_editor && - test_must_fail env FAKE_LINES="exec_echo_foo_>file1 1" git rebase -i HEAD^ && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="exec_echo_foo_>file1 1" \ + git rebase -i HEAD^ + ) && test_cmp_rev master^ HEAD && git reset --hard && git rebase --continue @@ -155,8 +159,6 @@ test_expect_success 'rebase -x with empty command fails' ' test_i18ncmp expected actual ' -LF=' -' test_expect_success 'rebase -x with newline in command fails' ' test_when_finished "git rebase --abort ||:" && test_must_fail env git rebase -x "a${LF}b" @ 2>actual && @@ -168,9 +170,11 @@ test_expect_success 'rebase -x with newline in command fails' ' test_expect_success 'rebase -i with exec of inexistent command' ' git checkout master && test_when_finished "git rebase --abort" && - set_fake_editor && - test_must_fail env FAKE_LINES="exec_this-command-does-not-exist 1" \ - git rebase -i HEAD^ >actual 2>&1 && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="exec_this-command-does-not-exist 1" \ + git rebase -i HEAD^ >actual 2>&1 + ) && ! grep "Maybe git-rebase is broken" actual ' @@ -181,7 +185,6 @@ test_expect_success 'implicit interactive rebase does not invoke sequence editor test_expect_success 'no changes are a nop' ' git checkout branch2 && - set_fake_editor && git rebase -i F && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" && test $(git rev-parse I) = $(git rev-parse HEAD) @@ -191,7 +194,6 @@ test_expect_success 'test the [branch] option' ' git checkout -b dead-end && git rm file6 && git commit -m "stop here" && - set_fake_editor && git rebase -i F branch2 && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" && test $(git rev-parse I) = $(git rev-parse branch2) && @@ -200,7 +202,6 @@ test_expect_success 'test the [branch] option' ' test_expect_success 'test --onto ' ' git checkout -b test-onto branch2 && - set_fake_editor && git rebase -i --onto branch1 F && test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" && test $(git rev-parse HEAD^) = $(git rev-parse branch1) && @@ -210,7 +211,6 @@ test_expect_success 'test --onto ' ' test_expect_success 'rebase on top of a non-conflicting commit' ' git checkout branch1 && git tag original-branch1 && - set_fake_editor && git rebase -i branch2 && test file6 = $(git diff --name-only original-branch1) && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" && @@ -223,38 +223,42 @@ test_expect_success 'reflog for the branch shows state before rebase' ' ' test_expect_success 'reflog for the branch shows correct finish message' ' - printf "rebase -i (finish): refs/heads/branch1 onto %s\n" \ + printf "rebase (finish): refs/heads/branch1 onto %s\n" \ "$(git rev-parse branch2)" >expected && git log -g --pretty=%gs -1 refs/heads/branch1 >actual && test_cmp expected actual ' test_expect_success 'exchange two commits' ' - set_fake_editor && - FAKE_LINES="2 1" git rebase -i HEAD~2 && + ( + set_fake_editor && + FAKE_LINES="2 1" git rebase -i HEAD~2 + ) && test H = $(git cat-file commit HEAD^ | sed -ne \$p) && - test G = $(git cat-file commit HEAD | sed -ne \$p) + test G = $(git cat-file commit HEAD | sed -ne \$p) && + blob1=$(git rev-parse --short HEAD^:file1) && + blob2=$(git rev-parse --short HEAD:file1) && + commit=$(git rev-parse --short HEAD) ' test_expect_success 'stop on conflicting pick' ' - cat >expect <<-\EOF && + cat >expect <<-EOF && diff --git a/file1 b/file1 - index f70f10e..fd79235 100644 + index $blob1..$blob2 100644 --- a/file1 +++ b/file1 @@ -1 +1 @@ -A +G EOF - cat >expect2 <<-\EOF && + cat >expect2 <<-EOF && <<<<<<< HEAD D ======= G - >>>>>>> 5d18e54... G + >>>>>>> $commit... G EOF git tag new-branch1 && - set_fake_editor && test_must_fail git rebase -i master && test "$(git rev-parse HEAD~3)" = "$(git rev-parse master)" && test_cmp expect .git/rebase-merge/patch && @@ -283,7 +287,6 @@ test_expect_success 'abort' ' test_expect_success 'abort with error when new base cannot be checked out' ' git rm --cached file1 && git commit -m "remove file in base" && - set_fake_editor && test_must_fail git rebase -i master > output 2>&1 && test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" \ output && @@ -298,7 +301,6 @@ test_expect_success 'retain authorship' ' test_tick && GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" && git tag twerp && - set_fake_editor && git rebase -i --onto master HEAD^ && git show HEAD | grep "^Author: Twerp Snog" ' @@ -316,7 +318,6 @@ test_expect_success 'retain authorship w/ conflicts' ' test_commit b conflict b conflict-b && GIT_AUTHOR_NAME=$oGIT_AUTHOR_NAME && - set_fake_editor && test_must_fail git rebase -i conflict-a && echo resolved >conflict && git add conflict && @@ -332,9 +333,11 @@ test_expect_success 'squash' ' test_tick && GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 && echo "******************************" && - set_fake_editor && - FAKE_LINES="1 squash 2" EXPECT_HEADER_COUNT=2 \ - git rebase -i --onto master HEAD~2 && + ( + set_fake_editor && + FAKE_LINES="1 squash 2" EXPECT_HEADER_COUNT=2 \ + git rebase -i --onto master HEAD~2 + ) && test B = $(cat file7) && test $(git rev-parse HEAD^) = $(git rev-parse master) ' @@ -345,7 +348,6 @@ test_expect_success 'retain authorship when squashing' ' test_expect_success REBASE_P '-p handles "no changes" gracefully' ' HEAD=$(git rev-parse HEAD) && - set_fake_editor && git rebase -i -p HEAD^ && git update-index --refresh && git diff-files --quiet && @@ -355,8 +357,10 @@ test_expect_success REBASE_P '-p handles "no changes" gracefully' ' test_expect_failure REBASE_P 'exchange two commits with -p' ' git checkout H && - set_fake_editor && - FAKE_LINES="2 1" git rebase -i -p HEAD~2 && + ( + set_fake_editor && + FAKE_LINES="2 1" git rebase -i -p HEAD~2 + ) && test H = $(git cat-file commit HEAD^ | sed -ne \$p) && test G = $(git cat-file commit HEAD | sed -ne \$p) ' @@ -390,7 +394,6 @@ test_expect_success REBASE_P 'preserve merges with -p' ' git commit -m M file1 && git checkout -b to-be-rebased && test_tick && - set_fake_editor && git rebase -i -p --onto branch1 master && git update-index --refresh && git diff-files --quiet && @@ -405,8 +408,10 @@ test_expect_success REBASE_P 'preserve merges with -p' ' ' test_expect_success REBASE_P 'edit ancestor with -p' ' - set_fake_editor && - FAKE_LINES="1 2 edit 3 4" git rebase -i -p HEAD~3 && + ( + set_fake_editor && + FAKE_LINES="1 2 edit 3 4" git rebase -i -p HEAD~3 + ) && echo 2 > unrelated-file && test_tick && git commit -m L2-modified --amend unrelated-file && @@ -420,11 +425,13 @@ test_expect_success REBASE_P 'edit ancestor with -p' ' test_expect_success '--continue tries to commit' ' git reset --hard D && test_tick && - set_fake_editor && - test_must_fail git rebase -i --onto new-branch1 HEAD^ && - echo resolved > file1 && - git add file1 && - FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue && + ( + set_fake_editor && + test_must_fail git rebase -i --onto new-branch1 HEAD^ && + echo resolved > file1 && + git add file1 && + FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue + ) && test $(git rev-parse HEAD^) = $(git rev-parse new-branch1) && git show HEAD | grep chouette ' @@ -432,7 +439,6 @@ test_expect_success '--continue tries to commit' ' test_expect_success 'verbose flag is heeded, even after --continue' ' git reset --hard master@{1} && test_tick && - set_fake_editor && test_must_fail git rebase -v -i --onto new-branch1 HEAD^ && echo resolved > file1 && git add file1 && @@ -442,10 +448,13 @@ test_expect_success 'verbose flag is heeded, even after --continue' ' test_expect_success C_LOCALE_OUTPUT 'multi-squash only fires up editor once' ' base=$(git rev-parse HEAD~4) && - set_fake_editor && - FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 squash 2 squash 3 squash 4" \ - EXPECT_HEADER_COUNT=4 \ - git rebase -i $base && + ( + set_fake_editor && + FAKE_COMMIT_AMEND="ONCE" \ + FAKE_LINES="1 squash 2 squash 3 squash 4" \ + EXPECT_HEADER_COUNT=4 \ + git rebase -i $base + ) && test $base = $(git rev-parse HEAD^) && test 1 = $(git show | grep ONCE | wc -l) ' @@ -453,9 +462,12 @@ test_expect_success C_LOCALE_OUTPUT 'multi-squash only fires up editor once' ' test_expect_success C_LOCALE_OUTPUT 'multi-fixup does not fire up editor' ' git checkout -b multi-fixup E && base=$(git rev-parse HEAD~4) && - set_fake_editor && - FAKE_COMMIT_AMEND="NEVER" FAKE_LINES="1 fixup 2 fixup 3 fixup 4" \ - git rebase -i $base && + ( + set_fake_editor && + FAKE_COMMIT_AMEND="NEVER" \ + FAKE_LINES="1 fixup 2 fixup 3 fixup 4" \ + git rebase -i $base + ) && test $base = $(git rev-parse HEAD^) && test 0 = $(git show | grep NEVER | wc -l) && git checkout @{-1} && @@ -465,12 +477,15 @@ test_expect_success C_LOCALE_OUTPUT 'multi-fixup does not fire up editor' ' test_expect_success 'commit message used after conflict' ' git checkout -b conflict-fixup conflict-branch && base=$(git rev-parse HEAD~4) && - set_fake_editor && - test_must_fail env FAKE_LINES="1 fixup 3 fixup 4" git rebase -i $base && - echo three > conflict && - git add conflict && - FAKE_COMMIT_AMEND="ONCE" EXPECT_HEADER_COUNT=2 \ - git rebase --continue && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 fixup 3 fixup 4" \ + git rebase -i $base && + echo three > conflict && + git add conflict && + FAKE_COMMIT_AMEND="ONCE" EXPECT_HEADER_COUNT=2 \ + git rebase --continue + ) && test $base = $(git rev-parse HEAD^) && test 1 = $(git show | grep ONCE | wc -l) && git checkout @{-1} && @@ -480,12 +495,15 @@ test_expect_success 'commit message used after conflict' ' test_expect_success 'commit message retained after conflict' ' git checkout -b conflict-squash conflict-branch && base=$(git rev-parse HEAD~4) && - set_fake_editor && - test_must_fail env FAKE_LINES="1 fixup 3 squash 4" git rebase -i $base && - echo three > conflict && - git add conflict && - FAKE_COMMIT_AMEND="TWICE" EXPECT_HEADER_COUNT=2 \ - git rebase --continue && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 fixup 3 squash 4" \ + git rebase -i $base && + echo three > conflict && + git add conflict && + FAKE_COMMIT_AMEND="TWICE" EXPECT_HEADER_COUNT=2 \ + git rebase --continue + ) && test $base = $(git rev-parse HEAD^) && test 2 = $(git show | grep TWICE | wc -l) && git checkout @{-1} && @@ -502,10 +520,13 @@ test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messa EOF git checkout -b squash-fixup E && base=$(git rev-parse HEAD~4) && - set_fake_editor && - FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 squash 3 fixup 4" \ - EXPECT_HEADER_COUNT=4 \ - git rebase -i $base && + ( + set_fake_editor && + FAKE_COMMIT_AMEND="ONCE" \ + FAKE_LINES="1 fixup 2 squash 3 fixup 4" \ + EXPECT_HEADER_COUNT=4 \ + git rebase -i $base + ) && git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup && test_cmp expect-squash-fixup actual-squash-fixup && git cat-file commit HEAD@{2} | @@ -519,10 +540,13 @@ test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messa test_expect_success C_LOCALE_OUTPUT 'squash ignores comments' ' git checkout -b skip-comments E && base=$(git rev-parse HEAD~4) && - set_fake_editor && - FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="# 1 # squash 2 # squash 3 # squash 4 #" \ - EXPECT_HEADER_COUNT=4 \ - git rebase -i $base && + ( + set_fake_editor && + FAKE_COMMIT_AMEND="ONCE" \ + FAKE_LINES="# 1 # squash 2 # squash 3 # squash 4 #" \ + EXPECT_HEADER_COUNT=4 \ + git rebase -i $base + ) && test $base = $(git rev-parse HEAD^) && test 1 = $(git show | grep ONCE | wc -l) && git checkout @{-1} && @@ -532,10 +556,13 @@ test_expect_success C_LOCALE_OUTPUT 'squash ignores comments' ' test_expect_success C_LOCALE_OUTPUT 'squash ignores blank lines' ' git checkout -b skip-blank-lines E && base=$(git rev-parse HEAD~4) && - set_fake_editor && - FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="> 1 > squash 2 > squash 3 > squash 4 >" \ - EXPECT_HEADER_COUNT=4 \ - git rebase -i $base && + ( + set_fake_editor && + FAKE_COMMIT_AMEND="ONCE" \ + FAKE_LINES="> 1 > squash 2 > squash 3 > squash 4 >" \ + EXPECT_HEADER_COUNT=4 \ + git rebase -i $base + ) && test $base = $(git rev-parse HEAD^) && test 1 = $(git show | grep ONCE | wc -l) && git checkout @{-1} && @@ -545,17 +572,21 @@ test_expect_success C_LOCALE_OUTPUT 'squash ignores blank lines' ' test_expect_success 'squash works as expected' ' git checkout -b squash-works no-conflict-branch && one=$(git rev-parse HEAD~3) && - set_fake_editor && - FAKE_LINES="1 s 3 2" EXPECT_HEADER_COUNT=2 \ - git rebase -i HEAD~3 && + ( + set_fake_editor && + FAKE_LINES="1 s 3 2" EXPECT_HEADER_COUNT=2 git rebase -i HEAD~3 + ) && test $one = $(git rev-parse HEAD~2) ' test_expect_success 'interrupted squash works as expected' ' git checkout -b interrupted-squash conflict-branch && one=$(git rev-parse HEAD~3) && - set_fake_editor && - test_must_fail env FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 squash 3 2" \ + git rebase -i HEAD~3 + ) && test_write_lines one two four > conflict && git add conflict && test_must_fail git rebase --continue && @@ -568,8 +599,11 @@ test_expect_success 'interrupted squash works as expected' ' test_expect_success 'interrupted squash works as expected (case 2)' ' git checkout -b interrupted-squash2 conflict-branch && one=$(git rev-parse HEAD~3) && - set_fake_editor && - test_must_fail env FAKE_LINES="3 squash 1 2" git rebase -i HEAD~3 && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="3 squash 1 2" \ + git rebase -i HEAD~3 + ) && test_write_lines one four > conflict && git add conflict && test_must_fail git rebase --continue && @@ -589,11 +623,13 @@ test_expect_success '--continue tries to commit, even for "edit"' ' git commit -m "unrelated change" && parent=$(git rev-parse HEAD^) && test_tick && - set_fake_editor && - FAKE_LINES="edit 1" git rebase -i HEAD^ && - echo edited > file7 && - git add file7 && - FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue && + ( + set_fake_editor && + FAKE_LINES="edit 1" git rebase -i HEAD^ && + echo edited > file7 && + git add file7 && + FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue + ) && test edited = $(git show HEAD:file7) && git show HEAD | grep chouette && test $parent = $(git rev-parse HEAD^) @@ -602,34 +638,41 @@ test_expect_success '--continue tries to commit, even for "edit"' ' test_expect_success 'aborted --continue does not squash commits after "edit"' ' old=$(git rev-parse HEAD) && test_tick && - set_fake_editor && - FAKE_LINES="edit 1" git rebase -i HEAD^ && - echo "edited again" > file7 && - git add file7 && - test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue && + ( + set_fake_editor && + FAKE_LINES="edit 1" git rebase -i HEAD^ && + echo "edited again" > file7 && + git add file7 && + test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue + ) && test $old = $(git rev-parse HEAD) && git rebase --abort ' test_expect_success 'auto-amend only edited commits after "edit"' ' test_tick && - set_fake_editor && - FAKE_LINES="edit 1" git rebase -i HEAD^ && - echo "edited again" > file7 && - git add file7 && - FAKE_COMMIT_MESSAGE="edited file7 again" git commit && - echo "and again" > file7 && - git add file7 && - test_tick && - test_must_fail env FAKE_COMMIT_MESSAGE="and again" git rebase --continue && + ( + set_fake_editor && + FAKE_LINES="edit 1" git rebase -i HEAD^ && + echo "edited again" > file7 && + git add file7 && + FAKE_COMMIT_MESSAGE="edited file7 again" git commit && + echo "and again" > file7 && + git add file7 && + test_tick && + test_must_fail env FAKE_COMMIT_MESSAGE="and again" \ + git rebase --continue + ) && git rebase --abort ' test_expect_success 'clean error after failed "exec"' ' test_tick && test_when_finished "git rebase --abort || :" && - set_fake_editor && - test_must_fail env FAKE_LINES="1 exec_false" git rebase -i HEAD^ && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 exec_false" git rebase -i HEAD^ + ) && echo "edited again" > file7 && git add file7 && test_must_fail git rebase --continue 2>error && @@ -640,8 +683,10 @@ test_expect_success 'rebase a detached HEAD' ' grandparent=$(git rev-parse HEAD~2) && git checkout $(git rev-parse HEAD) && test_tick && - set_fake_editor && - FAKE_LINES="2 1" git rebase -i HEAD~2 && + ( + set_fake_editor && + FAKE_LINES="2 1" git rebase -i HEAD~2 + ) && test $grandparent = $(git rev-parse HEAD~2) ' @@ -656,9 +701,10 @@ test_expect_success 'rebase a commit violating pre-commit' ' test_must_fail git commit -m doesnt-verify file1 && git commit -m doesnt-verify --no-verify file1 && test_tick && - set_fake_editor && - FAKE_LINES=2 git rebase -i HEAD~2 - + ( + set_fake_editor && + FAKE_LINES=2 git rebase -i HEAD~2 + ) ' test_expect_success 'rebase with a file named HEAD in worktree' ' @@ -678,8 +724,10 @@ test_expect_success 'rebase with a file named HEAD in worktree' ' git commit -m "Add body" ) && - set_fake_editor && - FAKE_LINES="1 squash 2" git rebase -i @{-1} && + ( + set_fake_editor && + FAKE_LINES="1 squash 2" git rebase -i @{-1} + ) && test "$(git show -s --pretty=format:%an)" = "Squashed Away" ' @@ -690,7 +738,6 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' ' GIT_EDITOR=: git commit --amend \ --author="Somebody else " && test $(git rev-parse branch3) != $(git rev-parse branch4) && - set_fake_editor && git rebase -i branch3 && test $(git rev-parse branch3) = $(git rev-parse branch4) @@ -715,13 +762,14 @@ test_expect_success 'submodule rebase setup' ' git commit -a -m "submodule second" ) && test_tick && - set_fake_editor && git commit -a -m "Three changes submodule" ' test_expect_success 'submodule rebase -i' ' - set_fake_editor && - FAKE_LINES="1 squash 2 3" git rebase -i A + ( + set_fake_editor && + FAKE_LINES="1 squash 2 3" git rebase -i A + ) ' test_expect_success 'submodule conflict setup' ' @@ -738,7 +786,6 @@ test_expect_success 'submodule conflict setup' ' ' test_expect_success 'rebase -i continue with only submodule staged' ' - set_fake_editor && test_must_fail git rebase -i submodule-base && git add sub && git rebase --continue && @@ -748,7 +795,6 @@ test_expect_success 'rebase -i continue with only submodule staged' ' test_expect_success 'rebase -i continue with unstaged submodule' ' git checkout submodule-topic && git reset --hard && - set_fake_editor && test_must_fail git rebase -i submodule-base && git reset && git rebase --continue && @@ -761,7 +807,6 @@ test_expect_success 'avoid unnecessary reset' ' test-tool chmtime =123456789 file3 && git update-index --refresh && HEAD=$(git rev-parse HEAD) && - set_fake_editor && git rebase -i HEAD~4 && test $HEAD = $(git rev-parse HEAD) && MTIME=$(test-tool chmtime --get file3) && @@ -770,16 +815,22 @@ test_expect_success 'avoid unnecessary reset' ' test_expect_success 'reword' ' git checkout -b reword-branch master && - set_fake_editor && - FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" git rebase -i A && - git show HEAD | grep "E changed" && - test $(git rev-parse master) != $(git rev-parse HEAD) && - test $(git rev-parse master^) = $(git rev-parse HEAD^) && - FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" git rebase -i A && - git show HEAD^ | grep "D changed" && - FAKE_LINES="reword 1 2 3 4" FAKE_COMMIT_MESSAGE="B changed" git rebase -i A && - git show HEAD~3 | grep "B changed" && - FAKE_LINES="1 r 2 pick 3 p 4" FAKE_COMMIT_MESSAGE="C changed" git rebase -i A && + ( + set_fake_editor && + FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" \ + git rebase -i A && + git show HEAD | grep "E changed" && + test $(git rev-parse master) != $(git rev-parse HEAD) && + test $(git rev-parse master^) = $(git rev-parse HEAD^) && + FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" \ + git rebase -i A && + git show HEAD^ | grep "D changed" && + FAKE_LINES="reword 1 2 3 4" FAKE_COMMIT_MESSAGE="B changed" \ + git rebase -i A && + git show HEAD~3 | grep "B changed" && + FAKE_LINES="1 r 2 pick 3 p 4" FAKE_COMMIT_MESSAGE="C changed" \ + git rebase -i A + ) && git show HEAD~2 | grep "C changed" ' @@ -790,7 +841,6 @@ test_expect_success 'rebase -i can copy notes' ' test_commit n2 && test_commit n3 && git notes add -m"a note" n3 && - set_fake_editor && git rebase -i --onto n1 n2 && test "a note" = "$(git notes show HEAD)" ' @@ -803,8 +853,11 @@ test_expect_success 'rebase -i can copy notes over a fixup' ' EOF git reset --hard n3 && git notes add -m"an earlier note" n2 && - set_fake_editor && - GIT_NOTES_REWRITE_MODE=concatenate FAKE_LINES="1 f 2" git rebase -i n1 && + ( + set_fake_editor && + GIT_NOTES_REWRITE_MODE=concatenate FAKE_LINES="1 f 2" \ + git rebase -i n1 + ) && git notes show > output && test_cmp expect output ' @@ -813,8 +866,10 @@ test_expect_success 'rebase while detaching HEAD' ' git symbolic-ref HEAD && grandparent=$(git rev-parse HEAD~2) && test_tick && - set_fake_editor && - FAKE_LINES="2 1" git rebase -i HEAD~2 HEAD^0 && + ( + set_fake_editor && + FAKE_LINES="2 1" git rebase -i HEAD~2 HEAD^0 + ) && test $grandparent = $(git rev-parse HEAD~2) && test_must_fail git symbolic-ref HEAD ' @@ -823,7 +878,6 @@ test_tick # Ensure that the rebased commits get a different timestamp. test_expect_success 'always cherry-pick with --no-ff' ' git checkout no-ff-branch && git tag original-no-ff-branch && - set_fake_editor && git rebase -i --no-ff A && for p in 0 1 2 do @@ -855,8 +909,10 @@ test_expect_success 'set up commits with funny messages' ' test_expect_success 'rebase-i history with funny messages' ' git rev-list A..funny >expect && test_tick && - set_fake_editor && - FAKE_LINES="1 2 3 4" git rebase -i A && + ( + set_fake_editor && + FAKE_LINES="1 2 3 4" git rebase -i A + ) && git rev-list A.. >actual && test_cmp expect actual ' @@ -870,9 +926,9 @@ test_expect_success 'prepare for rebase -i --exec' ' ' test_expect_success 'running "git rebase -i --exec git show HEAD"' ' - set_fake_editor && - git rebase -i --exec "git show HEAD" HEAD~2 >actual && ( + set_fake_editor && + git rebase -i --exec "git show HEAD" HEAD~2 >actual && FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" && export FAKE_LINES && git rebase -i HEAD~2 >expect @@ -883,9 +939,9 @@ test_expect_success 'running "git rebase -i --exec git show HEAD"' ' test_expect_success 'running "git rebase --exec git show HEAD -i"' ' git reset --hard execute && - set_fake_editor && - git rebase --exec "git show HEAD" -i HEAD~2 >actual && ( + set_fake_editor && + git rebase --exec "git show HEAD" -i HEAD~2 >actual && FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" && export FAKE_LINES && git rebase -i HEAD~2 >expect @@ -896,9 +952,9 @@ test_expect_success 'running "git rebase --exec git show HEAD -i"' ' test_expect_success 'running "git rebase -ix git show HEAD"' ' git reset --hard execute && - set_fake_editor && - git rebase -ix "git show HEAD" HEAD~2 >actual && ( + set_fake_editor && + git rebase -ix "git show HEAD" HEAD~2 >actual && FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" && export FAKE_LINES && git rebase -i HEAD~2 >expect @@ -910,9 +966,9 @@ test_expect_success 'running "git rebase -ix git show HEAD"' ' test_expect_success 'rebase -ix with several ' ' git reset --hard execute && - set_fake_editor && - git rebase -ix "git show HEAD; pwd" HEAD~2 >actual && ( + set_fake_editor && + git rebase -ix "git show HEAD; pwd" HEAD~2 >actual && FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd" && export FAKE_LINES && git rebase -i HEAD~2 >expect @@ -923,9 +979,9 @@ test_expect_success 'rebase -ix with several ' ' test_expect_success 'rebase -ix with several instances of --exec' ' git reset --hard execute && - set_fake_editor && - git rebase -i --exec "git show HEAD" --exec "pwd" HEAD~2 >actual && ( + set_fake_editor && + git rebase -i --exec "git show HEAD" --exec "pwd" HEAD~2 >actual && FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2 exec_git_show_HEAD exec_pwd" && export FAKE_LINES && @@ -944,13 +1000,11 @@ test_expect_success C_LOCALE_OUTPUT 'rebase -ix with --autosquash' ' echo bis >bis.txt && git add bis.txt && git commit -m "fixup! two_exec" && - set_fake_editor && - ( - git checkout -b autosquash_actual && - git rebase -i --exec "git show HEAD" --autosquash HEAD~4 >actual - ) && + git checkout -b autosquash_actual && + git rebase -i --exec "git show HEAD" --autosquash HEAD~4 >actual && git checkout autosquash && ( + set_fake_editor && git checkout -b autosquash_expected && FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD" && export FAKE_LINES && @@ -971,7 +1025,6 @@ test_expect_success 'rebase --exec works without -i ' ' test_expect_success 'rebase -i --exec without ' ' git reset --hard execute && - set_fake_editor && test_must_fail git rebase -i --exec 2>actual && test_i18ngrep "requires a value" actual && git checkout master @@ -979,8 +1032,10 @@ test_expect_success 'rebase -i --exec without ' ' test_expect_success 'rebase -i --root re-order and drop commits' ' git checkout E && - set_fake_editor && - FAKE_LINES="3 1 2 5" git rebase -i --root && + ( + set_fake_editor && + FAKE_LINES="3 1 2 5" git rebase -i --root + ) && test E = $(git cat-file commit HEAD | sed -ne \$p) && test B = $(git cat-file commit HEAD^ | sed -ne \$p) && test A = $(git cat-file commit HEAD^^ | sed -ne \$p) && @@ -993,39 +1048,59 @@ test_expect_success 'rebase -i --root retain root commit author and message' ' echo B >file7 && git add file7 && GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" && - set_fake_editor && - FAKE_LINES="2" git rebase -i --root && + ( + set_fake_editor && + FAKE_LINES="2" git rebase -i --root + ) && git cat-file commit HEAD | grep -q "^author Twerp Snog" && git cat-file commit HEAD | grep -q "^different author$" ' test_expect_success 'rebase -i --root temporary sentinel commit' ' git checkout B && - set_fake_editor && - test_must_fail env FAKE_LINES="2" git rebase -i --root && - git cat-file commit HEAD | grep "^tree 4b825dc642cb" && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="2" git rebase -i --root + ) && + git cat-file commit HEAD | grep "^tree $EMPTY_TREE" && git rebase --abort ' test_expect_success 'rebase -i --root fixup root commit' ' git checkout B && - set_fake_editor && - FAKE_LINES="1 fixup 2" git rebase -i --root && + ( + set_fake_editor && + FAKE_LINES="1 fixup 2" git rebase -i --root + ) && test A = $(git cat-file commit HEAD | sed -ne \$p) && test B = $(git show HEAD:file1) && test 0 = $(git cat-file commit HEAD | grep -c ^parent\ ) ' -test_expect_success 'rebase -i --root reword root commit' ' +test_expect_success 'rebase -i --root reword original root commit' ' test_when_finished "test_might_fail git rebase --abort" && - git checkout -b reword-root-branch master && - set_fake_editor && - FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \ - git rebase -i --root && + git checkout -b reword-original-root-branch master && + ( + set_fake_editor && + FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \ + git rebase -i --root + ) && git show HEAD^ | grep "A changed" && test -z "$(git show -s --format=%p HEAD^)" ' +test_expect_success 'rebase -i --root reword new root commit' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout -b reword-now-root-branch master && + ( + set_fake_editor && + FAKE_LINES="reword 3 1" FAKE_COMMIT_MESSAGE="C changed" \ + git rebase -i --root + ) && + git show HEAD^ | grep "C changed" && + test -z "$(git show -s --format=%p HEAD^)" +' + test_expect_success 'rebase -i --root when root has untracked file conflict' ' test_when_finished "reset_rebase" && git checkout -b failing-root-pick A && @@ -1033,8 +1108,10 @@ test_expect_success 'rebase -i --root when root has untracked file conflict' ' git rm file1 && git commit -m "remove file 1 add file 2" && echo z >file1 && - set_fake_editor && - test_must_fail env FAKE_LINES="1 2" git rebase -i --root && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 2" git rebase -i --root + ) && rm file1 && git rebase --continue && test "$(git log -1 --format=%B)" = "remove file 1 add file 2" && @@ -1044,32 +1121,38 @@ test_expect_success 'rebase -i --root when root has untracked file conflict' ' test_expect_success 'rebase -i --root reword root when root has untracked file conflict' ' test_when_finished "reset_rebase" && echo z>file1 && - set_fake_editor && - test_must_fail env FAKE_LINES="reword 1 2" \ - FAKE_COMMIT_MESSAGE="Modified A" git rebase -i --root && - rm file1 && - FAKE_COMMIT_MESSAGE="Reworded A" git rebase --continue && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="reword 1 2" \ + FAKE_COMMIT_MESSAGE="Modified A" git rebase -i --root && + rm file1 && + FAKE_COMMIT_MESSAGE="Reworded A" git rebase --continue + ) && test "$(git log -1 --format=%B HEAD^)" = "Reworded A" && test "$(git rev-list --count HEAD)" = 2 ' test_expect_success C_LOCALE_OUTPUT 'rebase --edit-todo does not work on non-interactive rebase' ' - git checkout reword-root-branch && + git checkout reword-original-root-branch && git reset --hard && git checkout conflict-branch && - set_fake_editor && - test_must_fail git rebase --onto HEAD~2 HEAD~ && - test_must_fail git rebase --edit-todo && + ( + set_fake_editor && + test_must_fail git rebase -f --apply --onto HEAD~2 HEAD~ && + test_must_fail git rebase --edit-todo + ) && git rebase --abort ' test_expect_success 'rebase --edit-todo can be used to modify todo' ' git reset --hard && git checkout no-conflict-branch^0 && - set_fake_editor && - FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 && - FAKE_LINES="2 1" git rebase --edit-todo && - git rebase --continue && + ( + set_fake_editor && + FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 && + FAKE_LINES="2 1" git rebase --edit-todo && + git rebase --continue + ) && test M = $(git cat-file commit HEAD^ | sed -ne \$p) && test L = $(git cat-file commit HEAD | sed -ne \$p) ' @@ -1077,13 +1160,12 @@ test_expect_success 'rebase --edit-todo can be used to modify todo' ' test_expect_success 'rebase -i produces readable reflog' ' git reset --hard && git branch -f branch-reflog-test H && - set_fake_editor && git rebase -i --onto I F branch-reflog-test && cat >expect <<-\EOF && - rebase -i (finish): returning to refs/heads/branch-reflog-test - rebase -i (pick): H - rebase -i (pick): G - rebase -i (start): checkout I + rebase (finish): returning to refs/heads/branch-reflog-test + rebase (pick): H + rebase (pick): G + rebase (start): checkout I EOF git reflog -n4 HEAD | sed "s/[^:]*: //" >actual && @@ -1098,8 +1180,10 @@ test_expect_success 'rebase -i respects core.commentchar' ' sed -e "2,\$s/^/\\\\/" "$1" >"$1.tmp" && mv "$1.tmp" "$1" EOF - test_set_editor "$(pwd)/remove-all-but-first.sh" && - git rebase -i B && + ( + test_set_editor "$(pwd)/remove-all-but-first.sh" && + git rebase -i B + ) && test B = $(git cat-file commit HEAD^ | sed -ne \$p) ' @@ -1108,9 +1192,11 @@ test_expect_success 'rebase -i respects core.commentchar=auto' ' write_script copy-edit-script.sh <<-\EOF && cp "$1" edit-script EOF - test_set_editor "$(pwd)/copy-edit-script.sh" && test_when_finished "git rebase --abort || :" && - git rebase -i HEAD^ && + ( + test_set_editor "$(pwd)/copy-edit-script.sh" && + git rebase -i HEAD^ + ) && test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)" ' @@ -1145,8 +1231,11 @@ test_expect_success 'interrupted rebase -i with --strategy and -X' ' echo five >conflict && echo Z >file1 && git commit -a -m "one file conflict" && - set_fake_editor && - FAKE_LINES="edit 1 2" git rebase -i --strategy=recursive -Xours conflict-branch && + ( + set_fake_editor && + FAKE_LINES="edit 1 2" git rebase -i --strategy=recursive \ + -Xours conflict-branch + ) && git rebase --continue && test $(git show conflict-branch:conflict) = $(cat conflict) && test $(cat file1) = Z @@ -1161,7 +1250,7 @@ test_expect_success 'rebase -i error on commits with \ in message' ' test_expect_code 1 grep " emp" error ' -test_expect_success 'short SHA-1 setup' ' +test_expect_success SHA1 'short SHA-1 setup' ' test_when_finished "git checkout master" && git checkout --orphan collide && git rm -rf . && @@ -1173,22 +1262,37 @@ test_expect_success 'short SHA-1 setup' ' ) ' -test_expect_success 'short SHA-1 collide' ' +test_expect_success SHA1 'short SHA-1 collide' ' test_when_finished "reset_rebase && git checkout master" && git checkout collide && + colliding_sha1=6bcda37 && + test $colliding_sha1 = "$(git rev-parse HEAD | cut -c 1-7)" && ( - unset test_tick && - test_tick && - set_fake_editor && - FAKE_COMMIT_MESSAGE="collide2 ac4f2ee" \ - FAKE_LINES="reword 1 2" git rebase -i HEAD~2 - ) + unset test_tick && + test_tick && + set_fake_editor && + FAKE_COMMIT_MESSAGE="collide2 ac4f2ee" \ + FAKE_LINES="reword 1 break 2" git rebase -i HEAD~2 && + test $colliding_sha1 = "$(git rev-parse HEAD | cut -c 1-7)" && + grep "^pick $colliding_sha1 " \ + .git/rebase-merge/git-rebase-todo.tmp && + grep "^pick [0-9a-f]\{40\}" \ + .git/rebase-merge/git-rebase-todo && + grep "^pick [0-9a-f]\{40\}" \ + .git/rebase-merge/git-rebase-todo.backup && + git rebase --continue + ) && + collide2="$(git rev-parse HEAD~1 | cut -c 1-4)" && + collide3="$(git rev-parse collide3 | cut -c 1-4)" && + test "$collide2" = "$collide3" ' test_expect_success 'respect core.abbrev' ' git config core.abbrev 12 && - set_cat_todo_editor && - test_must_fail git rebase -i HEAD~4 >todo-list && + ( + set_cat_todo_editor && + test_must_fail git rebase -i HEAD~4 >todo-list + ) && test 4 = $(grep -c "pick [0-9a-f]\{12,\}" todo-list) ' @@ -1196,16 +1300,20 @@ test_expect_success 'todo count' ' write_script dump-raw.sh <<-\EOF && cat "$1" EOF - test_set_editor "$(pwd)/dump-raw.sh" && - git rebase -i HEAD~4 >actual && + ( + test_set_editor "$(pwd)/dump-raw.sh" && + git rebase -i HEAD~4 >actual + ) && test_i18ngrep "^# Rebase ..* onto ..* ([0-9]" actual ' test_expect_success 'rebase -i commits that overwrite untracked files (pick)' ' git checkout --force branch2 && git clean -f && - set_fake_editor && - FAKE_LINES="edit 1 2" git rebase -i A && + ( + set_fake_editor && + FAKE_LINES="edit 1 2" git rebase -i A + ) && test_cmp_rev HEAD F && test_path_is_missing file6 && >file6 && @@ -1220,8 +1328,10 @@ test_expect_success 'rebase -i commits that overwrite untracked files (squash)' git checkout --force branch2 && git clean -f && git tag original-branch2 && - set_fake_editor && - FAKE_LINES="edit 1 squash 2" git rebase -i A && + ( + set_fake_editor && + FAKE_LINES="edit 1 squash 2" git rebase -i A + ) && test_cmp_rev HEAD F && test_path_is_missing file6 && >file6 && @@ -1236,8 +1346,10 @@ test_expect_success 'rebase -i commits that overwrite untracked files (squash)' test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' ' git checkout --force branch2 && git clean -f && - set_fake_editor && - FAKE_LINES="edit 1 2" git rebase -i --no-ff A && + ( + set_fake_editor && + FAKE_LINES="edit 1 2" git rebase -i --no-ff A + ) && test $(git cat-file commit HEAD | sed -ne \$p) = F && test_path_is_missing file6 && >file6 && @@ -1260,8 +1372,10 @@ test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' ' git tag seq-onto && git reset --hard HEAD~2 && git cherry-pick seq-onto && - set_fake_editor && - test_must_fail env FAKE_LINES= git rebase -i seq-onto && + ( + set_fake_editor && + test_must_fail env FAKE_LINES= git rebase -i seq-onto + ) && test -d .git/rebase-merge && git rebase --continue && git diff --exit-code seq-onto && @@ -1280,8 +1394,10 @@ rebase_setup_and_clean () { test_expect_success 'drop' ' rebase_setup_and_clean drop-test && - set_fake_editor && - FAKE_LINES="1 drop 2 3 d 4 5" git rebase -i --root && + ( + set_fake_editor && + FAKE_LINES="1 drop 2 3 d 4 5" git rebase -i --root + ) && test E = $(git cat-file commit HEAD | sed -ne \$p) && test C = $(git cat-file commit HEAD^ | sed -ne \$p) && test A = $(git cat-file commit HEAD^^ | sed -ne \$p) @@ -1290,9 +1406,10 @@ test_expect_success 'drop' ' test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' ' test_config rebase.missingCommitsCheck ignore && rebase_setup_and_clean missing-commit && - set_fake_editor && - FAKE_LINES="1 2 3 4" \ - git rebase -i --root 2>actual && + ( + set_fake_editor && + FAKE_LINES="1 2 3 4" git rebase -i --root 2>actual + ) && test D = $(git cat-file commit HEAD | sed -ne \$p) && test_i18ngrep \ "Successfully rebased and updated refs/heads/missing-commit" \ @@ -1308,9 +1425,10 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' ' EOF test_config rebase.missingCommitsCheck warn && rebase_setup_and_clean missing-commit && - set_fake_editor && - FAKE_LINES="1 2 3 4" \ - git rebase -i --root 2>actual.2 && + ( + set_fake_editor && + FAKE_LINES="1 2 3 4" git rebase -i --root 2>actual.2 + ) && head -n4 actual.2 >actual && test_i18ncmp expect actual && test D = $(git cat-file commit HEAD | sed -ne \$p) @@ -1332,19 +1450,141 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' ' EOF test_config rebase.missingCommitsCheck error && rebase_setup_and_clean missing-commit && - set_fake_editor && - test_must_fail env FAKE_LINES="1 2 4" \ - git rebase -i --root 2>actual && - test_i18ncmp expect actual && - cp .git/rebase-merge/git-rebase-todo.backup \ - .git/rebase-merge/git-rebase-todo && - FAKE_LINES="1 2 drop 3 4 drop 5" \ - git rebase --edit-todo && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 2 4" \ + git rebase -i --root 2>actual && + test_i18ncmp expect actual && + cp .git/rebase-merge/git-rebase-todo.backup \ + .git/rebase-merge/git-rebase-todo && + FAKE_LINES="1 2 drop 3 4 drop 5" git rebase --edit-todo + ) && git rebase --continue && test D = $(git cat-file commit HEAD | sed -ne \$p) && test B = $(git cat-file commit HEAD^ | sed -ne \$p) ' +test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = ignore' ' + test_config rebase.missingCommitsCheck ignore && + rebase_setup_and_clean missing-commit && + ( + set_fake_editor && + FAKE_LINES="break 1 2 3 4 5" git rebase -i --root && + FAKE_LINES="1 2 3 4" git rebase --edit-todo && + git rebase --continue 2>actual + ) && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test_i18ngrep \ + "Successfully rebased and updated refs/heads/missing-commit" \ + actual +' + +test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' ' + cat >expect <<-EOF && + error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 master~4) + Warning: some commits may have been dropped accidentally. + Dropped commits (newer to older): + - $(git rev-list --pretty=oneline --abbrev-commit -1 master) + - $(git rev-list --pretty=oneline --abbrev-commit -1 master~4) + To avoid this message, use "drop" to explicitly remove a commit. + EOF + head -n4 expect >expect.2 && + tail -n1 expect >>expect.2 && + tail -n4 expect.2 >expect.3 && + test_config rebase.missingCommitsCheck warn && + rebase_setup_and_clean missing-commit && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="bad 1 2 3 4 5" \ + git rebase -i --root && + cp .git/rebase-merge/git-rebase-todo.backup orig && + FAKE_LINES="2 3 4" git rebase --edit-todo 2>actual.2 && + head -n6 actual.2 >actual && + test_i18ncmp expect actual && + cp orig .git/rebase-merge/git-rebase-todo && + FAKE_LINES="1 2 3 4" git rebase --edit-todo 2>actual.2 && + head -n4 actual.2 >actual && + test_i18ncmp expect.3 actual && + git rebase --continue 2>actual + ) && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test_i18ngrep \ + "Successfully rebased and updated refs/heads/missing-commit" \ + actual +' + +test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = error' ' + cat >expect <<-EOF && + error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 master~4) + Warning: some commits may have been dropped accidentally. + Dropped commits (newer to older): + - $(git rev-list --pretty=oneline --abbrev-commit -1 master) + - $(git rev-list --pretty=oneline --abbrev-commit -1 master~4) + To avoid this message, use "drop" to explicitly remove a commit. + + Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings. + The possible behaviours are: ignore, warn, error. + + You can fix this with '\''git rebase --edit-todo'\'' and then run '\''git rebase --continue'\''. + Or you can abort the rebase with '\''git rebase --abort'\''. + EOF + tail -n11 expect >expect.2 && + head -n3 expect.2 >expect.3 && + tail -n7 expect.2 >>expect.3 && + test_config rebase.missingCommitsCheck error && + rebase_setup_and_clean missing-commit && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="bad 1 2 3 4 5" \ + git rebase -i --root && + cp .git/rebase-merge/git-rebase-todo.backup orig && + test_must_fail env FAKE_LINES="2 3 4" \ + git rebase --edit-todo 2>actual && + test_i18ncmp expect actual && + test_must_fail git rebase --continue 2>actual && + test_i18ncmp expect.2 actual && + test_must_fail git rebase --edit-todo && + cp orig .git/rebase-merge/git-rebase-todo && + test_must_fail env FAKE_LINES="1 2 3 4" \ + git rebase --edit-todo 2>actual && + test_i18ncmp expect.3 actual && + test_must_fail git rebase --continue 2>actual && + test_i18ncmp expect.3 actual && + cp orig .git/rebase-merge/git-rebase-todo && + FAKE_LINES="1 2 3 4 drop 5" git rebase --edit-todo && + git rebase --continue 2>actual + ) && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test_i18ngrep \ + "Successfully rebased and updated refs/heads/missing-commit" \ + actual +' + +test_expect_success 'rebase.missingCommitsCheck = error after resolving conflicts' ' + test_config rebase.missingCommitsCheck error && + ( + set_fake_editor && + FAKE_LINES="drop 1 break 2 3 4" git rebase -i A E + ) && + git rebase --edit-todo && + test_must_fail git rebase --continue && + echo x >file1 && + git add file1 && + git rebase --continue +' + +test_expect_success 'rebase.missingCommitsCheck = error when editing for a second time' ' + test_config rebase.missingCommitsCheck error && + ( + set_fake_editor && + FAKE_LINES="1 break 2 3" git rebase -i A D && + cp .git/rebase-merge/git-rebase-todo todo && + test_must_fail env FAKE_LINES=2 git rebase --edit-todo && + GIT_SEQUENCE_EDITOR="cp todo" git rebase --edit-todo && + git rebase --continue + ) +' + test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and exec' ' rebase_setup_and_clean abbrevcmd && test_commit "first" file1.txt "first line" first && @@ -1360,21 +1600,27 @@ test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and e x git show HEAD EOF git checkout abbrevcmd && - set_cat_todo_editor && test_config rebase.abbreviateCommands true && - test_must_fail git rebase -i --exec "git show HEAD" \ - --autosquash master >actual && + ( + set_cat_todo_editor && + test_must_fail git rebase -i --exec "git show HEAD" \ + --autosquash master >actual + ) && test_cmp expected actual ' test_expect_success 'static check of bad command' ' rebase_setup_and_clean bad-cmd && - set_fake_editor && - test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \ + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \ git rebase -i --root 2>actual && - test_i18ngrep "badcmd $(git rev-list --oneline -1 master~1)" actual && - test_i18ngrep "You can fix this with .git rebase --edit-todo.." actual && - FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo && + test_i18ngrep "badcmd $(git rev-list --oneline -1 master~1)" \ + actual && + test_i18ngrep "You can fix this with .git rebase --edit-todo.." \ + actual && + FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo + ) && git rebase --continue && test E = $(git cat-file commit HEAD | sed -ne \$p) && test C = $(git cat-file commit HEAD^ | sed -ne \$p) @@ -1390,19 +1636,24 @@ test_expect_success 'tabs and spaces are accepted in the todolist' ' ) >"$1.new" mv "$1.new" "$1" EOF - test_set_editor "$(pwd)/add-indent.sh" && - git rebase -i HEAD^^^ && + ( + test_set_editor "$(pwd)/add-indent.sh" && + git rebase -i HEAD^^^ + ) && test E = $(git cat-file commit HEAD | sed -ne \$p) ' test_expect_success 'static check of bad SHA-1' ' rebase_setup_and_clean bad-sha && - set_fake_editor && - test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \ - git rebase -i --root 2>actual && - test_i18ngrep "edit XXXXXXX False commit" actual && - test_i18ngrep "You can fix this with .git rebase --edit-todo.." actual && - FAKE_LINES="1 2 4 5 6" git rebase --edit-todo && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \ + git rebase -i --root 2>actual && + test_i18ngrep "edit XXXXXXX False commit" actual && + test_i18ngrep "You can fix this with .git rebase --edit-todo.." \ + actual && + FAKE_LINES="1 2 4 5 6" git rebase --edit-todo + ) && git rebase --continue && test E = $(git cat-file commit HEAD | sed -ne \$p) ' @@ -1419,42 +1670,73 @@ test_expect_success 'editor saves as CR/LF' ' ) ' -SQ="'" test_expect_success 'rebase -i --gpg-sign=' ' test_when_finished "test_might_fail git rebase --abort" && - set_fake_editor && - FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \ - >out 2>err && + ( + set_fake_editor && + FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" \ + HEAD^ >out 2>err + ) && test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err ' test_expect_success 'rebase -i --gpg-sign= overrides commit.gpgSign' ' test_when_finished "test_might_fail git rebase --abort" && test_config commit.gpgsign true && - set_fake_editor && - FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \ - >out 2>err && + ( + set_fake_editor && + FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" \ + HEAD^ >out 2>err + ) && test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err ' test_expect_success 'valid author header after --root swap' ' rebase_setup_and_clean author-header no-conflict-branch && - set_fake_editor && git commit --amend --author="Au ${SQ}thor " --no-edit && git cat-file commit HEAD | grep ^author >expected && - FAKE_LINES="5 1" git rebase -i --root && + ( + set_fake_editor && + FAKE_LINES="5 1" git rebase -i --root + ) && git cat-file commit HEAD^ | grep ^author >actual && test_cmp expected actual ' test_expect_success 'valid author header when author contains single quote' ' rebase_setup_and_clean author-header no-conflict-branch && - set_fake_editor && git commit --amend --author="Au ${SQ}thor " --no-edit && git cat-file commit HEAD | grep ^author >expected && - FAKE_LINES="2" git rebase -i HEAD~2 && + ( + set_fake_editor && + FAKE_LINES="2" git rebase -i HEAD~2 + ) && git cat-file commit HEAD | grep ^author >actual && test_cmp expected actual ' +test_expect_success 'post-commit hook is called' ' + test_when_finished "rm -f .git/hooks/post-commit" && + >actual && + mkdir -p .git/hooks && + write_script .git/hooks/post-commit <<-\EOS && + git rev-parse HEAD >>actual + EOS + ( + set_fake_editor && + FAKE_LINES="edit 4 1 reword 2 fixup 3" git rebase -i A E && + echo x>file3 && + git add file3 && + FAKE_COMMIT_MESSAGE=edited git rebase --continue + ) && + git rev-parse HEAD@{5} HEAD@{4} HEAD@{3} HEAD@{2} HEAD@{1} HEAD \ + >expect && + test_cmp expect actual +' + +# This must be the last test in this file +test_expect_success '$EDITOR and friends are unchanged' ' + test_editor_unchanged +' + test_done diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index b393e1e9fee8..61b76f330198 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -18,32 +18,29 @@ test_expect_success 'setup' ' ' test_expect_success 'rebase -m' ' - git rebase -m master >report && - >expect && - sed -n -e "/^Already applied: /p" \ - -e "/^Committed: /p" report >actual && - test_cmp expect actual + git rebase -m master >actual && + test_must_be_empty actual ' test_expect_success 'rebase against master twice' ' - git rebase master >out && + git rebase --apply master >out && test_i18ngrep "Current branch topic is up to date" out ' test_expect_success 'rebase against master twice with --force' ' - git rebase --force-rebase master >out && + git rebase --force-rebase --apply master >out && test_i18ngrep "Current branch topic is up to date, rebase forced" out ' test_expect_success 'rebase against master twice from another branch' ' git checkout topic^ && - git rebase master topic >out && + git rebase --apply master topic >out && test_i18ngrep "Current branch topic is up to date" out ' test_expect_success 'rebase fast-forward to master' ' git checkout topic^ && - git rebase topic >out && + git rebase --apply topic >out && test_i18ngrep "Fast-forwarded HEAD to topic" out ' @@ -92,7 +89,7 @@ test_expect_success 'GIT_REFLOG_ACTION' ' git checkout -b reflog-topic start && test_commit reflog-to-rebase && - git rebase reflog-onto && + git rebase --apply reflog-onto && git log -g --format=%gs -3 >actual && cat >expect <<-\EOF && rebase finished: returning to refs/heads/reflog-topic @@ -102,7 +99,7 @@ test_expect_success 'GIT_REFLOG_ACTION' ' test_cmp expect actual && git checkout -b reflog-prefix reflog-to-rebase && - GIT_REFLOG_ACTION=change-the-reflog git rebase reflog-onto && + GIT_REFLOG_ACTION=change-the-reflog git rebase --apply reflog-onto && git log -g --format=%gs -3 >actual && cat >expect <<-\EOF && rebase finished: returning to refs/heads/reflog-prefix diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 910f21828434..97efea0f5697 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -96,14 +96,14 @@ testrebase() { ' } -testrebase "" .git/rebase-apply +testrebase " --apply" .git/rebase-apply testrebase " --merge" .git/rebase-merge -test_expect_success 'rebase --quit' ' +test_expect_success 'rebase --apply --quit' ' cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && - test_must_fail git rebase master && + test_must_fail git rebase --apply master && test_path_is_dir .git/rebase-apply && head_before=$(git rev-parse HEAD) && git rebase --quit && diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh index 22d218698e95..093de9005b76 100755 --- a/t/t3415-rebase-autosquash.sh +++ b/t/t3415-rebase-autosquash.sh @@ -25,6 +25,13 @@ test_expect_success setup ' ' test_auto_fixup () { + no_squash= && + if test "x$1" = 'x!' + then + no_squash=true + shift + fi && + git reset --hard base && echo 1 >file1 && git add -u && @@ -35,10 +42,19 @@ test_auto_fixup () { test_tick && git rebase $2 -i HEAD^^^ && git log --oneline >actual && - test_line_count = 3 actual && - git diff --exit-code $1 && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 1 = $(git cat-file commit HEAD^ | grep first | wc -l) + if test -n "$no_squash" + then + test_line_count = 4 actual + else + test_line_count = 3 actual && + git diff --exit-code $1 && + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep first commit >actual && + test_line_count = 1 actual + fi } test_expect_success 'auto fixup (option)' ' @@ -48,12 +64,19 @@ test_expect_success 'auto fixup (option)' ' test_expect_success 'auto fixup (config)' ' git config rebase.autosquash true && test_auto_fixup final-fixup-config-true && - test_must_fail test_auto_fixup fixup-config-true-no --no-autosquash && + test_auto_fixup ! fixup-config-true-no --no-autosquash && git config rebase.autosquash false && - test_must_fail test_auto_fixup final-fixup-config-false + test_auto_fixup ! final-fixup-config-false ' test_auto_squash () { + no_squash= && + if test "x$1" = 'x!' + then + no_squash=true + shift + fi && + git reset --hard base && echo 1 >file1 && git add -u && @@ -64,10 +87,19 @@ test_auto_squash () { test_tick && git rebase $2 -i HEAD^^^ && git log --oneline >actual && - test_line_count = 3 actual && - git diff --exit-code $1 && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 2 = $(git cat-file commit HEAD^ | grep first | wc -l) + if test -n "$no_squash" + then + test_line_count = 4 actual + else + test_line_count = 3 actual && + git diff --exit-code $1 && + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep first commit >actual && + test_line_count = 2 actual + fi } test_expect_success 'auto squash (option)' ' @@ -77,9 +109,9 @@ test_expect_success 'auto squash (option)' ' test_expect_success 'auto squash (config)' ' git config rebase.autosquash true && test_auto_squash final-squash-config-true && - test_must_fail test_auto_squash squash-config-true-no --no-autosquash && + test_auto_squash ! squash-config-true-no --no-autosquash && git config rebase.autosquash false && - test_must_fail test_auto_squash final-squash-config-false + test_auto_squash ! final-squash-config-false ' test_expect_success 'misspelled auto squash' ' @@ -94,7 +126,8 @@ test_expect_success 'misspelled auto squash' ' git log --oneline >actual && test_line_count = 4 actual && git diff --exit-code final-missquash && - test 0 = $(git rev-list final-missquash...HEAD | wc -l) + git rev-list final-missquash...HEAD >list && + test_must_be_empty list ' test_expect_success 'auto squash that matches 2 commits' ' @@ -113,9 +146,15 @@ test_expect_success 'auto squash that matches 2 commits' ' git log --oneline >actual && test_line_count = 4 actual && git diff --exit-code final-multisquash && - test 1 = "$(git cat-file blob HEAD^^:file1)" && - test 2 = $(git cat-file commit HEAD^^ | grep first | wc -l) && - test 1 = $(git cat-file commit HEAD | grep first | wc -l) + echo 1 >expect && + git cat-file blob HEAD^^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^^ >commit && + grep first commit >actual && + test_line_count = 2 actual && + git cat-file commit HEAD >commit && + grep first commit >actual && + test_line_count = 1 actual ' test_expect_success 'auto squash that matches a commit after the squash' ' @@ -134,25 +173,38 @@ test_expect_success 'auto squash that matches a commit after the squash' ' git log --oneline >actual && test_line_count = 5 actual && git diff --exit-code final-presquash && - test 0 = "$(git cat-file blob HEAD^^:file1)" && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 1 = $(git cat-file commit HEAD | grep third | wc -l) && - test 1 = $(git cat-file commit HEAD^ | grep third | wc -l) + echo 0 >expect && + git cat-file blob HEAD^^:file1 >actual && + test_cmp expect actual && + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD >commit && + grep third commit >actual && + test_line_count = 1 actual && + git cat-file commit HEAD^ >commit && + grep third commit >actual && + test_line_count = 1 actual ' test_expect_success 'auto squash that matches a sha1' ' git reset --hard base && echo 1 >file1 && git add -u && test_tick && - git commit -m "squash! $(git rev-parse --short HEAD^)" && + oid=$(git rev-parse --short HEAD^) && + git commit -m "squash! $oid" && git tag final-shasquash && test_tick && git rebase --autosquash -i HEAD^^^ && git log --oneline >actual && test_line_count = 3 actual && git diff --exit-code final-shasquash && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l) + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep squash commit >actual && + test_line_count = 1 actual ' test_expect_success 'auto squash that matches longer sha1' ' @@ -160,15 +212,20 @@ test_expect_success 'auto squash that matches longer sha1' ' echo 1 >file1 && git add -u && test_tick && - git commit -m "squash! $(git rev-parse --short=11 HEAD^)" && + oid=$(git rev-parse --short=11 HEAD^) && + git commit -m "squash! $oid" && git tag final-longshasquash && test_tick && git rebase --autosquash -i HEAD^^^ && git log --oneline >actual && test_line_count = 3 actual && git diff --exit-code final-longshasquash && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l) + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep squash commit >actual && + test_line_count = 1 actual ' test_auto_commit_flags () { @@ -183,8 +240,12 @@ test_auto_commit_flags () { git log --oneline >actual && test_line_count = 3 actual && git diff --exit-code final-commit-$1 && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test $2 = $(git cat-file commit HEAD^ | grep first | wc -l) + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep first commit >actual && + test_line_count = $2 actual } test_expect_success 'use commit --fixup' ' @@ -210,11 +271,15 @@ test_auto_fixup_fixup () { ( set_cat_todo_editor && test_must_fail git rebase --autosquash -i HEAD^^^^ >actual && + head=$(git rev-parse --short HEAD) && + parent1=$(git rev-parse --short HEAD^) && + parent2=$(git rev-parse --short HEAD^^) && + parent3=$(git rev-parse --short HEAD^^^) && cat >expected <<-EOF && - pick $(git rev-parse --short HEAD^^^) first commit - $1 $(git rev-parse --short HEAD^) $1! first - $1 $(git rev-parse --short HEAD) $1! $2! first - pick $(git rev-parse --short HEAD^^) second commit + pick $parent3 first commit + $1 $parent1 $1! first + $1 $head $1! $2! first + pick $parent2 second commit EOF test_cmp expected actual ) && @@ -222,13 +287,17 @@ test_auto_fixup_fixup () { git log --oneline >actual && test_line_count = 3 actual git diff --exit-code "final-$1-$2" && - test 2 = "$(git cat-file blob HEAD^:file1)" && + echo 2 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep first commit >actual && if test "$1" = "fixup" then - test 1 = $(git cat-file commit HEAD^ | grep first | wc -l) + test_line_count = 1 actual elif test "$1" = "squash" then - test 3 = $(git cat-file commit HEAD^ | grep first | wc -l) + test_line_count = 3 actual else false fi @@ -256,19 +325,25 @@ test_expect_success C_LOCALE_OUTPUT 'autosquash with custom inst format' ' echo 2 >file1 && git add -u && test_tick && - git commit -m "squash! $(git rev-parse --short HEAD^)" && + oid=$(git rev-parse --short HEAD^) && + git commit -m "squash! $oid" && echo 1 >file1 && git add -u && test_tick && - git commit -m "squash! $(git log -n 1 --format=%s HEAD~2)" && + subject=$(git log -n 1 --format=%s HEAD~2) && + git commit -m "squash! $subject" && git tag final-squash-instFmt && test_tick && git rebase --autosquash -i HEAD~4 && git log --oneline >actual && test_line_count = 3 actual && git diff --exit-code final-squash-instFmt && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 2 = $(git cat-file commit HEAD^ | grep squash | wc -l) + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep squash commit >actual && + test_line_count = 2 actual ' test_expect_success 'autosquash with empty custom instructionFormat' ' diff --git a/t/t3416-rebase-onto-threedots.sh b/t/t3416-rebase-onto-threedots.sh index ddf2f6485383..9c2548423bce 100755 --- a/t/t3416-rebase-onto-threedots.sh +++ b/t/t3416-rebase-onto-threedots.sh @@ -99,7 +99,64 @@ test_expect_success 'rebase -i --onto master...side' ' git checkout side && git reset --hard K && + set_fake_editor && test_must_fail git rebase -i --onto master...side J ' +test_expect_success 'rebase --keep-base --onto incompatible' ' + test_must_fail git rebase --keep-base --onto master... +' + +test_expect_success 'rebase --keep-base --root incompatible' ' + test_must_fail git rebase --keep-base --root +' + +test_expect_success 'rebase --keep-base master from topic' ' + git reset --hard && + git checkout topic && + git reset --hard G && + + git rebase --keep-base master && + git rev-parse C >base.expect && + git merge-base master HEAD >base.actual && + test_cmp base.expect base.actual && + + git rev-parse HEAD~2 >actual && + git rev-parse C^0 >expect && + test_cmp expect actual +' + +test_expect_success 'rebase --keep-base master from side' ' + git reset --hard && + git checkout side && + git reset --hard K && + + test_must_fail git rebase --keep-base master +' + +test_expect_success 'rebase -i --keep-base master from topic' ' + git reset --hard && + git checkout topic && + git reset --hard G && + + set_fake_editor && + EXPECT_COUNT=2 git rebase -i --keep-base master && + git rev-parse C >base.expect && + git merge-base master HEAD >base.actual && + test_cmp base.expect base.actual && + + git rev-parse HEAD~2 >actual && + git rev-parse C^0 >expect && + test_cmp expect actual +' + +test_expect_success 'rebase -i --keep-base master from side' ' + git reset --hard && + git checkout side && + git reset --hard K && + + set_fake_editor && + test_must_fail git rebase -i --keep-base master +' + test_done diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 4eff14dae532..7a2da972fd37 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -120,6 +120,20 @@ test_expect_success REBASE_P 'rebase passes merge strategy options correctly' ' git rebase --continue ' +test_expect_success 'rebase -r passes merge strategy options correctly' ' + rm -fr .git/rebase-* && + git reset --hard commit-new-file-F3-on-topic-branch && + test_commit merge-theirs && + git reset --hard HEAD^ && + test_commit some-other-commit && + test_tick && + git merge --no-ff merge-theirs && + FAKE_LINES="1 3 edit 4 5 7 8 9" git rebase -i -f -r -m \ + -s recursive --strategy-option=theirs HEAD~2 && + test_commit force-change-ours && + git rebase --continue +' + test_expect_success '--skip after failed fixup cleans commit message' ' test_when_finished "test_might_fail git rebase --abort" && git checkout -b with-conflicting-fixup && diff --git a/t/t3419-rebase-patch-id.sh b/t/t3419-rebase-patch-id.sh index 49f548cdb93d..d93458377690 100755 --- a/t/t3419-rebase-patch-id.sh +++ b/t/t3419-rebase-patch-id.sh @@ -80,7 +80,8 @@ do_tests () { git commit -q -m "change big file again" && git checkout -q other^{} && git rebase master && - test_must_fail test -n "$(git rev-list master...HEAD~)" + git rev-list master...HEAD~ >revs && + test_must_be_empty revs ' test_expect_success $pr 'do not drop patch' ' @@ -90,7 +91,7 @@ do_tests () { git commit -q -m squashed && git checkout -q other^{} && test_must_fail git rebase squashed && - rm -rf .git/rebase-apply + git rebase --quit ' } diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh index b8f4d0346723..b97ea6236394 100755 --- a/t/t3420-rebase-autostash.sh +++ b/t/t3420-rebase-autostash.sh @@ -34,10 +34,9 @@ test_expect_success setup ' remove_progress_re="$(printf "s/.*\\r//")" ' -create_expected_success_am () { +create_expected_success_apply () { cat >expected <<-EOF $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual) - HEAD is now at $(git rev-parse --short feature-branch) third commit First, rewinding head to replay your work on top of it... Applying: second commit Applying: third commit @@ -45,19 +44,17 @@ create_expected_success_am () { EOF } -create_expected_success_interactive () { +create_expected_success_merge () { q_to_cr >expected <<-EOF $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual) - HEAD is now at $(git rev-parse --short feature-branch) third commit Applied autostash. Successfully rebased and updated refs/heads/rebased-feature-branch. EOF } -create_expected_failure_am () { +create_expected_failure_apply () { cat >expected <<-EOF $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual) - HEAD is now at $(git rev-parse --short feature-branch) third commit First, rewinding head to replay your work on top of it... Applying: second commit Applying: third commit @@ -67,10 +64,9 @@ create_expected_failure_am () { EOF } -create_expected_failure_interactive () { +create_expected_failure_merge () { cat >expected <<-EOF $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual) - HEAD is now at $(git rev-parse --short feature-branch) third commit Applying autostash resulted in conflicts. Your changes are safe in the stash. You can run "git stash pop" or "git stash drop" at any time. @@ -105,9 +101,9 @@ testrebase () { test_expect_success "rebase$type --autostash: check output" ' test_when_finished git branch -D rebased-feature-branch && - suffix=${type#\ --} && suffix=${suffix:-am} && - if test ${suffix} = "merge"; then - suffix=interactive + suffix=${type#\ --} && suffix=${suffix:-apply} && + if test ${suffix} = "interactive"; then + suffix=merge fi && create_expected_success_$suffix && sed "$remove_progress_re" actual2 && @@ -206,9 +202,9 @@ testrebase () { test_expect_success "rebase$type: check output with conflicting stash" ' test_when_finished git branch -D rebased-feature-branch && - suffix=${type#\ --} && suffix=${suffix:-am} && - if test ${suffix} = "merge"; then - suffix=interactive + suffix=${type#\ --} && suffix=${suffix:-apply} && + if test ${suffix} = "interactive"; then + suffix=merge fi && create_expected_failure_$suffix && sed "$remove_progress_re" actual2 && @@ -238,7 +234,7 @@ test_expect_success "rebase: noop rebase" ' git checkout feature-branch ' -testrebase "" .git/rebase-apply +testrebase " --apply" .git/rebase-apply testrebase " --merge" .git/rebase-merge testrebase " --interactive" .git/rebase-merge @@ -306,4 +302,12 @@ test_expect_success 'branch is left alone when possible' ' test unchanged-branch = "$(git rev-parse --abbrev-ref HEAD)" ' +test_expect_success 'never change active branch' ' + git checkout -b not-the-feature-branch unrelated-onto-branch && + test_when_finished "git reset --hard && git checkout master" && + echo changed >file0 && + git rebase --autostash not-the-feature-branch feature-branch && + test_cmp_rev not-the-feature-branch unrelated-onto-branch +' + test_done diff --git a/t/t3421-rebase-topology-linear.sh b/t/t3421-rebase-topology-linear.sh index 7274dca40b1c..cf8dfd6c203b 100755 --- a/t/t3421-rebase-topology-linear.sh +++ b/t/t3421-rebase-topology-linear.sh @@ -26,11 +26,21 @@ test_run_rebase () { test_linear_range 'd e' c.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p +test_expect_success 'setup branches and remote tracking' ' + git tag -l >tags && + for tag in $(cat tags) + do + git branch branch-$tag $tag || return 1 + done && + git remote add origin "file://$PWD" && + git fetch origin +' + test_run_rebase () { result=$1 shift @@ -40,7 +50,7 @@ test_run_rebase () { test_cmp_rev e HEAD " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p @@ -51,16 +61,34 @@ test_run_rebase () { test_expect_$result "rebase $* -f rewrites even if upstream is an ancestor" " reset_rebase && git rebase $* -f b e && - ! test_cmp_rev e HEAD && + test_cmp_rev ! e HEAD && test_cmp_rev b HEAD~2 && test_linear_range 'd e' b.. " } -test_run_rebase success '' +test_run_rebase success --apply +test_run_rebase success --fork-point test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase failure -p +test_run_rebase () { + result=$1 + shift + test_expect_$result "rebase $* -f rewrites even if remote upstream is an ancestor" " + reset_rebase && + git rebase $* -f branch-b branch-e && + test_cmp_rev ! branch-e origin/branch-e && + test_cmp_rev branch-b HEAD~2 && + test_linear_range 'd e' branch-b.. + " +} +test_run_rebase success --apply +test_run_rebase success --fork-point +test_run_rebase success -m +test_run_rebase success -i +test_have_prereq !REBASE_P || test_run_rebase success -p + test_run_rebase () { result=$1 shift @@ -70,7 +98,8 @@ test_run_rebase () { test_cmp_rev e HEAD " } -test_run_rebase success '' +test_run_rebase success --apply +test_run_rebase success --fork-point test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p @@ -110,7 +139,7 @@ test_run_rebase () { test_linear_range 'd i' h.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p @@ -125,7 +154,7 @@ test_run_rebase () { test_linear_range 'd' h.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p @@ -140,7 +169,7 @@ test_run_rebase () { test_linear_range 'd i' f.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p @@ -155,7 +184,7 @@ test_run_rebase () { test_linear_range 'd gp i' h.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p @@ -176,17 +205,17 @@ test_expect_success 'setup of linear history for empty commit tests' ' test_run_rebase () { result=$1 shift - test_expect_$result "rebase $* drops empty commit" " + test_expect_$result "rebase $* keeps begin-empty commits" " reset_rebase && - git rebase $* c l && - test_cmp_rev c HEAD~2 && - test_linear_range 'd l' c.. + git rebase $* j l && + test_cmp_rev c HEAD~4 && + test_linear_range 'j d k l' c.. " } -test_run_rebase success '' +test_run_rebase failure --apply test_run_rebase success -m test_run_rebase success -i -test_have_prereq !REBASE_P || test_run_rebase success -p +test_have_prereq !REBASE_P || test_run_rebase failure -p test_run_rebase () { result=$1 @@ -198,10 +227,10 @@ test_run_rebase () { test_linear_range 'd k l' c.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i -test_have_prereq !REBASE_P || test_run_rebase failure -p +test_have_prereq !REBASE_P || test_run_rebase success -p test_run_rebase () { result=$1 @@ -213,10 +242,10 @@ test_run_rebase () { test_linear_range 'd k l' j.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i -test_have_prereq !REBASE_P || test_run_rebase failure -p +test_have_prereq !REBASE_P || test_run_rebase success -p test_run_rebase success --rebase-merges # m @@ -253,7 +282,7 @@ test_run_rebase () { test_linear_range 'x y' c.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p @@ -268,7 +297,7 @@ test_run_rebase () { test_linear_range 'x y' c.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase failure -p @@ -283,7 +312,7 @@ test_run_rebase () { test_linear_range 'x y' m.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p @@ -299,7 +328,7 @@ test_run_rebase () { " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase failure -p @@ -314,7 +343,7 @@ test_run_rebase () { test_linear_range 'x y' m.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase failure -p @@ -339,7 +368,7 @@ test_run_rebase () { test_expect_$result "rebase $* -f --root on linear history causes re-write" " reset_rebase && git rebase $* -f --root c && - ! test_cmp_rev a HEAD~2 && + test_cmp_rev ! a HEAD~2 && test_linear_range 'a b c' HEAD " } diff --git a/t/t3422-rebase-incompatible-options.sh b/t/t3422-rebase-incompatible-options.sh index a5868ea152f9..50e7960702da 100755 --- a/t/t3422-rebase-incompatible-options.sh +++ b/t/t3422-rebase-incompatible-options.sh @@ -76,14 +76,4 @@ test_expect_success REBASE_P \ test_must_fail git rebase --preserve-merges --rebase-merges A ' -test_expect_success '--rebase-merges incompatible with --strategy' ' - git checkout B^0 && - test_must_fail git rebase --rebase-merges -s resolve A -' - -test_expect_success '--rebase-merges incompatible with --strategy-option' ' - git checkout B^0 && - test_must_fail git rebase --rebase-merges -Xignore-space-change A -' - test_done diff --git a/t/t3424-rebase-empty.sh b/t/t3424-rebase-empty.sh new file mode 100755 index 000000000000..e1e30517ea64 --- /dev/null +++ b/t/t3424-rebase-empty.sh @@ -0,0 +1,134 @@ +#!/bin/sh + +test_description='git rebase of commits that start or become empty' + +. ./test-lib.sh + +test_expect_success 'setup test repository' ' + test_write_lines 1 2 3 4 5 6 7 8 9 10 >numbers && + test_write_lines A B C D E F G H I J >letters && + git add numbers letters && + git commit -m A && + + git branch upstream && + git branch localmods && + + git checkout upstream && + test_write_lines A B C D E >letters && + git add letters && + git commit -m B && + + test_write_lines 1 2 3 4 five 6 7 8 9 ten >numbers && + git add numbers && + git commit -m C && + + git checkout localmods && + test_write_lines 1 2 3 4 five 6 7 8 9 10 >numbers && + git add numbers && + git commit -m C2 && + + git commit --allow-empty -m D && + + test_write_lines A B C D E >letters && + git add letters && + git commit -m "Five letters ought to be enough for anybody" +' + +test_expect_failure 'rebase (apply-backend)' ' + test_when_finished "git rebase --abort" && + git checkout -B testing localmods && + # rebase (--apply) should not drop commits that start empty + git rebase --apply upstream && + + test_write_lines D C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --merge --empty=drop' ' + git checkout -B testing localmods && + git rebase --merge --empty=drop upstream && + + test_write_lines D C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --merge uses default of --empty=drop' ' + git checkout -B testing localmods && + git rebase --merge upstream && + + test_write_lines D C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --merge --empty=keep' ' + git checkout -B testing localmods && + git rebase --merge --empty=keep upstream && + + test_write_lines D C2 C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --merge --empty=ask' ' + git checkout -B testing localmods && + test_must_fail git rebase --merge --empty=ask upstream && + + git rebase --skip && + + test_write_lines D C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --interactive --empty=drop' ' + git checkout -B testing localmods && + git rebase --interactive --empty=drop upstream && + + test_write_lines D C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --interactive --empty=keep' ' + git checkout -B testing localmods && + git rebase --interactive --empty=keep upstream && + + test_write_lines D C2 C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --interactive --empty=ask' ' + git checkout -B testing localmods && + test_must_fail git rebase --interactive --empty=ask upstream && + + git rebase --skip && + + test_write_lines D C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --interactive uses default of --empty=ask' ' + git checkout -B testing localmods && + test_must_fail git rebase --interactive upstream && + + git rebase --skip && + + test_write_lines D C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --merge does not leave state laying around' ' + git checkout -B testing localmods~2 && + git rebase --merge upstream && + + test_path_is_missing .git/CHERRY_PICK_HEAD && + test_path_is_missing .git/MERGE_MSG +' + +test_done diff --git a/t/t3425-rebase-topology-merges.sh b/t/t3425-rebase-topology-merges.sh index fd8efe84fe8f..e42faa44e74f 100755 --- a/t/t3425-rebase-topology-merges.sh +++ b/t/t3425-rebase-topology-merges.sh @@ -54,7 +54,7 @@ test_run_rebase () { test_linear_range 'n o' e.. " } -test_run_rebase success '' +test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i @@ -70,7 +70,7 @@ test_run_rebase () { test_linear_range "\'"$expected"\'" d.. " } -test_run_rebase success 'n o e' '' +test_run_rebase success 'n o e' --apply test_run_rebase success 'n o e' -m test_run_rebase success 'n o e' -i @@ -86,7 +86,7 @@ test_run_rebase () { test_linear_range "\'"$expected"\'" c.. " } -test_run_rebase success 'd n o e' '' +test_run_rebase success 'd n o e' --apply test_run_rebase success 'd n o e' -m test_run_rebase success 'd n o e' -i @@ -102,7 +102,7 @@ test_run_rebase () { test_linear_range "\'"$expected"\'" c.. " } -test_run_rebase success 'd n o e' '' +test_run_rebase success 'd n o e' --apply test_run_rebase success 'd n o e' -m test_run_rebase success 'd n o e' -i diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index d8640522a086..79e43a370bac 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -11,113 +11,99 @@ commit_message() { git log --pretty=format:%s -1 "$1" } +# There are a few bugs in the rebase with regards to the subtree strategy, and +# this test script tries to document them. First, the following commit history +# is generated (the onelines are shown, time flows from left to right): +# +# master1 - master2 - master3 +# \ +# README ---------------------- Add subproject master - master4 - files_subtree/master5 +# +# Where the merge moves the files master[123].t into the subdirectory +# files_subtree/ and master4 as well as files_subtree/master5 add files to that +# directory directly. +# +# Then, in subsequent test cases, `git filter-branch` is used to distill just +# the commits that touch files_subtree/. To give it a final pre-rebase touch, +# an empty commit is added on top. The pre-rebase commit history looks like +# this: +# +# Add subproject master - master4 - files_subtree/master5 - Empty commit +# +# where the root commit adds three files: master1.t, master2.t and master3.t. +# +# This commit history is then rebased onto `master3` with the +# `-Xsubtree=files_subtree` option in three different ways: +# +# 1. using `--preserve-merges` +# 2. using `--preserve-merges` and --keep-empty +# 3. without specifying a rebase backend + test_expect_success 'setup' ' test_commit README && - mkdir files && - ( - cd files && - git init && - test_commit master1 && - test_commit master2 && - test_commit master3 - ) && - git fetch files master && - git branch files-master FETCH_HEAD && - git read-tree --prefix=files_subtree files-master && - git checkout -- files_subtree && - tree=$(git write-tree) && - head=$(git rev-parse HEAD) && - rev=$(git rev-parse --verify files-master^0) && - commit=$(git commit-tree -p $head -p $rev -m "Add subproject master" $tree) && - git update-ref HEAD $commit && - ( - cd files_subtree && - test_commit master4 - ) && - test_commit files_subtree/master5 -' -# FAILURE: Does not preserve master4. -test_expect_failure REBASE_P \ - 'Rebase -Xsubtree --preserve-merges --onto commit 4' ' - reset_rebase && - git checkout -b rebase-preserve-merges-4 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && - git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master && - verbose test "$(commit_message HEAD~)" = "files_subtree/master4" + git init files && + test_commit -C files master1 && + test_commit -C files master2 && + test_commit -C files master3 && + + : perform subtree merge into files_subtree/ && + git fetch files refs/heads/master:refs/heads/files-master && + git merge -s ours --no-commit --allow-unrelated-histories \ + files-master && + git read-tree --prefix=files_subtree -u files-master && + git commit -m "Add subproject master" && + + : add two extra commits to rebase && + test_commit -C files_subtree master4 && + test_commit files_subtree/master5 && + + git checkout -b to-rebase && + git fast-export --no-data HEAD -- files_subtree/ | + sed -e "s%\([0-9a-f]\{40\} \)files_subtree/%\1%" | + git fast-import --force --quiet && + git reset --hard && + git commit -m "Empty commit" --allow-empty ' -# FAILURE: Does not preserve master5. -test_expect_failure REBASE_P \ - 'Rebase -Xsubtree --preserve-merges --onto commit 5' ' +# FAILURE: Does not preserve master4. +test_expect_failure REBASE_P 'Rebase -Xsubtree --preserve-merges --onto commit' ' reset_rebase && - git checkout -b rebase-preserve-merges-5 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && + git checkout -b rebase-preserve-merges to-rebase && git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master && + verbose test "$(commit_message HEAD~)" = "master4" && verbose test "$(commit_message HEAD)" = "files_subtree/master5" ' # FAILURE: Does not preserve master4. -test_expect_failure REBASE_P \ - 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 4' ' - reset_rebase && - git checkout -b rebase-keep-empty-4 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && - git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && - verbose test "$(commit_message HEAD~2)" = "files_subtree/master4" -' - -# FAILURE: Does not preserve master5. -test_expect_failure REBASE_P \ - 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 5' ' - reset_rebase && - git checkout -b rebase-keep-empty-5 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && - git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && - verbose test "$(commit_message HEAD~)" = "files_subtree/master5" -' - -# FAILURE: Does not preserve Empty. -test_expect_failure REBASE_P \ - 'Rebase -Xsubtree --keep-empty --preserve-merges --onto empty commit' ' +test_expect_failure REBASE_P 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit' ' reset_rebase && - git checkout -b rebase-keep-empty-empty master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && + git checkout -b rebase-keep-empty to-rebase && git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master && + verbose test "$(commit_message HEAD~2)" = "master4" && + verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && verbose test "$(commit_message HEAD)" = "Empty commit" ' -# FAILURE: fatal: Could not parse object -test_expect_failure 'Rebase -Xsubtree --onto commit 4' ' +test_expect_success 'Rebase -Xsubtree --empty=ask --onto commit' ' reset_rebase && - git checkout -b rebase-onto-4 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && - git rebase -Xsubtree=files_subtree --onto files-master master && - verbose test "$(commit_message HEAD~2)" = "files_subtree/master4" + git checkout -b rebase-onto to-rebase && + test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --onto files-master master && + : first pick results in no changes && + git rebase --skip && + verbose test "$(commit_message HEAD~2)" = "master4" && + verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && + verbose test "$(commit_message HEAD)" = "Empty commit" ' -# FAILURE: fatal: Could not parse object -test_expect_failure 'Rebase -Xsubtree --onto commit 5' ' - reset_rebase && - git checkout -b rebase-onto-5 master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && - git rebase -Xsubtree=files_subtree --onto files-master master && - verbose test "$(commit_message HEAD~)" = "files_subtree/master5" -' -# FAILURE: fatal: Could not parse object -test_expect_failure 'Rebase -Xsubtree --onto empty commit' ' +test_expect_success 'Rebase -Xsubtree --empty=ask --rebase-merges --onto commit' ' reset_rebase && - git checkout -b rebase-onto-empty master && - git filter-branch --prune-empty -f --subdirectory-filter files_subtree && - git commit -m "Empty commit" --allow-empty && - git rebase -Xsubtree=files_subtree --onto files-master master && + git checkout -b rebase-merges-onto to-rebase && + test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --rebase-merges --onto files-master --root && + : first pick results in no changes && + git rebase --skip && + verbose test "$(commit_message HEAD~2)" = "master4" && + verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && verbose test "$(commit_message HEAD)" = "Empty commit" ' diff --git a/t/t3429-rebase-edit-todo.sh b/t/t3429-rebase-edit-todo.sh index 76f6d306eaf3..7024d49ae7b9 100755 --- a/t/t3429-rebase-edit-todo.sh +++ b/t/t3429-rebase-edit-todo.sh @@ -3,15 +3,21 @@ test_description='rebase should reread the todo file if an exec modifies it' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-rebase.sh + +test_expect_success 'setup' ' + test_commit first file && + test_commit second file && + test_commit third file +' test_expect_success 'rebase exec modifies rebase-todo' ' - test_commit initial && todo=.git/rebase-merge/git-rebase-todo && git rebase HEAD -x "echo exec touch F >>$todo" && test -e F ' -test_expect_success SHA1 'loose object cache vs re-reading todo list' ' +test_expect_success 'loose object cache vs re-reading todo list' ' GIT_REBASE_TODO=.git/rebase-merge/git-rebase-todo && export GIT_REBASE_TODO && write_script append-todo.sh <<-\EOS && @@ -33,4 +39,47 @@ test_expect_success SHA1 'loose object cache vs re-reading todo list' ' git rebase HEAD -x "./append-todo.sh 5 6" ' +test_expect_success 'todo is re-read after reword and squash' ' + write_script reword-editor.sh <<-\EOS && + GIT_SEQUENCE_EDITOR="echo \"exec echo $(cat file) >>actual\" >>" \ + git rebase --edit-todo + EOS + + test_write_lines first third >expected && + set_fake_editor && + GIT_SEQUENCE_EDITOR="$EDITOR" FAKE_LINES="reword 1 squash 2 fixup 3" \ + GIT_EDITOR=./reword-editor.sh git rebase -i --root third && + test_cmp expected actual +' + +test_expect_success 're-reading todo doesnt interfere with revert --edit' ' + git reset --hard third && + + git revert --edit third second && + + cat >expect <<-\EOF && + Revert "second" + Revert "third" + third + second + first + EOF + git log --format="%s" >actual && + test_cmp expect actual +' + +test_expect_success 're-reading todo doesnt interfere with cherry-pick --edit' ' + git reset --hard first && + + git cherry-pick --edit second third && + + cat >expect <<-\EOF && + third + second + first + EOF + git log --format="%s" >actual && + test_cmp expect actual +' + test_done diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index 7b6c4847ad6b..a1bc3e20016b 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -20,12 +20,11 @@ Initial setup: ' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh +. "$TEST_DIRECTORY"/lib-log-graph.sh test_cmp_graph () { cat >expect && - git log --graph --boundary --format=%s "$@" >output && - sed "s/ *$//" output.trimmed && - test_cmp expect output.trimmed + lib_test_cmp_graph --boundary --format=%s "$@" } test_expect_success 'setup' ' @@ -37,20 +36,27 @@ test_expect_success 'setup' ' test_commit A && git checkout -b first && test_commit B && + b=$(git rev-parse --short HEAD) && git checkout master && test_commit C && + c=$(git rev-parse --short HEAD) && test_commit D && + d=$(git rev-parse --short HEAD) && git merge --no-commit B && test_tick && git commit -m E && git tag -m E E && + e=$(git rev-parse --short HEAD) && git checkout -b second C && test_commit F && + f=$(git rev-parse --short HEAD) && test_commit G && + g=$(git rev-parse --short HEAD) && git checkout master && git merge --no-commit G && test_tick && git commit -m H && + h=$(git rev-parse --short HEAD) && git tag -m H H && git checkout A && test_commit conflicting-G G.t @@ -93,24 +99,24 @@ test_expect_success 'create completely different structure' ' ' test_expect_success 'generate correct todo list' ' - cat >expect <<-\EOF && + cat >expect <<-EOF && label onto reset onto - pick d9df450 B + pick $b B label E reset onto - pick 5dee784 C + pick $c C label branch-point - pick ca2c861 F - pick 088b00a G + pick $f F + pick $g G label H reset branch-point # C - pick 12bd07b D - merge -C 2051b56 E # E - merge -C 233d48a H # H + pick $d D + merge -C $e E # E + merge -C $h H # H EOF @@ -151,7 +157,6 @@ test_expect_success 'failed `merge -C` writes patch (may be rescheduled, too)' ' test_path_is_file .git/rebase-merge/patch ' -SQ="'" test_expect_success 'failed `merge ` does not crash' ' test_when_finished "test_might_fail git rebase --abort" && git checkout conflicting-G && @@ -340,7 +345,7 @@ test_expect_success 'A root commit can be a cousin, treat it that way' ' git merge --allow-unrelated-histories khnum && test_tick && git rebase -f -r HEAD^ && - ! test_cmp_rev HEAD^2 khnum && + test_cmp_rev ! HEAD^2 khnum && test_cmp_graph HEAD^.. <<-\EOF && * Merge branch '\''khnum'\'' into asherah |\ @@ -402,7 +407,7 @@ test_expect_success 'octopus merges' ' | | * three | * | two | |/ - * | one + * / one |/ o before-octopus EOF @@ -441,4 +446,52 @@ test_expect_success '--continue after resolving conflicts after a merge' ' test_path_is_missing .git/MERGE_HEAD ' +test_expect_success '--rebase-merges with strategies' ' + git checkout -b with-a-strategy F && + test_tick && + git merge -m "Merge conflicting-G" conflicting-G && + + : first, test with a merge strategy option && + git rebase -ir -Xtheirs G && + echo conflicting-G >expect && + test_cmp expect G.t && + + : now, try with a merge strategy other than recursive && + git reset --hard @{1} && + write_script git-merge-override <<-\EOF && + echo overridden$1 >>G.t + git add G.t + EOF + PATH="$PWD:$PATH" git rebase -ir -s override -Xxopt G && + test_write_lines G overridden--xopt >expect && + test_cmp expect G.t +' + +test_expect_success '--rebase-merges with commit that can generate bad characters for filename' ' + git checkout -b colon-in-label E && + git merge -m "colon: this should work" G && + git rebase --rebase-merges --force-rebase E +' + +test_expect_success '--rebase-merges with message matched with onto label' ' + git checkout -b onto-label E && + git merge -m onto G && + git rebase --rebase-merges --force-rebase E && + test_cmp_graph <<-\EOF + * onto + |\ + | * G + | * F + * | E + |\ \ + | * | B + * | | D + | |/ + |/| + * | C + |/ + * A + EOF +' + test_done diff --git a/t/t3431-rebase-fork-point.sh b/t/t3431-rebase-fork-point.sh new file mode 100755 index 000000000000..78851b9a2ae8 --- /dev/null +++ b/t/t3431-rebase-fork-point.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Copyright (c) 2019 Denton Liu +# + +test_description='git rebase --fork-point test' + +. ./test-lib.sh + +# A---B---D---E (master) +# \ +# C*---F---G (side) +# +# C was formerly part of master but master was rewound to remove C +# +test_expect_success setup ' + test_commit A && + test_commit B && + test_commit C && + git branch -t side && + git reset --hard HEAD^ && + test_commit D && + test_commit E && + git checkout side && + test_commit F && + test_commit G +' + +test_rebase () { + expected="$1" && + shift && + test_expect_success "git rebase $*" " + git checkout master && + git reset --hard E && + git checkout side && + git reset --hard G && + git rebase $* && + test_write_lines $expected >expect && + git log --pretty=%s >actual && + test_cmp expect actual + " +} + +test_rebase 'G F E D B A' +test_rebase 'G F D B A' --onto D +test_rebase 'G F B A' --keep-base +test_rebase 'G F C E D B A' --no-fork-point +test_rebase 'G F C D B A' --no-fork-point --onto D +test_rebase 'G F C B A' --no-fork-point --keep-base +test_rebase 'G F E D B A' --fork-point refs/heads/master +test_rebase 'G F D B A' --fork-point --onto D refs/heads/master +test_rebase 'G F B A' --fork-point --keep-base refs/heads/master +test_rebase 'G F C E D B A' refs/heads/master +test_rebase 'G F C D B A' --onto D refs/heads/master +test_rebase 'G F C B A' --keep-base refs/heads/master + +test_done diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh new file mode 100755 index 000000000000..6c9d4a137581 --- /dev/null +++ b/t/t3432-rebase-fast-forward.sh @@ -0,0 +1,123 @@ +#!/bin/sh +# +# Copyright (c) 2019 Denton Liu +# + +test_description='ensure rebase fast-forwards commits when possible' + +. ./test-lib.sh + +test_expect_success setup ' + test_commit A && + test_commit B && + test_commit C && + test_commit D && + git checkout -t -b side +' + +test_rebase_same_head () { + status_n="$1" && + shift && + what_n="$1" && + shift && + cmp_n="$1" && + shift && + status_f="$1" && + shift && + what_f="$1" && + shift && + cmp_f="$1" && + shift && + test_rebase_same_head_ $status_n $what_n $cmp_n " --apply" "$*" && + test_rebase_same_head_ $status_f $what_f $cmp_f " --apply --no-ff" "$*" + test_rebase_same_head_ $status_n $what_n $cmp_n " --merge" "$*" && + test_rebase_same_head_ $status_f $what_f $cmp_f " --merge --no-ff" "$*" +} + +test_rebase_same_head_ () { + status="$1" && + shift && + what="$1" && + shift && + cmp="$1" && + shift && + flag="$1" + shift && + test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" " + oldhead=\$(git rev-parse HEAD) && + test_when_finished 'git reset --hard \$oldhead' && + cp .git/logs/HEAD expect && + git rebase$flag $* >stdout && + if test $what = work + then + old=\$(wc -l DS/whatever && + git add DS && + git commit -m base && + + git branch side1 && + git branch side2 && + + git checkout side1 && + git rm -rf DS && + test_ln_s_add unrelated DS && + git commit -m side1 && + + git checkout side2 && + >unrelated && + git add unrelated && + git commit -m commit1 && + + echo >>unrelated && + git commit -am commit2 +' + +test_expect_success 'rebase changes with the apply backend' ' + test_when_finished "git rebase --abort || true" && + git checkout -b apply-backend side2 && + git rebase side1 +' + +test_expect_success 'rebase changes with the merge backend' ' + test_when_finished "git rebase --abort || true" && + git checkout -b merge-backend side2 && + git rebase -m side1 +' + +test_expect_success 'rebase changes with the merge backend with a delay' ' + test_when_finished "git rebase --abort || true" && + git checkout -b merge-delay-backend side2 && + git rebase -m --exec "sleep 1" side1 +' + +test_done diff --git a/t/t3434-rebase-i18n.sh b/t/t3434-rebase-i18n.sh new file mode 100755 index 000000000000..c7c835cde9b2 --- /dev/null +++ b/t/t3434-rebase-i18n.sh @@ -0,0 +1,84 @@ +#!/bin/sh +# +# Copyright (c) 2019 Doan Tran Cong Danh +# + +test_description='rebase with changing encoding + +Initial setup: + +1 - 2 master + \ + 3 - 4 first + \ + 5 - 6 second +' + +. ./test-lib.sh + +compare_msg () { + iconv -f "$2" -t "$3" "$TEST_DIRECTORY/t3434/$1" >expect && + git cat-file commit HEAD >raw && + sed "1,/^$/d" raw >actual && + test_cmp expect actual +} + +test_expect_success setup ' + test_commit one && + git branch first && + test_commit two && + git switch first && + test_commit three && + git branch second && + test_commit four && + git switch second && + test_commit five && + test_commit six +' + +test_expect_success 'rebase --rebase-merges update encoding eucJP to UTF-8' ' + git switch -c merge-eucJP-UTF-8 first && + git config i18n.commitencoding eucJP && + git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second && + git config i18n.commitencoding UTF-8 && + git rebase --rebase-merges master && + compare_msg eucJP.txt eucJP UTF-8 +' + +test_expect_success 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' ' + git switch -c merge-eucJP-ISO-2022-JP first && + git config i18n.commitencoding eucJP && + git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second && + git config i18n.commitencoding ISO-2022-JP && + git rebase --rebase-merges master && + compare_msg eucJP.txt eucJP ISO-2022-JP +' + +test_rebase_continue_update_encode () { + old=$1 + new=$2 + msgfile=$3 + test_expect_success "rebase --continue update from $old to $new" ' + (git rebase --abort || : abort current git-rebase failure) && + git switch -c conflict-$old-$new one && + echo for-conflict >two.t && + git add two.t && + git config i18n.commitencoding $old && + git commit -F "$TEST_DIRECTORY/t3434/$msgfile" && + git config i18n.commitencoding $new && + test_must_fail git rebase -m master && + test -f .git/rebase-merge/message && + git stripspace <.git/rebase-merge/message >two.t && + git add two.t && + git rebase --continue && + compare_msg $msgfile $old $new && + : git-commit assume invalid utf-8 is latin1 && + test_cmp expect two.t + ' +} + +test_rebase_continue_update_encode ISO-8859-1 UTF-8 ISO8859-1.txt +test_rebase_continue_update_encode eucJP UTF-8 eucJP.txt +test_rebase_continue_update_encode eucJP ISO-2022-JP eucJP.txt + +test_done diff --git a/t/t3434/ISO8859-1.txt b/t/t3434/ISO8859-1.txt new file mode 100644 index 000000000000..7cbef0ee6f43 --- /dev/null +++ b/t/t3434/ISO8859-1.txt @@ -0,0 +1,3 @@ + + +bdfg diff --git a/t/t3434/eucJP.txt b/t/t3434/eucJP.txt new file mode 100644 index 000000000000..546f2aac01b6 --- /dev/null +++ b/t/t3434/eucJP.txt @@ -0,0 +1,4 @@ +ϤҤۤ + +ƤΤΤǡ +ͤۤפݤޤӤء diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index d1c68af8c50e..7c1da21df149 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -106,7 +106,7 @@ test_expect_success 'cherry-pick on unborn branch' ' rm -rf * && git cherry-pick initial && git diff --quiet initial && - ! test_cmp_rev initial HEAD + test_cmp_rev ! initial HEAD ' test_expect_success 'cherry-pick "-" to pick from previous branch' ' @@ -150,7 +150,7 @@ test_expect_success 'cherry-pick works with dirty renamed file' ' test_tick && git commit -m renamed && echo modified >renamed && - git cherry-pick refs/heads/unrelated >out && + git cherry-pick refs/heads/unrelated && test $(git rev-parse :0:renamed) = $(git rev-parse HEAD~2:to-rename.t) && grep -q "^modified$" renamed ' diff --git a/t/t3504-cherry-pick-rerere.sh b/t/t3504-cherry-pick-rerere.sh index a267b2d144df..80a0d0870653 100755 --- a/t/t3504-cherry-pick-rerere.sh +++ b/t/t3504-cherry-pick-rerere.sh @@ -94,8 +94,10 @@ test_expect_success 'cherry-pick --rerere-autoupdate more than once' ' test_expect_success 'cherry-pick conflict without rerere' ' test_config rerere.enabled false && - test_must_fail git cherry-pick master && - test_must_fail test_cmp expect foo + test_must_fail git cherry-pick foo-master && + grep ===== foo && + grep foo-dev foo && + grep foo-master foo ' test_done diff --git a/t/t3506-cherry-pick-ff.sh b/t/t3506-cherry-pick-ff.sh index 127dd0082ff8..9d5adbc130b1 100755 --- a/t/t3506-cherry-pick-ff.sh +++ b/t/t3506-cherry-pick-ff.sh @@ -16,7 +16,11 @@ test_expect_success setup ' git add file1 && test_tick && git commit -m "second" && - git tag second + git tag second && + test_oid_cache <<-EOF + cp_ff sha1:1df192cd8bc58a2b275d842cede4d221ad9000d1 + cp_ff sha256:e70d6b7fc064bddb516b8d512c9057094b96ce6ff08e12080acc4fe7f1d60a1d + EOF ' test_expect_success 'cherry-pick using --ff fast forwards' ' @@ -102,7 +106,7 @@ test_expect_success 'cherry pick a root commit with --ff' ' git add file2 && git commit --amend -m "file2" && git cherry-pick --ff first && - test "$(git rev-parse --verify HEAD)" = "1df192cd8bc58a2b275d842cede4d221ad9000d1" + test "$(git rev-parse --verify HEAD)" = "$(test_oid cp_ff)" ' test_expect_success 'cherry-pick --ff on unborn branch' ' diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 9b9b4ca8d4f2..9bd482ce3b89 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -168,7 +168,7 @@ test_expect_success 'successful final commit clears cherry-pick state' ' echo resolved >foo && test_path_is_file .git/sequencer/todo && git commit -a && - test_must_fail test_path_exists .git/sequencer + test_path_is_missing .git/sequencer ' test_expect_success 'reset after final pick clears cherry-pick state' ' @@ -178,7 +178,7 @@ test_expect_success 'reset after final pick clears cherry-pick state' ' echo resolved >foo && test_path_is_file .git/sequencer/todo && git reset && - test_must_fail test_path_exists .git/sequencer + test_path_is_missing .git/sequencer ' test_expect_success 'failed cherry-pick produces dirty index' ' @@ -381,23 +381,23 @@ test_expect_success 'failed commit does not clear REVERT_HEAD' ' ' test_expect_success 'successful final commit clears revert state' ' - pristine_detach picked-signed && + pristine_detach picked-signed && - test_must_fail git revert picked-signed base && - echo resolved >foo && - test_path_is_file .git/sequencer/todo && - git commit -a && - test_must_fail test_path_exists .git/sequencer + test_must_fail git revert picked-signed base && + echo resolved >foo && + test_path_is_file .git/sequencer/todo && + git commit -a && + test_path_is_missing .git/sequencer ' test_expect_success 'reset after final pick clears revert state' ' - pristine_detach picked-signed && + pristine_detach picked-signed && - test_must_fail git revert picked-signed base && - echo resolved >foo && - test_path_is_file .git/sequencer/todo && - git reset && - test_must_fail test_path_exists .git/sequencer + test_must_fail git revert picked-signed base && + echo resolved >foo && + test_path_is_file .git/sequencer/todo && + git reset && + test_path_is_missing .git/sequencer ' test_expect_success 'revert conflict, diff3 -m style' ' diff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh index b457333e1865..23070a7b73ca 100755 --- a/t/t3508-cherry-pick-many-commits.sh +++ b/t/t3508-cherry-pick-many-commits.sh @@ -5,7 +5,7 @@ test_description='test cherry-picking many commits' . ./test-lib.sh check_head_differs_from() { - ! test_cmp_rev HEAD "$1" + test_cmp_rev ! HEAD "$1" } check_head_equals() { diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 66282a720ee8..f2c0168941ad 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -113,9 +113,10 @@ test_expect_success '"rm" command printed' ' echo frotz >test-file && git add test-file && git commit -m "add file for rm test" && - git rm test-file >rm-output && - test $(grep "^rm " rm-output | wc -l) = 1 && - rm -f test-file rm-output && + git rm test-file >rm-output.raw && + grep "^rm " rm-output.raw >rm-output && + test_line_count = 1 rm-output && + rm -f test-file rm-output.raw rm-output && git commit -m "remove file from rm test" ' @@ -240,14 +241,17 @@ test_expect_success 'refresh index before checking if it is up-to-date' ' ' test_expect_success 'choking "git rm" should not let it die with cruft' ' + test_oid_init && git reset -q --hard && test_when_finished "rm -f .git/index.lock && git reset -q --hard" && i=0 && + hash=$(test_oid deadbeef) && while test $i -lt 12000 do - echo "100644 1234567890123456789012345678901234567890 0 some-file-$i" + echo "100644 $hash 0 some-file-$i" i=$(( $i + 1 )) done | git update-index --index-info && + # git command is intentionally placed upstream of pipe to induce SIGPIPE git rm -n "some-file-*" | : && test_path_is_missing .git/index.lock ' @@ -301,7 +305,8 @@ EOF test_expect_success 'rm removes empty submodules from work tree' ' mkdir submod && - git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) submod && + hash=$(git rev-parse HEAD) && + git update-index --add --cacheinfo 160000 "$hash" submod && git config -f .gitmodules submodule.sub.url ./. && git config -f .gitmodules submodule.sub.path submod && git submodule init && @@ -420,6 +425,13 @@ test_expect_success 'rm will error out on a modified .gitmodules file unless sta git status -s -uno >actual && test_cmp expect actual ' +test_expect_success 'rm will not error out on .gitmodules file with zero stat data' ' + git reset --hard && + git submodule update && + git read-tree HEAD && + git rm submod && + test_path_is_missing submod +' test_expect_success 'rm issues a warning when section is not found in .gitmodules' ' git reset --hard && @@ -620,7 +632,8 @@ test_expect_success 'setup subsubmodule' ' git submodule update && ( cd submod && - git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) subsubmod && + hash=$(git rev-parse HEAD) && + git update-index --add --cacheinfo 160000 "$hash" subsubmod && git config -f .gitmodules submodule.sub.url ../. && git config -f .gitmodules submodule.sub.path subsubmod && git submodule init && diff --git a/t/t3601-rm-pathspec-file.sh b/t/t3601-rm-pathspec-file.sh new file mode 100755 index 000000000000..7de21f8bcff1 --- /dev/null +++ b/t/t3601-rm-pathspec-file.sh @@ -0,0 +1,79 @@ +#!/bin/sh + +test_description='rm --pathspec-from-file' + +. ./test-lib.sh + +test_tick + +test_expect_success setup ' + echo A >fileA.t && + echo B >fileB.t && + echo C >fileC.t && + echo D >fileD.t && + git add fileA.t fileB.t fileC.t fileD.t && + git commit -m "files" && + + git tag checkpoint +' + +restore_checkpoint () { + git reset --hard checkpoint +} + +verify_expect () { + git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual && + test_cmp expect actual +} + +test_expect_success 'simplest' ' + restore_checkpoint && + + cat >expect <<-\EOF && + D fileA.t + EOF + + echo fileA.t | git rm --pathspec-from-file=- && + verify_expect +' + +test_expect_success '--pathspec-file-nul' ' + restore_checkpoint && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + EOF + + printf "fileA.t\0fileB.t\0" | git rm --pathspec-from-file=- --pathspec-file-nul && + verify_expect +' + +test_expect_success 'only touches what was listed' ' + restore_checkpoint && + + cat >expect <<-\EOF && + D fileB.t + D fileC.t + EOF + + printf "fileB.t\nfileC.t\n" | git rm --pathspec-from-file=- && + verify_expect +' + +test_expect_success 'error conditions' ' + restore_checkpoint && + echo fileA.t >list && + + test_must_fail git rm --pathspec-from-file=list -- fileA.t 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err && + + test_must_fail git rm --pathspec-file-nul 2>err && + test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err && + + >empty_list && + test_must_fail git rm --pathspec-from-file=empty_list 2>err && + test_i18ngrep -e "No pathspec was given. Which files should I remove?" err +' + +test_done diff --git a/t/t3700-add.sh b/t/t3700-add.sh index c325167b9031..88bc799807f7 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -326,7 +326,9 @@ test_expect_success 'git add --dry-run of an existing file output' " cat >expect.err <<\EOF The following paths are ignored by one of your .gitignore files: ignored-file -Use -f if you really want to add them. +hint: Use -f if you really want to add them. +hint: Turn this message off by running +hint: "git config advice.addIgnoredFile false" EOF cat >expect.out <<\EOF add 'track-this' diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 69991a3168f3..5bae6e50f1f3 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -23,6 +23,17 @@ diff_cmp () { test_cmp "$1.filtered" "$2.filtered" } +# This function uses a trick to manipulate the interactive add to use color: +# the `want_color()` function special-cases the situation where a pager was +# spawned and Git now wants to output colored text: to detect that situation, +# the environment variable `GIT_PAGER_IN_USE` is set. However, color is +# suppressed despite that environment variable if the `TERM` variable +# indicates a dumb terminal, so we set that variable, too. + +force_color () { + env GIT_PAGER_IN_USE=true TERM=vt100 "$@" +} + test_expect_success 'setup (initial)' ' echo content >file && git add file && @@ -57,6 +68,15 @@ test_expect_success 'revert works (initial)' ' ! grep . output ' +test_expect_success 'add untracked (multiple)' ' + test_when_finished "git reset && rm [1-9]" && + touch $(test_seq 9) && + test_write_lines a "2-5 8-" | git add -i -- [1-9] && + test_write_lines 2 3 4 5 8 9 >expected && + git ls-files [1-9] >output && + test_cmp expected output +' + test_expect_success 'setup (commit)' ' echo baseline >file && git add file && @@ -94,7 +114,6 @@ test_expect_success 'revert works (commit)' ' grep "unchanged *+3/-0 file" output ' - test_expect_success 'setup expected' ' cat >expected <<-\EOF EOF @@ -263,6 +282,35 @@ test_expect_success FILEMODE 'stage mode and hunk' ' # end of tests disabled when filemode is not usable +test_expect_success 'different prompts for mode change/deleted' ' + git reset --hard && + >file && + >deleted && + git add --chmod=+x file deleted && + echo changed >file && + rm deleted && + test_write_lines n n n | + git -c core.filemode=true add -p >actual && + sed -n "s/^\(([0-9/]*) Stage .*?\).*/\1/p" actual >actual.filtered && + cat >expect <<-\EOF && + (1/1) Stage deletion [y,n,q,a,d,?]? + (1/2) Stage mode change [y,n,q,a,d,j,J,g,/,?]? + (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? + EOF + test_cmp expect actual.filtered +' + +test_expect_success 'correct message when there is nothing to do' ' + git reset --hard && + git add -p 2>err && + test_i18ngrep "No changes" err && + printf "\\0123" >binary && + git add binary && + printf "\\0abc" >binary && + git add -p 2>err && + test_i18ngrep "Only binary files changed" err +' + test_expect_success 'setup again' ' git reset --hard && test_chmod +x file && @@ -314,7 +362,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' ' git commit -am "clear local changes" && git apply patch && printf "%s\n" s y y | git add -p file 2>error | - sed -n -e "s/^Stage this hunk[^@]*\(@@ .*\)/\1/" \ + sed -n -e "s/^([1-2]\/[1-2]) Stage this hunk[^@]*\(@@ .*\)/\1/" \ -e "/^[-+@ \\\\]"/p >output && test_must_be_empty error && git diff --cached >diff && @@ -374,6 +422,36 @@ test_expect_success 'split hunk setup' ' test_write_lines 10 15 20 21 22 23 24 30 40 50 60 >test ' +test_expect_success 'goto hunk' ' + test_when_finished "git reset" && + tr _ " " >expect <<-EOF && + (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? + 1: -1,2 +1,3 +15 + _ 2: -2,4 +3,8 +21 + go to which hunk? @@ -1,2 +1,3 @@ + _10 + +15 + _20 + (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_ + EOF + test_write_lines s y g 1 | git add -p >actual && + tail -n 7 actual.trimmed && + test_cmp expect actual.trimmed +' + +test_expect_success 'navigate to hunk via regex' ' + test_when_finished "git reset" && + tr _ " " >expect <<-EOF && + (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? @@ -1,2 +1,3 @@ + _10 + +15 + _20 + (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_ + EOF + test_write_lines s y /1,2 | git add -p >actual && + tail -n 5 actual.trimmed && + test_cmp expect actual.trimmed +' + test_expect_success 'split hunk "add -p (edit)"' ' # Split, say Edit and do nothing. Then: # @@ -403,6 +481,40 @@ test_expect_failure 'split hunk "add -p (no, yes, edit)"' ' ! grep "^+31" actual ' +test_expect_success 'split hunk with incomplete line at end' ' + git reset --hard && + printf "missing LF" >>test && + git add test && + test_write_lines before 10 20 30 40 50 60 70 >test && + git grep --cached missing && + test_write_lines s n y q | git add -p && + test_must_fail git grep --cached missing && + git grep before && + test_must_fail git grep --cached before +' + +test_expect_failure 'edit, adding lines to the first hunk' ' + test_write_lines 10 11 20 30 40 50 51 60 >test && + git reset && + tr _ " " >patch <<-EOF && + @@ -1,5 +1,6 @@ + _10 + +11 + +12 + _20 + +21 + +22 + _30 + EOF + # test sequence is s(plit), e(dit), n(o) + # q n q q is there to make sure we exit at the end. + printf "%s\n" s e n q n q q | + EDITOR=./fake_editor.sh git add -p 2>error && + test_must_be_empty error && + git diff --cached >actual && + grep "^+22" actual +' + test_expect_success 'patch mode ignores unmerged entries' ' git reset --hard && test_commit conflict && @@ -429,35 +541,61 @@ test_expect_success 'patch mode ignores unmerged entries' ' diff_cmp expected diff ' -test_expect_success TTY 'diffs can be colorized' ' +test_expect_success 'diffs can be colorized' ' git reset --hard && echo content >test && - printf y | test_terminal git add -p >output 2>&1 && + printf y >y && + force_color git add -p >output 2>&1 test && + git add test && + echo "new " >test && + + printf y >y && + force_color git -c diff.wsErrorHighlight=all add -p >output.raw 2>&1 output && + grep "old<" output +' + +test_expect_success 'diffFilter filters diff' ' git reset --hard && echo content >test && test_config interactive.diffFilter "sed s/^/foo:/" && - printf y | test_terminal git add -p >output 2>&1 && + printf y >y && + force_color git add -p >output 2>&1 test && - test_config interactive.diffFilter "echo too-short" && - printf y | test_must_fail test_terminal git add -p + test_config interactive.diffFilter "sed 1d" && + printf y >y && + test_must_fail force_color git add -p file && + git add file && + echo changed >file && + test_must_fail git -c diff.algorithm=bogus add -p 2>err && + test_i18ngrep "error: option diff-algorithm accepts " err ' test_expect_success 'patch-mode via -i prompts for files' ' @@ -647,4 +785,29 @@ test_expect_success 'checkout -p works with pathological context lines' ' test_write_lines a b a b a a b a b a >expect && test_cmp expect a ' + +test_expect_success 'show help from add--helper' ' + git reset --hard && + cat >expect <<-EOF && + + *** Commands *** + 1: status 2: update 3: revert 4: add untracked + 5: patch 6: diff 7: quit 8: help + What now> status - show paths with changes + update - add working tree state to the staged set of changes + revert - revert staged set of changes back to the HEAD version + patch - pick hunks and update selectively + diff - view diff between HEAD and index + add untracked - add contents of untracked files to the staged set of changes + *** Commands *** + 1: status 2: update 3: revert 4: add untracked + 5: patch 6: diff 7: quit 8: help + What now>$SP + Bye. + EOF + test_write_lines h | force_color git add -i >actual.colored && + test_decode_color actual && + test_i18ncmp expect actual +' + test_done diff --git a/t/t3704-add-pathspec-file.sh b/t/t3704-add-pathspec-file.sh new file mode 100755 index 000000000000..9e35c1fbca68 --- /dev/null +++ b/t/t3704-add-pathspec-file.sh @@ -0,0 +1,159 @@ +#!/bin/sh + +test_description='add --pathspec-from-file' + +. ./test-lib.sh + +test_tick + +test_expect_success setup ' + test_commit file0 && + echo A >fileA.t && + echo B >fileB.t && + echo C >fileC.t && + echo D >fileD.t +' + +restore_checkpoint () { + git reset +} + +verify_expect () { + git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual && + test_cmp expect actual +} + +test_expect_success '--pathspec-from-file from stdin' ' + restore_checkpoint && + + echo fileA.t | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect +' + +test_expect_success '--pathspec-from-file from file' ' + restore_checkpoint && + + echo fileA.t >list && + git add --pathspec-from-file=list && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect +' + +test_expect_success 'NUL delimiters' ' + restore_checkpoint && + + printf "fileA.t\0fileB.t\0" | git add --pathspec-from-file=- --pathspec-file-nul && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'LF delimiters' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t\n" | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'no trailing delimiter' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t" | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'CRLF delimiters' ' + restore_checkpoint && + + printf "fileA.t\r\nfileB.t\r\n" | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'quotes' ' + restore_checkpoint && + + cat >list <<-\EOF && + "file\101.t" + EOF + + git add --pathspec-from-file=list && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect +' + +test_expect_success 'quotes not compatible with --pathspec-file-nul' ' + restore_checkpoint && + + cat >list <<-\EOF && + "file\101.t" + EOF + + test_must_fail git add --pathspec-from-file=list --pathspec-file-nul +' + +test_expect_success 'only touches what was listed' ' + restore_checkpoint && + + printf "fileB.t\nfileC.t\n" | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileB.t + A fileC.t + EOF + verify_expect +' + +test_expect_success 'error conditions' ' + restore_checkpoint && + echo fileA.t >list && + >empty_list && + + test_must_fail git add --pathspec-from-file=list --interactive 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err && + + test_must_fail git add --pathspec-from-file=list --patch 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err && + + test_must_fail git add --pathspec-from-file=list --edit 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with --edit" err && + + test_must_fail git add --pathspec-from-file=list -- fileA.t 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err && + + test_must_fail git add --pathspec-file-nul 2>err && + test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err && + + # This case succeeds, but still prints to stderr + git add --pathspec-from-file=empty_list 2>err && + test_i18ngrep -e "Nothing specified, nothing added." err +' + +test_done diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 8eb47942e2d7..64dcc5ec289e 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -23,6 +23,7 @@ check_verify_failure () { # first create a commit, so we have a valid object/type # for the tag. test_expect_success 'setup' ' + test_oid_init && echo Hello >A && git update-index --add A && git commit -m "Initial commit" && @@ -69,28 +70,28 @@ check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$' # 4. type line label check cat >tag.sig < 0 +0000 EOF -check_verify_failure '"type" line label check' '^error: char47: .*"\\ntype "$' +check_verify_failure '"type" line label check' '^error: char.*: .*"\\ntype "$' ############################################################ # 5. type line eol check -echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig +echo "object $head" >tag.sig printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig -check_verify_failure '"type" line eol check' '^error: char48: .*"\\n"$' +check_verify_failure '"type" line eol check' '^error: char.*: .*"\\n"$' ############################################################ # 6. tag line label check #1 cat >tag.sig < 0 +0000 @@ -98,37 +99,37 @@ tagger . <> 0 +0000 EOF check_verify_failure '"tag" line label check #1' \ - '^error: char57: no "tag " found$' + '^error: char.*: no "tag " found$' ############################################################ # 7. tag line label check #2 cat >tag.sig <tag.sig <tag.sig < 0 +0000 @@ -150,7 +151,7 @@ tagger . <> 0 +0000 EOF check_verify_failure 'verify tag-name check' \ - '^error: char67: could not verify tag name$' + '^error: char.*: could not verify tag name$' ############################################################ # 11. tagger line label check #1 @@ -164,7 +165,7 @@ This is filler EOF check_verify_failure '"tagger" line label check #1' \ - '^error: char70: could not find "tagger "$' + '^error: char.*: could not find "tagger "$' ############################################################ # 12. tagger line label check #2 @@ -179,7 +180,7 @@ This is filler EOF check_verify_failure '"tagger" line label check #2' \ - '^error: char70: could not find "tagger "$' + '^error: char.*: could not find "tagger "$' ############################################################ # 13. disallow missing tag author name @@ -194,7 +195,7 @@ This is filler EOF check_verify_failure 'disallow missing tag author name' \ - '^error: char77: missing tagger name$' + '^error: char.*: missing tagger name$' ############################################################ # 14. disallow missing tag author name @@ -209,7 +210,7 @@ tagger T A Gger < EOF check_verify_failure 'disallow malformed tagger' \ - '^error: char77: malformed tagger field$' + '^error: char.*: malformed tagger field$' ############################################################ # 15. allow empty tag email @@ -238,7 +239,7 @@ tagger T A Gger 0 +0000 EOF check_verify_failure 'disallow spaces in tag email' \ - '^error: char77: malformed tagger field$' + '^error: char.*: malformed tagger field$' ############################################################ # 17. disallow missing tag timestamp @@ -252,7 +253,7 @@ tagger T A Gger __ EOF check_verify_failure 'disallow missing tag timestamp' \ - '^error: char107: missing tag timestamp$' + '^error: char.*: missing tag timestamp$' ############################################################ # 18. detect invalid tag timestamp1 @@ -266,7 +267,7 @@ tagger T A Gger Tue Mar 25 15:47:44 2008 EOF check_verify_failure 'detect invalid tag timestamp1' \ - '^error: char107: missing tag timestamp$' + '^error: char.*: missing tag timestamp$' ############################################################ # 19. detect invalid tag timestamp2 @@ -280,7 +281,7 @@ tagger T A Gger 2008-03-31T12:20:15-0500 EOF check_verify_failure 'detect invalid tag timestamp2' \ - '^error: char111: malformed tag timestamp$' + '^error: char.*: malformed tag timestamp$' ############################################################ # 20. detect invalid tag timezone1 @@ -294,7 +295,7 @@ tagger T A Gger 1206478233 GMT EOF check_verify_failure 'detect invalid tag timezone1' \ - '^error: char118: malformed tag timezone$' + '^error: char.*: malformed tag timezone$' ############################################################ # 21. detect invalid tag timezone2 @@ -308,7 +309,7 @@ tagger T A Gger 1206478233 + 30 EOF check_verify_failure 'detect invalid tag timezone2' \ - '^error: char118: malformed tag timezone$' + '^error: char.*: malformed tag timezone$' ############################################################ # 22. detect invalid tag timezone3 @@ -322,7 +323,7 @@ tagger T A Gger 1206478233 -1430 EOF check_verify_failure 'detect invalid tag timezone3' \ - '^error: char118: malformed tag timezone$' + '^error: char.*: malformed tag timezone$' ############################################################ # 23. detect invalid header entry @@ -337,7 +338,7 @@ this line should not be here EOF check_verify_failure 'detect invalid header entry' \ - '^error: char124: trailing garbage in tag header$' + '^error: char.*: trailing garbage in tag header$' ############################################################ # 24. create valid tag diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh index b92ff9597728..d277a9f4b721 100755 --- a/t/t3900-i18n-commit.sh +++ b/t/t3900-i18n-commit.sh @@ -204,4 +204,41 @@ test_commit_autosquash_flags eucJP fixup test_commit_autosquash_flags ISO-2022-JP squash +test_commit_autosquash_multi_encoding () { + flag=$1 + old=$2 + new=$3 + msg=$4 + test_expect_success "commit --$flag into $old from $new" ' + git checkout -b $flag-$old-$new C0 && + git config i18n.commitencoding $old && + echo $old >>F && + git commit -a -F "$TEST_DIRECTORY"/t3900/$msg && + test_tick && + echo intermediate stuff >>G && + git add G && + git commit -a -m "intermediate commit" && + test_tick && + git config i18n.commitencoding $new && + echo $new-$flag >>F && + git commit -a --$flag HEAD^ && + git rebase --autosquash -i HEAD^^^ && + git rev-list HEAD >actual && + test_line_count = 3 actual && + iconv -f $old -t UTF-8 "$TEST_DIRECTORY"/t3900/$msg >expect && + if test $flag = squash; then + subject="$(head -1 expect)" && + printf "\nsquash! %s\n" "$subject" >>expect + fi && + git cat-file commit HEAD^ >raw && + (sed "1,/^$/d" raw | iconv -f $new -t utf-8) >actual && + test_cmp expect actual + ' +} + +test_commit_autosquash_multi_encoding fixup UTF-8 ISO-8859-1 1-UTF-8.txt +test_commit_autosquash_multi_encoding squash ISO-8859-1 UTF-8 ISO8859-1.txt +test_commit_autosquash_multi_encoding squash eucJP ISO-2022-JP eucJP.txt +test_commit_autosquash_multi_encoding fixup ISO-2022-JP UTF-8 ISO-2022-JP.txt + test_done diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index b8e337893f3e..3ad23e2502be 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -7,6 +7,18 @@ test_description='Test git stash' . ./test-lib.sh +diff_cmp () { + for i in "$1" "$2" + do + sed -e 's/^index 0000000\.\.[0-9a-f]*/index 0000000..1234567/' \ + -e 's/^index [0-9a-f]*\.\.[0-9a-f]*/index 1234567..89abcde/' \ + -e 's/^index [0-9a-f]*,[0-9a-f]*\.\.[0-9a-f]*/index 1234567,7654321..89abcde/' \ + "$i" >"$i.compare" || return 1 + done && + test_cmp "$1.compare" "$2.compare" && + rm -f "$1.compare" "$2.compare" +} + test_expect_success 'stash some dirty working directory' ' echo 1 >file && git add file && @@ -36,7 +48,7 @@ EOF test_expect_success 'parents of stash' ' test $(git rev-parse stash^) = $(git rev-parse HEAD) && git diff stash^2..stash >output && - test_cmp expect output + diff_cmp expect output ' test_expect_success 'applying bogus stash does nothing' ' @@ -210,13 +222,13 @@ test_expect_success 'stash branch' ' test refs/heads/stashbranch = $(git symbolic-ref HEAD) && test $(git rev-parse HEAD) = $(git rev-parse master^) && git diff --cached >output && - test_cmp expect output && + diff_cmp expect output && git diff >output && - test_cmp expect1 output && + diff_cmp expect1 output && git add file && git commit -m alternate\ second && git diff master..stashbranch >output && - test_cmp output expect2 && + diff_cmp output expect2 && test 0 = $(git stash list | wc -l) ' @@ -232,8 +244,11 @@ test_expect_success 'save -q is quiet' ' test_must_be_empty output.out ' -test_expect_success 'pop -q is quiet' ' +test_expect_success 'pop -q works and is quiet' ' git stash pop -q >output.out 2>&1 && + echo bar >expect && + git show :file >actual && + test_cmp expect actual && test_must_be_empty output.out ' @@ -242,6 +257,8 @@ test_expect_success 'pop -q --index works and is quiet' ' git add file && git stash save --quiet && git stash pop -q --index >output.out 2>&1 && + git diff-files file2 >file2.diff && + test_must_be_empty file2.diff && test foo = "$(git show :file)" && test_must_be_empty output.out ' @@ -268,6 +285,11 @@ test_expect_success 'stash --no-keep-index' ' test bar,bar2 = $(cat file),$(cat file2) ' +test_expect_success 'dont assume push with non-option args' ' + test_must_fail git stash -q drop 2>err && + test_i18ngrep -e "subcommand wasn'\''t specified; '\''push'\'' can'\''t be assumed due to unexpected token '\''drop'\''" err +' + test_expect_success 'stash --invalid-option' ' echo bar5 >file && echo bar6 >file2 && @@ -577,7 +599,7 @@ test_expect_success 'stash show -p - stashes on stack, stash-like argument' ' +bar EOF git stash show -p ${STASH_ID} >actual && - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'stash show - no stashes on stack, stash-like argument' ' @@ -609,7 +631,7 @@ test_expect_success 'stash show -p - no stashes on stack, stash-like argument' ' +foo EOF git stash show -p ${STASH_ID} >actual && - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'stash show --patience shows diff' ' @@ -627,7 +649,7 @@ test_expect_success 'stash show --patience shows diff' ' +foo EOF git stash show --patience ${STASH_ID} >actual && - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'drop: fail early if specified stash is not a stash ref' ' @@ -791,7 +813,7 @@ test_expect_success 'stash where working directory contains "HEAD" file' ' git diff-index --cached --quiet HEAD && test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" && git diff stash^..stash >output && - test_cmp expect output + diff_cmp expect output ' test_expect_success 'store called with invalid commit' ' @@ -847,7 +869,7 @@ test_expect_success 'stash list implies --first-parent -m' ' +working EOF git stash list --format=%gd -p >actual && - test_cmp expect actual + diff_cmp expect actual ' test_expect_success 'stash list --cc shows combined diff' ' @@ -864,7 +886,7 @@ test_expect_success 'stash list --cc shows combined diff' ' ++working EOF git stash list --format=%gd -p --cc >actual && - test_cmp expect actual + diff_cmp expect actual ' test_expect_success 'stash is not confused by partial renames' ' @@ -1241,4 +1263,31 @@ test_expect_success 'stash --keep-index with file deleted in index does not resu test_path_is_missing to-remove ' +test_expect_success 'stash apply should succeed with unmodified file' ' + echo base >file && + git add file && + git commit -m base && + + # now stash a modification + echo modified >file && + git stash && + + # make the file stat dirty + cp file other && + mv other file && + + git stash apply +' + +test_expect_success 'stash handles skip-worktree entries nicely' ' + test_commit A && + echo changed >A.t && + git add A.t && + git update-index --skip-worktree A.t && + rm A.t && + git stash && + + git rev-parse --verify refs/stash:A.t +' + test_done diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index 29ca76f2fbea..f075c7f1f316 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh @@ -277,8 +277,8 @@ test_expect_success 'stash -u -- leaves ignored file alone' ' test_path_is_file ignored.d/bar ' -test_expect_success 'stash -u -- shows no changes when there are none' ' - git stash push -u -- non-existant >actual && +test_expect_success 'stash -u -- shows no changes when there are none' ' + git stash push -u -- non-existent >actual && echo "No local changes to save" >expect && test_i18ncmp expect actual ' diff --git a/t/t3906-stash-submodule.sh b/t/t3906-stash-submodule.sh index d7219d6f8f18..b93d1d74da7b 100755 --- a/t/t3906-stash-submodule.sh +++ b/t/t3906-stash-submodule.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='stash apply can handle submodules' +test_description='stash can handle submodules' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-submodule-update.sh @@ -21,4 +21,44 @@ KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1 KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 test_submodule_switch "git_stash" +setup_basic () { + test_when_finished "rm -rf main sub" && + git init sub && + ( + cd sub && + test_commit sub_file + ) && + git init main && + ( + cd main && + git submodule add ../sub && + test_commit main_file + ) +} + +test_expect_success 'stash push with submodule.recurse=true preserves dirty submodule worktree' ' + setup_basic && + ( + cd main && + git config submodule.recurse true && + echo "x" >main_file.t && + echo "y" >sub/sub_file.t && + git stash push && + test_must_fail git -C sub diff --quiet + ) +' + +test_expect_success 'stash push and pop with submodule.recurse=true preserves dirty submodule worktree' ' + setup_basic && + ( + cd main && + git config submodule.recurse true && + echo "x" >main_file.t && + echo "y" >sub/sub_file.t && + git stash push && + git stash pop && + test_must_fail git -C sub diff --quiet + ) +' + test_done diff --git a/t/t3908-stash-in-worktree.sh b/t/t3908-stash-in-worktree.sh new file mode 100755 index 000000000000..2b2b366ef94b --- /dev/null +++ b/t/t3908-stash-in-worktree.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# Copyright (c) 2019 Johannes E Schindelin +# + +test_description='Test git stash in a worktree' + +. ./test-lib.sh + +test_expect_success 'setup' ' + test_commit initial && + git worktree add wt && + test_commit -C wt in-worktree +' + +test_expect_success 'apply in subdirectory' ' + mkdir wt/subdir && + ( + cd wt/subdir && + echo modified >../initial.t && + git stash && + git stash apply >out + ) && + grep "\.\.\/initial\.t" wt/subdir/out +' + +test_done diff --git a/t/t3909-stash-pathspec-file.sh b/t/t3909-stash-pathspec-file.sh new file mode 100755 index 000000000000..55e050cfd4db --- /dev/null +++ b/t/t3909-stash-pathspec-file.sh @@ -0,0 +1,100 @@ +#!/bin/sh + +test_description='stash --pathspec-from-file' + +. ./test-lib.sh + +test_tick + +test_expect_success setup ' + >fileA.t && + >fileB.t && + >fileC.t && + >fileD.t && + git add fileA.t fileB.t fileC.t fileD.t && + git commit -m "Files" && + + git tag checkpoint +' + +restore_checkpoint () { + git reset --hard checkpoint +} + +verify_expect () { + git stash show --name-status >actual && + test_cmp expect actual +} + +test_expect_success 'simplest' ' + restore_checkpoint && + + # More files are written to make sure that git didnt ignore + # --pathspec-from-file, stashing everything + echo A >fileA.t && + echo B >fileB.t && + echo C >fileC.t && + echo D >fileD.t && + + cat >expect <<-\EOF && + M fileA.t + EOF + + echo fileA.t | git stash push --pathspec-from-file=- && + verify_expect +' + +test_expect_success '--pathspec-file-nul' ' + restore_checkpoint && + + # More files are written to make sure that git didnt ignore + # --pathspec-from-file, stashing everything + echo A >fileA.t && + echo B >fileB.t && + echo C >fileC.t && + echo D >fileD.t && + + cat >expect <<-\EOF && + M fileA.t + M fileB.t + EOF + + printf "fileA.t\0fileB.t\0" | git stash push --pathspec-from-file=- --pathspec-file-nul && + verify_expect +' + +test_expect_success 'only touches what was listed' ' + restore_checkpoint && + + # More files are written to make sure that git didnt ignore + # --pathspec-from-file, stashing everything + echo A >fileA.t && + echo B >fileB.t && + echo C >fileC.t && + echo D >fileD.t && + + cat >expect <<-\EOF && + M fileB.t + M fileC.t + EOF + + printf "fileB.t\nfileC.t\n" | git stash push --pathspec-from-file=- && + verify_expect +' + +test_expect_success 'error conditions' ' + restore_checkpoint && + echo A >fileA.t && + echo fileA.t >list && + + test_must_fail git stash push --pathspec-from-file=list --patch 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err && + + test_must_fail git stash push --pathspec-from-file=list -- fileA.t 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err && + + test_must_fail git stash push --pathspec-file-nul 2>err && + test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err +' + +test_done diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh index 8de36b7d1222..e5116a76a1cc 100755 --- a/t/t4000-diff-format.sh +++ b/t/t4000-diff-format.sh @@ -78,7 +78,7 @@ test_expect_success 'git diff-files --no-patch --patch shows the patch' ' test_expect_success 'git diff-files --no-patch --patch-with-raw shows the patch and raw data' ' git diff-files --no-patch --patch-with-raw >actual && - grep -q "^:100644 100755 .* 0000000000000000000000000000000000000000 M path0\$" actual && + grep -q "^:100644 100755 .* $ZERO_OID M path0\$" actual && tail -n +4 actual >actual-patch && compare_diff_patch expected actual-patch ' diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh index 3a6c21e8251b..cbcdd104647b 100755 --- a/t/t4002-diff-basic.sh +++ b/t/t4002-diff-basic.sh @@ -7,123 +7,272 @@ test_description='Test diff raw-output. ' . ./test-lib.sh + . "$TEST_DIRECTORY"/lib-read-tree-m-3way.sh -cat >.test-plain-OA <<\EOF -:000000 100644 0000000000000000000000000000000000000000 ccba72ad3888a3520b39efcf780b9ee64167535d A AA -:000000 100644 0000000000000000000000000000000000000000 7e426fb079479fd67f6d81f984e4ec649a44bc25 A AN -:100644 000000 bcc68ef997017466d5c9094bcf7692295f588c9a 0000000000000000000000000000000000000000 D DD -:000000 040000 0000000000000000000000000000000000000000 6d50f65d3bdab91c63444294d38f08aeff328e42 A DF -:100644 000000 141c1f1642328e4bc46a7d801a71da392e66791e 0000000000000000000000000000000000000000 D DM -:100644 000000 35abde1506ddf806572ff4d407bd06885d0f8ee9 0000000000000000000000000000000000000000 D DN -:000000 100644 0000000000000000000000000000000000000000 1d41122ebdd7a640f29d3c9cc4f9d70094374762 A LL -:100644 100644 03f24c8c4700babccfd28b654e7e8eac402ad6cd 103d9f89b50b9aad03054b579be5e7aa665f2d57 M MD -:100644 100644 b258508afb7ceb449981bd9d63d2d3e971bf8d34 b431b272d829ff3aa4d1a5085f4394ab4d3305b6 M MM -:100644 100644 bd084b0c27c7b6cc34f11d6d0509a29be3caf970 a716d58de4a570e0038f5c307bd8db34daea021f M MN -:100644 100644 40c959f984c8b89a2b02520d17f00d717f024397 2ac547ae9614a00d1b28275de608131f7a0e259f M SS -:100644 100644 4ac13458899ab908ef3b1128fa378daefc88d356 4c86f9a85fbc5e6804ee2e17a797538fbe785bca M TT -:040000 040000 7d670fdcdb9929f6c7dac196ff78689cd1c566a1 5e5f22072bb39f6e12cf663a57cb634c76eefb49 M Z +test_oid_init + +test_oid_cache <<\EOF +aa_1 sha1:ccba72ad3888a3520b39efcf780b9ee64167535d +aa_1 sha256:9febfbf18197819b2735c45291f138525d2476d59470f98239647544586ba403 + +aa_2 sha1:6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 +aa_2 sha256:6eaa3437de83f145a4aaa6ba355303075ade547b128ec6a2cd00a81ff7ce7a56 + +an_1 sha1:7e426fb079479fd67f6d81f984e4ec649a44bc25 +an_1 sha256:8f92a0bec99e399a38e3bd0e1bf19fbf121e0160efb29b857df79d439f1c4536 + +dd_1 sha1:bcc68ef997017466d5c9094bcf7692295f588c9a +dd_1 sha256:07e17428b00639b85485d2b01083d219e2f3e3ba8579e9ca44e9cc8dd554d952 + +df_1 sha1:6d50f65d3bdab91c63444294d38f08aeff328e42 +df_1 sha256:e367cecc27e9bf5451b1c65828cb21938d36a5f8e39c1b03ad6509cc36bb8e9d + +df_2 sha1:71420ab81e254145d26d6fc0cddee64c1acd4787 +df_2 sha256:0f0a86d10347ff6921d03a3c954679f3f1d14fa3d5cd82f57b32c09755f3a47d + +dfd1 sha1:68a6d8b91da11045cf4aa3a5ab9f2a781c701249 +dfd1 sha256:f3bd3265b02b6978ce86490d8ad026c573639c974b3de1d9faf30d8d5a77d3d5 + +dm_1 sha1:141c1f1642328e4bc46a7d801a71da392e66791e +dm_1 sha256:c89f8656e7b94e21ee5fbaf0e2149bbf783c51edbe2ce110349cac13059ee7ed + +dm_2 sha1:3c4d8de5fbad08572bab8e10eef8dbb264cf0231 +dm_2 sha256:83a572e37e0c94086294dae2cecc43d9131afd6f6c906e495c78972230b54988 + +dn_1 sha1:35abde1506ddf806572ff4d407bd06885d0f8ee9 +dn_1 sha256:775d5852582070e620be63327bfa515fab8f71c7ac3e4f0c3cd6267b4377ba28 + +ll_2 sha1:1d41122ebdd7a640f29d3c9cc4f9d70094374762 +ll_2 sha256:7917b4948a883cfed0a77d3d5a625dc8577d6ddcc3c6c3bbc56c4d4226a2246d + +md_1 sha1:03f24c8c4700babccfd28b654e7e8eac402ad6cd +md_1 sha256:fc9f30369b978595ad685ba11ca9a17de0af16d79cd4b629975f4f1590033902 + +md_2 sha1:103d9f89b50b9aad03054b579be5e7aa665f2d57 +md_2 sha256:fc78ec75275628762fe520479a6b2398dec295ce7aabcb1d15e5963c7b4e9317 + +mm_1 sha1:b258508afb7ceb449981bd9d63d2d3e971bf8d34 +mm_1 sha256:a4b7847d228e900e3000285e240c20fd96f9dd41ce1445305f6eada126d4a04a + +mm_2 sha1:b431b272d829ff3aa4d1a5085f4394ab4d3305b6 +mm_2 sha256:3f8b83ea36aacf689bcf1a1290a9a8ed341564d32682ea6f76fea9a979186782 + +mm_3 sha1:19989d4559aae417fedee240ccf2ba315ea4dc2b +mm_3 sha256:71b3bfc5747ac033fff9ea0ab39ee453a3af2969890e75d6ef547b87544e2681 + +mn_1 sha1:bd084b0c27c7b6cc34f11d6d0509a29be3caf970 +mn_1 sha256:47a67450583d7a329eb01a7c4ba644945af72c0ed2c7c95eb5a00d6e46d4d483 + +mn_2 sha1:a716d58de4a570e0038f5c307bd8db34daea021f +mn_2 sha256:f95104c1ebe27acb84bac25a7be98c71f6b8d3054b21f357a5be0c524ad97e08 + +nm_1 sha1:c8f25781e8f1792e3e40b74225e20553041b5226 +nm_1 sha256:09baddc7afaa62e62e152c23c9c3ab94bf15a3894031e227e9be7fe68e1f4e49 + +nm_2 sha1:cdb9a8c3da571502ac30225e9c17beccb8387983 +nm_2 sha256:58b5227956ac2d2a08d0efa513c0ae37430948b16791ea3869a1308dbf05536d + +na_1 sha1:15885881ea69115351c09b38371f0348a3fb8c67 +na_1 sha256:18e4fdd1670cd7968ee23d35bfd29e5418d56fb190c840094c1c57ceee0aad8f + +nd_1 sha1:a4e179e4291e5536a5e1c82e091052772d2c5a93 +nd_1 sha256:07dac9b01d00956ea0c65bd993d7de4864aeef2ed3cbb1255d9f1d949fcd6df6 + +ss_1 sha1:40c959f984c8b89a2b02520d17f00d717f024397 +ss_1 sha256:50fc1b5df74d9910db2f9270993484235f15b69b75b01bcfb53e059289d14af9 + +ss_2 sha1:2ac547ae9614a00d1b28275de608131f7a0e259f +ss_2 sha256:a90f02e6044f1497d13db587d22ab12f90150a7d1e084afcf96065fab35ae2bc + +tt_1 sha1:4ac13458899ab908ef3b1128fa378daefc88d356 +tt_1 sha256:c53113c7dd5060e86b5b251428bd058f6726f66273c6a24bff1c61a04f498dd3 + +tt_2 sha1:4c86f9a85fbc5e6804ee2e17a797538fbe785bca +tt_2 sha256:0775f2a296129a7cf2862b46bc0e88c14d593f2773a3e3fb1c5193db6f5a7e77 + +tt_3 sha1:c4e4a12231b9fa79a0053cb6077fcb21bb5b135a +tt_3 sha256:47860f93cdd211f96443e0560f21c57ab6c2f4b0ac27ff03651a352e53fe8484 + +z__1 sha1:7d670fdcdb9929f6c7dac196ff78689cd1c566a1 +z__1 sha256:44d0f37aff5e51cfcfdd1134c93a6419bcca7b9964f792ffcd5f9b4fcba1ee63 + +z__2 sha1:5e5f22072bb39f6e12cf663a57cb634c76eefb49 +z__2 sha256:d29de162113190fed104eb5f010820cef4e315f89b9326e8497f7219fb737894 + +z__3 sha1:1ba523955d5160681af65cb776411f574c1e8155 +z__3 sha256:07422d772b07794ab4369a5648e617719f89c2d2212cbeab05d97214b6471636 + +zaa1 sha1:8acb8e9750e3f644bf323fcf3d338849db106c77 +zaa1 sha256:e79b029282c8abec2d9f3f7faceaf2a1405e02d1f368e66450ae66cf5b68d1f4 + +zaa2 sha1:6c0b99286d0bce551ac4a7b3dff8b706edff3715 +zaa2 sha256:c82bd78c3e69ea1796e6b1a7a3ba45bb106c50e819296475b862123d3f5cc5a0 + +zan1 sha1:087494262084cefee7ed484d20c8dc0580791272 +zan1 sha256:4b159eb3804d05599023dd074f771d06d02870f4ab24a7165add8ac3d703b8d3 + +zdd1 sha1:879007efae624d2b1307214b24a956f0a8d686a8 +zdd1 sha256:eecfdd4d8092dd0363fb6d4548b54c6afc8982c3ed9b34e393f1d6a921d8eaa3 + +zdm1 sha1:9b541b2275c06e3a7b13f28badf5294e2ae63df4 +zdm1 sha256:ab136e88e19a843c4bf7713d2090d5a2186ba16a6a80dacc12eeddd256a8e556 + +zdm2 sha1:d77371d15817fcaa57eeec27f770c505ba974ec1 +zdm2 sha256:1c1a5f57363f46a15d95ce8527b3c2c158d88d16853b4acbf81bd20fd2c89a46 + +zdn1 sha1:beb5d38c55283d280685ea21a0e50cfcc0ca064a +zdn1 sha256:0f0eca66183617b0aa5ad74b256540329f841470922ca6760263c996d825eb18 + +zmd1 sha1:d41fda41b7ec4de46b43cb7ea42a45001ae393d5 +zmd1 sha256:1ed32d481852eddf31a0ce12652a0ad14bf5b7a842667b5dbb0b50f35bf1c80a + +zmd2 sha1:a79ac3be9377639e1c7d1edf1ae1b3a5f0ccd8a9 +zmd2 sha256:b238da211b404f8917df2d9c6f7030535e904b2186131007a3c292ec6902f933 + +zmm1 sha1:4ca22bae2527d3d9e1676498a0fba3b355bd1278 +zmm1 sha256:072b1d85b5f34fabc99dfa46008c5418df68302d3e317430006f49b32d244226 + +zmm2 sha1:61422ba9c2c873416061a88cd40a59a35b576474 +zmm2 sha256:81dd5d2b3c5cda16fef552256aed4e2ea0802a8450a08f308a92142112ff6dda + +zmm3 sha1:697aad7715a1e7306ca76290a3dd4208fbaeddfa +zmm3 sha256:8b10fab49e9be3414aa5e9a93d0e46f9569053440138a7c19a5eb5536d8e95bf + +zmn1 sha1:b16d7b25b869f2beb124efa53467d8a1550ad694 +zmn1 sha256:609e4f75d1295e844c826feeba213acb0b6cfc609adfe8ff705b19e3829ae3e9 + +zmn2 sha1:a5c544c21cfcb07eb80a4d89a5b7d1570002edfd +zmn2 sha256:d6d03edf2dc1a3b267a8205de5f41a2ff4b03def8c7ae02052b543fb09d589fc + +zna1 sha1:d12979c22fff69c59ca9409e7a8fe3ee25eaee80 +zna1 sha256:b37b80e789e8ea32aa323f004628f02013f632124b0282c7fe00a127d3c64c3c + +znd1 sha1:a18393c636b98e9bd7296b8b437ea4992b72440c +znd1 sha256:af92a22eee8c38410a0c9d2b5135a10aeb052cbc7cf675541ed9a67bfcaf7cf9 + +znm1 sha1:3fdbe17fd013303a2e981e1ca1c6cd6e72789087 +znm1 sha256:f75aeaa0c11e76918e381c105f0752932c6150e941fec565d24fa31098a13dc1 + +znm2 sha1:7e09d6a3a14bd630913e8c75693cea32157b606d +znm2 sha256:938d73cfbaa1c902a84fb5b3afd9736aa0590367fb9bd59c6c4d072ce70fcd6d +EOF + +cat >.test-plain-OA <.test-recursive-OA <<\EOF -:000000 100644 0000000000000000000000000000000000000000 ccba72ad3888a3520b39efcf780b9ee64167535d A AA -:000000 100644 0000000000000000000000000000000000000000 7e426fb079479fd67f6d81f984e4ec649a44bc25 A AN -:100644 000000 bcc68ef997017466d5c9094bcf7692295f588c9a 0000000000000000000000000000000000000000 D DD -:000000 100644 0000000000000000000000000000000000000000 68a6d8b91da11045cf4aa3a5ab9f2a781c701249 A DF/DF -:100644 000000 141c1f1642328e4bc46a7d801a71da392e66791e 0000000000000000000000000000000000000000 D DM -:100644 000000 35abde1506ddf806572ff4d407bd06885d0f8ee9 0000000000000000000000000000000000000000 D DN -:000000 100644 0000000000000000000000000000000000000000 1d41122ebdd7a640f29d3c9cc4f9d70094374762 A LL -:100644 100644 03f24c8c4700babccfd28b654e7e8eac402ad6cd 103d9f89b50b9aad03054b579be5e7aa665f2d57 M MD -:100644 100644 b258508afb7ceb449981bd9d63d2d3e971bf8d34 b431b272d829ff3aa4d1a5085f4394ab4d3305b6 M MM -:100644 100644 bd084b0c27c7b6cc34f11d6d0509a29be3caf970 a716d58de4a570e0038f5c307bd8db34daea021f M MN -:100644 100644 40c959f984c8b89a2b02520d17f00d717f024397 2ac547ae9614a00d1b28275de608131f7a0e259f M SS -:100644 100644 4ac13458899ab908ef3b1128fa378daefc88d356 4c86f9a85fbc5e6804ee2e17a797538fbe785bca M TT -:000000 100644 0000000000000000000000000000000000000000 8acb8e9750e3f644bf323fcf3d338849db106c77 A Z/AA -:000000 100644 0000000000000000000000000000000000000000 087494262084cefee7ed484d20c8dc0580791272 A Z/AN -:100644 000000 879007efae624d2b1307214b24a956f0a8d686a8 0000000000000000000000000000000000000000 D Z/DD -:100644 000000 9b541b2275c06e3a7b13f28badf5294e2ae63df4 0000000000000000000000000000000000000000 D Z/DM -:100644 000000 beb5d38c55283d280685ea21a0e50cfcc0ca064a 0000000000000000000000000000000000000000 D Z/DN -:100644 100644 d41fda41b7ec4de46b43cb7ea42a45001ae393d5 a79ac3be9377639e1c7d1edf1ae1b3a5f0ccd8a9 M Z/MD -:100644 100644 4ca22bae2527d3d9e1676498a0fba3b355bd1278 61422ba9c2c873416061a88cd40a59a35b576474 M Z/MM -:100644 100644 b16d7b25b869f2beb124efa53467d8a1550ad694 a5c544c21cfcb07eb80a4d89a5b7d1570002edfd M Z/MN +cat >.test-recursive-OA <.test-plain-OB <<\EOF -:000000 100644 0000000000000000000000000000000000000000 6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 A AA -:100644 000000 bcc68ef997017466d5c9094bcf7692295f588c9a 0000000000000000000000000000000000000000 D DD -:000000 100644 0000000000000000000000000000000000000000 71420ab81e254145d26d6fc0cddee64c1acd4787 A DF -:100644 100644 141c1f1642328e4bc46a7d801a71da392e66791e 3c4d8de5fbad08572bab8e10eef8dbb264cf0231 M DM -:000000 100644 0000000000000000000000000000000000000000 1d41122ebdd7a640f29d3c9cc4f9d70094374762 A LL -:100644 000000 03f24c8c4700babccfd28b654e7e8eac402ad6cd 0000000000000000000000000000000000000000 D MD -:100644 100644 b258508afb7ceb449981bd9d63d2d3e971bf8d34 19989d4559aae417fedee240ccf2ba315ea4dc2b M MM -:000000 100644 0000000000000000000000000000000000000000 15885881ea69115351c09b38371f0348a3fb8c67 A NA -:100644 000000 a4e179e4291e5536a5e1c82e091052772d2c5a93 0000000000000000000000000000000000000000 D ND -:100644 100644 c8f25781e8f1792e3e40b74225e20553041b5226 cdb9a8c3da571502ac30225e9c17beccb8387983 M NM -:100644 100644 40c959f984c8b89a2b02520d17f00d717f024397 2ac547ae9614a00d1b28275de608131f7a0e259f M SS -:100644 100644 4ac13458899ab908ef3b1128fa378daefc88d356 c4e4a12231b9fa79a0053cb6077fcb21bb5b135a M TT -:040000 040000 7d670fdcdb9929f6c7dac196ff78689cd1c566a1 1ba523955d5160681af65cb776411f574c1e8155 M Z +cat >.test-plain-OB <.test-recursive-OB <<\EOF -:000000 100644 0000000000000000000000000000000000000000 6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 A AA -:100644 000000 bcc68ef997017466d5c9094bcf7692295f588c9a 0000000000000000000000000000000000000000 D DD -:000000 100644 0000000000000000000000000000000000000000 71420ab81e254145d26d6fc0cddee64c1acd4787 A DF -:100644 100644 141c1f1642328e4bc46a7d801a71da392e66791e 3c4d8de5fbad08572bab8e10eef8dbb264cf0231 M DM -:000000 100644 0000000000000000000000000000000000000000 1d41122ebdd7a640f29d3c9cc4f9d70094374762 A LL -:100644 000000 03f24c8c4700babccfd28b654e7e8eac402ad6cd 0000000000000000000000000000000000000000 D MD -:100644 100644 b258508afb7ceb449981bd9d63d2d3e971bf8d34 19989d4559aae417fedee240ccf2ba315ea4dc2b M MM -:000000 100644 0000000000000000000000000000000000000000 15885881ea69115351c09b38371f0348a3fb8c67 A NA -:100644 000000 a4e179e4291e5536a5e1c82e091052772d2c5a93 0000000000000000000000000000000000000000 D ND -:100644 100644 c8f25781e8f1792e3e40b74225e20553041b5226 cdb9a8c3da571502ac30225e9c17beccb8387983 M NM -:100644 100644 40c959f984c8b89a2b02520d17f00d717f024397 2ac547ae9614a00d1b28275de608131f7a0e259f M SS -:100644 100644 4ac13458899ab908ef3b1128fa378daefc88d356 c4e4a12231b9fa79a0053cb6077fcb21bb5b135a M TT -:000000 100644 0000000000000000000000000000000000000000 6c0b99286d0bce551ac4a7b3dff8b706edff3715 A Z/AA -:100644 000000 879007efae624d2b1307214b24a956f0a8d686a8 0000000000000000000000000000000000000000 D Z/DD -:100644 100644 9b541b2275c06e3a7b13f28badf5294e2ae63df4 d77371d15817fcaa57eeec27f770c505ba974ec1 M Z/DM -:100644 000000 d41fda41b7ec4de46b43cb7ea42a45001ae393d5 0000000000000000000000000000000000000000 D Z/MD -:100644 100644 4ca22bae2527d3d9e1676498a0fba3b355bd1278 697aad7715a1e7306ca76290a3dd4208fbaeddfa M Z/MM -:000000 100644 0000000000000000000000000000000000000000 d12979c22fff69c59ca9409e7a8fe3ee25eaee80 A Z/NA -:100644 000000 a18393c636b98e9bd7296b8b437ea4992b72440c 0000000000000000000000000000000000000000 D Z/ND -:100644 100644 3fdbe17fd013303a2e981e1ca1c6cd6e72789087 7e09d6a3a14bd630913e8c75693cea32157b606d M Z/NM +cat >.test-recursive-OB <.test-plain-AB <<\EOF -:100644 100644 ccba72ad3888a3520b39efcf780b9ee64167535d 6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 M AA -:100644 000000 7e426fb079479fd67f6d81f984e4ec649a44bc25 0000000000000000000000000000000000000000 D AN -:000000 100644 0000000000000000000000000000000000000000 71420ab81e254145d26d6fc0cddee64c1acd4787 A DF -:040000 000000 6d50f65d3bdab91c63444294d38f08aeff328e42 0000000000000000000000000000000000000000 D DF -:000000 100644 0000000000000000000000000000000000000000 3c4d8de5fbad08572bab8e10eef8dbb264cf0231 A DM -:000000 100644 0000000000000000000000000000000000000000 35abde1506ddf806572ff4d407bd06885d0f8ee9 A DN -:100644 000000 103d9f89b50b9aad03054b579be5e7aa665f2d57 0000000000000000000000000000000000000000 D MD -:100644 100644 b431b272d829ff3aa4d1a5085f4394ab4d3305b6 19989d4559aae417fedee240ccf2ba315ea4dc2b M MM -:100644 100644 a716d58de4a570e0038f5c307bd8db34daea021f bd084b0c27c7b6cc34f11d6d0509a29be3caf970 M MN -:000000 100644 0000000000000000000000000000000000000000 15885881ea69115351c09b38371f0348a3fb8c67 A NA -:100644 000000 a4e179e4291e5536a5e1c82e091052772d2c5a93 0000000000000000000000000000000000000000 D ND -:100644 100644 c8f25781e8f1792e3e40b74225e20553041b5226 cdb9a8c3da571502ac30225e9c17beccb8387983 M NM -:100644 100644 4c86f9a85fbc5e6804ee2e17a797538fbe785bca c4e4a12231b9fa79a0053cb6077fcb21bb5b135a M TT -:040000 040000 5e5f22072bb39f6e12cf663a57cb634c76eefb49 1ba523955d5160681af65cb776411f574c1e8155 M Z +cat >.test-plain-AB <.test-recursive-AB <<\EOF -:100644 100644 ccba72ad3888a3520b39efcf780b9ee64167535d 6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 M AA -:100644 000000 7e426fb079479fd67f6d81f984e4ec649a44bc25 0000000000000000000000000000000000000000 D AN -:000000 100644 0000000000000000000000000000000000000000 71420ab81e254145d26d6fc0cddee64c1acd4787 A DF -:100644 000000 68a6d8b91da11045cf4aa3a5ab9f2a781c701249 0000000000000000000000000000000000000000 D DF/DF -:000000 100644 0000000000000000000000000000000000000000 3c4d8de5fbad08572bab8e10eef8dbb264cf0231 A DM -:000000 100644 0000000000000000000000000000000000000000 35abde1506ddf806572ff4d407bd06885d0f8ee9 A DN -:100644 000000 103d9f89b50b9aad03054b579be5e7aa665f2d57 0000000000000000000000000000000000000000 D MD -:100644 100644 b431b272d829ff3aa4d1a5085f4394ab4d3305b6 19989d4559aae417fedee240ccf2ba315ea4dc2b M MM -:100644 100644 a716d58de4a570e0038f5c307bd8db34daea021f bd084b0c27c7b6cc34f11d6d0509a29be3caf970 M MN -:000000 100644 0000000000000000000000000000000000000000 15885881ea69115351c09b38371f0348a3fb8c67 A NA -:100644 000000 a4e179e4291e5536a5e1c82e091052772d2c5a93 0000000000000000000000000000000000000000 D ND -:100644 100644 c8f25781e8f1792e3e40b74225e20553041b5226 cdb9a8c3da571502ac30225e9c17beccb8387983 M NM -:100644 100644 4c86f9a85fbc5e6804ee2e17a797538fbe785bca c4e4a12231b9fa79a0053cb6077fcb21bb5b135a M TT -:100644 100644 8acb8e9750e3f644bf323fcf3d338849db106c77 6c0b99286d0bce551ac4a7b3dff8b706edff3715 M Z/AA -:100644 000000 087494262084cefee7ed484d20c8dc0580791272 0000000000000000000000000000000000000000 D Z/AN -:000000 100644 0000000000000000000000000000000000000000 d77371d15817fcaa57eeec27f770c505ba974ec1 A Z/DM -:000000 100644 0000000000000000000000000000000000000000 beb5d38c55283d280685ea21a0e50cfcc0ca064a A Z/DN -:100644 000000 a79ac3be9377639e1c7d1edf1ae1b3a5f0ccd8a9 0000000000000000000000000000000000000000 D Z/MD -:100644 100644 61422ba9c2c873416061a88cd40a59a35b576474 697aad7715a1e7306ca76290a3dd4208fbaeddfa M Z/MM -:100644 100644 a5c544c21cfcb07eb80a4d89a5b7d1570002edfd b16d7b25b869f2beb124efa53467d8a1550ad694 M Z/MN -:000000 100644 0000000000000000000000000000000000000000 d12979c22fff69c59ca9409e7a8fe3ee25eaee80 A Z/NA -:100644 000000 a18393c636b98e9bd7296b8b437ea4992b72440c 0000000000000000000000000000000000000000 D Z/ND -:100644 100644 3fdbe17fd013303a2e981e1ca1c6cd6e72789087 7e09d6a3a14bd630913e8c75693cea32157b606d M Z/NM +cat >.test-recursive-AB <COPYING && echo frotz >rezrov && git update-index --add COPYING rezrov && + orig=$(git hash-object COPYING) && tree=$(git write-tree) && echo $tree' @@ -22,6 +23,8 @@ test_expect_success \ 'sed -e 's/HOWEVER/However/' COPYING.1 && sed -e 's/GPL/G.P.L/g' COPYING.2 && rm -f COPYING && + c1=$(git hash-object COPYING.1) && + c2=$(git hash-object COPYING.2) && git update-index --add --remove COPYING COPYING.?' # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, @@ -31,11 +34,11 @@ test_expect_success \ git diff-index -z -C $tree >current -cat >expected <<\EOF -:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 +cat >expected <current -cat >expected <<\EOF -:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M +cat >expected <current -cat >expected <<\EOF -:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 +cat >expected <file0 && mkdir path1 && echo rezrov >path1/file1 && + before0=$(git hash-object file0) && + before1=$(git hash-object path1/file1) && git update-index --add file0 path1/file1 && tree=$(git write-tree) && echo "$tree" && echo nitfol >file0 && echo yomin >path1/file1 && + after0=$(git hash-object file0) && + after1=$(git hash-object path1/file1) && git update-index file0 path1/file1' cat >expected <<\EOF @@ -31,32 +35,32 @@ test_expect_success \ 'git diff-index --cached $tree -- path >current && compare_diff_raw current expected' -cat >expected <<\EOF -:100644 100644 766498d93a4b06057a8e49d23f4068f1170ff38f 0a41e115ab61be0328a19b29f18cdcb49338d516 M path1/file1 +cat >expected <current && compare_diff_raw current expected' -cat >expected <<\EOF -:100644 100644 766498d93a4b06057a8e49d23f4068f1170ff38f 0a41e115ab61be0328a19b29f18cdcb49338d516 M path1/file1 +cat >expected <current && compare_diff_raw current expected' -cat >expected <<\EOF -:100644 100644 766498d93a4b06057a8e49d23f4068f1170ff38f 0a41e115ab61be0328a19b29f18cdcb49338d516 M path1/file1 +cat >expected <current && compare_diff_raw current expected' -cat >expected <<\EOF -:100644 100644 8e4020bb5a8d8c873b25de15933e75cc0fc275df dca6b92303befc93086aa025d90a5facd7eb2812 M file0 +cat >expected <expected <<-\EOF && + symlink=$(symlink_oid xyzzy) && + cat >expected <<-EOF && diff --git a/frotz b/frotz new file mode 120000 - index 0000000..7c465af + index 0000000..$symlink --- /dev/null +++ b/frotz @@ -0,0 +1 @@ @@ -21,7 +34,7 @@ test_expect_success 'diff new symlink and file' ' \ No newline at end of file diff --git a/nitfol b/nitfol new file mode 100644 - index 0000000..7c465af + index 0000000..$symlink --- /dev/null +++ b/nitfol @@ -0,0 +1 @@ @@ -46,10 +59,10 @@ test_expect_success 'diff unchanged symlink and file' ' ' test_expect_success 'diff removed symlink and file' ' - cat >expected <<-\EOF && + cat >expected <<-EOF && diff --git a/frotz b/frotz deleted file mode 120000 - index 7c465af..0000000 + index $symlink..0000000 --- a/frotz +++ /dev/null @@ -1 +0,0 @@ @@ -57,7 +70,7 @@ test_expect_success 'diff removed symlink and file' ' \ No newline at end of file diff --git a/nitfol b/nitfol deleted file mode 100644 - index 7c465af..0000000 + index $symlink..0000000 --- a/nitfol +++ /dev/null @@ -1 +0,0 @@ @@ -90,9 +103,10 @@ test_expect_success 'diff identical, but newly created symlink and file' ' ' test_expect_success 'diff different symlink and file' ' - cat >expected <<-\EOF && + new=$(symlink_oid yxyyz) && + cat >expected <<-EOF && diff --git a/frotz b/frotz - index 7c465af..df1db54 120000 + index $symlink..$new 120000 --- a/frotz +++ b/frotz @@ -1 +1 @@ @@ -101,7 +115,7 @@ test_expect_success 'diff different symlink and file' ' +yxyyz \ No newline at end of file diff --git a/nitfol b/nitfol - index 7c465af..df1db54 100644 + index $symlink..$new 100644 --- a/nitfol +++ b/nitfol @@ -1 +1 @@ @@ -137,14 +151,16 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' ' ' test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' ' - cat >expect <<-\EOF && + file=$(short_oid file.bin) && + link=$(symlink_oid file.bin) && + cat >expect <<-EOF && diff --git a/file.bin b/file.bin new file mode 100644 - index 0000000..d95f3ad + index 0000000..$file Binary files /dev/null and b/file.bin differ diff --git a/link.bin b/link.bin new file mode 120000 - index 0000000..dce41ec + index 0000000..$link --- /dev/null +++ b/link.bin @@ -0,0 +1 @@ diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index a9054d2db116..dde3f11fec36 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -7,9 +7,6 @@ test_description='Various diff formatting options' . ./test-lib.sh -LF=' -' - test_expect_success setup ' GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" && @@ -123,6 +120,30 @@ test_expect_success setup ' +*++ [initial] Initial EOF +process_diffs () { + _x04="[0-9a-f][0-9a-f][0-9a-f][0-9a-f]" && + _x07="$_x05[0-9a-f][0-9a-f]" && + sed -e "s/$OID_REGEX/$ZERO_OID/g" \ + -e "s/From $_x40 /From $ZERO_OID /" \ + -e "s/from $_x40)/from $ZERO_OID)/" \ + -e "s/commit $_x40\$/commit $ZERO_OID/" \ + -e "s/commit $_x40 (/commit $ZERO_OID (/" \ + -e "s/$_x40 $_x40 $_x40/$ZERO_OID $ZERO_OID $ZERO_OID/" \ + -e "s/$_x40 $_x40 /$ZERO_OID $ZERO_OID /" \ + -e "s/^$_x40 $_x40$/$ZERO_OID $ZERO_OID/" \ + -e "s/^$_x40 /$ZERO_OID /" \ + -e "s/^$_x40$/$ZERO_OID/" \ + -e "s/$_x07\.\.$_x07/fffffff..fffffff/g" \ + -e "s/$_x07,$_x07\.\.$_x07/fffffff,fffffff..fffffff/g" \ + -e "s/$_x07 $_x07 $_x07/fffffff fffffff fffffff/g" \ + -e "s/$_x07 $_x07 /fffffff fffffff /g" \ + -e "s/Merge: $_x07 $_x07/Merge: fffffff fffffff/g" \ + -e "s/$_x07\.\.\./fffffff.../g" \ + -e "s/ $_x04\.\.\./ ffff.../g" \ + -e "s/ $_x04/ ffff/g" \ + "$1" +} + V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g') while read magic cmd do @@ -161,13 +182,15 @@ do } >"$actual" && if test -f "$expect" then + process_diffs "$actual" >actual && + process_diffs "$expect" >expect && case $cmd in *format-patch* | *-stat*) - test_i18ncmp "$expect" "$actual";; + test_i18ncmp expect actual;; *) - test_cmp "$expect" "$actual";; + test_cmp expect actual;; esac && - rm -f "$actual" + rm -f "$actual" actual expect else # this is to help developing new tests. cp "$actual" "$expect" @@ -386,16 +409,22 @@ test_expect_success 'log -S requires an argument' ' test_expect_success 'diff --cached on unborn branch' ' echo ref: refs/heads/unborn >.git/HEAD && git diff --cached >result && - test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached" result + process_diffs result >actual && + process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--cached" >expected && + test_cmp expected actual ' test_expect_success 'diff --cached -- file on unborn branch' ' git diff --cached -- file0 >result && - test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" result + process_diffs result >actual && + process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" >expected && + test_cmp expected actual ' test_expect_success 'diff --line-prefix with spaces' ' git diff --line-prefix="| | | " --cached -- file0 >result && - test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--line-prefix_--cached_--_file0" result + process_diffs result >actual && + process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--line-prefix_--cached_--_file0" >expected && + test_cmp expected actual ' test_expect_success 'diff-tree --stdin with log formatting' ' diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index ca7debf1d4c0..b653dd7d4452 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -9,7 +9,6 @@ test_description='various format-patch tests' . "$TEST_DIRECTORY"/lib-terminal.sh test_expect_success setup ' - for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file && cat file >elif && git add file elif && @@ -34,7 +33,8 @@ test_expect_success setup ' git commit -m "Side changes #3 with \\n backslash-n in it." && git checkout master && - git diff-tree -p C2 | git apply --index && + git diff-tree -p C2 >patch && + git apply --index patch0 && - cnt=$(grep "^From " patch0 | wc -l) && - test $cnt = 3 - + grep "^From " patch0 >from0 && + test_line_count = 3 from0 ' -test_expect_success "format-patch --ignore-if-in-upstream" ' - +test_expect_success 'format-patch --ignore-if-in-upstream' ' git format-patch --stdout \ --ignore-if-in-upstream master..side >patch1 && - cnt=$(grep "^From " patch1 | wc -l) && - test $cnt = 2 - + grep "^From " patch1 >from1 && + test_line_count = 2 from1 ' -test_expect_success "format-patch --ignore-if-in-upstream handles tags" ' +test_expect_success 'format-patch --ignore-if-in-upstream handles tags' ' git tag -a v1 -m tag side && git tag -a v2 -m tag master && git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 && - cnt=$(grep "^From " patch1 | wc -l) && - test $cnt = 2 + grep "^From " patch1 >from1 && + test_line_count = 2 from1 ' test_expect_success "format-patch doesn't consider merge commits" ' - git checkout -b slave master && echo "Another line" >>file && test_tick && @@ -96,148 +91,138 @@ test_expect_success "format-patch doesn't consider merge commits" ' git checkout -b merger master && test_tick && git merge --no-ff slave && - cnt=$(git format-patch -3 --stdout | grep "^From " | wc -l) && - test $cnt = 3 + git format-patch -3 --stdout >patch && + grep "^From " patch >from && + test_line_count = 3 from ' -test_expect_success "format-patch result applies" ' - +test_expect_success 'format-patch result applies' ' git checkout -b rebuild-0 master && git am -3 patch0 && - cnt=$(git rev-list master.. | wc -l) && - test $cnt = 2 + git rev-list master.. >list && + test_line_count = 2 list ' -test_expect_success "format-patch --ignore-if-in-upstream result applies" ' - +test_expect_success 'format-patch --ignore-if-in-upstream result applies' ' git checkout -b rebuild-1 master && git am -3 patch1 && - cnt=$(git rev-list master.. | wc -l) && - test $cnt = 2 + git rev-list master.. >list && + test_line_count = 2 list ' test_expect_success 'commit did not screw up the log message' ' - - git cat-file commit side | grep "^Side .* with .* backslash-n" - + git cat-file commit side >actual && + grep "^Side .* with .* backslash-n" actual ' test_expect_success 'format-patch did not screw up the log message' ' - grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 && grep "^Subject: .*Side changes #3 with .* backslash-n" patch1 - ' test_expect_success 'replay did not screw up the log message' ' - - git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n" - + git cat-file commit rebuild-1 >actual && + grep "^Side .* with .* backslash-n" actual ' test_expect_success 'extra headers' ' - git config format.headers "To: R E Cipient " && git config --add format.headers "Cc: S E Cipient " && - git format-patch --stdout master..side > patch2 && - sed -e "/^\$/q" patch2 > hdrs2 && + git format-patch --stdout master..side >patch2 && + sed -e "/^\$/q" patch2 >hdrs2 && grep "^To: R E Cipient \$" hdrs2 && grep "^Cc: S E Cipient \$" hdrs2 - ' test_expect_success 'extra headers without newlines' ' - git config --replace-all format.headers "To: R E Cipient " && git config --add format.headers "Cc: S E Cipient " && git format-patch --stdout master..side >patch3 && - sed -e "/^\$/q" patch3 > hdrs3 && + sed -e "/^\$/q" patch3 >hdrs3 && grep "^To: R E Cipient \$" hdrs3 && grep "^Cc: S E Cipient \$" hdrs3 - ' test_expect_success 'extra headers with multiple To:s' ' - git config --replace-all format.headers "To: R E Cipient " && git config --add format.headers "To: S E Cipient " && - git format-patch --stdout master..side > patch4 && - sed -e "/^\$/q" patch4 > hdrs4 && + git format-patch --stdout master..side >patch4 && + sed -e "/^\$/q" patch4 >hdrs4 && grep "^To: R E Cipient ,\$" hdrs4 && grep "^ *S E Cipient \$" hdrs4 ' test_expect_success 'additional command line cc (ascii)' ' - git config --replace-all format.headers "Cc: R E Cipient " && - git format-patch --cc="S E Cipient " --stdout master..side | sed -e "/^\$/q" >patch5 && - grep "^Cc: R E Cipient ,\$" patch5 && - grep "^ *S E Cipient \$" patch5 + git format-patch --cc="S E Cipient " --stdout master..side >patch5 && + sed -e "/^\$/q" patch5 >hdrs5 && + grep "^Cc: R E Cipient ,\$" hdrs5 && + grep "^ *S E Cipient \$" hdrs5 ' test_expect_failure 'additional command line cc (rfc822)' ' - git config --replace-all format.headers "Cc: R E Cipient " && - git format-patch --cc="S. E. Cipient " --stdout master..side | sed -e "/^\$/q" >patch5 && - grep "^Cc: R E Cipient ,\$" patch5 && - grep "^ *\"S. E. Cipient\" \$" patch5 + git format-patch --cc="S. E. Cipient " --stdout master..side >patch5 && + sed -e "/^\$/q" patch5 >hdrs5 && + grep "^Cc: R E Cipient ,\$" hdrs5 && + grep "^ *\"S. E. Cipient\" \$" hdrs5 ' test_expect_success 'command line headers' ' - git config --unset-all format.headers && - git format-patch --add-header="Cc: R E Cipient " --stdout master..side | sed -e "/^\$/q" >patch6 && - grep "^Cc: R E Cipient \$" patch6 + git format-patch --add-header="Cc: R E Cipient " --stdout master..side >patch6 && + sed -e "/^\$/q" patch6 >hdrs6 && + grep "^Cc: R E Cipient \$" hdrs6 ' test_expect_success 'configuration headers and command line headers' ' - git config --replace-all format.headers "Cc: R E Cipient " && - git format-patch --add-header="Cc: S E Cipient " --stdout master..side | sed -e "/^\$/q" >patch7 && - grep "^Cc: R E Cipient ,\$" patch7 && - grep "^ *S E Cipient \$" patch7 + git format-patch --add-header="Cc: S E Cipient " --stdout master..side >patch7 && + sed -e "/^\$/q" patch7 >hdrs7 && + grep "^Cc: R E Cipient ,\$" hdrs7 && + grep "^ *S E Cipient \$" hdrs7 ' test_expect_success 'command line To: header (ascii)' ' - git config --unset-all format.headers && - git format-patch --to="R E Cipient " --stdout master..side | sed -e "/^\$/q" >patch8 && - grep "^To: R E Cipient \$" patch8 + git format-patch --to="R E Cipient " --stdout master..side >patch8 && + sed -e "/^\$/q" patch8 >hdrs8 && + grep "^To: R E Cipient \$" hdrs8 ' test_expect_failure 'command line To: header (rfc822)' ' - - git format-patch --to="R. E. Cipient " --stdout master..side | sed -e "/^\$/q" >patch8 && - grep "^To: \"R. E. Cipient\" \$" patch8 + git format-patch --to="R. E. Cipient " --stdout master..side >patch8 && + sed -e "/^\$/q" patch8 >hdrs8 && + grep "^To: \"R. E. Cipient\" \$" hdrs8 ' test_expect_failure 'command line To: header (rfc2047)' ' - - git format-patch --to="R Ä Cipient " --stdout master..side | sed -e "/^\$/q" >patch8 && - grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= \$" patch8 + git format-patch --to="R Ä Cipient " --stdout master..side >patch8 && + sed -e "/^\$/q" patch8 >hdrs8 && + grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= \$" hdrs8 ' test_expect_success 'configuration To: header (ascii)' ' - git config format.to "R E Cipient " && - git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 && - grep "^To: R E Cipient \$" patch9 + git format-patch --stdout master..side >patch9 && + sed -e "/^\$/q" patch9 >hdrs9 && + grep "^To: R E Cipient \$" hdrs9 ' test_expect_failure 'configuration To: header (rfc822)' ' - git config format.to "R. E. Cipient " && - git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 && - grep "^To: \"R. E. Cipient\" \$" patch9 + git format-patch --stdout master..side >patch9 && + sed -e "/^\$/q" patch9 >hdrs9 && + grep "^To: \"R. E. Cipient\" \$" hdrs9 ' test_expect_failure 'configuration To: header (rfc2047)' ' - git config format.to "R Ä Cipient " && - git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 && - grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= \$" patch9 + git format-patch --stdout master..side >patch9 && + sed -e "/^\$/q" patch9 >hdrs9 && + grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= \$" hdrs9 ' # check_patch : Verify that looks like a half-sane @@ -249,89 +234,79 @@ check_patch () { } test_expect_success 'format.from=false' ' - - git -c format.from=false format-patch --stdout master..side | - sed -e "/^\$/q" >patch && + git -c format.from=false format-patch --stdout master..side >patch && + sed -e "/^\$/q" patch >hdrs && check_patch patch && - ! grep "^From: C O Mitter \$" patch + ! grep "^From: C O Mitter \$" hdrs ' test_expect_success 'format.from=true' ' - - git -c format.from=true format-patch --stdout master..side | - sed -e "/^\$/q" >patch && - check_patch patch && - grep "^From: C O Mitter \$" patch + git -c format.from=true format-patch --stdout master..side >patch && + sed -e "/^\$/q" patch >hdrs && + check_patch hdrs && + grep "^From: C O Mitter \$" hdrs ' test_expect_success 'format.from with address' ' - - git -c format.from="F R Om " format-patch --stdout master..side | - sed -e "/^\$/q" >patch && - check_patch patch && - grep "^From: F R Om \$" patch + git -c format.from="F R Om " format-patch --stdout master..side >patch && + sed -e "/^\$/q" patch >hdrs && + check_patch hdrs && + grep "^From: F R Om \$" hdrs ' test_expect_success '--no-from overrides format.from' ' - - git -c format.from="F R Om " format-patch --no-from --stdout master..side | - sed -e "/^\$/q" >patch && - check_patch patch && - ! grep "^From: F R Om \$" patch + git -c format.from="F R Om " format-patch --no-from --stdout master..side >patch && + sed -e "/^\$/q" patch >hdrs && + check_patch hdrs && + ! grep "^From: F R Om \$" hdrs ' test_expect_success '--from overrides format.from' ' - - git -c format.from="F R Om " format-patch --from --stdout master..side | - sed -e "/^\$/q" >patch && - check_patch patch && - ! grep "^From: F R Om \$" patch + git -c format.from="F R Om " format-patch --from --stdout master..side >patch && + sed -e "/^\$/q" patch >hdrs && + check_patch hdrs && + ! grep "^From: F R Om \$" hdrs ' test_expect_success '--no-to overrides config.to' ' - git config --replace-all format.to \ "R E Cipient " && - git format-patch --no-to --stdout master..side | - sed -e "/^\$/q" >patch10 && - check_patch patch10 && - ! grep "^To: R E Cipient \$" patch10 + git format-patch --no-to --stdout master..side >patch10 && + sed -e "/^\$/q" patch10 >hdrs10 && + check_patch hdrs10 && + ! grep "^To: R E Cipient \$" hdrs10 ' test_expect_success '--no-to and --to replaces config.to' ' - git config --replace-all format.to \ "Someone " && git format-patch --no-to --to="Someone Else " \ - --stdout master..side | - sed -e "/^\$/q" >patch11 && - check_patch patch11 && - ! grep "^To: Someone \$" patch11 && - grep "^To: Someone Else \$" patch11 + --stdout master..side >patch11 && + sed -e "/^\$/q" patch11 >hdrs11 && + check_patch hdrs11 && + ! grep "^To: Someone \$" hdrs11 && + grep "^To: Someone Else \$" hdrs11 ' test_expect_success '--no-cc overrides config.cc' ' - git config --replace-all format.cc \ "C E Cipient " && - git format-patch --no-cc --stdout master..side | - sed -e "/^\$/q" >patch12 && - check_patch patch12 && - ! grep "^Cc: C E Cipient \$" patch12 + git format-patch --no-cc --stdout master..side >patch12 && + sed -e "/^\$/q" patch12 >hdrs12 && + check_patch hdrs12 && + ! grep "^Cc: C E Cipient \$" hdrs12 ' test_expect_success '--no-add-header overrides config.headers' ' - git config --replace-all format.headers \ "Header1: B E Cipient " && - git format-patch --no-add-header --stdout master..side | - sed -e "/^\$/q" >patch13 && - check_patch patch13 && - ! grep "^Header1: B E Cipient \$" patch13 + git format-patch --no-add-header --stdout master..side >patch13 && + sed -e "/^\$/q" patch13 >hdrs13 && + check_patch hdrs13 && + ! grep "^Header1: B E Cipient \$" hdrs13 ' test_expect_success 'multiple files' ' - rm -rf patches/ && git checkout side && git format-patch -o patches/ master && @@ -357,7 +332,7 @@ test_expect_success 'reroll count (-v)' ' check_threading () { expect="$1" && shift && - (git format-patch --stdout "$@"; echo $? > status.out) | + git format-patch --stdout "$@" >patch && # Prints everything between the Message-ID and In-Reply-To, # and replaces all Message-ID-lookalikes by a sequence number perl -ne ' @@ -372,12 +347,11 @@ check_threading () { print; } print "---\n" if /^From /i; - ' > actual && - test 0 = "$(cat status.out)" && + ' actual && test_cmp "$expect" actual } -cat >> expect.no-threading <>expect.no-threading < expect.thread <expect.thread < --- @@ -405,7 +379,7 @@ test_expect_success 'thread' ' check_threading expect.thread --thread master ' -cat > expect.in-reply-to <expect.in-reply-to < In-Reply-To: <1> @@ -425,7 +399,7 @@ test_expect_success 'thread in-reply-to' ' --thread master ' -cat > expect.cover-letter <expect.cover-letter < --- @@ -446,7 +420,7 @@ test_expect_success 'thread cover-letter' ' check_threading expect.cover-letter --cover-letter --thread master ' -cat > expect.cl-irt <expect.cl-irt < In-Reply-To: <1> @@ -478,7 +452,7 @@ test_expect_success 'thread explicit shallow' ' --in-reply-to="" --thread=shallow master ' -cat > expect.deep <expect.deep < --- @@ -496,7 +470,7 @@ test_expect_success 'thread deep' ' check_threading expect.deep --thread=deep master ' -cat > expect.deep-irt <expect.deep-irt < In-Reply-To: <1> @@ -519,7 +493,7 @@ test_expect_success 'thread deep in-reply-to' ' --in-reply-to="" master ' -cat > expect.deep-cl <expect.deep-cl < --- @@ -543,7 +517,7 @@ test_expect_success 'thread deep cover-letter' ' check_threading expect.deep-cl --cover-letter --thread=deep master ' -cat > expect.deep-cl-irt <expect.deep-cl-irt < In-Reply-To: <1> @@ -594,7 +568,6 @@ test_expect_success 'thread config + --no-thread' ' ' test_expect_success 'excessive subject' ' - rm -rf patches/ && git checkout side && before=$(git hash-object file) && @@ -622,10 +595,9 @@ test_expect_success 'cover-letter inherits diff options' ' ! grep "file => foo .* 0 *\$" 0000-cover-letter.patch && git format-patch --cover-letter -1 -M && grep "file => foo .* 0 *\$" 0000-cover-letter.patch - ' -cat > expect << EOF +cat >expect < expect << EOF EOF test_expect_success 'shortlog of cover-letter wraps overly-long onelines' ' - git format-patch --cover-letter -2 && - sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output && + sed -e "1,/A U Thor/d" -e "/^\$/q" 0000-cover-letter.patch >output && test_cmp expect output - ' -cat > expect << EOF +cat >expect <output && test_cmp expect output - ' -cat > expect << EOF +cat >expect < output && + sed -e "1,/^\$/d" -e "/^+5/q" 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch >output && test_cmp expect output - ' test_expect_success 'format-patch from a subdirectory (1)' ' @@ -736,7 +702,7 @@ test_expect_success 'format-patch from a subdirectory (3)' ' ' test_expect_success 'format-patch --in-reply-to' ' - git format-patch -1 --stdout --in-reply-to "baz@foo.bar" > patch8 && + git format-patch -1 --stdout --in-reply-to "baz@foo.bar" >patch8 && grep "^In-Reply-To: " patch8 && grep "^References: " patch8 ' @@ -827,21 +793,56 @@ test_expect_success 'format-patch with multiple notes refs' ' ! grep "this is note 2" out ' -echo "fatal: --name-only does not make sense" > expect.name-only -echo "fatal: --name-status does not make sense" > expect.name-status -echo "fatal: --check does not make sense" > expect.check +test_expect_success 'format-patch with multiple notes refs in config' ' + test_when_finished "test_unconfig format.notes" && + + git notes --ref note1 add -m "this is note 1" HEAD && + test_when_finished git notes --ref note1 remove HEAD && + git notes --ref note2 add -m "this is note 2" HEAD && + test_when_finished git notes --ref note2 remove HEAD && + + git config format.notes note1 && + git format-patch -1 --stdout >out && + grep "this is note 1" out && + ! grep "this is note 2" out && + git config format.notes note2 && + git format-patch -1 --stdout >out && + ! grep "this is note 1" out && + grep "this is note 2" out && + git config --add format.notes note1 && + git format-patch -1 --stdout >out && + grep "this is note 1" out && + grep "this is note 2" out && + + git config --replace-all format.notes note1 && + git config --add format.notes false && + git format-patch -1 --stdout >out && + ! grep "this is note 1" out && + ! grep "this is note 2" out && + git config --add format.notes note2 && + git format-patch -1 --stdout >out && + ! grep "this is note 1" out && + grep "this is note 2" out +' + +echo "fatal: --name-only does not make sense" >expect.name-only +echo "fatal: --name-status does not make sense" >expect.name-status +echo "fatal: --check does not make sense" >expect.check test_expect_success 'options no longer allowed for format-patch' ' - test_must_fail git format-patch --name-only 2> output && + test_must_fail git format-patch --name-only 2>output && test_i18ncmp expect.name-only output && - test_must_fail git format-patch --name-status 2> output && + test_must_fail git format-patch --name-status 2>output && test_i18ncmp expect.name-status output && - test_must_fail git format-patch --check 2> output && - test_i18ncmp expect.check output' + test_must_fail git format-patch --check 2>output && + test_i18ncmp expect.check output +' test_expect_success 'format-patch --numstat should produce a patch' ' - git format-patch --numstat --stdout master..side > output && - test 5 = $(grep "^diff --git a/" output | wc -l)' + git format-patch --numstat --stdout master..side >output && + grep "^diff --git a/" output >diff && + test_line_count = 5 diff +' test_expect_success 'format-patch -- ' ' git format-patch master..side -- file 2>error && @@ -852,20 +853,25 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' ' git format-patch --ignore-if-in-upstream HEAD ' -git_version="$(git --version | sed "s/.* //")" +test_expect_success 'get git version' ' + git_version=$(git --version) && + git_version=${git_version##* } +' signature() { printf "%s\n%s\n\n" "-- " "${1:-$git_version}" } test_expect_success 'format-patch default signature' ' - git format-patch --stdout -1 | tail -n 3 >output && + git format-patch --stdout -1 >patch && + tail -n 3 patch >output && signature >expect && test_cmp expect output ' test_expect_success 'format-patch --signature' ' - git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output && + git format-patch --stdout --signature="my sig" -1 >patch && + tail -n 3 patch >output && signature "my sig" >expect && test_cmp expect output ' @@ -897,8 +903,8 @@ test_expect_success 'format-patch --signature --cover-letter' ' git config --unset-all format.signature && git format-patch --stdout --signature="my sig" --cover-letter \ -1 >output && - grep "my sig" output && - test 2 = $(grep "my sig" output | wc -l) + grep "my sig" output >sig && + test_line_count = 2 sig ' test_expect_success 'format.signature="" suppresses signatures' ' @@ -935,7 +941,7 @@ test_expect_success 'prepare mail-signature input' ' test_expect_success '--signature-file=file works' ' git format-patch --stdout --signature-file=mail-signature -1 >output && check_patch output && - sed -e "1,/^-- \$/d" actual && + sed -e "1,/^-- \$/d" output >actual && { cat mail-signature && echo } >expect && @@ -946,7 +952,7 @@ test_expect_success 'format.signaturefile works' ' test_config format.signaturefile mail-signature && git format-patch --stdout -1 >output && check_patch output && - sed -e "1,/^-- \$/d" actual && + sed -e "1,/^-- \$/d" output >actual && { cat mail-signature && echo } >expect && @@ -968,7 +974,7 @@ test_expect_success '--signature-file overrides format.signaturefile' ' git format-patch --stdout \ --signature-file=other-mail-signature -1 >output && check_patch output && - sed -e "1,/^-- \$/d" actual && + sed -e "1,/^-- \$/d" output >actual && { cat other-mail-signature && echo } >expect && @@ -1037,7 +1043,7 @@ test_expect_success 'format-patch wraps extremely long subject (ascii)' ' git add file && git commit -m "$M512" && git format-patch --stdout -1 >patch && - sed -n "/^Subject/p; /^ /p; /^$/q" subject && + sed -n "/^Subject/p; /^ /p; /^$/q" patch >subject && test_cmp expect subject ' @@ -1076,7 +1082,7 @@ test_expect_success 'format-patch wraps extremely long subject (rfc2047)' ' git add file && git commit -m "$M512" && git format-patch --stdout -1 >patch && - sed -n "/^Subject/p; /^ /p; /^$/q" subject && + sed -n "/^Subject/p; /^ /p; /^$/q" patch >subject && test_cmp expect subject ' @@ -1085,7 +1091,7 @@ check_author() { git add file && GIT_AUTHOR_NAME=$1 git commit -m author-check && git format-patch --stdout -1 >patch && - sed -n "/^From: /p; /^ /p; /^$/q" actual && + sed -n "/^From: /p; /^ /p; /^$/q" patch >actual && test_cmp expect actual } @@ -1205,7 +1211,7 @@ test_expect_success '--from=ident replaces author' ' From: A U Thor EOF - sed -ne "/^From:/p; /^$/p; /^---$/q" patch.head && + sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head && test_cmp expect patch.head ' @@ -1217,7 +1223,7 @@ test_expect_success '--from uses committer ident' ' From: A U Thor EOF - sed -ne "/^From:/p; /^$/p; /^---$/q" patch.head && + sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head && test_cmp expect patch.head ' @@ -1227,7 +1233,7 @@ test_expect_success '--from omits redundant in-body header' ' From: A U Thor EOF - sed -ne "/^From:/p; /^$/p; /^---$/q" patch.head && + sed -ne "/^From:/p; /^$/p; /^---$/q" patch >patch.head && test_cmp expect patch.head ' @@ -1242,7 +1248,7 @@ test_expect_success 'in-body headers trigger content encoding' ' From: éxötìc EOF - sed -ne "/^From:/p; /^$/p; /^Content-Type/p; /^---$/q" patch.head && + sed -ne "/^From:/p; /^$/p; /^Content-Type/p; /^---$/q" patch >patch.head && test_cmp expect patch.head ' @@ -1256,283 +1262,283 @@ append_signoff() test_expect_success 'signoff: commit with no body' ' append_signoff actual && - cat <<\EOF | sed "s/EOL$//" >expected && -4:Subject: [PATCH] EOL -8: -9:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + cat <<-\EOF | sed "s/EOL$//" >expect && + 4:Subject: [PATCH] EOL + 8: + 9:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: commit with only subject' ' echo subject | append_signoff >actual && - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -9:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: commit with only subject that does not end with NL' ' printf subject | append_signoff >actual && - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -9:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: no existing signoffs' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + body + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: no existing signoffs and no trailing NL' ' printf "subject\n\nbody" | append_signoff >actual && - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: some random signoff' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Signed-off-by: my@house -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: my@house -12:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + Signed-off-by: my@house + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: my@house + 12:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: misc conforming footer elements' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Signed-off-by: my@house -(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709) -Tested-by: Some One -Bug: 1234 -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: my@house -15:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + Signed-off-by: my@house + (cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709) + Tested-by: Some One + Bug: 1234 + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: my@house + 15:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: some random signoff-alike' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body -Fooled-by-me: my@house -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -11: -12:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + body + Fooled-by-me: my@house + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 11: + 12:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: not really a signoff' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -I want to mention about Signed-off-by: here. -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -9:I want to mention about Signed-off-by: here. -10: -11:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + I want to mention about Signed-off-by: here. + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:I want to mention about Signed-off-by: here. + 10: + 11:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: not really a signoff (2)' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -My unfortunate -Signed-off-by: example happens to be wrapped here. -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10:Signed-off-by: example happens to be wrapped here. -11:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + My unfortunate + Signed-off-by: example happens to be wrapped here. + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10:Signed-off-by: example happens to be wrapped here. + 11:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: valid S-o-b paragraph in the middle' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -Signed-off-by: my@house -Signed-off-by: your@house + Signed-off-by: my@house + Signed-off-by: your@house -A lot of houses. -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -9:Signed-off-by: my@house -10:Signed-off-by: your@house -11: -13: -14:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + A lot of houses. + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: my@house + 10:Signed-off-by: your@house + 11: + 13: + 14:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: the same signoff at the end' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Signed-off-by: C O Mitter -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + Signed-off-by: C O Mitter + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: the same signoff at the end, no trailing NL' ' printf "subject\n\nSigned-off-by: C O Mitter " | append_signoff >actual && - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -9:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 9:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: the same signoff NOT at the end' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Signed-off-by: C O Mitter -Signed-off-by: my@house -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -11:Signed-off-by: C O Mitter -12:Signed-off-by: my@house -EOF - test_cmp expected actual + Signed-off-by: C O Mitter + Signed-off-by: my@house + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 11:Signed-off-by: C O Mitter + 12:Signed-off-by: my@house + EOF + test_cmp expect actual ' test_expect_success 'signoff: tolerate garbage in conforming footer' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Tested-by: my@house -Some Trash -Signed-off-by: C O Mitter -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -13:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + Tested-by: my@house + Some Trash + Signed-off-by: C O Mitter + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 13:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: respect trailer config' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -Myfooter: x -Some Trash -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -11: -12:Signed-off-by: C O Mitter -EOF - test_cmp expected actual && + Myfooter: x + Some Trash + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 11: + 12:Signed-off-by: C O Mitter + EOF + test_cmp expect actual && test_config trailer.Myfooter.ifexists add && - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -Myfooter: x -Some Trash -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -11:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + Myfooter: x + Some Trash + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 11:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'signoff: footer begins with non-signoff without @ sign' ' - append_signoff <<\EOF >actual && -subject + append_signoff <<-\EOF >actual && + subject -body + body -Reviewed-id: Noone -Tested-by: my@house -Change-id: Ideadbeef -Signed-off-by: C O Mitter -Bug: 1234 -EOF - cat >expected <<\EOF && -4:Subject: [PATCH] subject -8: -10: -14:Signed-off-by: C O Mitter -EOF - test_cmp expected actual + Reviewed-id: Noone + Tested-by: my@house + Change-id: Ideadbeef + Signed-off-by: C O Mitter + Bug: 1234 + EOF + cat >expect <<-\EOF && + 4:Subject: [PATCH] subject + 8: + 10: + 14:Signed-off-by: C O Mitter + EOF + test_cmp expect actual ' test_expect_success 'format patch ignores color.ui' ' @@ -1543,46 +1549,218 @@ test_expect_success 'format patch ignores color.ui' ' test_cmp expect actual ' +test_expect_success 'cover letter with invalid --cover-from-description and config' ' + test_config branch.rebuild-1.description "config subject + +body" && + test_must_fail git format-patch --cover-letter --cover-from-description garbage master && + test_config format.coverFromDescription garbage && + test_must_fail git format-patch --cover-letter master +' + +test_expect_success 'cover letter with format.coverFromDescription = default' ' + test_config branch.rebuild-1.description "config subject + +body" && + test_config format.coverFromDescription default && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter master >actual && + grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + grep "^config subject$" actual && + grep "^body$" actual +' + +test_expect_success 'cover letter with --cover-from-description default' ' + test_config branch.rebuild-1.description "config subject + +body" && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter --cover-from-description default master >actual && + grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + grep "^config subject$" actual && + grep "^body$" actual +' + +test_expect_success 'cover letter with format.coverFromDescription = none' ' + test_config branch.rebuild-1.description "config subject + +body" && + test_config format.coverFromDescription none && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter master >actual && + grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + grep "^\*\*\* BLURB HERE \*\*\*$" actual && + ! grep "^config subject$" actual && + ! grep "^body$" actual +' + +test_expect_success 'cover letter with --cover-from-description none' ' + test_config branch.rebuild-1.description "config subject + +body" && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter --cover-from-description none master >actual && + grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + grep "^\*\*\* BLURB HERE \*\*\*$" actual && + ! grep "^config subject$" actual && + ! grep "^body$" actual +' + +test_expect_success 'cover letter with format.coverFromDescription = message' ' + test_config branch.rebuild-1.description "config subject + +body" && + test_config format.coverFromDescription message && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter master >actual && + grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + grep "^config subject$" actual && + grep "^body$" actual +' + +test_expect_success 'cover letter with --cover-from-description message' ' + test_config branch.rebuild-1.description "config subject + +body" && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter --cover-from-description message master >actual && + grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + grep "^config subject$" actual && + grep "^body$" actual +' + +test_expect_success 'cover letter with format.coverFromDescription = subject' ' + test_config branch.rebuild-1.description "config subject + +body" && + test_config format.coverFromDescription subject && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter master >actual && + grep "^Subject: \[PATCH 0/2\] config subject$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + ! grep "^config subject$" actual && + grep "^body$" actual +' + +test_expect_success 'cover letter with --cover-from-description subject' ' + test_config branch.rebuild-1.description "config subject + +body" && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter --cover-from-description subject master >actual && + grep "^Subject: \[PATCH 0/2\] config subject$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + ! grep "^config subject$" actual && + grep "^body$" actual +' + +test_expect_success 'cover letter with format.coverFromDescription = auto (short subject line)' ' + test_config branch.rebuild-1.description "config subject + +body" && + test_config format.coverFromDescription auto && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter master >actual && + grep "^Subject: \[PATCH 0/2\] config subject$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + ! grep "^config subject$" actual && + grep "^body$" actual +' + +test_expect_success 'cover letter with --cover-from-description auto (short subject line)' ' + test_config branch.rebuild-1.description "config subject + +body" && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter --cover-from-description auto master >actual && + grep "^Subject: \[PATCH 0/2\] config subject$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + ! grep "^config subject$" actual && + grep "^body$" actual +' + +test_expect_success 'cover letter with format.coverFromDescription = auto (long subject line)' ' + test_config branch.rebuild-1.description "this is a really long first line and it is over 100 characters long which is the threshold for long subjects + +body" && + test_config format.coverFromDescription auto && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter master >actual && + grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual && + grep "^body$" actual +' + +test_expect_success 'cover letter with --cover-from-description auto (long subject line)' ' + test_config branch.rebuild-1.description "this is a really long first line and it is over 100 characters long which is the threshold for long subjects + +body" && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter --cover-from-description auto master >actual && + grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual && + grep "^body$" actual +' + +test_expect_success 'cover letter with command-line --cover-from-description overrides config' ' + test_config branch.rebuild-1.description "config subject + +body" && + test_config format.coverFromDescription none && + git checkout rebuild-1 && + git format-patch --stdout --cover-letter --cover-from-description subject master >actual && + grep "^Subject: \[PATCH 0/2\] config subject$" actual && + ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && + ! grep "^config subject$" actual && + grep "^body$" actual +' + test_expect_success 'cover letter using branch description (1)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter master >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter using branch description (2)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter using branch description (3)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter ^master rebuild-1 >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter using branch description (4)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter master.. >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter using branch description (5)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter -2 HEAD >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter using branch description (6)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter -2 >actual && - grep hello actual >/dev/null + grep hello actual ' test_expect_success 'cover letter with nothing' ' @@ -1632,11 +1810,39 @@ test_expect_success 'From line has expected format' ' test_cmp from filtered ' +test_expect_success 'format-patch -o with no leading directories' ' + rm -fr patches && + git format-patch -o patches master..side && + count=$(git rev-list --count master..side) && + ls patches >list && + test_line_count = $count list +' + +test_expect_success 'format-patch -o with leading existing directories' ' + rm -rf existing-dir && + mkdir existing-dir && + git format-patch -o existing-dir/patches master..side && + count=$(git rev-list --count master..side) && + ls existing-dir/patches >list && + test_line_count = $count list +' + +test_expect_success 'format-patch -o with leading non-existing directories' ' + rm -rf non-existing-dir && + git format-patch -o non-existing-dir/patches master..side && + count=$(git rev-list --count master..side) && + test_path_is_dir non-existing-dir && + ls non-existing-dir/patches >list && + test_line_count = $count list +' + test_expect_success 'format-patch format.outputDirectory option' ' test_config format.outputDirectory patches && rm -fr patches && git format-patch master..side && - test $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l) + count=$(git rev-list --count master..side) && + ls patches >list && + test_line_count = $count list ' test_expect_success 'format-patch -o overrides format.outputDirectory' ' @@ -1649,20 +1855,41 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' ' test_expect_success 'format-patch --base' ' git checkout patchid && - git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 && - git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 && - echo >expected && - echo "base-commit: $(git rev-parse HEAD~3)" >>expected && - echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected && - echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected && - signature >> expected && - test_cmp expected actual1 && - test_cmp expected actual2 && + + git format-patch --stdout --base=HEAD~3 -1 >patch && + tail -n 7 patch >actual1 && + + git format-patch --stdout --base=HEAD~3 HEAD~.. >patch && + tail -n 7 patch >actual2 && + + echo >expect && + git rev-parse HEAD~3 >commit-id-base && + echo "base-commit: $(cat commit-id-base)" >>expect && + + git show --patch HEAD~2 >patch && + git patch-id --stable patch.id.raw && + awk "{print \"prerequisite-patch-id:\", \$1}" >expect && + + git show --patch HEAD~1 >patch && + git patch-id --stable patch.id.raw && + awk "{print \"prerequisite-patch-id:\", \$1}" >expect && + + signature >>expect && + test_cmp expect actual1 && + test_cmp expect actual2 && + echo >fail && - echo "base-commit: $(git rev-parse HEAD~3)" >>fail && - echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail && - echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>fail && - signature >> fail && + echo "base-commit: $(cat commit-id-base)" >>fail && + + git show --patch HEAD~2 >patch && + git patch-id --unstable patch.id.raw && + awk "{print \"prerequisite-patch-id:\", \$1}" >fail && + + git show --patch HEAD~1 >patch && + git patch-id --unstable patch.id.raw && + awk "{print \"prerequisite-patch-id:\", \$1}" >fail && + + signature >>fail && ! test_cmp fail actual1 && ! test_cmp fail actual2 ' @@ -1672,8 +1899,9 @@ test_expect_success 'format-patch --base errors out when base commit is in revis test_must_fail git format-patch --base=HEAD~1 -2 && git format-patch --stdout --base=HEAD~2 -2 >patch && grep "^base-commit:" patch >actual && - echo "base-commit: $(git rev-parse HEAD~2)" >expected && - test_cmp expected actual + git rev-parse HEAD~2 >commit-id-base && + echo "base-commit: $(cat commit-id-base)" >expect && + test_cmp expect actual ' test_expect_success 'format-patch --base errors out when base commit is not ancestor of revision list' ' @@ -1699,8 +1927,8 @@ test_expect_success 'format-patch --base errors out when base commit is not ance test_must_fail git format-patch --base=$(cat commit-id-Z) -3 && git format-patch --stdout --base=$(cat commit-id-base) -3 >patch && grep "^base-commit:" patch >actual && - echo "base-commit: $(cat commit-id-base)" >expected && - test_cmp expected actual + echo "base-commit: $(cat commit-id-base)" >expect && + test_cmp expect actual ' test_expect_success 'format-patch --base=auto' ' @@ -1711,8 +1939,9 @@ test_expect_success 'format-patch --base=auto' ' test_commit N2 && git format-patch --stdout --base=auto -2 >patch && grep "^base-commit:" patch >actual && - echo "base-commit: $(git rev-parse upstream)" >expected && - test_cmp expected actual + git rev-parse upstream >commit-id-base && + echo "base-commit: $(cat commit-id-base)" >expect && + test_cmp expect actual ' test_expect_success 'format-patch errors out when history involves criss-cross' ' @@ -1742,23 +1971,29 @@ test_expect_success 'format-patch errors out when history involves criss-cross' test_must_fail git format-patch --base=auto -1 ' -test_expect_success 'format-patch format.useAutoBaseoption' ' - test_when_finished "git config --unset format.useAutoBase" && +test_expect_success 'format-patch format.useAutoBase option' ' git checkout local && - git config format.useAutoBase true && + test_config format.useAutoBase true && git format-patch --stdout -1 >patch && grep "^base-commit:" patch >actual && - echo "base-commit: $(git rev-parse upstream)" >expected && - test_cmp expected actual + git rev-parse upstream >commit-id-base && + echo "base-commit: $(cat commit-id-base)" >expect && + test_cmp expect actual ' test_expect_success 'format-patch --base overrides format.useAutoBase' ' - test_when_finished "git config --unset format.useAutoBase" && - git config format.useAutoBase true && + test_config format.useAutoBase true && git format-patch --stdout --base=HEAD~1 -1 >patch && grep "^base-commit:" patch >actual && - echo "base-commit: $(git rev-parse HEAD~1)" >expected && - test_cmp expected actual + git rev-parse HEAD~1 >commit-id-base && + echo "base-commit: $(cat commit-id-base)" >expect && + test_cmp expect actual +' + +test_expect_success 'format-patch --no-base overrides format.useAutoBase' ' + test_config format.useAutoBase true && + git format-patch --stdout --no-base -1 >patch && + ! grep "^base-commit:" patch ' test_expect_success 'format-patch --base with --attach' ' @@ -1833,7 +2068,7 @@ test_expect_success 'interdiff: cover-letter' ' git format-patch --cover-letter --interdiff=boop~2 -1 boop && test_i18ngrep "^Interdiff:$" 0000-cover-letter.patch && test_i18ngrep ! "^Interdiff:$" 0001-fleep.patch && - sed "1,/^@@ /d; /^-- $/q" <0000-cover-letter.patch >actual && + sed "1,/^@@ /d; /^-- $/q" 0000-cover-letter.patch >actual && test_cmp expect actual ' @@ -1849,7 +2084,7 @@ test_expect_success 'interdiff: solo-patch' ' EOF git format-patch --interdiff=boop~2 -1 boop && test_i18ngrep "^Interdiff:$" 0001-fleep.patch && - sed "1,/^ @@ /d; /^$/q" <0001-fleep.patch >actual && + sed "1,/^ @@ /d; /^$/q" 0001-fleep.patch >actual && test_cmp expect actual ' diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 6b087df3dcbd..88d3026894f8 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -16,6 +16,8 @@ test_expect_success "Ray Lehtiniemi's example" ' } while (0); EOF git update-index --add x && + old_hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$old_hash_x") && cat <<-\EOF >x && do @@ -24,10 +26,12 @@ test_expect_success "Ray Lehtiniemi's example" ' } while (0); EOF + new_hash_x=$(git hash-object x) && + after=$(git rev-parse --short "$new_hash_x") && - cat <<-\EOF >expect && + cat <<-EOF >expect && diff --git a/x b/x - index adf3937..6edc172 100644 + index $before..$after 100644 --- a/x +++ b/x @@ -1,3 +1,5 @@ @@ -61,6 +65,8 @@ test_expect_success 'another test, without options' ' EOF git update-index x && + old_hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$old_hash_x") && tr "_" " " <<-\EOF >x && _ whitespace at beginning @@ -70,10 +76,12 @@ test_expect_success 'another test, without options' ' unchanged line CR at end EOF + new_hash_x=$(git hash-object x) && + after=$(git rev-parse --short "$new_hash_x") && - tr "Q_" "\015 " <<-\EOF >expect && + tr "Q_" "\015 " <<-EOF >expect && diff --git a/x b/x - index d99af23..22d9f73 100644 + index $before..$after 100644 --- a/x +++ b/x @@ -1,6 +1,6 @@ @@ -108,9 +116,9 @@ test_expect_success 'another test, without options' ' git diff -w --ignore-cr-at-eol >out && test_must_be_empty out && - tr "Q_" "\015 " <<-\EOF >expect && + tr "Q_" "\015 " <<-EOF >expect && diff --git a/x b/x - index d99af23..22d9f73 100644 + index $before..$after 100644 --- a/x +++ b/x @@ -1,6 +1,6 @@ @@ -132,9 +140,9 @@ test_expect_success 'another test, without options' ' git diff -b --ignore-cr-at-eol >out && test_cmp expect out && - tr "Q_" "\015 " <<-\EOF >expect && + tr "Q_" "\015 " <<-EOF >expect && diff --git a/x b/x - index d99af23..22d9f73 100644 + index $before..$after 100644 --- a/x +++ b/x @@ -1,6 +1,6 @@ @@ -154,9 +162,9 @@ test_expect_success 'another test, without options' ' git diff --ignore-space-at-eol --ignore-cr-at-eol >out && test_cmp expect out && - tr "Q_" "\015 " <<-\EOF >expect && + tr "Q_" "\015 " <<-EOF >expect && diff --git a/x b/x - index_d99af23..22d9f73 100644 + index_$before..$after 100644 --- a/x +++ b/x @@ -1,6 +1,6 @@ @@ -522,13 +530,15 @@ test_expect_success 'ignore-blank-lines: mix changes and blank lines' ' test_expect_success 'check mixed spaces and tabs in indent' ' # This is indented with SP HT SP. echo " foo();" >x && - git diff --check | grep "space before tab in indent" + test_must_fail git diff --check >check && + grep "space before tab in indent" check ' test_expect_success 'check mixed tabs and spaces in indent' ' # This is indented with HT SP HT. echo " foo();" >x && - git diff --check | grep "space before tab in indent" + test_must_fail git diff --check >check && + grep "space before tab in indent" check ' test_expect_success 'check with no whitespace errors' ' @@ -749,20 +759,23 @@ test_expect_success 'check tab-in-indent excluded from wildcard whitespace attri test_expect_success 'line numbers in --check output are correct' ' echo "" >x && echo "foo(); " >>x && - git diff --check | grep "x:2:" + test_must_fail git diff --check >check && + grep "x:2:" check ' test_expect_success 'checkdiff detects new trailing blank lines (1)' ' echo "foo();" >x && echo "" >>x && - git diff --check | grep "new blank line" + test_must_fail git diff --check >check && + grep "new blank line" check ' test_expect_success 'checkdiff detects new trailing blank lines (2)' ' - { echo a; echo b; echo; echo; } >x && + test_write_lines a b "" "" >x && git add x && - { echo a; echo; echo; echo; echo; } >x && - git diff --check | grep "new blank line" + test_write_lines a "" "" "" "" >x && + test_must_fail git diff --check >check && + grep "new blank line" check ' test_expect_success 'checkdiff allows new blank lines' ' @@ -786,23 +799,27 @@ test_expect_success 'whitespace-only changes not reported' ' test_must_be_empty actual ' -cat <expect -diff --git a/x b/z -similarity index NUM% -rename from x -rename to z -index 380c32a..a97b785 100644 -EOF test_expect_success 'whitespace-only changes reported across renames' ' git reset --hard && for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i"; done >x && git add x && + hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$hash_x") && git commit -m "base" && sed -e "5s/^/ /" x >z && git rm x && git add z && - git diff -w -M --cached | - sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" >actual && + hash_z=$(git hash-object z) && + after=$(git rev-parse --short "$hash_z") && + git diff -w -M --cached >actual.raw && + sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" actual.raw >actual && + cat <<-EOF >expect && + diff --git a/x b/z + similarity index NUM% + rename from x + rename to z + index $before..$after 100644 + EOF test_cmp expect actual ' @@ -834,7 +851,8 @@ test_expect_success 'combined diff with autocrlf conversion' ' git config core.autocrlf true && test_must_fail git merge master && - git diff | sed -e "1,/^@@@/d" >actual && + git diff >actual.raw && + sed -e "1,/^@@@/d" actual.raw >actual && ! grep "^-" actual ' @@ -858,13 +876,18 @@ test_expect_success 'diff that introduces a line with only tabs' ' git config core.whitespace blank-at-eol && git reset --hard && echo "test" >x && + old_hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$old_hash_x") && git commit -m "initial" x && echo "{NTN}" | tr "NT" "\n\t" >>x && - git diff --color | test_decode_color >current && + new_hash_x=$(git hash-object x) && + after=$(git rev-parse --short "$new_hash_x") && + git diff --color >current.raw && + test_decode_color current && - cat >expected <<-\EOF && + cat >expected <<-EOF && diff --git a/x b/x - index 9daeafb..2874b91 100644 + index $before..$after 100644 --- a/x +++ b/x @@ -1 +1,4 @@ @@ -883,19 +906,23 @@ test_expect_success 'diff that introduces and removes ws breakages' ' echo "0. blank-at-eol " && echo "1. blank-at-eol " } >x && + old_hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$old_hash_x") && git commit -a --allow-empty -m preimage && { echo "0. blank-at-eol " && echo "1. still-blank-at-eol " && echo "2. and a new line " } >x && + new_hash_x=$(git hash-object x) && + after=$(git rev-parse --short "$new_hash_x") && - git diff --color | - test_decode_color >current && + git diff --color >current.raw && + test_decode_color current && - cat >expected <<-\EOF && + cat >expected <<-EOF && diff --git a/x b/x - index d0233a2..700886e 100644 + index $before..$after 100644 --- a/x +++ b/x @@ -1,2 +1,3 @@ @@ -915,16 +942,20 @@ test_expect_success 'ws-error-highlight test setup' ' echo "0. blank-at-eol " && echo "1. blank-at-eol " } >x && + old_hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$old_hash_x") && git commit -a --allow-empty -m preimage && { echo "0. blank-at-eol " && echo "1. still-blank-at-eol " && echo "2. and a new line " } >x && + new_hash_x=$(git hash-object x) && + after=$(git rev-parse --short "$new_hash_x") && - cat >expect.default-old <<-\EOF && + cat >expect.default-old <<-EOF && diff --git a/x b/x - index d0233a2..700886e 100644 + index $before..$after 100644 --- a/x +++ b/x @@ -1,2 +1,3 @@ @@ -934,9 +965,9 @@ test_expect_success 'ws-error-highlight test setup' ' +2. and a new line EOF - cat >expect.all <<-\EOF && + cat >expect.all <<-EOF && diff --git a/x b/x - index d0233a2..700886e 100644 + index $before..$after 100644 --- a/x +++ b/x @@ -1,2 +1,3 @@ @@ -946,9 +977,9 @@ test_expect_success 'ws-error-highlight test setup' ' +2. and a new line EOF - cat >expect.none <<-\EOF + cat >expect.none <<-EOF diff --git a/x b/x - index d0233a2..700886e 100644 + index $before..$after 100644 --- a/x +++ b/x @@ -1,2 +1,3 @@ @@ -962,32 +993,32 @@ test_expect_success 'ws-error-highlight test setup' ' test_expect_success 'test --ws-error-highlight option' ' - git diff --color --ws-error-highlight=default,old | - test_decode_color >current && + git diff --color --ws-error-highlight=default,old >current.raw && + test_decode_color current && test_cmp expect.default-old current && - git diff --color --ws-error-highlight=all | - test_decode_color >current && + git diff --color --ws-error-highlight=all >current.raw && + test_decode_color current && test_cmp expect.all current && - git diff --color --ws-error-highlight=none | - test_decode_color >current && + git diff --color --ws-error-highlight=none >current.raw && + test_decode_color current && test_cmp expect.none current ' test_expect_success 'test diff.wsErrorHighlight config' ' - git -c diff.wsErrorHighlight=default,old diff --color | - test_decode_color >current && + git -c diff.wsErrorHighlight=default,old diff --color >current.raw && + test_decode_color current && test_cmp expect.default-old current && - git -c diff.wsErrorHighlight=all diff --color | - test_decode_color >current && + git -c diff.wsErrorHighlight=all diff --color >current.raw && + test_decode_color current && test_cmp expect.all current && - git -c diff.wsErrorHighlight=none diff --color | - test_decode_color >current && + git -c diff.wsErrorHighlight=none diff --color >current.raw && + test_decode_color current && test_cmp expect.none current ' @@ -995,18 +1026,18 @@ test_expect_success 'test diff.wsErrorHighlight config' ' test_expect_success 'option overrides diff.wsErrorHighlight' ' git -c diff.wsErrorHighlight=none \ - diff --color --ws-error-highlight=default,old | - test_decode_color >current && + diff --color --ws-error-highlight=default,old >current.raw && + test_decode_color current && test_cmp expect.default-old current && git -c diff.wsErrorHighlight=default \ - diff --color --ws-error-highlight=all | - test_decode_color >current && + diff --color --ws-error-highlight=all >current.raw && + test_decode_color current && test_cmp expect.all current && git -c diff.wsErrorHighlight=all \ - diff --color --ws-error-highlight=none | - test_decode_color >current && + diff --color --ws-error-highlight=none >current.raw && + test_decode_color current && test_cmp expect.none current ' @@ -1022,14 +1053,16 @@ test_expect_success 'detect moved code, complete file' ' EOF git add test.c && git commit -m "add main function" && + file=$(git rev-parse --short HEAD:test.c) && git mv test.c main.c && test_config color.diff.oldMoved "normal red" && test_config color.diff.newMoved "normal green" && - git diff HEAD --color-moved=zebra --color --no-renames | test_decode_color >actual && - cat >expected <<-\EOF && + git diff HEAD --color-moved=zebra --color --no-renames >actual.raw && + test_decode_color actual && + cat >expected <<-EOF && diff --git a/main.c b/main.c new file mode 100644 - index 0000000..a986c57 + index 0000000..$file --- /dev/null +++ b/main.c @@ -0,0 +1,5 @@ @@ -1040,7 +1073,7 @@ test_expect_success 'detect moved code, complete file' ' +} diff --git a/test.c b/test.c deleted file mode 100644 - index a986c57..0000000 + index $file..0000000 --- a/test.c +++ /dev/null @@ -1,5 +0,0 @@ @@ -1094,6 +1127,8 @@ test_expect_success 'detect malicious moved code, inside file' ' EOF git add main.c test.c && git commit -m "add main and test file" && + before_main=$(git rev-parse --short HEAD:main.c) && + before_test=$(git rev-parse --short HEAD:test.c) && cat <<-\EOF >main.c && #include int stuff() @@ -1126,10 +1161,15 @@ test_expect_success 'detect malicious moved code, inside file' ' bar(); } EOF - git diff HEAD --no-renames --color-moved=zebra --color | test_decode_color >actual && - cat <<-\EOF >expected && + hash_main=$(git hash-object main.c) && + after_main=$(git rev-parse --short "$hash_main") && + hash_test=$(git hash-object test.c) && + after_test=$(git rev-parse --short "$hash_test") && + git diff HEAD --no-renames --color-moved=zebra --color >actual.raw && + test_decode_color actual && + cat <<-EOF >expected && diff --git a/main.c b/main.c - index 27a619c..7cf9336 100644 + index $before_main..$after_main 100644 --- a/main.c +++ b/main.c @@ -5,13 +5,6 @@ printf("Hello "); @@ -1147,7 +1187,7 @@ test_expect_success 'detect malicious moved code, inside file' ' { foo(); diff --git a/test.c b/test.c - index 1dc1d85..2bedec9 100644 + index $before_test..$after_test 100644 --- a/test.c +++ b/test.c @@ -4,6 +4,13 @@ int bar() @@ -1175,10 +1215,11 @@ test_expect_success 'plain moved code, inside file' ' test_config color.diff.oldMovedAlternative "blue" && test_config color.diff.newMovedAlternative "yellow" && # needs previous test as setup - git diff HEAD --no-renames --color-moved=plain --color | test_decode_color >actual && - cat <<-\EOF >expected && + git diff HEAD --no-renames --color-moved=plain --color >actual.raw && + test_decode_color actual && + cat <<-EOF >expected && diff --git a/main.c b/main.c - index 27a619c..7cf9336 100644 + index $before_main..$after_main 100644 --- a/main.c +++ b/main.c @@ -5,13 +5,6 @@ printf("Hello "); @@ -1196,7 +1237,7 @@ test_expect_success 'plain moved code, inside file' ' { foo(); diff --git a/test.c b/test.c - index 1dc1d85..2bedec9 100644 + index $before_test..$after_test 100644 --- a/test.c +++ b/test.c @@ -4,6 +4,13 @@ int bar() @@ -1754,7 +1795,8 @@ test_expect_success 'move detection with submodules' ' ! grep BRED decoded_actual && # nor did we mess with it another way - git diff --submodule=diff --color | test_decode_color >expect && + git diff --submodule=diff --color >expect.raw && + test_decode_color expect && test_cmp expect decoded_actual && rm -rf bananas && git submodule deinit bananas @@ -2008,11 +2050,6 @@ test_expect_success 'compare mixed whitespace delta across moved blocks' ' test_cmp expected actual ' -# Note that the "6" in the expected hunk header below is funny, since we only -# show 5 lines (the missing one was blank and thus ignored). This is how -# --ignore-blank-lines behaves even without --function-context, and this test -# is just checking the interaction of the two features. Don't take it as an -# endorsement of that output. test_expect_success 'combine --ignore-blank-lines with --function-context' ' test_write_lines 1 "" 2 3 4 5 >a && test_write_lines 1 2 3 4 >b && @@ -2022,6 +2059,7 @@ test_expect_success 'combine --ignore-blank-lines with --function-context' ' cat <<-\EOF >expect && @@ -1,6 +1,4 @@ 1 + - 2 3 4 @@ -2030,4 +2068,27 @@ test_expect_success 'combine --ignore-blank-lines with --function-context' ' test_cmp expect actual ' +test_expect_success 'combine --ignore-blank-lines with --function-context 2' ' + test_write_lines a b c "" function 1 2 3 4 5 "" 6 7 8 9 >a && + test_write_lines "" a b c "" function 1 2 3 4 5 6 7 8 >b && + test_must_fail git diff --no-index \ + --ignore-blank-lines --function-context a b >actual.raw && + sed -n "/@@/,\$p" actual && + cat <<-\EOF >expect && + @@ -5,11 +6,9 @@ c + function + 1 + 2 + 3 + 4 + 5 + - + 6 + 7 + 8 + -9 + EOF + test_cmp expect actual +' + test_done diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 9261d6d3a000..02255a08bf17 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -31,6 +31,8 @@ diffpatterns=" cpp csharp css + dts + elixir fortran fountain golang @@ -104,7 +106,6 @@ do result=success fi test_expect_$result "hunk header: $i" " - test_when_finished 'cat actual' && # for debugging only git diff -U1 $i >actual && grep '@@ .* @@.*RIGHT' actual " diff --git a/t/t4018/dts-labels b/t/t4018/dts-labels new file mode 100644 index 000000000000..b21ef8737bb8 --- /dev/null +++ b/t/t4018/dts-labels @@ -0,0 +1,9 @@ +/ { + label_1: node1@ff00 { + label2: RIGHT { + vendor,some-property; + + ChangeMe = <0x45-30>; + }; + }; +}; diff --git a/t/t4018/dts-node-unitless b/t/t4018/dts-node-unitless new file mode 100644 index 000000000000..c5287d91416e --- /dev/null +++ b/t/t4018/dts-node-unitless @@ -0,0 +1,8 @@ +/ { + label_1: node1 { + RIGHT { + prop-array = <1>, <4>; + ChangeMe = <0xffeedd00>; + }; + }; +}; diff --git a/t/t4018/dts-nodes b/t/t4018/dts-nodes new file mode 100644 index 000000000000..5a4334bb1645 --- /dev/null +++ b/t/t4018/dts-nodes @@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + RIGHT@deadf00,4000 { + #size-cells = <1>; + ChangeMe = <0xffeedd00>; + }; + }; +}; diff --git a/t/t4018/dts-nodes-boolean-prop b/t/t4018/dts-nodes-boolean-prop new file mode 100644 index 000000000000..afc6b5b404e4 --- /dev/null +++ b/t/t4018/dts-nodes-boolean-prop @@ -0,0 +1,9 @@ +/ { + label_1: node1@ff00 { + RIGHT@deadf00,4000 { + boolean-prop1; + + ChangeMe; + }; + }; +}; diff --git a/t/t4018/dts-nodes-comment1 b/t/t4018/dts-nodes-comment1 new file mode 100644 index 000000000000..559dfce9b308 --- /dev/null +++ b/t/t4018/dts-nodes-comment1 @@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + RIGHT@deadf00,4000 /* &a comment */ { + #size-cells = <1>; + ChangeMe = <0xffeedd00>; + }; + }; +}; diff --git a/t/t4018/dts-nodes-comment2 b/t/t4018/dts-nodes-comment2 new file mode 100644 index 000000000000..27e9718b31cf --- /dev/null +++ b/t/t4018/dts-nodes-comment2 @@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + RIGHT@deadf00,4000 { /* a trailing comment */ + #size-cells = <1>; + ChangeMe = <0xffeedd00>; + }; + }; +}; diff --git a/t/t4018/dts-nodes-multiline-prop b/t/t4018/dts-nodes-multiline-prop new file mode 100644 index 000000000000..072d58b69dc2 --- /dev/null +++ b/t/t4018/dts-nodes-multiline-prop @@ -0,0 +1,13 @@ +/ { + label_1: node1@ff00 { + RIGHT@deadf00,4000 { + multilineprop = <3>, + <4>, + <5>, + <6>, + <7>; + + ChangeMe = <0xffeedd00>; + }; + }; +}; diff --git a/t/t4018/dts-reference b/t/t4018/dts-reference new file mode 100644 index 000000000000..8f0c87d8637f --- /dev/null +++ b/t/t4018/dts-reference @@ -0,0 +1,9 @@ +&label_1 { + TEST = <455>; +}; + +&RIGHT { + vendor,some-property; + + ChangeMe = <0x45-30>; +}; diff --git a/t/t4018/dts-root b/t/t4018/dts-root new file mode 100644 index 000000000000..4353b8220c91 --- /dev/null +++ b/t/t4018/dts-root @@ -0,0 +1,5 @@ +/ { RIGHT /* Technically just supposed to be a slash and brace */ + #size-cells = <1>; + + ChangeMe = <0xffeedd00>; +}; diff --git a/t/t4018/dts-root-comment b/t/t4018/dts-root-comment new file mode 100644 index 000000000000..333a625c7007 --- /dev/null +++ b/t/t4018/dts-root-comment @@ -0,0 +1,8 @@ +/ { RIGHT /* Technically just supposed to be a slash and brace */ + #size-cells = <1>; + + /* This comment should be ignored */ + + some-property = <40+2>; + ChangeMe = <0xffeedd00>; +}; diff --git a/t/t4018/elixir-do-not-pick-end b/t/t4018/elixir-do-not-pick-end new file mode 100644 index 000000000000..fae08ba7e8cb --- /dev/null +++ b/t/t4018/elixir-do-not-pick-end @@ -0,0 +1,5 @@ +defmodule RIGHT do +end +# +# +# ChangeMe; do not pick up 'end' line diff --git a/t/t4018/elixir-ex-unit-test b/t/t4018/elixir-ex-unit-test new file mode 100644 index 000000000000..0560a2b69718 --- /dev/null +++ b/t/t4018/elixir-ex-unit-test @@ -0,0 +1,6 @@ +defmodule Test do + test "RIGHT" do + assert true == true + assert ChangeMe + end +end diff --git a/t/t4018/elixir-function b/t/t4018/elixir-function new file mode 100644 index 000000000000..d452f495a7e0 --- /dev/null +++ b/t/t4018/elixir-function @@ -0,0 +1,5 @@ +def function(RIGHT, arg) do + # comment + # comment + ChangeMe +end diff --git a/t/t4018/elixir-macro b/t/t4018/elixir-macro new file mode 100644 index 000000000000..4f925e9ad463 --- /dev/null +++ b/t/t4018/elixir-macro @@ -0,0 +1,5 @@ +defmacro foo(RIGHT) do + # Code + # Code + ChangeMe +end diff --git a/t/t4018/elixir-module b/t/t4018/elixir-module new file mode 100644 index 000000000000..91a4e7aa2000 --- /dev/null +++ b/t/t4018/elixir-module @@ -0,0 +1,9 @@ +defmodule RIGHT do + @moduledoc """ + Foo bar + """ + + def ChangeMe(a) where is_map(a) do + a + end +end diff --git a/t/t4018/elixir-module-func b/t/t4018/elixir-module-func new file mode 100644 index 000000000000..c9910d067513 --- /dev/null +++ b/t/t4018/elixir-module-func @@ -0,0 +1,8 @@ +defmodule Foo do + def fun(RIGHT) do + # Code + # Code + # Code + ChangeMe + end +end diff --git a/t/t4018/elixir-nested-module b/t/t4018/elixir-nested-module new file mode 100644 index 000000000000..771ebc5c42a9 --- /dev/null +++ b/t/t4018/elixir-nested-module @@ -0,0 +1,9 @@ +defmodule MyApp.RIGHT do + @moduledoc """ + Foo bar + """ + + def ChangeMe(a) where is_map(a) do + a + end +end diff --git a/t/t4018/elixir-private-function b/t/t4018/elixir-private-function new file mode 100644 index 000000000000..1aabe33b7a9a --- /dev/null +++ b/t/t4018/elixir-private-function @@ -0,0 +1,5 @@ +defp function(RIGHT, arg) do + # comment + # comment + ChangeMe +end diff --git a/t/t4018/elixir-protocol b/t/t4018/elixir-protocol new file mode 100644 index 000000000000..7d9173691e32 --- /dev/null +++ b/t/t4018/elixir-protocol @@ -0,0 +1,6 @@ +defprotocol RIGHT do + @doc """ + Calculates the size (and not the length!) of a data structure + """ + def size(data, ChangeMe) +end diff --git a/t/t4018/elixir-protocol-implementation b/t/t4018/elixir-protocol-implementation new file mode 100644 index 000000000000..f9234bbfc489 --- /dev/null +++ b/t/t4018/elixir-protocol-implementation @@ -0,0 +1,5 @@ +defimpl RIGHT do + # Docs + # Docs + def foo(ChangeMe), do: :ok +end diff --git a/t/t4018/python-async-def b/t/t4018/python-async-def new file mode 100644 index 000000000000..87640e03d213 --- /dev/null +++ b/t/t4018/python-async-def @@ -0,0 +1,4 @@ +async def RIGHT(pi: int = 3.14): + while True: + break + return ChangeMe() diff --git a/t/t4018/python-class b/t/t4018/python-class new file mode 100644 index 000000000000..ba9e741430f2 --- /dev/null +++ b/t/t4018/python-class @@ -0,0 +1,4 @@ +class RIGHT(int, str): + # comment + # another comment + # ChangeMe diff --git a/t/t4018/python-def b/t/t4018/python-def new file mode 100644 index 000000000000..e50b31b0ad5e --- /dev/null +++ b/t/t4018/python-def @@ -0,0 +1,4 @@ +def RIGHT(pi: int = 3.14): + while True: + break + return ChangeMe() diff --git a/t/t4018/python-indented-async-def b/t/t4018/python-indented-async-def new file mode 100644 index 000000000000..f5d03258af4d --- /dev/null +++ b/t/t4018/python-indented-async-def @@ -0,0 +1,7 @@ +class Foo: + async def RIGHT(self, x: int): + return [ + 1, + 2, + ChangeMe, + ] diff --git a/t/t4018/python-indented-class b/t/t4018/python-indented-class new file mode 100644 index 000000000000..19b4f35c4ca1 --- /dev/null +++ b/t/t4018/python-indented-class @@ -0,0 +1,5 @@ +if TYPE_CHECKING: + class RIGHT: + # comment + # another comment + # ChangeMe diff --git a/t/t4018/python-indented-def b/t/t4018/python-indented-def new file mode 100644 index 000000000000..208fbadd2be6 --- /dev/null +++ b/t/t4018/python-indented-def @@ -0,0 +1,7 @@ +class Foo: + def RIGHT(self, x: int): + return [ + 1, + 2, + ChangeMe, + ] diff --git a/t/t4026-color.sh b/t/t4026-color.sh index 671e951ee549..c0b642c1ab03 100755 --- a/t/t4026-color.sh +++ b/t/t4026-color.sh @@ -30,6 +30,14 @@ test_expect_success 'attribute before color name' ' color "bold red" "[1;31m" ' +test_expect_success 'aixterm bright fg color' ' + color "brightred" "[91m" +' + +test_expect_success 'aixterm bright bg color' ' + color "green brightblue" "[32;104m" +' + test_expect_success 'color name before attribute' ' color "red bold" "[1;31m" ' @@ -74,6 +82,10 @@ test_expect_success '0-7 are aliases for basic ANSI color names' ' color "0 7" "[30;47m" ' +test_expect_success '8-15 are aliases for aixterm color names' ' + color "12 13" "[94;105m" +' + test_expect_success '256 colors' ' color "254 bold 255" "[1;38;5;254;48;5;255m" ' diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh index 9aa8e2b39b45..e29deaf4a509 100755 --- a/t/t4027-diff-submodule.sh +++ b/t/t4027-diff-submodule.sh @@ -6,6 +6,7 @@ test_description='difference in submodules' . "$TEST_DIRECTORY"/diff-lib.sh test_expect_success setup ' + test_oid_init && test_tick && test_create_repo sub && ( @@ -36,7 +37,8 @@ test_expect_success setup ' ' test_expect_success 'git diff --raw HEAD' ' - git diff --raw --abbrev=40 HEAD >actual && + hexsz=$(test_oid hexsz) && + git diff --raw --abbrev=$hexsz HEAD >actual && test_cmp expect actual ' @@ -245,23 +247,21 @@ test_expect_success 'git diff (empty submodule dir)' ' ' test_expect_success 'conflicted submodule setup' ' - - # 39 efs - c=fffffffffffffffffffffffffffffffffffffff && + c=$(test_oid ff_1) && ( echo "000000 $ZERO_OID 0 sub" && echo "160000 1$c 1 sub" && echo "160000 2$c 2 sub" && echo "160000 3$c 3 sub" ) | git update-index --index-info && - echo >expect.nosub '\''diff --cc sub + echo >expect.nosub "diff --cc sub index 2ffffff,3ffffff..0000000 --- a/sub +++ b/sub @@@ -1,1 -1,1 +1,1 @@@ -- Subproject commit 2fffffffffffffffffffffffffffffffffffffff - -Subproject commit 3fffffffffffffffffffffffffffffffffffffff -++Subproject commit 0000000000000000000000000000000000000000'\'' && +- Subproject commit 2$c + -Subproject commit 3$c +++Subproject commit $ZERO_OID" && hh=$(git rev-parse HEAD) && sed -e "s/$ZERO_OID/$hh/" expect.nosub >expect.withsub diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh index 912df91226f2..fb145aa173ee 100755 --- a/t/t4034-diff-words.sh +++ b/t/t4034-diff-words.sh @@ -19,9 +19,11 @@ cat >post.simple <<-\EOF aeff = aeff * ( aaa ) EOF -cat >expect.letter-runs-are-words <<-\EOF +pre=$(git rev-parse --short $(git hash-object pre.simple)) +post=$(git rev-parse --short $(git hash-object post.simple)) +cat >expect.letter-runs-are-words <<-EOF diff --git a/pre b/post - index 330b04f..5ed8eff 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1,3 +1,7 @@ @@ -33,9 +35,9 @@ cat >expect.letter-runs-are-words <<-\EOF aeff = aeff * ( aaa ) EOF -cat >expect.non-whitespace-is-word <<-\EOF +cat >expect.non-whitespace-is-word <<-EOF diff --git a/pre b/post - index 330b04f..5ed8eff 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1,3 +1,7 @@ @@ -49,9 +51,12 @@ cat >expect.non-whitespace-is-word <<-\EOF EOF word_diff () { + pre=$(git rev-parse --short $(git hash-object pre)) && + post=$(git rev-parse --short $(git hash-object post)) && test_must_fail git diff --no-index "$@" pre post >output && test_decode_color output.decrypted && - test_cmp expect output.decrypted + sed -e "2s/index [^ ]*/index $pre..$post/" expect >expected + test_cmp expected output.decrypted } test_language_driver () { @@ -77,9 +82,9 @@ test_expect_success 'set up pre and post with runs of whitespace' ' ' test_expect_success 'word diff with runs of whitespace' ' - cat >expect <<-\EOF && + cat >expect <<-EOF && diff --git a/pre b/post - index 330b04f..5ed8eff 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1,3 +1,7 @@ @@ -97,9 +102,9 @@ test_expect_success 'word diff with runs of whitespace' ' ' test_expect_success '--word-diff=porcelain' ' - sed 's/#.*$//' >expect <<-\EOF && + sed 's/#.*$//' >expect <<-EOF && diff --git a/pre b/post - index 330b04f..5ed8eff 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1,3 +1,7 @@ @@ -121,9 +126,9 @@ test_expect_success '--word-diff=porcelain' ' ' test_expect_success '--word-diff=plain' ' - cat >expect <<-\EOF && + cat >expect <<-EOF && diff --git a/pre b/post - index 330b04f..5ed8eff 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1,3 +1,7 @@ @@ -140,9 +145,9 @@ test_expect_success '--word-diff=plain' ' ' test_expect_success '--word-diff=plain --color' ' - cat >expect <<-\EOF && + cat >expect <<-EOF && diff --git a/pre b/post - index 330b04f..5ed8eff 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1,3 +1,7 @@ @@ -158,9 +163,9 @@ test_expect_success '--word-diff=plain --color' ' ' test_expect_success 'word diff without context' ' - cat >expect <<-\EOF && + cat >expect <<-EOF && diff --git a/pre b/post - index 330b04f..5ed8eff 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1 +1 @@ @@ -207,9 +212,9 @@ test_expect_success 'command-line overrides config' ' ' test_expect_success 'command-line overrides config: --word-diff-regex' ' - cat >expect <<-\EOF && + cat >expect <<-EOF && diff --git a/pre b/post - index 330b04f..5ed8eff 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1,3 +1,7 @@ @@ -234,9 +239,9 @@ test_expect_success 'setup: remove diff driver regex' ' ' test_expect_success 'use configured regex' ' - cat >expect <<-\EOF && + cat >expect <<-EOF && diff --git a/pre b/post - index 330b04f..5ed8eff 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1,3 +1,7 @@ @@ -254,9 +259,11 @@ test_expect_success 'use configured regex' ' test_expect_success 'test parsing words for newline' ' echo "aaa (aaa)" >pre && echo "aaa (aaa) aaa" >post && - cat >expect <<-\EOF && + pre=$(git rev-parse --short $(git hash-object pre)) && + post=$(git rev-parse --short $(git hash-object post)) && + cat >expect <<-EOF && diff --git a/pre b/post - index c29453b..be22f37 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1 +1 @@ @@ -268,9 +275,11 @@ test_expect_success 'test parsing words for newline' ' test_expect_success 'test when words are only removed at the end' ' echo "(:" >pre && echo "(" >post && - cat >expect <<-\EOF && + pre=$(git rev-parse --short $(git hash-object pre)) && + post=$(git rev-parse --short $(git hash-object post)) && + cat >expect <<-EOF && diff --git a/pre b/post - index 289cb9d..2d06f37 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1 +1 @@ @@ -282,9 +291,11 @@ test_expect_success 'test when words are only removed at the end' ' test_expect_success '--word-diff=none' ' echo "(:" >pre && echo "(" >post && - cat >expect <<-\EOF && + pre=$(git rev-parse --short $(git hash-object pre)) && + post=$(git rev-parse --short $(git hash-object post)) && + cat >expect <<-EOF && diff --git a/pre b/post - index 289cb9d..2d06f37 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1 +1 @@ @@ -303,6 +314,7 @@ test_language_driver bibtex test_language_driver cpp test_language_driver csharp test_language_driver css +test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java @@ -316,16 +328,6 @@ test_language_driver ruby test_language_driver tex test_expect_success 'word-diff with diff.sbe' ' - cat >expect <<-\EOF && - diff --git a/pre b/post - index a1a53b5..bc8fe6d 100644 - --- a/pre - +++ b/post - @@ -1,3 +1,3 @@ - a - - [-b-]{+c+} - EOF cat >pre <<-\EOF && a @@ -336,21 +338,35 @@ test_expect_success 'word-diff with diff.sbe' ' c EOF + pre=$(git rev-parse --short $(git hash-object pre)) && + post=$(git rev-parse --short $(git hash-object post)) && + cat >expect <<-EOF && + diff --git a/pre b/post + index $pre..$post 100644 + --- a/pre + +++ b/post + @@ -1,3 +1,3 @@ + a + + [-b-]{+c+} + EOF test_config diff.suppress-blank-empty true && word_diff --word-diff=plain ' test_expect_success 'word-diff with no newline at EOF' ' - cat >expect <<-\EOF && + printf "%s" "a a a a a" >pre && + printf "%s" "a a ab a a" >post && + pre=$(git rev-parse --short $(git hash-object pre)) && + post=$(git rev-parse --short $(git hash-object post)) && + cat >expect <<-EOF && diff --git a/pre b/post - index 7bf316e..3dd0303 100644 + index $pre..$post 100644 --- a/pre +++ b/post @@ -1 +1 @@ a a [-a-]{+ab+} a a EOF - printf "%s" "a a a a a" >pre && - printf "%s" "a a ab a a" >post && word_diff --word-diff=plain ' diff --git a/t/t4034/dts/expect b/t/t4034/dts/expect new file mode 100644 index 000000000000..560fc9918476 --- /dev/null +++ b/t/t4034/dts/expect @@ -0,0 +1,37 @@ +diff --git a/pre b/post +index b6a9051..7803aee 100644 +--- a/pre ++++ b/post +@@ -1,32 +1,32 @@ +/ { + this_handleHANDLE_2: nodenew-node@f00eeda { + compatible = "mydevvendor,compat"; + string-prop = startend: "hello world!world?" endstart: ; + #size-cells#address-cells = <0+00+40>; + reg = <0xf000xeeda>; + prop = <(1)>; + prop = <(-1e10)>; + prop = <(!31)>; + prop = <(~31)>; + prop = <(31*42)>; + prop = <(31&42)>; + prop = <(31*42)>; + prop = <(31/42)>; + prop = <(31%42)>; + prop = <(3+41+2)>; + prop = <(3-41-2)>; + prop = /bits/ 6432 <(31<<42)>; + prop = <(31>>42)>; + prop = <(31&42)>; + prop = <(31^42)>; + prop = <(31|42)>; + prop = <(31&&42)>; + prop = <(31||42)>; + prop = <(4?51?2:3)>; + list = <&this_handleHANDLE_2>, <0 0 0 01>; + }; + + &phandlephandle2 { + pre-phandleprop_handle = <&this_handleHANDLE_2>; + }; +}; diff --git a/t/t4034/dts/post b/t/t4034/dts/post new file mode 100644 index 000000000000..7803aee28093 --- /dev/null +++ b/t/t4034/dts/post @@ -0,0 +1,32 @@ +/ { + HANDLE_2: new-node@eeda { + compatible = "vendor,compat"; + string-prop = end: "hello world?" start: ; + #address-cells = <0+40>; + reg = <0xeeda>; + prop = <(1)>; + prop = <(-1e10)>; + prop = <(!1)>; + prop = <(~1)>; + prop = <(1*2)>; + prop = <(1&2)>; + prop = <(1*2)>; + prop = <(1/2)>; + prop = <(1%2)>; + prop = <(1+2)>; + prop = <(1-2)>; + prop = /bits/ 32 <(1<<2)>; + prop = <(1>>2)>; + prop = <(1&2)>; + prop = <(1^2)>; + prop = <(1|2)>; + prop = <(1&&2)>; + prop = <(1||2)>; + prop = <(1?2:3)>; + list = <&HANDLE_2>, <0 0 0 1>; + }; + + &phandle2 { + prop_handle = <&HANDLE_2>; + }; +}; diff --git a/t/t4034/dts/pre b/t/t4034/dts/pre new file mode 100644 index 000000000000..b6a905113c22 --- /dev/null +++ b/t/t4034/dts/pre @@ -0,0 +1,32 @@ +/ { + this_handle: node@f00 { + compatible = "mydev"; + string-prop = start: "hello world!" end: ; + #size-cells = <0+0>; + reg = <0xf00>; + prop = <1>; + prop = <-1e10>; + prop = <(!3)>; + prop = <(~3)>; + prop = <(3*4)>; + prop = <(3&4)>; + prop = <(3*4)>; + prop = <(3/4)>; + prop = <(3%4)>; + prop = <(3+4)>; + prop = <(3-4)>; + prop = /bits/ 64 <(3<<4)>; + prop = <(3>>4)>; + prop = <(3&4)>; + prop = <(3^4)>; + prop = <(3|4)>; + prop = <(3&&4)>; + prop = <(3||4)>; + prop = <(4?5:3)>; + list = <&this_handle>, <0 0 0 0>; + }; + + &phandle { + pre-phandle = <&this_handle>; + }; +}; diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh index d4afe125548b..94680836ceb5 100755 --- a/t/t4038-diff-combined.sh +++ b/t/t4038-diff-combined.sh @@ -354,7 +354,7 @@ test_expect_failure 'combine diff coalesce three parents' ' ' # Test for a bug reported at -# https://public-inbox.org/git/20130515143508.GO25742@login.drsnuggles.stderr.nl/ +# https://lore.kernel.org/git/20130515143508.GO25742@login.drsnuggles.stderr.nl/ # where a delete lines were missing from combined diff output when they # occurred exactly before the context lines of a later change. test_expect_success 'combine diff missing delete bug' ' @@ -440,11 +440,13 @@ test_expect_success 'setup for --combined-all-paths' ' git branch side2c && git checkout side1c && test_seq 1 10 >filename-side1c && + side1cf=$(git hash-object filename-side1c) && git add filename-side1c && git commit -m with && git checkout side2c && test_seq 1 9 >filename-side2c && echo ten >>filename-side2c && + side2cf=$(git hash-object filename-side2c) && git add filename-side2c && git commit -m iam && git checkout -b mergery side1c && @@ -452,13 +454,14 @@ test_expect_success 'setup for --combined-all-paths' ' git rm filename-side1c && echo eleven >>filename-side2c && git mv filename-side2c filename-merged && + mergedf=$(git hash-object filename-merged) && git add filename-merged && git commit ' test_expect_success '--combined-all-paths and --raw' ' - cat <<-\EOF >expect && - ::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR filename-side1c filename-side2c filename-merged + cat <<-EOF >expect && + ::100644 100644 100644 $side1cf $side2cf $mergedf RR filename-side1c filename-side2c filename-merged EOF git diff-tree -c -M --raw --combined-all-paths HEAD >actual.tmp && sed 1d actual && @@ -482,11 +485,13 @@ test_expect_success FUNNYNAMES 'setup for --combined-all-paths with funny names' git checkout side1d && test_seq 1 10 >"$(printf "file\twith\ttabs")" && git add file* && + side1df=$(git hash-object *tabs) && git commit -m with && git checkout side2d && test_seq 1 9 >"$(printf "i\tam\ttabbed")" && echo ten >>"$(printf "i\tam\ttabbed")" && git add *tabbed && + side2df=$(git hash-object *tabbed) && git commit -m iam && git checkout -b funny-names-mergery side1d && git merge --no-commit side2d && @@ -494,12 +499,14 @@ test_expect_success FUNNYNAMES 'setup for --combined-all-paths with funny names' echo eleven >>"$(printf "i\tam\ttabbed")" && git mv "$(printf "i\tam\ttabbed")" "$(printf "fickle\tnaming")" && git add fickle* && - git commit + headf=$(git hash-object fickle*) && + git commit && + head=$(git rev-parse HEAD) ' test_expect_success FUNNYNAMES '--combined-all-paths and --raw and funny names' ' - cat <<-\EOF >expect && - ::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR "file\twith\ttabs" "i\tam\ttabbed" "fickle\tnaming" + cat <<-EOF >expect && + ::100644 100644 100644 $side1df $side2df $headf RR "file\twith\ttabs" "i\tam\ttabbed" "fickle\tnaming" EOF git diff-tree -c -M --raw --combined-all-paths HEAD >actual.tmp && sed 1d actual && @@ -507,9 +514,9 @@ test_expect_success FUNNYNAMES '--combined-all-paths and --raw and funny names' ' test_expect_success FUNNYNAMES '--combined-all-paths and --raw -and -z and funny names' ' - printf "aaf8087c3cbd4db8e185a2d074cf27c53cfb75d7\0::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR\0file\twith\ttabs\0i\tam\ttabbed\0fickle\tnaming\0" >expect && + printf "$head\0::100644 100644 100644 $side1df $side2df $headf RR\0file\twith\ttabs\0i\tam\ttabbed\0fickle\tnaming\0" >expect && git diff-tree -c -M --raw --combined-all-paths -z HEAD >actual && - test_cmp -a expect actual + test_cmp expect actual ' test_expect_success FUNNYNAMES '--combined-all-paths and --cc and funny names' ' diff --git a/t/t4039-diff-assume-unchanged.sh b/t/t4039-diff-assume-unchanged.sh index 53ac44b0f003..0eb0314a8b35 100755 --- a/t/t4039-diff-assume-unchanged.sh +++ b/t/t4039-diff-assume-unchanged.sh @@ -12,6 +12,7 @@ test_expect_success 'setup' ' git commit -m zero && echo one > one && echo two > two && + blob=$(git hash-object one) && git add one two && git commit -m onetwo && git update-index --assume-unchanged one && @@ -20,7 +21,7 @@ test_expect_success 'setup' ' ' test_expect_success 'diff-index does not examine assume-unchanged entries' ' - git diff-index HEAD^ -- one | grep -q 5626abf0f72e58d7a153368ba57db4c673c0e171 + git diff-index HEAD^ -- one | grep -q $blob ' test_expect_success 'diff-files does not examine assume-unchanged entries' ' diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh index 619bf970983e..f85213658560 100755 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@ -284,7 +284,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' ' test_must_be_empty actual ' -test_expect_success 'submodule contains untracked and modifed content' ' +test_expect_success 'submodule contains untracked and modified content' ' echo new > sm1/foo6 && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && @@ -294,7 +294,7 @@ test_expect_success 'submodule contains untracked and modifed content' ' test_cmp expected actual ' -test_expect_success 'submodule contains untracked and modifed content (untracked ignored)' ' +test_expect_success 'submodule contains untracked and modified content (untracked ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && cat >expected <<-EOF && @@ -303,19 +303,19 @@ test_expect_success 'submodule contains untracked and modifed content (untracked test_cmp expected actual ' -test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' ' +test_expect_success 'submodule contains untracked and modified content (dirty ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && test_must_be_empty actual ' -test_expect_success 'submodule contains untracked and modifed content (all ignored)' ' +test_expect_success 'submodule contains untracked and modified content (all ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules --submodule=log HEAD >actual && test_must_be_empty actual ' -test_expect_success 'submodule contains modifed content' ' +test_expect_success 'submodule contains modified content' ' rm -f sm1/new-file && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && @@ -369,7 +369,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored) test_must_be_empty actual ' -test_expect_success 'modified submodule contains untracked and modifed content' ' +test_expect_success 'modified submodule contains untracked and modified content' ' echo modification >> sm1/foo6 && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && @@ -381,7 +381,7 @@ test_expect_success 'modified submodule contains untracked and modifed content' test_cmp expected actual ' -test_expect_success 'modified submodule contains untracked and modifed content (untracked ignored)' ' +test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && cat >expected <<-EOF && @@ -392,7 +392,7 @@ test_expect_success 'modified submodule contains untracked and modifed content ( test_cmp expected actual ' -test_expect_success 'modified submodule contains untracked and modifed content (dirty ignored)' ' +test_expect_success 'modified submodule contains untracked and modified content (dirty ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && cat >expected <<-EOF && @@ -402,13 +402,13 @@ test_expect_success 'modified submodule contains untracked and modifed content ( test_cmp expected actual ' -test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' ' +test_expect_success 'modified submodule contains untracked and modified content (all ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules --submodule=log HEAD >actual && test_must_be_empty actual ' -test_expect_success 'modified submodule contains modifed content' ' +test_expect_success 'modified submodule contains modified content' ' rm -f sm1/new-file && git diff-index -p --submodule=log HEAD >actual && cat >expected <<-EOF && diff --git a/t/t4044-diff-index-unique-abbrev.sh b/t/t4044-diff-index-unique-abbrev.sh index 647905e01fb9..4701796d10e1 100755 --- a/t/t4044-diff-index-unique-abbrev.sh +++ b/t/t4044-diff-index-unique-abbrev.sh @@ -3,34 +3,48 @@ test_description='test unique sha1 abbreviation on "index from..to" line' . ./test-lib.sh -if ! test_have_prereq SHA1 -then - skip_all='not using SHA-1 for objects' - test_done -fi - -cat >expect_initial <expect_update < foo && + hash1 sha1:51d2738463ea4ca66f8691c91e33ce64b7d41bb1 + hash1 sha256:ae31dfff0af93b2c62b0098a039b38569c43b0a7e97b873000ca42d128f27350 + + hasht1 sha1:51d27384 + hasht1 sha256:ae31dfff + + hash2 sha1:51d2738efb4ad8a1e40bed839ab8e116f0a15e47 + hash2 sha256:ae31dffada88a46fd5f53c7ed5aa25a7a8951f1d5e88456c317c8d5484d263e5 + + hasht2 sha1:51d2738e + hasht2 sha256:ae31dffa + EOF + + cat >expect_initial <<-EOF && + 100644 blob $(test_oid hash1) foo + EOF + + cat >expect_update <<-EOF && + 100644 blob $(test_oid hash2) foo + EOF + + echo "$(test_oid val1)" > foo && git add foo && git commit -m "initial" && git cat-file -p HEAD: > actual && test_cmp expect_initial actual && - echo 11742 > foo && + echo "$(test_oid val2)" > foo && git commit -a -m "update" && git cat-file -p HEAD: > actual && test_cmp expect_update actual ' cat >expect <expected <<-EOF - :000000 100644 0000000000000000000000000000000000000000 $blob A $expect + :000000 100644 $ZERO_OID $blob A $expect EOF test_expect_success "--raw $*" " git -C '$dir' diff --no-abbrev --raw $* HEAD^ >actual && diff --git a/t/t4048-diff-combined-binary.sh b/t/t4048-diff-combined-binary.sh index 87a8949500bb..7f9ad9fa3d1f 100755 --- a/t/t4048-diff-combined-binary.sh +++ b/t/t4048-diff-combined-binary.sh @@ -9,24 +9,27 @@ test_expect_success 'setup binary merge conflict' ' git commit -m one && echo twoQ2 | q_to_nul >binary && git commit -a -m two && + two=$(git rev-parse --short HEAD:binary) && git checkout -b branch-binary HEAD^ && echo threeQ3 | q_to_nul >binary && git commit -a -m three && + three=$(git rev-parse --short HEAD:binary) && test_must_fail git merge master && echo resolvedQhooray | q_to_nul >binary && - git commit -a -m resolved + git commit -a -m resolved && + res=$(git rev-parse --short HEAD:binary) ' -cat >expect <<'EOF' +cat >expect <expect <<'EOF' +cat >expect <expect <<'EOF' +cat >expect <.gitattributes ' -cat >expect <<'EOF' +cat >expect <expect <<'EOF' +cat >expect <expect <<'EOF' +cat >expect <expect <<'EOF' +cat >expect <expect <<'EOF' +cat >expect <expect <<'EOF' +cat >expect <expect <<'EOF' +cat >expect <expect <<'EOF' +cat >expect </dev/null } +diff_cmp () { + for i in "$1" "$2" + do + sed -e 's/^index 0000000\.\.[0-9a-f]*/index 0000000..1234567/' \ + -e 's/^index [0-9a-f]*\.\.[0-9a-f]*/index 1234567..89abcde/' \ + "$i" >"$i.compare" || return 1 + done && + test_cmp "$1.compare" "$2.compare" && + rm -f "$1.compare" "$2.compare" +} + test_expect_success 'setup repository' ' test_create_repo sm1 && add_file . foo && @@ -69,7 +80,7 @@ test_expect_success 'added submodule' ' @@ -0,0 +1 @@ +foo2 EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'added submodule, set diff.submodule' ' @@ -93,7 +104,7 @@ test_expect_success 'added submodule, set diff.submodule' ' @@ -0,0 +1 @@ +foo2 EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success '--submodule=short overrides diff.submodule' ' @@ -109,7 +120,7 @@ test_expect_success '--submodule=short overrides diff.submodule' ' @@ -0,0 +1 @@ +Subproject commit $fullhead1 EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'diff.submodule does not affect plumbing' ' @@ -124,7 +135,7 @@ test_expect_success 'diff.submodule does not affect plumbing' ' @@ -0,0 +1 @@ +Subproject commit $fullhead1 EOF - test_cmp expected actual + diff_cmp expected actual ' commit_file sm1 && @@ -142,7 +153,7 @@ test_expect_success 'modified submodule(forward)' ' @@ -0,0 +1 @@ +foo3 EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'modified submodule(forward)' ' @@ -157,7 +168,7 @@ test_expect_success 'modified submodule(forward)' ' @@ -0,0 +1 @@ +foo3 EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'modified submodule(forward) --submodule' ' @@ -166,7 +177,7 @@ test_expect_success 'modified submodule(forward) --submodule' ' Submodule sm1 $head1..$head2: > Add foo3 ($added foo3) EOF - test_cmp expected actual + diff_cmp expected actual ' fullhead2=$(cd sm1; git rev-parse --verify HEAD) @@ -181,7 +192,7 @@ test_expect_success 'modified submodule(forward) --submodule=short' ' -Subproject commit $fullhead1 +Subproject commit $fullhead2 EOF - test_cmp expected actual + diff_cmp expected actual ' commit_file sm1 && @@ -210,7 +221,7 @@ test_expect_success 'modified submodule(backward)' ' @@ -1 +0,0 @@ -foo3 EOF - test_cmp expected actual + diff_cmp expected actual ' head4=$(add_file sm1 foo4 foo5) @@ -247,7 +258,7 @@ test_expect_success 'modified submodule(backward and forward)' ' @@ -0,0 +1 @@ +foo5 EOF - test_cmp expected actual + diff_cmp expected actual ' commit_file sm1 && @@ -291,7 +302,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --cached' ' @@ -0,0 +1 @@ +sm1 EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'typechanged submodule(submodule->blob)' ' @@ -327,7 +338,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' ' @@ -0,0 +1 @@ +foo5 EOF - test_cmp expected actual + diff_cmp expected actual ' rm -rf sm1 && @@ -344,7 +355,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' ' @@ -0,0 +1 @@ +sm1 EOF - test_cmp expected actual + diff_cmp expected actual ' rm -f sm1 && @@ -356,7 +367,7 @@ test_expect_success 'nonexistent commit' ' cat >expected <<-EOF && Submodule sm1 $head4...$head6 (commits not present) EOF - test_cmp expected actual + diff_cmp expected actual ' commit_file @@ -386,11 +397,12 @@ test_expect_success 'typechanged submodule(blob->submodule)' ' @@ -0,0 +1 @@ +foo7 EOF - test_cmp expected actual + diff_cmp expected actual ' commit_file sm1 && test_expect_success 'submodule is up to date' ' + head7=$(git -C sm1 rev-parse --short --verify HEAD) && git diff-index -p --submodule=diff HEAD >actual && test_must_be_empty actual ' @@ -401,7 +413,7 @@ test_expect_success 'submodule contains untracked content' ' cat >expected <<-EOF && Submodule sm1 contains untracked content EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'submodule contains untracked content (untracked ignored)' ' @@ -433,7 +445,7 @@ test_expect_success 'submodule contains untracked and modified content' ' -foo6 +new EOF - test_cmp expected actual + diff_cmp expected actual ' # NOT OK @@ -450,7 +462,7 @@ test_expect_success 'submodule contains untracked and modified content (untracke -foo6 +new EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'submodule contains untracked and modified content (dirty ignored)' ' @@ -478,7 +490,7 @@ test_expect_success 'submodule contains modified content' ' -foo6 +new EOF - test_cmp expected actual + diff_cmp expected actual ' (cd sm1; git commit -mchange foo6 >/dev/null) && @@ -486,7 +498,7 @@ head8=$(cd sm1; git rev-parse --short --verify HEAD) && test_expect_success 'submodule is modified' ' git diff-index -p --submodule=diff HEAD >actual && cat >expected <<-EOF && - Submodule sm1 17243c9..$head8: + Submodule sm1 $head7..$head8: diff --git a/sm1/foo6 b/sm1/foo6 index 462398b..3e75765 100644 --- a/sm1/foo6 @@ -495,7 +507,7 @@ test_expect_success 'submodule is modified' ' -foo6 +new EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'modified submodule contains untracked content' ' @@ -503,7 +515,7 @@ test_expect_success 'modified submodule contains untracked content' ' git diff-index -p --submodule=diff HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains untracked content - Submodule sm1 17243c9..$head8: + Submodule sm1 $head7..$head8: diff --git a/sm1/foo6 b/sm1/foo6 index 462398b..3e75765 100644 --- a/sm1/foo6 @@ -512,13 +524,13 @@ test_expect_success 'modified submodule contains untracked content' ' -foo6 +new EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'modified submodule contains untracked content (untracked ignored)' ' git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual && cat >expected <<-EOF && - Submodule sm1 17243c9..$head8: + Submodule sm1 $head7..$head8: diff --git a/sm1/foo6 b/sm1/foo6 index 462398b..3e75765 100644 --- a/sm1/foo6 @@ -527,13 +539,13 @@ test_expect_success 'modified submodule contains untracked content (untracked ig -foo6 +new EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'modified submodule contains untracked content (dirty ignored)' ' git diff-index -p --ignore-submodules=dirty --submodule=diff HEAD >actual && cat >expected <<-EOF && - Submodule sm1 17243c9..cfce562: + Submodule sm1 $head7..$head8: diff --git a/sm1/foo6 b/sm1/foo6 index 462398b..3e75765 100644 --- a/sm1/foo6 @@ -542,7 +554,7 @@ test_expect_success 'modified submodule contains untracked content (dirty ignore -foo6 +new EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'modified submodule contains untracked content (all ignored)' ' @@ -556,7 +568,7 @@ test_expect_success 'modified submodule contains untracked and modified content' cat >expected <<-EOF && Submodule sm1 contains untracked content Submodule sm1 contains modified content - Submodule sm1 17243c9..cfce562: + Submodule sm1 $head7..$head8: diff --git a/sm1/foo6 b/sm1/foo6 index 462398b..dfda541 100644 --- a/sm1/foo6 @@ -566,7 +578,7 @@ test_expect_success 'modified submodule contains untracked and modified content' +new +modification EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' ' @@ -574,7 +586,7 @@ test_expect_success 'modified submodule contains untracked and modified content git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains modified content - Submodule sm1 17243c9..cfce562: + Submodule sm1 $head7..$head8: diff --git a/sm1/foo6 b/sm1/foo6 index 462398b..e20e2d9 100644 --- a/sm1/foo6 @@ -585,14 +597,14 @@ test_expect_success 'modified submodule contains untracked and modified content +modification +modification EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'modified submodule contains untracked and modified content (dirty ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules=dirty --submodule=diff HEAD >actual && cat >expected <<-EOF && - Submodule sm1 17243c9..cfce562: + Submodule sm1 $head7..$head8: diff --git a/sm1/foo6 b/sm1/foo6 index 462398b..3e75765 100644 --- a/sm1/foo6 @@ -601,7 +613,7 @@ test_expect_success 'modified submodule contains untracked and modified content -foo6 +new EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'modified submodule contains untracked and modified content (all ignored)' ' @@ -616,7 +628,7 @@ test_expect_success 'modified submodule contains modified content' ' git diff-index -p --submodule=diff HEAD >actual && cat >expected <<-EOF && Submodule sm1 contains modified content - Submodule sm1 17243c9..cfce562: + Submodule sm1 $head7..$head8: diff --git a/sm1/foo6 b/sm1/foo6 index 462398b..ac466ca 100644 --- a/sm1/foo6 @@ -629,29 +641,29 @@ test_expect_success 'modified submodule contains modified content' ' +modification +modification EOF - test_cmp expected actual + diff_cmp expected actual ' rm -rf sm1 test_expect_success 'deleted submodule' ' git diff-index -p --submodule=diff HEAD >actual && cat >expected <<-EOF && - Submodule sm1 17243c9...0000000 (submodule deleted) + Submodule sm1 $head7...0000000 (submodule deleted) EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'create second submodule' ' test_create_repo sm2 && - head7=$(add_file sm2 foo8 foo9) && + head9=$(add_file sm2 foo8 foo9) && git add sm2 ' test_expect_success 'multiple submodules' ' git diff-index -p --submodule=diff HEAD >actual && cat >expected <<-EOF && - Submodule sm1 17243c9...0000000 (submodule deleted) - Submodule sm2 0000000...a5a65c9 (new submodule) + Submodule sm1 $head7...0000000 (submodule deleted) + Submodule sm2 0000000...$head9 (new submodule) diff --git a/sm2/foo8 b/sm2/foo8 new file mode 100644 index 0000000..db9916b @@ -667,13 +679,13 @@ test_expect_success 'multiple submodules' ' @@ -0,0 +1 @@ +foo9 EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'path filter' ' git diff-index -p --submodule=diff HEAD sm2 >actual && cat >expected <<-EOF && - Submodule sm2 0000000...a5a65c9 (new submodule) + Submodule sm2 0000000...$head9 (new submodule) diff --git a/sm2/foo8 b/sm2/foo8 new file mode 100644 index 0000000..db9916b @@ -689,15 +701,15 @@ test_expect_success 'path filter' ' @@ -0,0 +1 @@ +foo9 EOF - test_cmp expected actual + diff_cmp expected actual ' commit_file sm2 test_expect_success 'given commit' ' git diff-index -p --submodule=diff HEAD^ >actual && cat >expected <<-EOF && - Submodule sm1 17243c9...0000000 (submodule deleted) - Submodule sm2 0000000...a5a65c9 (new submodule) + Submodule sm1 $head7...0000000 (submodule deleted) + Submodule sm2 0000000...$head9 (new submodule) diff --git a/sm2/foo8 b/sm2/foo8 new file mode 100644 index 0000000..db9916b @@ -713,7 +725,7 @@ test_expect_success 'given commit' ' @@ -0,0 +1 @@ +foo9 EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'setup .git file for sm2' ' @@ -726,8 +738,8 @@ test_expect_success 'setup .git file for sm2' ' test_expect_success 'diff --submodule=diff with .git file' ' git diff --submodule=diff HEAD^ >actual && cat >expected <<-EOF && - Submodule sm1 17243c9...0000000 (submodule deleted) - Submodule sm2 0000000...a5a65c9 (new submodule) + Submodule sm1 $head7...0000000 (submodule deleted) + Submodule sm2 0000000...$head9 (new submodule) diff --git a/sm2/foo8 b/sm2/foo8 new file mode 100644 index 0000000..db9916b @@ -743,25 +755,27 @@ test_expect_success 'diff --submodule=diff with .git file' ' @@ -0,0 +1 @@ +foo9 EOF - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'setup nested submodule' ' git submodule add -f ./sm2 && git commit -a -m "add sm2" && git -C sm2 submodule add ../sm2 nested && - git -C sm2 commit -a -m "nested sub" + git -C sm2 commit -a -m "nested sub" && + head10=$(git -C sm2 rev-parse --short --verify HEAD) ' test_expect_success 'move nested submodule HEAD' ' echo "nested content" >sm2/nested/file && git -C sm2/nested add file && - git -C sm2/nested commit --allow-empty -m "new HEAD" + git -C sm2/nested commit --allow-empty -m "new HEAD" && + head11=$(git -C sm2/nested rev-parse --short --verify HEAD) ' test_expect_success 'diff --submodule=diff with moved nested submodule HEAD' ' cat >expected <<-EOF && - Submodule nested a5a65c9..b55928c: + Submodule nested $head9..$head11: diff --git a/nested/file b/nested/file new file mode 100644 index 0000000..ca281f5 @@ -772,13 +786,13 @@ test_expect_success 'diff --submodule=diff with moved nested submodule HEAD' ' EOF git -C sm2 diff --submodule=diff >actual 2>err && test_must_be_empty err && - test_cmp expected actual + diff_cmp expected actual ' test_expect_success 'diff --submodule=diff recurses into nested submodules' ' cat >expected <<-EOF && Submodule sm2 contains modified content - Submodule sm2 a5a65c9..280969a: + Submodule sm2 $head9..$head10: diff --git a/sm2/.gitmodules b/sm2/.gitmodules new file mode 100644 index 0000000..3a816b8 @@ -788,7 +802,7 @@ test_expect_success 'diff --submodule=diff recurses into nested submodules' ' +[submodule "nested"] + path = nested + url = ../sm2 - Submodule nested 0000000...b55928c (new submodule) + Submodule nested 0000000...$head11 (new submodule) diff --git a/sm2/nested/file b/sm2/nested/file new file mode 100644 index 0000000..ca281f5 @@ -813,7 +827,7 @@ test_expect_success 'diff --submodule=diff recurses into nested submodules' ' EOF git diff --submodule=diff >actual 2>err && test_must_be_empty err && - test_cmp expected actual + diff_cmp expected actual ' test_done diff --git a/t/t4066-diff-emit-delay.sh b/t/t4066-diff-emit-delay.sh index 5df6b5e64e0e..6331f63b127c 100755 --- a/t/t4066-diff-emit-delay.sh +++ b/t/t4066-diff-emit-delay.sh @@ -18,7 +18,7 @@ test_expect_success 'set up history with a merge' ' ' test_expect_success 'log --cc -p --stat --color-moved' ' - cat >expect <<-\EOF && + cat >expect <<-EOF && commit D --- D.t | 1 + @@ -26,7 +26,7 @@ test_expect_success 'log --cc -p --stat --color-moved' ' diff --git a/D.t b/D.t new file mode 100644 - index 0000000..1784810 + index 0000000..$(git rev-parse --short D:D.t) --- /dev/null +++ b/D.t @@ -0,0 +1 @@ @@ -42,7 +42,7 @@ test_expect_success 'log --cc -p --stat --color-moved' ' diff --git a/C.t b/C.t new file mode 100644 - index 0000000..3cc58df + index 0000000..$(git rev-parse --short C:C.t) --- /dev/null +++ b/C.t @@ -0,0 +1 @@ @@ -54,7 +54,7 @@ test_expect_success 'log --cc -p --stat --color-moved' ' diff --git a/B.t b/B.t new file mode 100644 - index 0000000..223b783 + index 0000000..$(git rev-parse --short B:B.t) --- /dev/null +++ b/B.t @@ -0,0 +1 @@ @@ -66,7 +66,7 @@ test_expect_success 'log --cc -p --stat --color-moved' ' diff --git a/A.t b/A.t new file mode 100644 - index 0000000..f70f10e + index 0000000..$(git rev-parse --short A:A.t) --- /dev/null +++ b/A.t @@ -0,0 +1 @@ diff --git a/t/t4067-diff-partial-clone.sh b/t/t4067-diff-partial-clone.sh index 90c8fb290175..4831ad35e614 100755 --- a/t/t4067-diff-partial-clone.sh +++ b/t/t4067-diff-partial-clone.sh @@ -75,6 +75,37 @@ test_expect_success 'diff skips same-OID blobs' ' ! grep "want $(cat hash-b)" trace ' +test_expect_success 'when fetching missing objects, diff skips GITLINKs' ' + test_when_finished "rm -rf sub server client trace" && + + test_create_repo sub && + test_commit -C sub first && + + test_create_repo server && + echo a >server/a && + git -C server add a && + git -C server submodule add "file://$(pwd)/sub" && + git -C server commit -m x && + + test_commit -C server/sub second && + echo another-a >server/a && + git -C server add a sub && + git -C server commit -m x && + + test_config -C server uploadpack.allowfilter 1 && + test_config -C server uploadpack.allowanysha1inwant 1 && + git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client && + + echo a | git hash-object --stdin >hash-old-a && + echo another-a | git hash-object --stdin >hash-new-a && + + # Ensure that a and another-a are fetched, and check (by successful + # execution of the diff) that no invalid OIDs are sent. + GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff HEAD^ HEAD && + grep "want $(cat hash-old-a)" trace && + grep "want $(cat hash-new-a)" trace +' + test_expect_success 'diff with rename detection batches blobs' ' test_when_finished "rm -rf server client trace" && diff --git a/t/t4100/t-apply-1.patch b/t/t4100/t-apply-1.patch index 90ab54f0f586..43394f828561 100644 --- a/t/t4100/t-apply-1.patch +++ b/t/t4100/t-apply-1.patch @@ -75,8 +75,8 @@ diff --git a/Documentation/git.txt b/Documentation/git.txt +link:git-ssh-pull.html[git-ssh-pull]:: Pulls from a remote repository over ssh connection - Interogators: -@@ -156,8 +156,8 @@ Interogators: + Interrogators: +@@ -156,8 +156,8 @@ Interrogators: link:git-diff-helper.html[git-diff-helper]:: Generates patch format output for git-diff-* diff --git a/t/t4100/t-apply-3.patch b/t/t4100/t-apply-3.patch index 90cdbaa5bb62..cac172e7791d 100644 --- a/t/t4100/t-apply-3.patch +++ b/t/t4100/t-apply-3.patch @@ -211,7 +211,7 @@ dissimilarity index 82% - - /* If this is an exact directory match, we may have - * directory files following this path. Match on them. -- * Otherwise, we're at a pach subcomponent, and we need +- * Otherwise, we're at a patch subcomponent, and we need - * to try to match again. - */ - if (mtype == 0) diff --git a/t/t4100/t-apply-5.patch b/t/t4100/t-apply-5.patch index 5f6ddc105950..57ec79d8879a 100644 --- a/t/t4100/t-apply-5.patch +++ b/t/t4100/t-apply-5.patch @@ -185,8 +185,8 @@ diff a/Documentation/git.txt b/Documentation/git.txt +link:git-ssh-pull.html[git-ssh-pull]:: Pulls from a remote repository over ssh connection - Interogators: -@@ -156,8 +156,8 @@ Interogators: + Interrogators: +@@ -156,8 +156,8 @@ Interrogators: link:git-diff-helper.html[git-diff-helper]:: Generates patch format output for git-diff-* diff --git a/t/t4100/t-apply-7.patch b/t/t4100/t-apply-7.patch index 07c6589e74fa..fa2430510864 100644 --- a/t/t4100/t-apply-7.patch +++ b/t/t4100/t-apply-7.patch @@ -335,7 +335,7 @@ diff a/ls-tree.c b/ls-tree.c - /* If this is an exact directory match, we may have - * directory files following this path. Match on them. -- * Otherwise, we're at a pach subcomponent, and we need +- * Otherwise, we're at a patch subcomponent, and we need - * to try to match again. + if (e->directory) { + /* If this is a directory, we have the following cases: diff --git a/t/t4108-apply-threeway.sh b/t/t4108-apply-threeway.sh index fa5d4efb89dc..d7349ced6be0 100755 --- a/t/t4108-apply-threeway.sh +++ b/t/t4108-apply-threeway.sh @@ -4,23 +4,17 @@ test_description='git apply --3way' . ./test-lib.sh -create_file () { - for i - do - echo "$i" - done -} - -sanitize_conflicted_diff () { +print_sanitized_conflicted_diff () { + git diff HEAD >diff.raw && sed -e ' /^index /d - s/^\(+[<>][<>][<>][<>]*\) .*/\1/ - ' + s/^\(+[<>|][<>|][<>|][<>|]*\) .*/\1/ + ' diff.raw } test_expect_success setup ' test_tick && - create_file >one 1 2 3 4 5 6 7 && + test_write_lines 1 2 3 4 5 6 7 >one && cat one >two && git add one two && git commit -m initial && @@ -28,13 +22,13 @@ test_expect_success setup ' git branch side && test_tick && - create_file >one 1 two 3 4 5 six 7 && - create_file >two 1 two 3 4 5 6 7 && + test_write_lines 1 two 3 4 5 six 7 >one && + test_write_lines 1 two 3 4 5 6 7 >two && git commit -a -m master && git checkout side && - create_file >one 1 2 3 4 five 6 7 && - create_file >two 1 2 3 4 five 6 7 && + test_write_lines 1 2 3 4 five 6 7 >one && + test_write_lines 1 2 3 4 five 6 7 >two && git commit -a -m side && git checkout master @@ -52,7 +46,7 @@ test_expect_success 'apply without --3way' ' git diff-index --exit-code --cached HEAD ' -test_expect_success 'apply with --3way' ' +test_apply_with_3way () { # Merging side should be similar to applying this patch git diff ...side >P.diff && @@ -61,22 +55,31 @@ test_expect_success 'apply with --3way' ' git checkout master^0 && test_must_fail git merge --no-commit side && git ls-files -s >expect.ls && - git diff HEAD | sanitize_conflicted_diff >expect.diff && + print_sanitized_conflicted_diff >expect.diff && # should fail to apply git reset --hard && git checkout master^0 && test_must_fail git apply --index --3way P.diff && git ls-files -s >actual.ls && - git diff HEAD | sanitize_conflicted_diff >actual.diff && + print_sanitized_conflicted_diff >actual.diff && # The result should resemble the corresponding merge test_cmp expect.ls actual.ls && test_cmp expect.diff actual.diff +} + +test_expect_success 'apply with --3way' ' + test_apply_with_3way +' + +test_expect_success 'apply with --3way with merge.conflictStyle = diff3' ' + test_config merge.conflictStyle diff3 && + test_apply_with_3way ' test_expect_success 'apply with --3way with rerere enabled' ' - git config rerere.enabled true && + test_config rerere.enabled true && # Merging side should be similar to applying this patch git diff ...side >P.diff && @@ -87,7 +90,7 @@ test_expect_success 'apply with --3way with rerere enabled' ' test_must_fail git merge --no-commit side && # Manually resolve and record the resolution - create_file 1 two 3 4 five six 7 >one && + test_write_lines 1 two 3 4 five six 7 >one && git rerere && cat one >expect && @@ -104,14 +107,14 @@ test_expect_success 'apply -3 with add/add conflict setup' ' git reset --hard && git checkout -b adder && - create_file 1 2 3 4 5 6 7 >three && - create_file 1 2 3 4 5 6 7 >four && + test_write_lines 1 2 3 4 5 6 7 >three && + test_write_lines 1 2 3 4 5 6 7 >four && git add three four && git commit -m "add three and four" && git checkout -b another adder^ && - create_file 1 2 3 4 5 6 7 >three && - create_file 1 2 3 four 5 6 7 >four && + test_write_lines 1 2 3 4 5 6 7 >three && + test_write_lines 1 2 3 four 5 6 7 >four && git add three four && git commit -m "add three and four" && @@ -121,7 +124,7 @@ test_expect_success 'apply -3 with add/add conflict setup' ' git checkout adder^0 && test_must_fail git merge --no-commit another && git ls-files -s >expect.ls && - git diff HEAD | sanitize_conflicted_diff >expect.diff + print_sanitized_conflicted_diff >expect.diff ' test_expect_success 'apply -3 with add/add conflict' ' @@ -131,7 +134,7 @@ test_expect_success 'apply -3 with add/add conflict' ' test_must_fail git apply --index --3way P.diff && # ... and leave conflicts in the index and in the working tree git ls-files -s >actual.ls && - git diff HEAD | sanitize_conflicted_diff >actual.diff && + print_sanitized_conflicted_diff >actual.diff && # The result should resemble the corresponding merge test_cmp expect.ls actual.ls && diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh index f7de6f077a6e..0ee93fe845af 100755 --- a/t/t4117-apply-reject.sh +++ b/t/t4117-apply-reject.sh @@ -74,7 +74,7 @@ test_expect_success 'apply with --reject should fail but update the file' ' test_must_fail git apply --reject patch.1 && test_cmp expected file1 && - cat file1.rej && + test_path_is_file file1.rej && test_path_is_missing file2.rej ' @@ -87,7 +87,7 @@ test_expect_success 'apply with --reject should fail but update the file' ' test_path_is_missing file1 && test_cmp expected file2 && - cat file2.rej && + test_path_is_file file2.rej && test_path_is_missing file1.rej ' @@ -101,7 +101,7 @@ test_expect_success 'the same test with --verbose' ' test_path_is_missing file1 && test_cmp expected file2 && - cat file2.rej && + test_path_is_file file2.rej && test_path_is_missing file1.rej ' diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index ff51e9e78914..971a5a7512ac 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -35,9 +35,15 @@ prepare_test_file () { } apply_patch () { + cmd_prefix= && + if test "x$1" = 'x!' + then + cmd_prefix=test_must_fail && + shift + fi && >target && sed -e "s|\([ab]\)/file|\1/target|" create-sm.patch < remove-sm.patch <after && printf "%64s\n" a b c >>after && printf "\t%s\n" 4 5 6 >>after && - git diff --no-index before after | - sed -e "s/before/test-1/" -e "s/after/test-1/" >patch1.patch && + test_expect_code 1 git diff --no-index before after >patch1.patch.raw && + sed -e "s/before/test-1/" -e "s/after/test-1/" patch1.patch.raw >patch1.patch && printf "%64s\n" 1 2 3 4 5 6 >test-1 && printf "%64s\n" 1 2 3 a b c 4 5 6 >expect-1 && @@ -33,8 +33,8 @@ test_expect_success setup ' x=$(( $x + 1 )) done && printf "\t%s\n" d e f >>after && - git diff --no-index before after | - sed -e "s/before/test-2/" -e "s/after/test-2/" >patch2.patch && + test_expect_code 1 git diff --no-index before after >patch2.patch.raw && + sed -e "s/before/test-2/" -e "s/after/test-2/" patch2.patch.raw >patch2.patch && printf "%64s\n" a b c d e f >test-2 && printf "%64s\n" a b c >expect-2 && x=1 && @@ -56,8 +56,8 @@ test_expect_success setup ' x=$(( $x + 1 )) done && printf "\t%s\n" d e f >>after && - git diff --no-index before after | - sed -e "s/before/test-3/" -e "s/after/test-3/" >patch3.patch && + test_expect_code 1 git diff --no-index before after >patch3.patch.raw && + sed -e "s/before/test-3/" -e "s/after/test-3/" patch3.patch.raw >patch3.patch && printf "%64s\n" a b c d e f >test-3 && printf "%64s\n" a b c >expect-3 && x=0 && @@ -84,8 +84,8 @@ test_expect_success setup ' printf "\t%02d\n" $x >>after x=$(( $x + 1 )) done && - git diff --no-index before after | - sed -e "s/before/test-4/" -e "s/after/test-4/" >patch4.patch && + test_expect_code 1 git diff --no-index before after >patch4.patch.raw && + sed -e "s/before/test-4/" -e "s/after/test-4/" patch4.patch.raw >patch4.patch && >test-4 && x=0 && while test $x -lt 50 diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 3f7f750cc8d7..cb4527145726 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -666,6 +666,26 @@ test_expect_success 'am --show-current-patch' ' test_cmp .git/rebase-apply/0001 actual.patch ' +test_expect_success 'am --show-current-patch=raw' ' + git am --show-current-patch=raw >actual.patch && + test_cmp .git/rebase-apply/0001 actual.patch +' + +test_expect_success 'am --show-current-patch=diff' ' + git am --show-current-patch=diff >actual.patch && + test_cmp .git/rebase-apply/patch actual.patch +' + +test_expect_success 'am accepts repeated --show-current-patch' ' + git am --show-current-patch --show-current-patch=raw >actual.patch && + test_cmp .git/rebase-apply/0001 actual.patch +' + +test_expect_success 'am detects incompatible --show-current-patch' ' + test_must_fail git am --show-current-patch=raw --show-current-patch=diff && + test_must_fail git am --show-current-patch --show-current-patch=diff +' + test_expect_success 'am --skip works' ' echo goodbye >expected && git am --skip && @@ -1061,4 +1081,56 @@ test_expect_success 'am --quit keeps HEAD where it is' ' test_cmp expected actual ' +test_expect_success 'am and .gitattibutes' ' + test_create_repo attributes && + ( + cd attributes && + test_commit init && + git config filter.test.clean "sed -e '\''s/smudged/clean/g'\''" && + git config filter.test.smudge "sed -e '\''s/clean/smudged/g'\''" && + + test_commit second && + git checkout -b test HEAD^ && + + echo "*.txt filter=test conflict-marker-size=10" >.gitattributes && + git add .gitattributes && + test_commit third && + + echo "This text is smudged." >a.txt && + git add a.txt && + test_commit fourth && + + git checkout -b removal HEAD^ && + git rm .gitattributes && + git add -u && + test_commit fifth && + git cherry-pick test && + + git checkout -b conflict third && + echo "This text is different." >a.txt && + git add a.txt && + test_commit sixth && + + git checkout test && + git format-patch --stdout master..HEAD >patches && + git reset --hard master && + git am patches && + grep "smudged" a.txt && + + git checkout removal && + git reset --hard && + git format-patch --stdout master..HEAD >patches && + git reset --hard master && + git am patches && + grep "clean" a.txt && + + git checkout conflict && + git reset --hard && + git format-patch --stdout master..HEAD >patches && + git reset --hard fourth && + test_must_fail git am -3 patches && + grep "<<<<<<<<<<" a.txt + ) +' + test_done diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index 55b7750ade1c..831d424c4720 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -25,6 +25,7 @@ test_description='git rerere . ./test-lib.sh test_expect_success 'setup' ' + test_oid_init && cat >a1 <<-\EOF && Some title ========== @@ -210,7 +211,7 @@ test_expect_success 'set up for garbage collection tests' ' echo Hello >$rr/preimage && echo World >$rr/postimage && - sha2=4000000000000000000000000000000000000000 && + sha2=$(test_oid deadbeef) && rr2=.git/rr-cache/$sha2 && mkdir $rr2 && echo Hello >$rr2/preimage && diff --git a/t/t4202-log.sh b/t/t4202-log.sh index c20209324c8e..0f766ba65f59 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -5,6 +5,11 @@ test_description='git log' . ./test-lib.sh . "$TEST_DIRECTORY/lib-gpg.sh" . "$TEST_DIRECTORY/lib-terminal.sh" +. "$TEST_DIRECTORY/lib-log-graph.sh" + +test_cmp_graph () { + lib_test_cmp_graph --format=%s "$@" +} test_expect_success setup ' @@ -87,12 +92,12 @@ test_expect_success 'format %w(,1,2)' ' ' cat > expect << EOF -804a787 sixth -394ef78 fifth -5d31159 fourth -2fbe8c0 third -f7dab8e second -3a2fdcb initial +$(git rev-parse --short :/sixth ) sixth +$(git rev-parse --short :/fifth ) fifth +$(git rev-parse --short :/fourth ) fourth +$(git rev-parse --short :/third ) third +$(git rev-parse --short :/second ) second +$(git rev-parse --short :/initial) initial EOF test_expect_success 'oneline' ' @@ -173,43 +178,45 @@ test_expect_success 'git config log.follow is overridden by --no-follow' ' verbose test "$actual" = "$expect" ' +# Note that these commits are intentionally listed out of order. +last_three="$(git rev-parse :/fourth :/sixth :/fifth)" cat > expect << EOF -804a787 sixth -394ef78 fifth -5d31159 fourth +$(git rev-parse --short :/sixth ) sixth +$(git rev-parse --short :/fifth ) fifth +$(git rev-parse --short :/fourth) fourth EOF test_expect_success 'git log --no-walk sorts by commit time' ' - git log --no-walk --oneline 5d31159 804a787 394ef78 > actual && + git log --no-walk --oneline $last_three > actual && test_cmp expect actual ' test_expect_success 'git log --no-walk=sorted sorts by commit time' ' - git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual && + git log --no-walk=sorted --oneline $last_three > actual && test_cmp expect actual ' cat > expect << EOF -=== 804a787 sixth -=== 394ef78 fifth -=== 5d31159 fourth +=== $(git rev-parse --short :/sixth ) sixth +=== $(git rev-parse --short :/fifth ) fifth +=== $(git rev-parse --short :/fourth) fourth EOF test_expect_success 'git log --line-prefix="=== " --no-walk sorts by commit time' ' - git log --line-prefix="=== " --no-walk --oneline 5d31159 804a787 394ef78 > actual && + git log --line-prefix="=== " --no-walk --oneline $last_three > actual && test_cmp expect actual ' cat > expect << EOF -5d31159 fourth -804a787 sixth -394ef78 fifth +$(git rev-parse --short :/fourth) fourth +$(git rev-parse --short :/sixth ) sixth +$(git rev-parse --short :/fifth ) fifth EOF test_expect_success 'git log --no-walk=unsorted leaves list of commits as given' ' - git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual && + git log --no-walk=unsorted --oneline $last_three > actual && test_cmp expect actual ' test_expect_success 'git show leaves list of commits as given' ' - git show --oneline -s 5d31159 804a787 394ef78 > actual && + git show --oneline -s $last_three > actual && test_cmp expect actual ' @@ -450,8 +457,7 @@ cat > expect <actual && - test_cmp expect actual + test_cmp_graph ' cat > expect < expect <actual && - test_cmp expect actual + test_cmp_graph --line-prefix="123 " ' test_expect_success 'set up merge history' ' @@ -493,9 +498,7 @@ cat > expect <<\EOF EOF test_expect_success 'log --graph with merge' ' - git log --graph --date-order --pretty=tformat:%s | - sed "s/ *\$//" >actual && - test_cmp expect actual + test_cmp_graph --date-order ' cat > expect <<\EOF @@ -514,9 +517,7 @@ cat > expect <<\EOF EOF test_expect_success 'log --graph --line-prefix="| | | " with merge' ' - git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s | - sed "s/ *\$//" >actual && - test_cmp expect actual + test_cmp_graph --line-prefix="| | | " --date-order ' cat > expect.colors <<\EOF @@ -536,9 +537,7 @@ EOF test_expect_success 'log --graph with merge with log.graphColors' ' test_config log.graphColors " blue,invalid-color, cyan, red , " && - git log --color=always --graph --date-order --pretty=tformat:%s | - test_decode_color | sed "s/ *\$//" >actual && - test_cmp expect.colors actual + lib_test_cmp_colored_graph --date-order --format=%s ' test_expect_success 'log --raw --graph -m with merge' ' @@ -667,16 +666,14 @@ cat > expect <<\EOF * | | fifth * | | fourth |/ / -* | third +* / third |/ * second * initial EOF test_expect_success 'log --graph with merge' ' - git log --graph --date-order --pretty=tformat:%s | - sed "s/ *\$//" >actual && - test_cmp expect actual + test_cmp_graph --date-order ' test_expect_success 'log.decorate configuration' ' @@ -837,6 +834,21 @@ test_expect_success 'decorate-refs and decorate-refs-exclude' ' test_cmp expect.decorate actual ' +test_expect_success 'decorate-refs-exclude and simplify-by-decoration' ' + cat >expect.decorate <<-\EOF && + Merge-tag-reach (HEAD -> master) + reach (tag: reach, reach) + seventh (tag: seventh) + Merge-branch-tangle + Merge-branch-side-early-part-into-tangle (tangle) + tangle-a (tag: tangle-a) + EOF + git log -n6 --decorate=short --pretty="tformat:%f%d" \ + --decorate-refs-exclude="*octopus*" \ + --simplify-by-decoration >actual && + test_cmp expect.decorate actual +' + test_expect_success 'log.decorate config parsing' ' git log --oneline --decorate=full >expect.full && git log --oneline --decorate=short >expect.short && @@ -942,7 +954,7 @@ cat >expect <<\EOF | | | | diff --git a/reach.t b/reach.t | | new file mode 100644 -| | index 0000000..10c9591 +| | index BEFORE..AFTER | | --- /dev/null | | +++ b/reach.t | | @@ -0,0 +1 @@ @@ -965,7 +977,7 @@ cat >expect <<\EOF | | | | | | diff --git a/octopus-b.t b/octopus-b.t | | | new file mode 100644 -| | | index 0000000..d5fcad0 +| | | index BEFORE..AFTER | | | --- /dev/null | | | +++ b/octopus-b.t | | | @@ -0,0 +1 @@ @@ -981,7 +993,7 @@ cat >expect <<\EOF | | | | diff --git a/octopus-a.t b/octopus-a.t | | new file mode 100644 -| | index 0000000..11ee015 +| | index BEFORE..AFTER | | --- /dev/null | | +++ b/octopus-a.t | | @@ -0,0 +1 @@ @@ -997,7 +1009,7 @@ cat >expect <<\EOF | | diff --git a/seventh.t b/seventh.t | new file mode 100644 -| index 0000000..9744ffc +| index BEFORE..AFTER | --- /dev/null | +++ b/seventh.t | @@ -0,0 +1 @@ @@ -1031,7 +1043,7 @@ cat >expect <<\EOF | | | | | | | | diff --git a/tangle-a b/tangle-a | | | | new file mode 100644 -| | | | index 0000000..7898192 +| | | | index BEFORE..AFTER | | | | --- /dev/null | | | | +++ b/tangle-a | | | | @@ -0,0 +1 @@ @@ -1053,7 +1065,7 @@ cat >expect <<\EOF | | | | | | | | diff --git a/2 b/2 | | | | new file mode 100644 -| | | | index 0000000..0cfbf08 +| | | | index BEFORE..AFTER | | | | --- /dev/null | | | | +++ b/2 | | | | @@ -0,0 +1 @@ @@ -1069,7 +1081,7 @@ cat >expect <<\EOF | | | | | | | | diff --git a/1 b/1 | | | | new file mode 100644 -| | | | index 0000000..d00491f +| | | | index BEFORE..AFTER | | | | --- /dev/null | | | | +++ b/1 | | | | @@ -0,0 +1 @@ @@ -1085,7 +1097,7 @@ cat >expect <<\EOF | | | | | | | | diff --git a/one b/one | | | | new file mode 100644 -| | | | index 0000000..9a33383 +| | | | index BEFORE..AFTER | | | | --- /dev/null | | | | +++ b/one | | | | @@ -0,0 +1 @@ @@ -1101,7 +1113,7 @@ cat >expect <<\EOF | | | | | | diff --git a/a/two b/a/two | | | deleted file mode 100644 -| | | index 9245af5..0000000 +| | | index BEFORE..AFTER | | | --- a/a/two | | | +++ /dev/null | | | @@ -1 +0,0 @@ @@ -1117,7 +1129,7 @@ cat >expect <<\EOF | | | | | | diff --git a/a/two b/a/two | | | new file mode 100644 -| | | index 0000000..9245af5 +| | | index BEFORE..AFTER | | | --- /dev/null | | | +++ b/a/two | | | @@ -0,0 +1 @@ @@ -1133,7 +1145,7 @@ cat >expect <<\EOF | | | | diff --git a/ein b/ein | | new file mode 100644 -| | index 0000000..9d7e69f +| | index BEFORE..AFTER | | --- /dev/null | | +++ b/ein | | @@ -0,0 +1 @@ @@ -1150,14 +1162,14 @@ cat >expect <<\EOF | | diff --git a/ichi b/ichi | new file mode 100644 -| index 0000000..9d7e69f +| index BEFORE..AFTER | --- /dev/null | +++ b/ichi | @@ -0,0 +1 @@ | +ichi | diff --git a/one b/one | deleted file mode 100644 -| index 9d7e69f..0000000 +| index BEFORE..AFTER | --- a/one | +++ /dev/null | @@ -1 +0,0 @@ @@ -1172,7 +1184,7 @@ cat >expect <<\EOF | 1 file changed, 1 insertion(+), 1 deletion(-) | | diff --git a/one b/one -| index 5626abf..9d7e69f 100644 +| index BEFORE..AFTER 100644 | --- a/one | +++ b/one | @@ -1 +1 @@ @@ -1189,30 +1201,15 @@ cat >expect <<\EOF diff --git a/one b/one new file mode 100644 - index 0000000..5626abf + index BEFORE..AFTER --- /dev/null +++ b/one @@ -0,0 +1 @@ +one EOF -sanitize_output () { - sed -e 's/ *$//' \ - -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \ - -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \ - -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \ - -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \ - -e 's/, 0 deletions(-)//' \ - -e 's/, 0 insertions(+)//' \ - -e 's/ 1 files changed, / 1 file changed, /' \ - -e 's/, 1 deletions(-)/, 1 deletion(-)/' \ - -e 's/, 1 insertions(+)/, 1 insertion(+)/' -} - test_expect_success 'log --graph with diff and stats' ' - git log --no-renames --graph --pretty=short --stat -p >actual && - sanitize_output >actual.sanitized expect <<\EOF @@ -1232,7 +1229,7 @@ cat >expect <<\EOF *** | | *** | | diff --git a/reach.t b/reach.t *** | | new file mode 100644 -*** | | index 0000000..10c9591 +*** | | index BEFORE..AFTER *** | | --- /dev/null *** | | +++ b/reach.t *** | | @@ -0,0 +1 @@ @@ -1255,7 +1252,7 @@ cat >expect <<\EOF *** | | | *** | | | diff --git a/octopus-b.t b/octopus-b.t *** | | | new file mode 100644 -*** | | | index 0000000..d5fcad0 +*** | | | index BEFORE..AFTER *** | | | --- /dev/null *** | | | +++ b/octopus-b.t *** | | | @@ -0,0 +1 @@ @@ -1271,7 +1268,7 @@ cat >expect <<\EOF *** | | *** | | diff --git a/octopus-a.t b/octopus-a.t *** | | new file mode 100644 -*** | | index 0000000..11ee015 +*** | | index BEFORE..AFTER *** | | --- /dev/null *** | | +++ b/octopus-a.t *** | | @@ -0,0 +1 @@ @@ -1287,7 +1284,7 @@ cat >expect <<\EOF *** | *** | diff --git a/seventh.t b/seventh.t *** | new file mode 100644 -*** | index 0000000..9744ffc +*** | index BEFORE..AFTER *** | --- /dev/null *** | +++ b/seventh.t *** | @@ -0,0 +1 @@ @@ -1321,7 +1318,7 @@ cat >expect <<\EOF *** | | | | *** | | | | diff --git a/tangle-a b/tangle-a *** | | | | new file mode 100644 -*** | | | | index 0000000..7898192 +*** | | | | index BEFORE..AFTER *** | | | | --- /dev/null *** | | | | +++ b/tangle-a *** | | | | @@ -0,0 +1 @@ @@ -1343,7 +1340,7 @@ cat >expect <<\EOF *** | | | | *** | | | | diff --git a/2 b/2 *** | | | | new file mode 100644 -*** | | | | index 0000000..0cfbf08 +*** | | | | index BEFORE..AFTER *** | | | | --- /dev/null *** | | | | +++ b/2 *** | | | | @@ -0,0 +1 @@ @@ -1359,7 +1356,7 @@ cat >expect <<\EOF *** | | | | *** | | | | diff --git a/1 b/1 *** | | | | new file mode 100644 -*** | | | | index 0000000..d00491f +*** | | | | index BEFORE..AFTER *** | | | | --- /dev/null *** | | | | +++ b/1 *** | | | | @@ -0,0 +1 @@ @@ -1375,7 +1372,7 @@ cat >expect <<\EOF *** | | | | *** | | | | diff --git a/one b/one *** | | | | new file mode 100644 -*** | | | | index 0000000..9a33383 +*** | | | | index BEFORE..AFTER *** | | | | --- /dev/null *** | | | | +++ b/one *** | | | | @@ -0,0 +1 @@ @@ -1391,7 +1388,7 @@ cat >expect <<\EOF *** | | | *** | | | diff --git a/a/two b/a/two *** | | | deleted file mode 100644 -*** | | | index 9245af5..0000000 +*** | | | index BEFORE..AFTER *** | | | --- a/a/two *** | | | +++ /dev/null *** | | | @@ -1 +0,0 @@ @@ -1407,7 +1404,7 @@ cat >expect <<\EOF *** | | | *** | | | diff --git a/a/two b/a/two *** | | | new file mode 100644 -*** | | | index 0000000..9245af5 +*** | | | index BEFORE..AFTER *** | | | --- /dev/null *** | | | +++ b/a/two *** | | | @@ -0,0 +1 @@ @@ -1423,7 +1420,7 @@ cat >expect <<\EOF *** | | *** | | diff --git a/ein b/ein *** | | new file mode 100644 -*** | | index 0000000..9d7e69f +*** | | index BEFORE..AFTER *** | | --- /dev/null *** | | +++ b/ein *** | | @@ -0,0 +1 @@ @@ -1440,14 +1437,14 @@ cat >expect <<\EOF *** | *** | diff --git a/ichi b/ichi *** | new file mode 100644 -*** | index 0000000..9d7e69f +*** | index BEFORE..AFTER *** | --- /dev/null *** | +++ b/ichi *** | @@ -0,0 +1 @@ *** | +ichi *** | diff --git a/one b/one *** | deleted file mode 100644 -*** | index 9d7e69f..0000000 +*** | index BEFORE..AFTER *** | --- a/one *** | +++ /dev/null *** | @@ -1 +0,0 @@ @@ -1462,7 +1459,7 @@ cat >expect <<\EOF *** | 1 file changed, 1 insertion(+), 1 deletion(-) *** | *** | diff --git a/one b/one -*** | index 5626abf..9d7e69f 100644 +*** | index BEFORE..AFTER 100644 *** | --- a/one *** | +++ b/one *** | @@ -1 +1 @@ @@ -1479,7 +1476,7 @@ cat >expect <<\EOF *** *** diff --git a/one b/one *** new file mode 100644 -*** index 0000000..5626abf +*** index BEFORE..AFTER *** --- /dev/null *** +++ b/one *** @@ -0,0 +1 @@ @@ -1487,9 +1484,7 @@ cat >expect <<\EOF EOF test_expect_success 'log --line-prefix="*** " --graph with diff and stats' ' - git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual && - sanitize_output >actual.sanitized expect <<-\EOF @@ -1511,9 +1506,7 @@ cat >expect <<-\EOF EOF test_expect_success 'log --graph with --name-status' ' - git log --graph --format=%s --name-status tangle..reach >actual && - sanitize_output actual.sanitized && - test_cmp expect actual.sanitized + test_cmp_graph --name-status tangle..reach ' cat >expect <<-\EOF @@ -1535,9 +1528,7 @@ cat >expect <<-\EOF EOF test_expect_success 'log --graph with --name-only' ' - git log --graph --format=%s --name-only tangle..reach >actual && - sanitize_output actual.sanitized && - test_cmp expect actual.sanitized + test_cmp_graph --name-only tangle..reach ' test_expect_success 'dotdot is a parent directory' ' @@ -1555,6 +1546,14 @@ test_expect_success GPG 'setup signed branch' ' git commit -S -m signed_commit ' +test_expect_success GPG 'setup signed branch with subkey' ' + test_when_finished "git reset --hard && git checkout master" && + git checkout -b signed-subkey master && + echo foo >foo && + git add foo && + git commit -SB7227189 -m signed_commit +' + test_expect_success GPGSM 'setup signed branch x509' ' test_when_finished "git reset --hard && git checkout master" && git checkout -b signed-x509 master && @@ -1565,6 +1564,18 @@ test_expect_success GPGSM 'setup signed branch x509' ' git commit -S -m signed_commit ' +test_expect_success GPGSM 'log x509 fingerprint' ' + echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect && + git log -n1 --format="%GF | %GP" signed-x509 >actual && + test_cmp expect actual +' + +test_expect_success GPGSM 'log OpenPGP fingerprint' ' + echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect && + git log -n1 --format="%GP" signed-subkey >actual && + test_cmp expect actual +' + test_expect_success GPG 'log --graph --show-signature' ' git log --graph --show-signature -n1 signed >actual && grep "^| gpg: Signature made" actual && @@ -1596,6 +1607,26 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' ' grep "^| | gpg: Good signature" actual ' +test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' ' + test_when_finished "git reset --hard && git checkout master" && + git checkout -b plain-shallow master && + echo aaa >bar && + git add bar && + git commit -m bar_commit && + git checkout --detach master && + echo bbb >baz && + git add baz && + git commit -m baz_commit && + git tag -s -m signed_tag_msg signed_tag_shallow && + hash=$(git rev-parse HEAD) && + git checkout plain-shallow && + git merge --no-ff -m msg signed_tag_shallow && + git clone --depth 1 --no-local . shallow && + test_when_finished "rm -rf shallow" && + git -C shallow log --graph --show-signature -n1 plain-shallow >actual && + grep "tag signed_tag_shallow names a non-parent $hash" actual +' + test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' ' test_when_finished "git reset --hard && git checkout master" && test_config gpg.format x509 && @@ -1674,10 +1705,10 @@ test_expect_success 'set up --source tests' ' ' test_expect_success 'log --source paints branch names' ' - cat >expect <<-\EOF && - 09e12a9 source-b three - 8e393e1 source-a two - 1ac6c77 source-b one + cat >expect <<-EOF && + $(git rev-parse --short :/three) source-b three + $(git rev-parse --short :/two ) source-a two + $(git rev-parse --short :/one ) source-b one EOF git log --oneline --source source-a source-b >actual && test_cmp expect actual @@ -1685,19 +1716,19 @@ test_expect_success 'log --source paints branch names' ' test_expect_success 'log --source paints tag names' ' git tag -m tagged source-tag && - cat >expect <<-\EOF && - 09e12a9 source-tag three - 8e393e1 source-a two - 1ac6c77 source-tag one + cat >expect <<-EOF && + $(git rev-parse --short :/three) source-tag three + $(git rev-parse --short :/two ) source-a two + $(git rev-parse --short :/one ) source-tag one EOF git log --oneline --source source-tag source-a >actual && test_cmp expect actual ' test_expect_success 'log --source paints symmetric ranges' ' - cat >expect <<-\EOF && - 09e12a9 source-b three - 8e393e1 source-a two + cat >expect <<-EOF && + $(git rev-parse --short :/three) source-b three + $(git rev-parse --short :/two ) source-a two EOF git log --oneline --source source-a...source-b >actual && test_cmp expect actual @@ -1707,4 +1738,11 @@ test_expect_success '--exclude-promisor-objects does not BUG-crash' ' test_must_fail git log --exclude-promisor-objects source-a ' +test_expect_success 'log --end-of-options' ' + git update-ref refs/heads/--source HEAD && + git log --end-of-options --source >actual && + git log >expect && + test_cmp expect actual +' + test_done diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index 918ada69eb96..586c3a86b1d2 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -13,8 +13,8 @@ fuzz_blame () { } test_expect_success setup ' - cat >contacts <<-\EOF && - A U Thor + cat >contacts <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 EOF @@ -33,19 +33,19 @@ test_expect_success 'check-mailmap no arguments' ' ' test_expect_success 'check-mailmap arguments' ' - cat >expect <<-\EOF && - A U Thor + cat >expect <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 EOF git check-mailmap \ - "A U Thor " \ + "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" \ "nick1 " >actual && test_cmp expect actual ' test_expect_success 'check-mailmap --stdin' ' - cat >expect <<-\EOF && - A U Thor + cat >expect <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 EOF git check-mailmap --stdin actual && @@ -66,8 +66,8 @@ test_expect_success 'check-mailmap bogus contact' ' test_must_fail git check-mailmap bogus ' -cat >expect <<\EOF -A U Thor (1): +cat >expect << EOF +$GIT_AUTHOR_NAME (1): initial nick1 (1): @@ -90,7 +90,7 @@ nick1 (1): EOF test_expect_success 'default .mailmap' ' - echo "Repo Guy " > .mailmap && + echo "Repo Guy <$GIT_AUTHOR_EMAIL>" > .mailmap && git shortlog HEAD >actual && test_cmp expect actual ' @@ -122,7 +122,7 @@ Internal Guy (1): EOF test_expect_success 'mailmap.file override' ' - echo "External Guy " >> internal_mailmap/.mailmap && + echo "External Guy <$GIT_AUTHOR_EMAIL>" >> internal_mailmap/.mailmap && git config mailmap.file internal_mailmap/.mailmap && git shortlog HEAD >actual && test_cmp expect actual @@ -178,8 +178,8 @@ test_expect_success 'name entry after email entry, case-insensitive' ' test_cmp expect actual ' -cat >expect <<\EOF -A U Thor (1): +cat >expect << EOF +$GIT_AUTHOR_NAME (1): initial nick1 (1): @@ -195,18 +195,18 @@ test_expect_success 'No mailmap files, but configured' ' test_expect_success 'setup mailmap blob tests' ' git checkout -b map && test_when_finished "git checkout master" && - cat >just-bugs <<-\EOF && + cat >just-bugs <<- EOF && Blob Guy EOF - cat >both <<-\EOF && - Blob Guy + cat >both <<- EOF && + Blob Guy <$GIT_AUTHOR_EMAIL> Blob Guy EOF - printf "Tricky Guy " >no-newline && + printf "Tricky Guy <$GIT_AUTHOR_EMAIL>" >no-newline && git add just-bugs both no-newline && git commit -m "my mailmaps" && - echo "Repo Guy " >.mailmap && - echo "Internal Guy " >internal.map + echo "Repo Guy <$GIT_AUTHOR_EMAIL>" >.mailmap && + echo "Internal Guy <$GIT_AUTHOR_EMAIL>" >internal.map ' test_expect_success 'mailmap.blob set' ' @@ -266,12 +266,12 @@ test_expect_success 'mailmap.blob defaults to off in non-bare repo' ' git init non-bare && ( cd non-bare && - test_commit one .mailmap "Fake Name " && + test_commit one .mailmap "Fake Name <$GIT_AUTHOR_EMAIL>" && echo " 1 Fake Name" >expect && git shortlog -ns HEAD >actual && test_cmp expect actual && rm .mailmap && - echo " 1 A U Thor" >expect && + echo " 1 $GIT_AUTHOR_NAME" >expect && git shortlog -ns HEAD >actual && test_cmp expect actual ) @@ -305,26 +305,26 @@ test_expect_success 'cleanup after mailmap.blob tests' ' ' test_expect_success 'single-character name' ' - echo " 1 A " >expect && + echo " 1 A <$GIT_AUTHOR_EMAIL>" >expect && echo " 1 nick1 " >>expect && - echo "A " >.mailmap && + echo "A <$GIT_AUTHOR_EMAIL>" >.mailmap && test_when_finished "rm .mailmap" && git shortlog -es HEAD >actual && test_cmp expect actual ' test_expect_success 'preserve canonical email case' ' - echo " 1 A U Thor " >expect && + echo " 1 $GIT_AUTHOR_NAME " >expect && echo " 1 nick1 " >>expect && - echo " " >.mailmap && + echo " <$GIT_AUTHOR_EMAIL>" >.mailmap && test_when_finished "rm .mailmap" && git shortlog -es HEAD >actual && test_cmp expect actual ' # Extended mailmap configurations should give us the following output for shortlog -cat >expect <<\EOF -A U Thor (1): +cat >expect << EOF +$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1): initial CTO (1): @@ -370,7 +370,7 @@ test_expect_success 'Shortlog output (complex mapping)' ' git commit --author "CTO " -m seventh && mkdir -p internal_mailmap && - echo "Committed " > internal_mailmap/.mailmap && + echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap && echo " " >> internal_mailmap/.mailmap && echo "Some Dude nick1 " >> internal_mailmap/.mailmap && echo "Other Author nick2 " >> internal_mailmap/.mailmap && @@ -384,27 +384,27 @@ test_expect_success 'Shortlog output (complex mapping)' ' ' # git log with --pretty format which uses the name and email mailmap placemarkers -cat >expect <<\EOF +cat >expect << EOF Author CTO maps to CTO -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author claus maps to Santa Claus -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author santa maps to Santa Claus -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author nick2 maps to Other Author -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author nick2 maps to Other Author -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author nick1 maps to Some Dude -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> -Author A U Thor maps to A U Thor -Committer C O Mitter maps to Committed +Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> EOF test_expect_success 'Log output (complex mapping)' ' @@ -412,14 +412,42 @@ test_expect_success 'Log output (complex mapping)' ' test_cmp expect actual ' -cat >expect <<\EOF +cat >expect << EOF +Author email cto@coompany.xx has local-part cto +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email me@company.xx has local-part me +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email me@company.xx has local-part me +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email nick2@company.xx has local-part nick2 +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email bugs@company.xx has local-part bugs +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email bugs@company.xx has local-part bugs +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email author@example.com has local-part author +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME +EOF + +test_expect_success 'Log output (local-part email address)' ' + git log --pretty=format:"Author email %ae has local-part %al%nCommitter email %ce has local-part %cl%n" >actual && + test_cmp expect actual +' + +cat >expect << EOF Author: CTO Author: Santa Claus Author: Santa Claus Author: Other Author Author: Other Author Author: Some Dude -Author: A U Thor +Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> EOF test_expect_success 'Log output with --use-mailmap' ' @@ -427,14 +455,14 @@ test_expect_success 'Log output with --use-mailmap' ' test_cmp expect actual ' -cat >expect <<\EOF +cat >expect << EOF Author: CTO Author: Santa Claus Author: Santa Claus Author: Other Author Author: Other Author Author: Some Dude -Author: A U Thor +Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> EOF test_expect_success 'Log output with log.mailmap' ' @@ -443,28 +471,28 @@ test_expect_success 'Log output with log.mailmap' ' ' test_expect_success 'log.mailmap=false disables mailmap' ' - cat >expect <<-\EOF && + cat >expect <<- EOF && Author: CTO Author: claus Author: santa Author: nick2 Author: nick2 Author: nick1 - Author: A U Thor + Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> EOF git -c log.mailmap=False log | grep Author > actual && test_cmp expect actual ' test_expect_success '--no-use-mailmap disables mailmap' ' - cat >expect <<-\EOF && + cat >expect <<- EOF && Author: CTO Author: claus Author: santa Author: nick2 Author: nick2 Author: nick1 - Author: A U Thor + Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> EOF git log --no-use-mailmap | grep Author > actual && test_cmp expect actual @@ -500,8 +528,8 @@ test_expect_success 'Only grep replaced author with --use-mailmap' ' ' # git blame -cat >expect <<\EOF -^OBJI (A U Thor DATE 1) one +cat >expect <output && - grep "^[a-f0-9]\{40\} $(git rev-parse HEAD)$" output + grep "^$OID_REGEX $(git rev-parse HEAD)$" output ' #calculate patch id. Make sure output is not empty. diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index f42a69faa2fd..204c149d5a49 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -134,6 +134,36 @@ test_expect_failure C_LOCALE_OUTPUT 'NUL termination with --stat' ' test_cmp expected actual ' +for p in short medium full fuller email raw +do + test_expect_success "NUL termination with --reflog --pretty=$p" ' + revs="$(git rev-list --reflog)" && + for r in $revs + do + git show -s "$r" --pretty="$p" && + printf "\0" || return 1 + done >expect && + { + git log -z --reflog --pretty="$p" && + printf "\0" + } >actual && + test_cmp expect actual + ' +done + +test_expect_success 'NUL termination with --reflog --pretty=oneline' ' + revs="$(git rev-list --reflog)" && + for r in $revs + do + git show -s --pretty=oneline "$r" >raw && + cat raw | lf_to_nul || exit 1 + done >expect && + # the trailing NUL is already produced so we do not need to + # output another one + git log -z --pretty=oneline --reflog >actual && + test_cmp expect actual +' + test_expect_success 'setup more commits' ' test_commit "message one" one one message-one && test_commit "message two" two two message-two && @@ -503,6 +533,12 @@ test_expect_success 'ISO and ISO-strict date formats display the same values' ' test_cmp expected actual ' +test_expect_success 'short date' ' + git log --format=%ad%n%cd --date=short >expected && + git log --format=%as%n%cs >actual && + test_cmp expected actual +' + # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' head1=$(git rev-parse --verify HEAD~0) && @@ -640,7 +676,7 @@ test_expect_success 'pretty format %(trailers:key=foo) multiple keys' ' test_cmp expect actual ' -test_expect_success '%(trailers:key=nonexistant) becomes empty' ' +test_expect_success '%(trailers:key=nonexistent) becomes empty' ' git log --no-walk --pretty="x%(trailers:key=Nacked-by)x" >actual && echo "xx" >expect && test_cmp expect actual @@ -788,4 +824,47 @@ test_expect_success '%S in git log --format works with other placeholders (part test_cmp expect actual ' +test_expect_success 'log --pretty=reference' ' + git log --pretty="tformat:%h (%s, %as)" >expect && + git log --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference with log.date is overridden by short date' ' + git log --pretty="tformat:%h (%s, %as)" >expect && + test_config log.date rfc && + git log --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference with explicit date overrides short date' ' + git log --date=rfc --pretty="tformat:%h (%s, %ad)" >expect && + git log --date=rfc --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference is never unabbreviated' ' + git log --pretty="tformat:%h (%s, %as)" >expect && + git log --no-abbrev-commit --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference is never decorated' ' + git log --pretty="tformat:%h (%s, %as)" >expect && + git log --decorate=short --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference does not output reflog info' ' + git log --walk-reflogs --pretty="tformat:%h (%s, %as)" >expect && + git log --walk-reflogs --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference is colored appropriately' ' + git log --color=always --pretty="tformat:%C(auto)%h (%s, %as)" >expect && + git log --color=always --pretty=reference >actual && + test_cmp expect actual +' + test_done diff --git a/t/t4210-log-i18n.sh b/t/t4210-log-i18n.sh index 7c519436ef3d..c3792081e627 100755 --- a/t/t4210-log-i18n.sh +++ b/t/t4210-log-i18n.sh @@ -1,12 +1,15 @@ #!/bin/sh test_description='test log with i18n features' -. ./test-lib.sh +. ./lib-gettext.sh # two forms of é utf8_e=$(printf '\303\251') latin1_e=$(printf '\351') +# invalid UTF-8 +invalid_e=$(printf '\303\50)') # ")" at end to close opening "(" + test_expect_success 'create commits in different encodings' ' test_tick && cat >msg <<-EOF && @@ -48,9 +51,43 @@ test_expect_success !MINGW 'log --grep does not find non-reencoded values (utf8) test_must_be_empty actual ' -test_expect_success 'log --grep does not find non-reencoded values (latin1)' ' +test_expect_success !MINGW 'log --grep does not find non-reencoded values (latin1)' ' git log --encoding=ISO-8859-1 --format=%s --grep=$utf8_e >actual && test_must_be_empty actual ' +for engine in fixed basic extended perl +do + prereq= + if test $engine = "perl" + then + prereq="PCRE" + else + prereq="" + fi + force_regex= + if test $engine != "fixed" + then + force_regex=.* + fi + test_expect_success !MINGW,!REGEX_ILLSEQ,GETTEXT_LOCALE,$prereq "-c grep.patternType=$engine log --grep does not find non-reencoded values (latin1 + locale)" " + cat >expect <<-\EOF && + latin1 + utf8 + EOF + LC_ALL=\"$is_IS_locale\" git -c grep.patternType=$engine log --encoding=ISO-8859-1 --format=%s --grep=\"$force_regex$latin1_e\" >actual && + test_cmp expect actual + " + + test_expect_success !MINGW,GETTEXT_LOCALE,$prereq "-c grep.patternType=$engine log --grep does not find non-reencoded values (latin1 + locale)" " + LC_ALL=\"$is_IS_locale\" git -c grep.patternType=$engine log --encoding=ISO-8859-1 --format=%s --grep=\"$force_regex$utf8_e\" >actual && + test_must_be_empty actual + " + + test_expect_success !MINGW,!REGEX_ILLSEQ,GETTEXT_LOCALE,$prereq "-c grep.patternType=$engine log --grep does not die on invalid UTF-8 value (latin1 + locale + invalid needle)" " + LC_ALL=\"$is_IS_locale\" git -c grep.patternType=$engine log --encoding=ISO-8859-1 --format=%s --grep=\"$force_regex$invalid_e\" >actual && + test_must_be_empty actual + " +done + test_done diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh index 1db7bd0f59b4..cda58186c2d2 100755 --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@ -4,6 +4,7 @@ test_description='test log -L' . ./test-lib.sh test_expect_success 'setup (import history)' ' + test_oid_init && git fast-import < "$TEST_DIRECTORY"/t4211/history.export && git reset --hard ' @@ -11,7 +12,7 @@ test_expect_success 'setup (import history)' ' canned_test_1 () { test_expect_$1 "$2" " git log $2 >actual && - test_cmp \"\$TEST_DIRECTORY\"/t4211/expect.$3 actual + test_cmp \"\$TEST_DIRECTORY\"/t4211/$(test_oid algo)/expect.$3 actual " } @@ -132,4 +133,86 @@ test_expect_success '--raw is forbidden' ' test_must_fail git log -L1,24:b.c --raw ' +test_expect_success 'setup for checking fancy rename following' ' + git checkout --orphan moves-start && + git reset --hard && + + printf "%s\n" 12 13 14 15 b c d e >file-1 && + printf "%s\n" 22 23 24 25 B C D E >file-2 && + git add file-1 file-2 && + test_tick && + git commit -m "Add file-1 and file-2" && + oid_add_f1_f2=$(git rev-parse --short HEAD) && + + git checkout -b moves-main && + printf "%s\n" 11 12 13 14 15 b c d e >file-1 && + git commit -a -m "Modify file-1 on main" && + oid_mod_f1_main=$(git rev-parse --short HEAD) && + + printf "%s\n" 21 22 23 24 25 B C D E >file-2 && + git commit -a -m "Modify file-2 on main #1" && + oid_mod_f2_main_1=$(git rev-parse --short HEAD) && + + git mv file-1 renamed-1 && + git commit -m "Rename file-1 to renamed-1 on main" && + + printf "%s\n" 11 12 13 14 15 b c d e f >renamed-1 && + git commit -a -m "Modify renamed-1 on main" && + oid_mod_r1_main=$(git rev-parse --short HEAD) && + + printf "%s\n" 21 22 23 24 25 B C D E F >file-2 && + git commit -a -m "Modify file-2 on main #2" && + oid_mod_f2_main_2=$(git rev-parse --short HEAD) && + + git checkout -b moves-side moves-start && + printf "%s\n" 12 13 14 15 16 b c d e >file-1 && + git commit -a -m "Modify file-1 on side #1" && + oid_mod_f1_side_1=$(git rev-parse --short HEAD) && + + printf "%s\n" 22 23 24 25 26 B C D E >file-2 && + git commit -a -m "Modify file-2 on side" && + oid_mod_f2_side=$(git rev-parse --short HEAD) && + + git mv file-2 renamed-2 && + git commit -m "Rename file-2 to renamed-2 on side" && + + printf "%s\n" 12 13 14 15 16 a b c d e >file-1 && + git commit -a -m "Modify file-1 on side #2" && + oid_mod_f1_side_2=$(git rev-parse --short HEAD) && + + printf "%s\n" 22 23 24 25 26 A B C D E >renamed-2 && + git commit -a -m "Modify renamed-2 on side" && + oid_mod_r2_side=$(git rev-parse --short HEAD) && + + git checkout moves-main && + git merge moves-side && + oid_merge=$(git rev-parse --short HEAD) +' + +test_expect_success 'fancy rename following #1' ' + cat >expect <<-EOF && + $oid_merge Merge branch '\''moves-side'\'' into moves-main + $oid_mod_f1_side_2 Modify file-1 on side #2 + $oid_mod_f1_side_1 Modify file-1 on side #1 + $oid_mod_r1_main Modify renamed-1 on main + $oid_mod_f1_main Modify file-1 on main + $oid_add_f1_f2 Add file-1 and file-2 + EOF + git log -L1:renamed-1 --oneline --no-patch >actual && + test_cmp expect actual +' + +test_expect_success 'fancy rename following #2' ' + cat >expect <<-EOF && + $oid_merge Merge branch '\''moves-side'\'' into moves-main + $oid_mod_r2_side Modify renamed-2 on side + $oid_mod_f2_side Modify file-2 on side + $oid_mod_f2_main_2 Modify file-2 on main #2 + $oid_mod_f2_main_1 Modify file-2 on main #1 + $oid_add_f1_f2 Add file-1 and file-2 + EOF + git log -L1:renamed-2 --oneline --no-patch >actual && + test_cmp expect actual +' + test_done diff --git a/t/t4211/expect.beginning-of-file b/t/t4211/expect.beginning-of-file deleted file mode 100644 index 91b405489892..000000000000 --- a/t/t4211/expect.beginning-of-file +++ /dev/null @@ -1,43 +0,0 @@ -commit 4a23ae5c98d59a58c6da036156959f2dc9f472ad -Author: Thomas Rast -Date: Thu Feb 28 10:47:40 2013 +0100 - - change at very beginning - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -1,3 +1,4 @@ -+#include - #include - - long f(long x) - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -1,3 +1,3 @@ - #include - --int f(int x) -+long f(long x) - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +1,3 @@ -+#include -+ -+int f(int x) diff --git a/t/t4211/expect.end-of-file b/t/t4211/expect.end-of-file deleted file mode 100644 index bd25bb2f591f..000000000000 --- a/t/t4211/expect.end-of-file +++ /dev/null @@ -1,62 +0,0 @@ -commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 -Author: Thomas Rast -Date: Thu Feb 28 10:48:43 2013 +0100 - - change back to complete line - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -20,3 +20,5 @@ - printf("%ld\n", f(15)); - return 0; --} -\ No newline at end of file -+} -+ -+/* incomplete lines are bad! */ - -commit 100b61a6f2f720f812620a9d10afb3a960ccb73c -Author: Thomas Rast -Date: Thu Feb 28 10:48:10 2013 +0100 - - change to an incomplete line at end - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -20,3 +20,3 @@ - printf("%ld\n", f(15)); - return 0; --} -+} -\ No newline at end of file - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -19,3 +19,3 @@ -- printf("%d\n", f(15)); -+ printf("%ld\n", f(15)); - return 0; - } - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +18,3 @@ -+ printf("%d\n", f(15)); -+ return 0; -+} diff --git a/t/t4211/expect.move-support-f b/t/t4211/expect.move-support-f deleted file mode 100644 index c905e01bc25c..000000000000 --- a/t/t4211/expect.move-support-f +++ /dev/null @@ -1,80 +0,0 @@ -commit 6ce3c4ff690136099bb17e1a8766b75764726ea7 -Author: Thomas Rast -Date: Thu Feb 28 10:49:50 2013 +0100 - - another simple change - -diff --git a/b.c b/b.c ---- a/b.c -+++ b/b.c -@@ -4,9 +4,9 @@ - long f(long x) - { - int s = 0; - while (x) { -- x >>= 1; -+ x /= 2; - s++; - } - return s; - } - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,9 +3,9 @@ --int f(int x) -+long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - -commit f04fb20f2c77850996cba739709acc6faecc58f7 -Author: Thomas Rast -Date: Thu Feb 28 10:44:55 2013 +0100 - - change f() - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,8 +3,9 @@ - int f(int x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } -+ return s; - } - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +3,8 @@ -+int f(int x) -+{ -+ int s = 0; -+ while (x) { -+ x >>= 1; -+ s++; -+ } -+} diff --git a/t/t4211/expect.multiple b/t/t4211/expect.multiple deleted file mode 100644 index 76ad5b598cb8..000000000000 --- a/t/t4211/expect.multiple +++ /dev/null @@ -1,104 +0,0 @@ -commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 -Author: Thomas Rast -Date: Thu Feb 28 10:48:43 2013 +0100 - - change back to complete line - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -18,5 +18,7 @@ - int main () - { - printf("%ld\n", f(15)); - return 0; --} -\ No newline at end of file -+} -+ -+/* incomplete lines are bad! */ - -commit 100b61a6f2f720f812620a9d10afb3a960ccb73c -Author: Thomas Rast -Date: Thu Feb 28 10:48:10 2013 +0100 - - change to an incomplete line at end - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -18,5 +18,5 @@ - int main () - { - printf("%ld\n", f(15)); - return 0; --} -+} -\ No newline at end of file - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,9 +3,9 @@ --int f(int x) -+long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } -@@ -17,5 +17,5 @@ - int main () - { -- printf("%d\n", f(15)); -+ printf("%ld\n", f(15)); - return 0; - } - -commit f04fb20f2c77850996cba739709acc6faecc58f7 -Author: Thomas Rast -Date: Thu Feb 28 10:44:55 2013 +0100 - - change f() - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,8 +3,9 @@ - int f(int x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } -+ return s; - } - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +3,8 @@ -+int f(int x) -+{ -+ int s = 0; -+ while (x) { -+ x >>= 1; -+ s++; -+ } -+} diff --git a/t/t4211/expect.multiple-overlapping b/t/t4211/expect.multiple-overlapping deleted file mode 100644 index d930b6eec4c4..000000000000 --- a/t/t4211/expect.multiple-overlapping +++ /dev/null @@ -1,187 +0,0 @@ -commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 -Author: Thomas Rast -Date: Thu Feb 28 10:48:43 2013 +0100 - - change back to complete line - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -4,19 +4,21 @@ - long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* - * This is only an example! - */ - - int main () - { - printf("%ld\n", f(15)); - return 0; --} -\ No newline at end of file -+} -+ -+/* incomplete lines are bad! */ - -commit 100b61a6f2f720f812620a9d10afb3a960ccb73c -Author: Thomas Rast -Date: Thu Feb 28 10:48:10 2013 +0100 - - change to an incomplete line at end - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -4,19 +4,19 @@ - long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* - * This is only an example! - */ - - int main () - { - printf("%ld\n", f(15)); - return 0; --} -+} -\ No newline at end of file - -commit 39b6eb2d5b706d3322184a169f666f25ed3fbd00 -Author: Thomas Rast -Date: Thu Feb 28 10:45:41 2013 +0100 - - touch comment - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,19 +3,19 @@ - long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* -- * A comment. -+ * This is only an example! - */ - - int main () - { - printf("%ld\n", f(15)); - return 0; - } - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,19 +3,19 @@ --int f(int x) -+long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* - * A comment. - */ - - int main () - { -- printf("%d\n", f(15)); -+ printf("%ld\n", f(15)); - return 0; - } - -commit f04fb20f2c77850996cba739709acc6faecc58f7 -Author: Thomas Rast -Date: Thu Feb 28 10:44:55 2013 +0100 - - change f() - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,18 +3,19 @@ - int f(int x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } -+ return s; - } - - /* - * A comment. - */ - - int main () - { - printf("%d\n", f(15)); - return 0; - } - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +3,18 @@ -+int f(int x) -+{ -+ int s = 0; -+ while (x) { -+ x >>= 1; -+ s++; -+ } -+} -+ -+/* -+ * A comment. -+ */ -+ -+int main () -+{ -+ printf("%d\n", f(15)); -+ return 0; -+} diff --git a/t/t4211/expect.multiple-superset b/t/t4211/expect.multiple-superset deleted file mode 100644 index d930b6eec4c4..000000000000 --- a/t/t4211/expect.multiple-superset +++ /dev/null @@ -1,187 +0,0 @@ -commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 -Author: Thomas Rast -Date: Thu Feb 28 10:48:43 2013 +0100 - - change back to complete line - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -4,19 +4,21 @@ - long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* - * This is only an example! - */ - - int main () - { - printf("%ld\n", f(15)); - return 0; --} -\ No newline at end of file -+} -+ -+/* incomplete lines are bad! */ - -commit 100b61a6f2f720f812620a9d10afb3a960ccb73c -Author: Thomas Rast -Date: Thu Feb 28 10:48:10 2013 +0100 - - change to an incomplete line at end - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -4,19 +4,19 @@ - long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* - * This is only an example! - */ - - int main () - { - printf("%ld\n", f(15)); - return 0; --} -+} -\ No newline at end of file - -commit 39b6eb2d5b706d3322184a169f666f25ed3fbd00 -Author: Thomas Rast -Date: Thu Feb 28 10:45:41 2013 +0100 - - touch comment - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,19 +3,19 @@ - long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* -- * A comment. -+ * This is only an example! - */ - - int main () - { - printf("%ld\n", f(15)); - return 0; - } - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,19 +3,19 @@ --int f(int x) -+long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* - * A comment. - */ - - int main () - { -- printf("%d\n", f(15)); -+ printf("%ld\n", f(15)); - return 0; - } - -commit f04fb20f2c77850996cba739709acc6faecc58f7 -Author: Thomas Rast -Date: Thu Feb 28 10:44:55 2013 +0100 - - change f() - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,18 +3,19 @@ - int f(int x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } -+ return s; - } - - /* - * A comment. - */ - - int main () - { - printf("%d\n", f(15)); - return 0; - } - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +3,18 @@ -+int f(int x) -+{ -+ int s = 0; -+ while (x) { -+ x >>= 1; -+ s++; -+ } -+} -+ -+/* -+ * A comment. -+ */ -+ -+int main () -+{ -+ printf("%d\n", f(15)); -+ return 0; -+} diff --git a/t/t4211/expect.parallel-change-f-to-main b/t/t4211/expect.parallel-change-f-to-main deleted file mode 100644 index 052def8074da..000000000000 --- a/t/t4211/expect.parallel-change-f-to-main +++ /dev/null @@ -1,160 +0,0 @@ -commit 0469c60bc4837d52d97b1f081dec5f98dea20fed -Merge: ba227c6 6ce3c4f -Author: Thomas Rast -Date: Fri Apr 12 16:16:24 2013 +0200 - - Merge across the rename - - -commit 6ce3c4ff690136099bb17e1a8766b75764726ea7 -Author: Thomas Rast -Date: Thu Feb 28 10:49:50 2013 +0100 - - another simple change - -diff --git a/b.c b/b.c ---- a/b.c -+++ b/b.c -@@ -4,14 +4,14 @@ - long f(long x) - { - int s = 0; - while (x) { -- x >>= 1; -+ x /= 2; - s++; - } - return s; - } - - /* - * This is only an example! - */ - - -commit ba227c6632349700fbb957dec2b50f5e2358be3f -Author: Thomas Rast -Date: Fri Apr 12 16:15:57 2013 +0200 - - change on another line of history while rename happens - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -4,14 +4,14 @@ - long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* -- * This is only an example! -+ * This is only a short example! - */ - - -commit 39b6eb2d5b706d3322184a169f666f25ed3fbd00 -Author: Thomas Rast -Date: Thu Feb 28 10:45:41 2013 +0100 - - touch comment - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,14 +3,14 @@ - long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* -- * A comment. -+ * This is only an example! - */ - - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,14 +3,14 @@ --int f(int x) -+long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* - * A comment. - */ - - -commit f04fb20f2c77850996cba739709acc6faecc58f7 -Author: Thomas Rast -Date: Thu Feb 28 10:44:55 2013 +0100 - - change f() - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,13 +3,14 @@ - int f(int x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } -+ return s; - } - - /* - * A comment. - */ - - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +3,13 @@ -+int f(int x) -+{ -+ int s = 0; -+ while (x) { -+ x >>= 1; -+ s++; -+ } -+} -+ -+/* -+ * A comment. -+ */ -+ diff --git a/t/t4211/expect.simple-f b/t/t4211/expect.simple-f deleted file mode 100644 index a1f5bc49c879..000000000000 --- a/t/t4211/expect.simple-f +++ /dev/null @@ -1,59 +0,0 @@ -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,9 +3,9 @@ --int f(int x) -+long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - -commit f04fb20f2c77850996cba739709acc6faecc58f7 -Author: Thomas Rast -Date: Thu Feb 28 10:44:55 2013 +0100 - - change f() - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,8 +3,9 @@ - int f(int x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } -+ return s; - } - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +3,8 @@ -+int f(int x) -+{ -+ int s = 0; -+ while (x) { -+ x >>= 1; -+ s++; -+ } -+} diff --git a/t/t4211/expect.simple-f-to-main b/t/t4211/expect.simple-f-to-main deleted file mode 100644 index a475768710b5..000000000000 --- a/t/t4211/expect.simple-f-to-main +++ /dev/null @@ -1,100 +0,0 @@ -commit 39b6eb2d5b706d3322184a169f666f25ed3fbd00 -Author: Thomas Rast -Date: Thu Feb 28 10:45:41 2013 +0100 - - touch comment - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,14 +3,14 @@ - long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* -- * A comment. -+ * This is only an example! - */ - - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,14 +3,14 @@ --int f(int x) -+long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } - - /* - * A comment. - */ - - -commit f04fb20f2c77850996cba739709acc6faecc58f7 -Author: Thomas Rast -Date: Thu Feb 28 10:44:55 2013 +0100 - - change f() - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,13 +3,14 @@ - int f(int x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } -+ return s; - } - - /* - * A comment. - */ - - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +3,13 @@ -+int f(int x) -+{ -+ int s = 0; -+ while (x) { -+ x >>= 1; -+ s++; -+ } -+} -+ -+/* -+ * A comment. -+ */ -+ diff --git a/t/t4211/expect.simple-main b/t/t4211/expect.simple-main deleted file mode 100644 index 39ce39bebed7..000000000000 --- a/t/t4211/expect.simple-main +++ /dev/null @@ -1,68 +0,0 @@ -commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 -Author: Thomas Rast -Date: Thu Feb 28 10:48:43 2013 +0100 - - change back to complete line - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -18,5 +18,5 @@ - int main () - { - printf("%ld\n", f(15)); - return 0; --} -\ No newline at end of file -+} - -commit 100b61a6f2f720f812620a9d10afb3a960ccb73c -Author: Thomas Rast -Date: Thu Feb 28 10:48:10 2013 +0100 - - change to an incomplete line at end - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -18,5 +18,5 @@ - int main () - { - printf("%ld\n", f(15)); - return 0; --} -+} -\ No newline at end of file - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -17,5 +17,5 @@ - int main () - { -- printf("%d\n", f(15)); -+ printf("%ld\n", f(15)); - return 0; - } - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +16,5 @@ -+int main () -+{ -+ printf("%d\n", f(15)); -+ return 0; -+} diff --git a/t/t4211/expect.simple-main-to-end b/t/t4211/expect.simple-main-to-end deleted file mode 100644 index 8480bd9cc45b..000000000000 --- a/t/t4211/expect.simple-main-to-end +++ /dev/null @@ -1,70 +0,0 @@ -commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 -Author: Thomas Rast -Date: Thu Feb 28 10:48:43 2013 +0100 - - change back to complete line - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -18,5 +18,7 @@ - int main () - { - printf("%ld\n", f(15)); - return 0; --} -\ No newline at end of file -+} -+ -+/* incomplete lines are bad! */ - -commit 100b61a6f2f720f812620a9d10afb3a960ccb73c -Author: Thomas Rast -Date: Thu Feb 28 10:48:10 2013 +0100 - - change to an incomplete line at end - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -18,5 +18,5 @@ - int main () - { - printf("%ld\n", f(15)); - return 0; --} -+} -\ No newline at end of file - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -17,5 +17,5 @@ - int main () - { -- printf("%d\n", f(15)); -+ printf("%ld\n", f(15)); - return 0; - } - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +16,5 @@ -+int main () -+{ -+ printf("%d\n", f(15)); -+ return 0; -+} diff --git a/t/t4211/expect.two-ranges b/t/t4211/expect.two-ranges deleted file mode 100644 index 6109aa0dcee7..000000000000 --- a/t/t4211/expect.two-ranges +++ /dev/null @@ -1,102 +0,0 @@ -commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 -Author: Thomas Rast -Date: Thu Feb 28 10:48:43 2013 +0100 - - change back to complete line - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -18,5 +18,5 @@ - int main () - { - printf("%ld\n", f(15)); - return 0; --} -\ No newline at end of file -+} - -commit 100b61a6f2f720f812620a9d10afb3a960ccb73c -Author: Thomas Rast -Date: Thu Feb 28 10:48:10 2013 +0100 - - change to an incomplete line at end - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -18,5 +18,5 @@ - int main () - { - printf("%ld\n", f(15)); - return 0; --} -+} -\ No newline at end of file - -commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 -Author: Thomas Rast -Date: Thu Feb 28 10:45:16 2013 +0100 - - touch both functions - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,9 +3,9 @@ --int f(int x) -+long f(long x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } - return s; - } -@@ -17,5 +17,5 @@ - int main () - { -- printf("%d\n", f(15)); -+ printf("%ld\n", f(15)); - return 0; - } - -commit f04fb20f2c77850996cba739709acc6faecc58f7 -Author: Thomas Rast -Date: Thu Feb 28 10:44:55 2013 +0100 - - change f() - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -3,8 +3,9 @@ - int f(int x) - { - int s = 0; - while (x) { - x >>= 1; - s++; - } -+ return s; - } - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +3,8 @@ -+int f(int x) -+{ -+ int s = 0; -+ while (x) { -+ x >>= 1; -+ s++; -+ } -+} diff --git a/t/t4211/expect.vanishes-early b/t/t4211/expect.vanishes-early deleted file mode 100644 index 1f7cd0694149..000000000000 --- a/t/t4211/expect.vanishes-early +++ /dev/null @@ -1,39 +0,0 @@ -commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 -Author: Thomas Rast -Date: Thu Feb 28 10:48:43 2013 +0100 - - change back to complete line - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -22,1 +24,1 @@ --} -\ No newline at end of file -+/* incomplete lines are bad! */ - -commit 100b61a6f2f720f812620a9d10afb3a960ccb73c -Author: Thomas Rast -Date: Thu Feb 28 10:48:10 2013 +0100 - - change to an incomplete line at end - -diff --git a/a.c b/a.c ---- a/a.c -+++ b/a.c -@@ -22,1 +22,1 @@ --} -+} -\ No newline at end of file - -commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a -Author: Thomas Rast -Date: Thu Feb 28 10:44:48 2013 +0100 - - initial - -diff --git a/a.c b/a.c ---- /dev/null -+++ b/a.c -@@ -0,0 +20,1 @@ -+} diff --git a/t/t4211/sha1/expect.beginning-of-file b/t/t4211/sha1/expect.beginning-of-file new file mode 100644 index 000000000000..91b405489892 --- /dev/null +++ b/t/t4211/sha1/expect.beginning-of-file @@ -0,0 +1,43 @@ +commit 4a23ae5c98d59a58c6da036156959f2dc9f472ad +Author: Thomas Rast +Date: Thu Feb 28 10:47:40 2013 +0100 + + change at very beginning + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -1,3 +1,4 @@ ++#include + #include + + long f(long x) + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -1,3 +1,3 @@ + #include + +-int f(int x) ++long f(long x) + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +1,3 @@ ++#include ++ ++int f(int x) diff --git a/t/t4211/sha1/expect.end-of-file b/t/t4211/sha1/expect.end-of-file new file mode 100644 index 000000000000..bd25bb2f591f --- /dev/null +++ b/t/t4211/sha1/expect.end-of-file @@ -0,0 +1,62 @@ +commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -20,3 +20,5 @@ + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} ++ ++/* incomplete lines are bad! */ + +commit 100b61a6f2f720f812620a9d10afb3a960ccb73c +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -20,3 +20,3 @@ + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -19,3 +19,3 @@ +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +18,3 @@ ++ printf("%d\n", f(15)); ++ return 0; ++} diff --git a/t/t4211/sha1/expect.move-support-f b/t/t4211/sha1/expect.move-support-f new file mode 100644 index 000000000000..c905e01bc25c --- /dev/null +++ b/t/t4211/sha1/expect.move-support-f @@ -0,0 +1,80 @@ +commit 6ce3c4ff690136099bb17e1a8766b75764726ea7 +Author: Thomas Rast +Date: Thu Feb 28 10:49:50 2013 +0100 + + another simple change + +diff --git a/b.c b/b.c +--- a/b.c ++++ b/b.c +@@ -4,9 +4,9 @@ + long f(long x) + { + int s = 0; + while (x) { +- x >>= 1; ++ x /= 2; + s++; + } + return s; + } + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,9 +3,9 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + +commit f04fb20f2c77850996cba739709acc6faecc58f7 +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,8 +3,9 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,8 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} diff --git a/t/t4211/sha1/expect.multiple b/t/t4211/sha1/expect.multiple new file mode 100644 index 000000000000..76ad5b598cb8 --- /dev/null +++ b/t/t4211/sha1/expect.multiple @@ -0,0 +1,104 @@ +commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,7 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} ++ ++/* incomplete lines are bad! */ + +commit 100b61a6f2f720f812620a9d10afb3a960ccb73c +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,9 +3,9 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } +@@ -17,5 +17,5 @@ + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit f04fb20f2c77850996cba739709acc6faecc58f7 +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,8 +3,9 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,8 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} diff --git a/t/t4211/sha1/expect.multiple-overlapping b/t/t4211/sha1/expect.multiple-overlapping new file mode 100644 index 000000000000..d930b6eec4c4 --- /dev/null +++ b/t/t4211/sha1/expect.multiple-overlapping @@ -0,0 +1,187 @@ +commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -4,19 +4,21 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} ++ ++/* incomplete lines are bad! */ + +commit 100b61a6f2f720f812620a9d10afb3a960ccb73c +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -4,19 +4,19 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit 39b6eb2d5b706d3322184a169f666f25ed3fbd00 +Author: Thomas Rast +Date: Thu Feb 28 10:45:41 2013 +0100 + + touch comment + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,19 +3,19 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* +- * A comment. ++ * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; + } + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,19 +3,19 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * A comment. + */ + + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit f04fb20f2c77850996cba739709acc6faecc58f7 +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,18 +3,19 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + + /* + * A comment. + */ + + int main () + { + printf("%d\n", f(15)); + return 0; + } + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,18 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} ++ ++/* ++ * A comment. ++ */ ++ ++int main () ++{ ++ printf("%d\n", f(15)); ++ return 0; ++} diff --git a/t/t4211/sha1/expect.multiple-superset b/t/t4211/sha1/expect.multiple-superset new file mode 100644 index 000000000000..d930b6eec4c4 --- /dev/null +++ b/t/t4211/sha1/expect.multiple-superset @@ -0,0 +1,187 @@ +commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -4,19 +4,21 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} ++ ++/* incomplete lines are bad! */ + +commit 100b61a6f2f720f812620a9d10afb3a960ccb73c +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -4,19 +4,19 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit 39b6eb2d5b706d3322184a169f666f25ed3fbd00 +Author: Thomas Rast +Date: Thu Feb 28 10:45:41 2013 +0100 + + touch comment + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,19 +3,19 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* +- * A comment. ++ * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; + } + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,19 +3,19 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * A comment. + */ + + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit f04fb20f2c77850996cba739709acc6faecc58f7 +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,18 +3,19 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + + /* + * A comment. + */ + + int main () + { + printf("%d\n", f(15)); + return 0; + } + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,18 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} ++ ++/* ++ * A comment. ++ */ ++ ++int main () ++{ ++ printf("%d\n", f(15)); ++ return 0; ++} diff --git a/t/t4211/sha1/expect.parallel-change-f-to-main b/t/t4211/sha1/expect.parallel-change-f-to-main new file mode 100644 index 000000000000..052def8074da --- /dev/null +++ b/t/t4211/sha1/expect.parallel-change-f-to-main @@ -0,0 +1,160 @@ +commit 0469c60bc4837d52d97b1f081dec5f98dea20fed +Merge: ba227c6 6ce3c4f +Author: Thomas Rast +Date: Fri Apr 12 16:16:24 2013 +0200 + + Merge across the rename + + +commit 6ce3c4ff690136099bb17e1a8766b75764726ea7 +Author: Thomas Rast +Date: Thu Feb 28 10:49:50 2013 +0100 + + another simple change + +diff --git a/b.c b/b.c +--- a/b.c ++++ b/b.c +@@ -4,14 +4,14 @@ + long f(long x) + { + int s = 0; + while (x) { +- x >>= 1; ++ x /= 2; + s++; + } + return s; + } + + /* + * This is only an example! + */ + + +commit ba227c6632349700fbb957dec2b50f5e2358be3f +Author: Thomas Rast +Date: Fri Apr 12 16:15:57 2013 +0200 + + change on another line of history while rename happens + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -4,14 +4,14 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* +- * This is only an example! ++ * This is only a short example! + */ + + +commit 39b6eb2d5b706d3322184a169f666f25ed3fbd00 +Author: Thomas Rast +Date: Thu Feb 28 10:45:41 2013 +0100 + + touch comment + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,14 +3,14 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* +- * A comment. ++ * This is only an example! + */ + + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,14 +3,14 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * A comment. + */ + + +commit f04fb20f2c77850996cba739709acc6faecc58f7 +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,13 +3,14 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + + /* + * A comment. + */ + + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,13 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} ++ ++/* ++ * A comment. ++ */ ++ diff --git a/t/t4211/sha1/expect.simple-f b/t/t4211/sha1/expect.simple-f new file mode 100644 index 000000000000..a1f5bc49c879 --- /dev/null +++ b/t/t4211/sha1/expect.simple-f @@ -0,0 +1,59 @@ +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,9 +3,9 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + +commit f04fb20f2c77850996cba739709acc6faecc58f7 +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,8 +3,9 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,8 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} diff --git a/t/t4211/sha1/expect.simple-f-to-main b/t/t4211/sha1/expect.simple-f-to-main new file mode 100644 index 000000000000..a475768710b5 --- /dev/null +++ b/t/t4211/sha1/expect.simple-f-to-main @@ -0,0 +1,100 @@ +commit 39b6eb2d5b706d3322184a169f666f25ed3fbd00 +Author: Thomas Rast +Date: Thu Feb 28 10:45:41 2013 +0100 + + touch comment + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,14 +3,14 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* +- * A comment. ++ * This is only an example! + */ + + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,14 +3,14 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * A comment. + */ + + +commit f04fb20f2c77850996cba739709acc6faecc58f7 +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,13 +3,14 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + + /* + * A comment. + */ + + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,13 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} ++ ++/* ++ * A comment. ++ */ ++ diff --git a/t/t4211/sha1/expect.simple-main b/t/t4211/sha1/expect.simple-main new file mode 100644 index 000000000000..39ce39bebed7 --- /dev/null +++ b/t/t4211/sha1/expect.simple-main @@ -0,0 +1,68 @@ +commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} + +commit 100b61a6f2f720f812620a9d10afb3a960ccb73c +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -17,5 +17,5 @@ + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +16,5 @@ ++int main () ++{ ++ printf("%d\n", f(15)); ++ return 0; ++} diff --git a/t/t4211/sha1/expect.simple-main-to-end b/t/t4211/sha1/expect.simple-main-to-end new file mode 100644 index 000000000000..8480bd9cc45b --- /dev/null +++ b/t/t4211/sha1/expect.simple-main-to-end @@ -0,0 +1,70 @@ +commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,7 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} ++ ++/* incomplete lines are bad! */ + +commit 100b61a6f2f720f812620a9d10afb3a960ccb73c +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -17,5 +17,5 @@ + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +16,5 @@ ++int main () ++{ ++ printf("%d\n", f(15)); ++ return 0; ++} diff --git a/t/t4211/sha1/expect.two-ranges b/t/t4211/sha1/expect.two-ranges new file mode 100644 index 000000000000..6109aa0dcee7 --- /dev/null +++ b/t/t4211/sha1/expect.two-ranges @@ -0,0 +1,102 @@ +commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} + +commit 100b61a6f2f720f812620a9d10afb3a960ccb73c +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2 +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,9 +3,9 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } +@@ -17,5 +17,5 @@ + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit f04fb20f2c77850996cba739709acc6faecc58f7 +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,8 +3,9 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,8 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} diff --git a/t/t4211/sha1/expect.vanishes-early b/t/t4211/sha1/expect.vanishes-early new file mode 100644 index 000000000000..1f7cd0694149 --- /dev/null +++ b/t/t4211/sha1/expect.vanishes-early @@ -0,0 +1,39 @@ +commit 4659538844daa2849b1a9e7d6fadb96fcd26fc83 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -22,1 +24,1 @@ +-} +\ No newline at end of file ++/* incomplete lines are bad! */ + +commit 100b61a6f2f720f812620a9d10afb3a960ccb73c +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -22,1 +22,1 @@ +-} ++} +\ No newline at end of file + +commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +20,1 @@ ++} diff --git a/t/t4211/sha256/expect.beginning-of-file b/t/t4211/sha256/expect.beginning-of-file new file mode 100644 index 000000000000..5adfdfc1a120 --- /dev/null +++ b/t/t4211/sha256/expect.beginning-of-file @@ -0,0 +1,43 @@ +commit 62a40b38fa4f00800004aee81ef287b7201317594ebcb990f38cbe493b01d200 +Author: Thomas Rast +Date: Thu Feb 28 10:47:40 2013 +0100 + + change at very beginning + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -1,3 +1,4 @@ ++#include + #include + + long f(long x) + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -1,3 +1,3 @@ + #include + +-int f(int x) ++long f(long x) + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +1,3 @@ ++#include ++ ++int f(int x) diff --git a/t/t4211/sha256/expect.end-of-file b/t/t4211/sha256/expect.end-of-file new file mode 100644 index 000000000000..03ab5c1784e2 --- /dev/null +++ b/t/t4211/sha256/expect.end-of-file @@ -0,0 +1,62 @@ +commit 5526ed05c2476b56af8b7be499e8f78bd50f490740733a9ca7e1f55878fa90a9 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -20,3 +20,5 @@ + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} ++ ++/* incomplete lines are bad! */ + +commit 29f32ac3141c48b22803e5c4127b719917b67d0f8ca8c5248bebfa2a19f7da10 +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -20,3 +20,3 @@ + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -19,3 +19,3 @@ +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +18,3 @@ ++ printf("%d\n", f(15)); ++ return 0; ++} diff --git a/t/t4211/sha256/expect.move-support-f b/t/t4211/sha256/expect.move-support-f new file mode 100644 index 000000000000..223b4ed2a0cf --- /dev/null +++ b/t/t4211/sha256/expect.move-support-f @@ -0,0 +1,80 @@ +commit 4f7a58195a92c400e28a2354328587f1ff14fb77f5cf894536f17ccbc72931b9 +Author: Thomas Rast +Date: Thu Feb 28 10:49:50 2013 +0100 + + another simple change + +diff --git a/b.c b/b.c +--- a/b.c ++++ b/b.c +@@ -4,9 +4,9 @@ + long f(long x) + { + int s = 0; + while (x) { +- x >>= 1; ++ x /= 2; + s++; + } + return s; + } + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,9 +3,9 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + +commit f6434acd34260a6c9f61e96d96bf9a323d330561df5b1ca2631104f82026dfed +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,8 +3,9 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,8 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} diff --git a/t/t4211/sha256/expect.multiple b/t/t4211/sha256/expect.multiple new file mode 100644 index 000000000000..ca00409b9a39 --- /dev/null +++ b/t/t4211/sha256/expect.multiple @@ -0,0 +1,104 @@ +commit 5526ed05c2476b56af8b7be499e8f78bd50f490740733a9ca7e1f55878fa90a9 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,7 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} ++ ++/* incomplete lines are bad! */ + +commit 29f32ac3141c48b22803e5c4127b719917b67d0f8ca8c5248bebfa2a19f7da10 +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,9 +3,9 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } +@@ -17,5 +17,5 @@ + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit f6434acd34260a6c9f61e96d96bf9a323d330561df5b1ca2631104f82026dfed +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,8 +3,9 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,8 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} diff --git a/t/t4211/sha256/expect.multiple-overlapping b/t/t4211/sha256/expect.multiple-overlapping new file mode 100644 index 000000000000..9015a45a256f --- /dev/null +++ b/t/t4211/sha256/expect.multiple-overlapping @@ -0,0 +1,187 @@ +commit 5526ed05c2476b56af8b7be499e8f78bd50f490740733a9ca7e1f55878fa90a9 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -4,19 +4,21 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} ++ ++/* incomplete lines are bad! */ + +commit 29f32ac3141c48b22803e5c4127b719917b67d0f8ca8c5248bebfa2a19f7da10 +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -4,19 +4,19 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit 5a1b3989063d55e71e7685efa3392f133385b4034bddde530dcb5090d8b8b8ca +Author: Thomas Rast +Date: Thu Feb 28 10:45:41 2013 +0100 + + touch comment + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,19 +3,19 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* +- * A comment. ++ * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; + } + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,19 +3,19 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * A comment. + */ + + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit f6434acd34260a6c9f61e96d96bf9a323d330561df5b1ca2631104f82026dfed +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,18 +3,19 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + + /* + * A comment. + */ + + int main () + { + printf("%d\n", f(15)); + return 0; + } + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,18 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} ++ ++/* ++ * A comment. ++ */ ++ ++int main () ++{ ++ printf("%d\n", f(15)); ++ return 0; ++} diff --git a/t/t4211/sha256/expect.multiple-superset b/t/t4211/sha256/expect.multiple-superset new file mode 100644 index 000000000000..9015a45a256f --- /dev/null +++ b/t/t4211/sha256/expect.multiple-superset @@ -0,0 +1,187 @@ +commit 5526ed05c2476b56af8b7be499e8f78bd50f490740733a9ca7e1f55878fa90a9 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -4,19 +4,21 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} ++ ++/* incomplete lines are bad! */ + +commit 29f32ac3141c48b22803e5c4127b719917b67d0f8ca8c5248bebfa2a19f7da10 +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -4,19 +4,19 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit 5a1b3989063d55e71e7685efa3392f133385b4034bddde530dcb5090d8b8b8ca +Author: Thomas Rast +Date: Thu Feb 28 10:45:41 2013 +0100 + + touch comment + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,19 +3,19 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* +- * A comment. ++ * This is only an example! + */ + + int main () + { + printf("%ld\n", f(15)); + return 0; + } + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,19 +3,19 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * A comment. + */ + + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit f6434acd34260a6c9f61e96d96bf9a323d330561df5b1ca2631104f82026dfed +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,18 +3,19 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + + /* + * A comment. + */ + + int main () + { + printf("%d\n", f(15)); + return 0; + } + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,18 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} ++ ++/* ++ * A comment. ++ */ ++ ++int main () ++{ ++ printf("%d\n", f(15)); ++ return 0; ++} diff --git a/t/t4211/sha256/expect.parallel-change-f-to-main b/t/t4211/sha256/expect.parallel-change-f-to-main new file mode 100644 index 000000000000..e68f8928ea70 --- /dev/null +++ b/t/t4211/sha256/expect.parallel-change-f-to-main @@ -0,0 +1,160 @@ +commit 98117c2059b76c36995748fb97b02542aef477fe26379e94c18fd70f7790bc67 +Merge: b511694 4f7a581 +Author: Thomas Rast +Date: Fri Apr 12 16:16:24 2013 +0200 + + Merge across the rename + + +commit 4f7a58195a92c400e28a2354328587f1ff14fb77f5cf894536f17ccbc72931b9 +Author: Thomas Rast +Date: Thu Feb 28 10:49:50 2013 +0100 + + another simple change + +diff --git a/b.c b/b.c +--- a/b.c ++++ b/b.c +@@ -4,14 +4,14 @@ + long f(long x) + { + int s = 0; + while (x) { +- x >>= 1; ++ x /= 2; + s++; + } + return s; + } + + /* + * This is only an example! + */ + + +commit b511694f5337663fbd697622993a5f8e1099eca84be4df313f2b3ee94a098b42 +Author: Thomas Rast +Date: Fri Apr 12 16:15:57 2013 +0200 + + change on another line of history while rename happens + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -4,14 +4,14 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* +- * This is only an example! ++ * This is only a short example! + */ + + +commit 5a1b3989063d55e71e7685efa3392f133385b4034bddde530dcb5090d8b8b8ca +Author: Thomas Rast +Date: Thu Feb 28 10:45:41 2013 +0100 + + touch comment + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,14 +3,14 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* +- * A comment. ++ * This is only an example! + */ + + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,14 +3,14 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * A comment. + */ + + +commit f6434acd34260a6c9f61e96d96bf9a323d330561df5b1ca2631104f82026dfed +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,13 +3,14 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + + /* + * A comment. + */ + + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,13 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} ++ ++/* ++ * A comment. ++ */ ++ diff --git a/t/t4211/sha256/expect.simple-f b/t/t4211/sha256/expect.simple-f new file mode 100644 index 000000000000..65508d7c0bc6 --- /dev/null +++ b/t/t4211/sha256/expect.simple-f @@ -0,0 +1,59 @@ +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,9 +3,9 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + +commit f6434acd34260a6c9f61e96d96bf9a323d330561df5b1ca2631104f82026dfed +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,8 +3,9 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,8 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} diff --git a/t/t4211/sha256/expect.simple-f-to-main b/t/t4211/sha256/expect.simple-f-to-main new file mode 100644 index 000000000000..77b721c196b1 --- /dev/null +++ b/t/t4211/sha256/expect.simple-f-to-main @@ -0,0 +1,100 @@ +commit 5a1b3989063d55e71e7685efa3392f133385b4034bddde530dcb5090d8b8b8ca +Author: Thomas Rast +Date: Thu Feb 28 10:45:41 2013 +0100 + + touch comment + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,14 +3,14 @@ + long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* +- * A comment. ++ * This is only an example! + */ + + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,14 +3,14 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } + + /* + * A comment. + */ + + +commit f6434acd34260a6c9f61e96d96bf9a323d330561df5b1ca2631104f82026dfed +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,13 +3,14 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + + /* + * A comment. + */ + + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,13 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} ++ ++/* ++ * A comment. ++ */ ++ diff --git a/t/t4211/sha256/expect.simple-main b/t/t4211/sha256/expect.simple-main new file mode 100644 index 000000000000..d20708c9f9a0 --- /dev/null +++ b/t/t4211/sha256/expect.simple-main @@ -0,0 +1,68 @@ +commit 5526ed05c2476b56af8b7be499e8f78bd50f490740733a9ca7e1f55878fa90a9 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} + +commit 29f32ac3141c48b22803e5c4127b719917b67d0f8ca8c5248bebfa2a19f7da10 +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -17,5 +17,5 @@ + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +16,5 @@ ++int main () ++{ ++ printf("%d\n", f(15)); ++ return 0; ++} diff --git a/t/t4211/sha256/expect.simple-main-to-end b/t/t4211/sha256/expect.simple-main-to-end new file mode 100644 index 000000000000..617cdf34819e --- /dev/null +++ b/t/t4211/sha256/expect.simple-main-to-end @@ -0,0 +1,70 @@ +commit 5526ed05c2476b56af8b7be499e8f78bd50f490740733a9ca7e1f55878fa90a9 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,7 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} ++ ++/* incomplete lines are bad! */ + +commit 29f32ac3141c48b22803e5c4127b719917b67d0f8ca8c5248bebfa2a19f7da10 +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -17,5 +17,5 @@ + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +16,5 @@ ++int main () ++{ ++ printf("%d\n", f(15)); ++ return 0; ++} diff --git a/t/t4211/sha256/expect.two-ranges b/t/t4211/sha256/expect.two-ranges new file mode 100644 index 000000000000..af57c8b99783 --- /dev/null +++ b/t/t4211/sha256/expect.two-ranges @@ -0,0 +1,102 @@ +commit 5526ed05c2476b56af8b7be499e8f78bd50f490740733a9ca7e1f55878fa90a9 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} +\ No newline at end of file ++} + +commit 29f32ac3141c48b22803e5c4127b719917b67d0f8ca8c5248bebfa2a19f7da10 +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -18,5 +18,5 @@ + int main () + { + printf("%ld\n", f(15)); + return 0; +-} ++} +\ No newline at end of file + +commit ccf97b9878189c40a981da50b15713bb80a35755326320ec80900caf22ced46f +Author: Thomas Rast +Date: Thu Feb 28 10:45:16 2013 +0100 + + touch both functions + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,9 +3,9 @@ +-int f(int x) ++long f(long x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } + return s; + } +@@ -17,5 +17,5 @@ + int main () + { +- printf("%d\n", f(15)); ++ printf("%ld\n", f(15)); + return 0; + } + +commit f6434acd34260a6c9f61e96d96bf9a323d330561df5b1ca2631104f82026dfed +Author: Thomas Rast +Date: Thu Feb 28 10:44:55 2013 +0100 + + change f() + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -3,8 +3,9 @@ + int f(int x) + { + int s = 0; + while (x) { + x >>= 1; + s++; + } ++ return s; + } + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +3,8 @@ ++int f(int x) ++{ ++ int s = 0; ++ while (x) { ++ x >>= 1; ++ s++; ++ } ++} diff --git a/t/t4211/sha256/expect.vanishes-early b/t/t4211/sha256/expect.vanishes-early new file mode 100644 index 000000000000..11ec9bdecfcc --- /dev/null +++ b/t/t4211/sha256/expect.vanishes-early @@ -0,0 +1,39 @@ +commit 5526ed05c2476b56af8b7be499e8f78bd50f490740733a9ca7e1f55878fa90a9 +Author: Thomas Rast +Date: Thu Feb 28 10:48:43 2013 +0100 + + change back to complete line + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -22,1 +24,1 @@ +-} +\ No newline at end of file ++/* incomplete lines are bad! */ + +commit 29f32ac3141c48b22803e5c4127b719917b67d0f8ca8c5248bebfa2a19f7da10 +Author: Thomas Rast +Date: Thu Feb 28 10:48:10 2013 +0100 + + change to an incomplete line at end + +diff --git a/a.c b/a.c +--- a/a.c ++++ b/a.c +@@ -22,1 +22,1 @@ +-} ++} +\ No newline at end of file + +commit 1dd7e9b2b1699324b53b341e728653b913bc192a14dfea168c5b51f2b3d03592 +Author: Thomas Rast +Date: Thu Feb 28 10:44:48 2013 +0100 + + initial + +diff --git a/a.c b/a.c +--- /dev/null ++++ b/a.c +@@ -0,0 +20,1 @@ ++} diff --git a/t/t4213-log-tabexpand.sh b/t/t4213-log-tabexpand.sh index 7f90f58c03e6..53a4af324495 100755 --- a/t/t4213-log-tabexpand.sh +++ b/t/t4213-log-tabexpand.sh @@ -36,7 +36,7 @@ count_expand () esac # Prefix the output with the command line arguments, and - # replace SP with a dot both in the expecte and actual output + # replace SP with a dot both in the expected and actual output # so that test_cmp would show the difference together with the # breakage in a way easier to consume by the debugging user. { diff --git a/t/t4214-log-graph-octopus.sh b/t/t4214-log-graph-octopus.sh index dab96c89aa8a..a08032509840 100755 --- a/t/t4214-log-graph-octopus.sh +++ b/t/t4214-log-graph-octopus.sh @@ -3,82 +3,86 @@ test_description='git log --graph of skewed left octopus merge.' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-log-graph.sh + +test_cmp_graph () { + cat >expect && + lib_test_cmp_graph --color=never --date-order --format=%s "$@" +} + +test_cmp_colored_graph () { + lib_test_cmp_colored_graph --date-order --format=%s "$@" +} test_expect_success 'set up merge history' ' - cat >expect.uncolored <<-\EOF && + test_commit initial && + for i in 1 2 3 4 ; do + git checkout master -b $i || return $? + # Make tag name different from branch name, to avoid + # ambiguity error when calling checkout. + test_commit $i $i $i tag$i || return $? + done && + git checkout 1 -b merge && + test_merge octopus-merge 1 2 3 4 && + test_commit after-merge && + git checkout 1 -b L && + test_commit left && + git checkout 4 -b crossover && + test_commit after-4 && + git checkout initial -b more-L && + test_commit after-initial +' + +test_expect_success 'log --graph with tricky octopus merge, no color' ' + test_cmp_graph left octopus-merge <<-\EOF * left - | *---. octopus-merge - | |\ \ \ - |/ / / / + | *-. octopus-merge + |/|\ \ | | | * 4 | | * | 3 | | |/ - | * | 2 + | * / 2 | |/ - * | 1 + * / 1 |/ * initial EOF +' + +test_expect_success 'log --graph with tricky octopus merge with colors' ' + test_config log.graphColors red,green,yellow,blue,magenta,cyan && cat >expect.colors <<-\EOF && * left - | *---. octopus-merge - | |\ \ \ - |/ / / / + | *-. octopus-merge + |/|\ \ | | | * 4 | | * | 3 | | |/ - | * | 2 + | * / 2 | |/ - * | 1 + * / 1 |/ * initial EOF - test_commit initial && - for i in 1 2 3 4 ; do - git checkout master -b $i || return $? - # Make tag name different from branch name, to avoid - # ambiguity error when calling checkout. - test_commit $i $i $i tag$i || return $? - done && - git checkout 1 -b merge && - test_tick && - git merge -m octopus-merge 1 2 3 4 && - git checkout 1 -b L && - test_commit left -' - -test_expect_success 'log --graph with tricky octopus merge with colors' ' - test_config log.graphColors red,green,yellow,blue,magenta,cyan && - git log --color=always --graph --date-order --pretty=tformat:%s --all >actual.colors.raw && - test_decode_color actual.colors && - test_cmp expect.colors actual.colors -' - -test_expect_success 'log --graph with tricky octopus merge, no color' ' - git log --color=never --graph --date-order --pretty=tformat:%s --all >actual.raw && - sed "s/ *\$//" actual.raw >actual && - test_cmp expect.uncolored actual + test_cmp_colored_graph left octopus-merge ' # Repeat the previous two tests with "normal" octopus merge (i.e., # without the first parent skewing to the "left" branch column). test_expect_success 'log --graph with normal octopus merge, no color' ' - cat >expect.uncolored <<-\EOF && + test_cmp_graph octopus-merge <<-\EOF *---. octopus-merge |\ \ \ | | | * 4 | | * | 3 | | |/ - | * | 2 + | * / 2 | |/ - * | 1 + * / 1 |/ * initial EOF - git log --color=never --graph --date-order --pretty=tformat:%s merge >actual.raw && - sed "s/ *\$//" actual.raw >actual && - test_cmp expect.uncolored actual ' test_expect_success 'log --graph with normal octopus merge with colors' ' @@ -88,15 +92,256 @@ test_expect_success 'log --graph with normal octopus merge with colors' ' | | | * 4 | | * | 3 | | |/ - | * | 2 + | * / 2 | |/ - * | 1 + * / 1 |/ * initial EOF test_config log.graphColors red,green,yellow,blue,magenta,cyan && - git log --color=always --graph --date-order --pretty=tformat:%s merge >actual.colors.raw && - test_decode_color actual.colors && - test_cmp expect.colors actual.colors + test_cmp_colored_graph octopus-merge ' + +test_expect_success 'log --graph with normal octopus merge and child, no color' ' + test_cmp_graph after-merge <<-\EOF + * after-merge + *---. octopus-merge + |\ \ \ + | | | * 4 + | | * | 3 + | | |/ + | * / 2 + | |/ + * / 1 + |/ + * initial + EOF +' + +test_expect_success 'log --graph with normal octopus and child merge with colors' ' + cat >expect.colors <<-\EOF && + * after-merge + *---. octopus-merge + |\ \ \ + | | | * 4 + | | * | 3 + | | |/ + | * / 2 + | |/ + * / 1 + |/ + * initial + EOF + test_config log.graphColors red,green,yellow,blue,magenta,cyan && + test_cmp_colored_graph after-merge +' + +test_expect_success 'log --graph with tricky octopus merge and its child, no color' ' + test_cmp_graph left after-merge <<-\EOF + * left + | * after-merge + | *-. octopus-merge + |/|\ \ + | | | * 4 + | | * | 3 + | | |/ + | * / 2 + | |/ + * / 1 + |/ + * initial + EOF +' + +test_expect_success 'log --graph with tricky octopus merge and its child with colors' ' + test_config log.graphColors red,green,yellow,blue,magenta,cyan && + cat >expect.colors <<-\EOF && + * left + | * after-merge + | *-. octopus-merge + |/|\ \ + | | | * 4 + | | * | 3 + | | |/ + | * / 2 + | |/ + * / 1 + |/ + * initial + EOF + test_cmp_colored_graph left after-merge +' + +test_expect_success 'log --graph with crossover in octopus merge, no color' ' + test_cmp_graph after-4 octopus-merge <<-\EOF + * after-4 + | *---. octopus-merge + | |\ \ \ + | |_|_|/ + |/| | | + * | | | 4 + | | | * 3 + | |_|/ + |/| | + | | * 2 + | |/ + |/| + | * 1 + |/ + * initial + EOF +' + +test_expect_success 'log --graph with crossover in octopus merge with colors' ' + test_config log.graphColors red,green,yellow,blue,magenta,cyan && + cat >expect.colors <<-\EOF && + * after-4 + | *---. octopus-merge + | |\ \ \ + | |_|_|/ + |/| | | + * | | | 4 + | | | * 3 + | |_|/ + |/| | + | | * 2 + | |/ + |/| + | * 1 + |/ + * initial + EOF + test_cmp_colored_graph after-4 octopus-merge +' + +test_expect_success 'log --graph with crossover in octopus merge and its child, no color' ' + test_cmp_graph after-4 after-merge <<-\EOF + * after-4 + | * after-merge + | *---. octopus-merge + | |\ \ \ + | |_|_|/ + |/| | | + * | | | 4 + | | | * 3 + | |_|/ + |/| | + | | * 2 + | |/ + |/| + | * 1 + |/ + * initial + EOF +' + +test_expect_success 'log --graph with crossover in octopus merge and its child with colors' ' + test_config log.graphColors red,green,yellow,blue,magenta,cyan && + cat >expect.colors <<-\EOF && + * after-4 + | * after-merge + | *---. octopus-merge + | |\ \ \ + | |_|_|/ + |/| | | + * | | | 4 + | | | * 3 + | |_|/ + |/| | + | | * 2 + | |/ + |/| + | * 1 + |/ + * initial + EOF + test_cmp_colored_graph after-4 after-merge +' + +test_expect_success 'log --graph with unrelated commit and octopus tip, no color' ' + test_cmp_graph after-initial octopus-merge <<-\EOF + * after-initial + | *---. octopus-merge + | |\ \ \ + | | | | * 4 + | |_|_|/ + |/| | | + | | | * 3 + | |_|/ + |/| | + | | * 2 + | |/ + |/| + | * 1 + |/ + * initial + EOF +' + +test_expect_success 'log --graph with unrelated commit and octopus tip with colors' ' + test_config log.graphColors red,green,yellow,blue,magenta,cyan && + cat >expect.colors <<-\EOF && + * after-initial + | *---. octopus-merge + | |\ \ \ + | | | | * 4 + | |_|_|/ + |/| | | + | | | * 3 + | |_|/ + |/| | + | | * 2 + | |/ + |/| + | * 1 + |/ + * initial + EOF + test_cmp_colored_graph after-initial octopus-merge +' + +test_expect_success 'log --graph with unrelated commit and octopus child, no color' ' + test_cmp_graph after-initial after-merge <<-\EOF + * after-initial + | * after-merge + | *---. octopus-merge + | |\ \ \ + | | | | * 4 + | |_|_|/ + |/| | | + | | | * 3 + | |_|/ + |/| | + | | * 2 + | |/ + |/| + | * 1 + |/ + * initial + EOF +' + +test_expect_success 'log --graph with unrelated commit and octopus child with colors' ' + test_config log.graphColors red,green,yellow,blue,magenta,cyan && + cat >expect.colors <<-\EOF && + * after-initial + | * after-merge + | *---. octopus-merge + | |\ \ \ + | | | | * 4 + | |_|_|/ + |/| | | + | | | * 3 + | |_|/ + |/| | + | | * 2 + | |/ + |/| + | * 1 + |/ + * initial + EOF + test_cmp_colored_graph after-initial after-merge +' + test_done diff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh new file mode 100755 index 000000000000..28d0779a8c59 --- /dev/null +++ b/t/t4215-log-skewed-merges.sh @@ -0,0 +1,373 @@ +#!/bin/sh + +test_description='git log --graph of skewed merges' + +. ./test-lib.sh +. "$TEST_DIRECTORY"/lib-log-graph.sh + +check_graph () { + cat >expect && + lib_test_cmp_graph --format=%s "$@" +} + +test_expect_success 'log --graph with merge fusing with its left and right neighbors' ' + git checkout --orphan _p && + test_commit A && + test_commit B && + git checkout -b _q @^ && test_commit C && + git checkout -b _r @^ && test_commit D && + git checkout _p && git merge --no-ff _q _r -m E && + git checkout _r && test_commit F && + git checkout _p && git merge --no-ff _r -m G && + git checkout @^^ && git merge --no-ff _p -m H && + + check_graph <<-\EOF + * H + |\ + | * G + | |\ + | | * F + | * | E + |/|\| + | | * D + | * | C + | |/ + * / B + |/ + * A + EOF +' + +test_expect_success 'log --graph with left-skewed merge' ' + git checkout --orphan 0_p && test_commit 0_A && + git checkout -b 0_q 0_p && test_commit 0_B && + git checkout -b 0_r 0_p && + test_commit 0_C && + test_commit 0_D && + git checkout -b 0_s 0_p && test_commit 0_E && + git checkout -b 0_t 0_p && git merge --no-ff 0_r^ 0_s -m 0_F && + git checkout 0_p && git merge --no-ff 0_s -m 0_G && + git checkout @^ && git merge --no-ff 0_q 0_r 0_t 0_p -m 0_H && + + check_graph <<-\EOF + *-----. 0_H + |\ \ \ \ + | | | | * 0_G + | |_|_|/| + |/| | | | + | | | * | 0_F + | |_|/|\| + |/| | | | + | | | | * 0_E + | |_|_|/ + |/| | | + | | * | 0_D + | | |/ + | | * 0_C + | |/ + |/| + | * 0_B + |/ + * 0_A + EOF +' + +test_expect_success 'log --graph with nested left-skewed merge' ' + git checkout --orphan 1_p && + test_commit 1_A && + test_commit 1_B && + test_commit 1_C && + git checkout -b 1_q @^ && test_commit 1_D && + git checkout 1_p && git merge --no-ff 1_q -m 1_E && + git checkout -b 1_r @~3 && test_commit 1_F && + git checkout 1_p && git merge --no-ff 1_r -m 1_G && + git checkout @^^ && git merge --no-ff 1_p -m 1_H && + + check_graph <<-\EOF + * 1_H + |\ + | * 1_G + | |\ + | | * 1_F + | * | 1_E + |/| | + | * | 1_D + * | | 1_C + |/ / + * / 1_B + |/ + * 1_A + EOF +' + +test_expect_success 'log --graph with nested left-skewed merge following normal merge' ' + git checkout --orphan 2_p && + test_commit 2_A && + test_commit 2_B && + test_commit 2_C && + git checkout -b 2_q @^^ && + test_commit 2_D && + test_commit 2_E && + git checkout -b 2_r @^ && test_commit 2_F && + git checkout 2_q && + git merge --no-ff 2_r -m 2_G && + git merge --no-ff 2_p^ -m 2_H && + git checkout -b 2_s @^^ && git merge --no-ff 2_q -m 2_J && + git checkout 2_p && git merge --no-ff 2_s -m 2_K && + + check_graph <<-\EOF + * 2_K + |\ + | * 2_J + | |\ + | | * 2_H + | | |\ + | | * | 2_G + | |/| | + | | * | 2_F + | * | | 2_E + | |/ / + | * | 2_D + * | | 2_C + | |/ + |/| + * | 2_B + |/ + * 2_A + EOF +' + +test_expect_success 'log --graph with nested right-skewed merge following left-skewed merge' ' + git checkout --orphan 3_p && + test_commit 3_A && + git checkout -b 3_q && + test_commit 3_B && + test_commit 3_C && + git checkout -b 3_r @^ && + test_commit 3_D && + git checkout 3_q && git merge --no-ff 3_r -m 3_E && + git checkout 3_p && git merge --no-ff 3_q -m 3_F && + git checkout 3_r && test_commit 3_G && + git checkout 3_p && git merge --no-ff 3_r -m 3_H && + git checkout @^^ && git merge --no-ff 3_p -m 3_J && + + check_graph <<-\EOF + * 3_J + |\ + | * 3_H + | |\ + | | * 3_G + | * | 3_F + |/| | + | * | 3_E + | |\| + | | * 3_D + | * | 3_C + | |/ + | * 3_B + |/ + * 3_A + EOF +' + +test_expect_success 'log --graph with right-skewed merge following a left-skewed one' ' + git checkout --orphan 4_p && + test_commit 4_A && + test_commit 4_B && + test_commit 4_C && + git checkout -b 4_q @^^ && test_commit 4_D && + git checkout -b 4_r 4_p^ && git merge --no-ff 4_q -m 4_E && + git checkout -b 4_s 4_p^^ && + git merge --no-ff 4_r -m 4_F && + git merge --no-ff 4_p -m 4_G && + git checkout @^^ && git merge --no-ff 4_s -m 4_H && + + check_graph --date-order <<-\EOF + * 4_H + |\ + | * 4_G + | |\ + | * | 4_F + |/| | + | * | 4_E + | |\ \ + | | * | 4_D + | |/ / + |/| | + | | * 4_C + | |/ + | * 4_B + |/ + * 4_A + EOF +' + +test_expect_success 'log --graph with octopus merge with column joining its penultimate parent' ' + git checkout --orphan 5_p && + test_commit 5_A && + git branch 5_q && + git branch 5_r && + test_commit 5_B && + git checkout 5_q && test_commit 5_C && + git checkout 5_r && test_commit 5_D && + git checkout 5_p && + git merge --no-ff 5_q 5_r -m 5_E && + git checkout 5_q && test_commit 5_F && + git checkout -b 5_s 5_p^ && + git merge --no-ff 5_p 5_q -m 5_G && + git checkout 5_r && + git merge --no-ff 5_s -m 5_H && + + check_graph <<-\EOF + * 5_H + |\ + | *-. 5_G + | |\ \ + | | | * 5_F + | | * | 5_E + | |/|\ \ + | |_|/ / + |/| | / + | | |/ + * | | 5_D + | | * 5_C + | |/ + |/| + | * 5_B + |/ + * 5_A + EOF +' + +test_expect_success 'log --graph with multiple tips' ' + git checkout --orphan 6_1 && + test_commit 6_A && + git branch 6_2 && + git branch 6_4 && + test_commit 6_B && + git branch 6_3 && + test_commit 6_C && + git checkout 6_2 && test_commit 6_D && + git checkout 6_3 && test_commit 6_E && + git checkout -b 6_5 6_1 && + git merge --no-ff 6_2 -m 6_F && + git checkout 6_4 && test_commit 6_G && + git checkout 6_3 && + git merge --no-ff 6_4 -m 6_H && + git checkout 6_1 && + git merge --no-ff 6_2 -m 6_I && + + check_graph 6_1 6_3 6_5 <<-\EOF + * 6_I + |\ + | | * 6_H + | | |\ + | | | * 6_G + | | * | 6_E + | | | | * 6_F + | |_|_|/| + |/| | |/ + | | |/| + | |/| | + | * | | 6_D + | | |/ + | |/| + * | | 6_C + | |/ + |/| + * | 6_B + |/ + * 6_A + EOF +' + +test_expect_success 'log --graph with multiple tips and colors' ' + test_config log.graphColors red,green,yellow,blue,magenta,cyan && + cat >expect.colors <<-\EOF && + * 6_I + |\ + | | * 6_H + | | |\ + | | | * 6_G + | | | | * 6_F + | |_|_|/| + |/| | |/ + | | |/| + | |/| | + | | * | 6_E + | * | | 6_D + | | |/ + | |/| + * | | 6_C + | |/ + |/| + * | 6_B + |/ + * 6_A + EOF + lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 +' + +test_expect_success 'log --graph with multiple tips' ' + git checkout --orphan 7_1 && + test_commit 7_A && + test_commit 7_B && + test_commit 7_C && + git checkout -b 7_2 7_1~2 && + test_commit 7_D && + test_commit 7_E && + git checkout -b 7_3 7_1~1 && + test_commit 7_F && + test_commit 7_G && + git checkout -b 7_4 7_2~1 && + test_commit 7_H && + git checkout -b 7_5 7_1~2 && + test_commit 7_I && + git checkout -b 7_6 7_3~1 && + test_commit 7_J && + git checkout -b M_1 7_1 && + git merge --no-ff 7_2 -m 7_M1 && + git checkout -b M_3 7_3 && + git merge --no-ff 7_4 -m 7_M2 && + git checkout -b M_5 7_5 && + git merge --no-ff 7_6 -m 7_M3 && + git checkout -b M_7 7_1 && + git merge --no-ff 7_2 7_3 -m 7_M4 && + + check_graph M_1 M_3 M_5 M_7 <<-\EOF + * 7_M1 + |\ + | | * 7_M2 + | | |\ + | | | * 7_H + | | | | * 7_M3 + | | | | |\ + | | | | | * 7_J + | | | | * | 7_I + | | | | | | * 7_M4 + | |_|_|_|_|/|\ + |/| | | | |/ / + | | |_|_|/| / + | |/| | | |/ + | | | |_|/| + | | |/| | | + | | * | | | 7_G + | | | |_|/ + | | |/| | + | | * | | 7_F + | * | | | 7_E + | | |/ / + | |/| | + | * | | 7_D + | | |/ + | |/| + * | | 7_C + | |/ + |/| + * | 7_B + |/ + * 7_A + EOF +' + +test_done diff --git a/t/t4256-am-format-flowed.sh b/t/t4256-am-format-flowed.sh index 6340310e9afb..2369c4e17ad8 100755 --- a/t/t4256-am-format-flowed.sh +++ b/t/t4256-am-format-flowed.sh @@ -11,7 +11,7 @@ test_expect_success 'setup' ' ' test_expect_success 'am with format=flowed' ' - git am <"$TEST_DIRECTORY/t4256/1/patch" >stdout 2>stderr && + git am <"$TEST_DIRECTORY/t4256/1/patch" 2>stderr && test_i18ngrep "warning: Patch sent with format=flowed" stderr && test_cmp "$TEST_DIRECTORY/t4256/1/mailinfo.c" mailinfo.c ' diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh index d87cc7d9efde..e59601e5fe9b 100755 --- a/t/t4300-merge-tree.sh +++ b/t/t4300-merge-tree.sh @@ -11,16 +11,16 @@ test_expect_success setup ' ' test_expect_success 'file add A, !B' ' - cat >expected <<\EXPECTED && + git reset --hard initial && + test_commit "add-a-not-b" "ONE" "AAA" && + git merge-tree initial initial add-a-not-b >actual && + cat >expected <actual && test_cmp expected actual ' @@ -41,10 +41,15 @@ test_expect_success 'file add A, B (same)' ' ' test_expect_success 'file add A, B (different)' ' - cat >expected <<\EXPECTED && + git reset --hard initial && + test_commit "add-a-b-diff-A" "ONE" "AAA" && + git reset --hard initial && + test_commit "add-a-b-diff-B" "ONE" "BBB" && + git merge-tree initial add-a-b-diff-A add-a-b-diff-B >actual && + cat >expected <>>>>>> .their EXPECTED - git reset --hard initial && - test_commit "add-a-b-diff-A" "ONE" "AAA" && - git reset --hard initial && - test_commit "add-a-b-diff-B" "ONE" "BBB" && - git merge-tree initial add-a-b-diff-A add-a-b-diff-B >actual && test_cmp expected actual ' @@ -69,18 +69,18 @@ test_expect_success 'file change A, !B' ' ' test_expect_success 'file change !A, B' ' - cat >expected <<\EXPECTED && + git reset --hard initial && + test_commit "change-not-a-b" "initial-file" "BBB" && + git merge-tree initial initial change-not-a-b >actual && + cat >expected <actual && test_cmp expected actual ' @@ -94,11 +94,16 @@ test_expect_success 'file change A, B (same)' ' ' test_expect_success 'file change A, B (different)' ' - cat >expected <<\EXPECTED && + git reset --hard initial && + test_commit "change-a-b-diff-A" "initial-file" "AAA" && + git reset --hard initial && + test_commit "change-a-b-diff-B" "initial-file" "BBB" && + git merge-tree initial change-a-b-diff-A change-a-b-diff-B >actual && + cat >expected <>>>>>> .their EXPECTED - git reset --hard initial && - test_commit "change-a-b-diff-A" "initial-file" "AAA" && - git reset --hard initial && - test_commit "change-a-b-diff-B" "initial-file" "BBB" && - git merge-tree initial change-a-b-diff-A change-a-b-diff-B >actual && test_cmp expected actual ' test_expect_success 'file change A, B (mixed)' ' - cat >expected <<\EXPECTED && -changed in both - base 100644 f4f1f998c7776568c4ff38f516d77fef9399b5a7 ONE - our 100644 af14c2c3475337c73759d561ef70b59e5c731176 ONE - their 100644 372d761493f524d44d59bd24700c3bdf914c973c ONE -@@ -7,7 +7,11 @@ - AAA - AAA - AAA -+<<<<<<< .our - BBB -+======= -+CCC -+>>>>>>> .their - AAA - AAA - AAA -EXPECTED - git reset --hard initial && test_commit "change-a-b-mix-base" "ONE" " AAA @@ -159,6 +140,26 @@ AAA" && "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/CCC/;}" actual && + + cat >expected <>>>>>> .their + AAA + AAA + AAA +EXPECTED + test_cmp expected actual ' @@ -173,20 +174,20 @@ test_expect_success 'file remove A, !B' ' ' test_expect_success 'file remove !A, B' ' - cat >expected <<\EXPECTED && -removed in remote - base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE - our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE -@@ -1 +0,0 @@ --AAA -EXPECTED - git reset --hard initial && test_commit "rm-not-a-b-base" "ONE" "AAA" && git rm ONE && git commit -m "rm-not-a-b" && git tag "rm-not-a-b" && git merge-tree rm-a-not-b-base rm-a-not-b-base rm-a-not-b >actual && + cat >expected <expected <<\EXPECTED && -removed in remote - base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE - our 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE -@@ -1 +0,0 @@ --BBB -EXPECTED - git reset --hard initial && test_commit "change-a-rm-b-base" "ONE" "AAA" && test_commit "change-a-rm-b-A" "ONE" "BBB" && @@ -218,16 +211,18 @@ EXPECTED git tag "change-a-rm-b-B" && git merge-tree change-a-rm-b-base change-a-rm-b-A change-a-rm-b-B \ >actual && + cat >expected <expected <<\EXPECTED && -removed in local - base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE - their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE -EXPECTED - git reset --hard initial && test_commit "rm-a-change-b-base" "ONE" "AAA" && @@ -238,6 +233,11 @@ EXPECTED test_commit "rm-a-change-b-B" "ONE" "BBB" && git merge-tree rm-a-change-b-base rm-a-change-b-A rm-a-change-b-B \ >actual && + cat >expected <expect <<-\EOF && + git reset --hard initial && + mkdir sub && + test_commit "add sub/file" "sub/file" "AAA" add-tree-a-b-A && + git reset --hard initial && + mkdir sub && + test_commit "add sub/file" "sub/file" "BBB" add-tree-a-b-B && + git merge-tree initial add-tree-a-b-A add-tree-a-b-B >actual && + cat >expect <<-EOF && added in both - our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file - their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 sub/file + our 100644 $(git rev-parse add-tree-a-b-A:sub/file) sub/file + their 100644 $(git rev-parse add-tree-a-b-B:sub/file) sub/file @@ -1 +1,5 @@ +<<<<<<< .our AAA @@ -261,24 +268,10 @@ test_expect_success 'tree add A, B (different)' ' +BBB +>>>>>>> .their EOF - git reset --hard initial && - mkdir sub && - test_commit "add sub/file" "sub/file" "AAA" add-tree-a-b-A && - git reset --hard initial && - mkdir sub && - test_commit "add sub/file" "sub/file" "BBB" add-tree-a-b-B && - git merge-tree initial add-tree-a-b-A add-tree-a-b-B >actual && test_cmp expect actual ' test_expect_success 'tree unchanged A, removed B' ' - cat >expect <<-\EOF && - removed in remote - base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file - our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file - @@ -1 +0,0 @@ - -AAA - EOF git reset --hard initial && mkdir sub && test_commit "add sub/file" "sub/file" "AAA" tree-remove-b-initial && @@ -287,6 +280,13 @@ test_expect_success 'tree unchanged A, removed B' ' git commit -m "remove sub/file" && git tag tree-remove-b-B && git merge-tree tree-remove-b-initial tree-remove-b-initial tree-remove-b-B >actual && + cat >expect <<-EOF && + removed in remote + base 100644 $(git rev-parse tree-remove-b-initial:sub/file) sub/file + our 100644 $(git rev-parse tree-remove-b-initial:sub/file) sub/file + @@ -1 +0,0 @@ + -AAA + EOF test_cmp expect actual ' @@ -296,14 +296,14 @@ test_expect_success 'turn file to tree' ' mkdir initial-file && test_commit "turn-file-to-tree" "initial-file/ONE" "CCC" && git merge-tree initial initial turn-file-to-tree >actual && - cat >expect <<-\EOF && + cat >expect <<-EOF && added in remote - their 100644 43aa4fdec31eb92e1fdc2f0ce6ea9ddb7c32bcf7 initial-file/ONE + their 100644 $(git rev-parse turn-file-to-tree:initial-file/ONE) initial-file/ONE @@ -0,0 +1 @@ +CCC removed in remote - base 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file - our 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file + base 100644 $(git rev-parse initial:initial-file) initial-file + our 100644 $(git rev-parse initial:initial-file) initial-file @@ -1 +0,0 @@ -initial EOF @@ -318,14 +318,14 @@ test_expect_success 'turn tree to file' ' rm -fr dir && test_commit "make-file" "dir" "CCC" && git merge-tree add-tree add-another-tree make-file >actual && - cat >expect <<-\EOF && + cat >expect <<-EOF && removed in remote - base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path - our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path + base 100644 $(git rev-parse add-tree:dir/path) dir/path + our 100644 $(git rev-parse add-tree:dir/path) dir/path @@ -1 +0,0 @@ -AAA added in remote - their 100644 43aa4fdec31eb92e1fdc2f0ce6ea9ddb7c32bcf7 dir + their 100644 $(git rev-parse make-file:dir) dir @@ -0,0 +1 @@ +CCC EOF diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh index 271eb5a1fdfb..3e7b23cb32c5 100755 --- a/t/t5004-archive-corner-cases.sh +++ b/t/t5004-archive-corner-cases.sh @@ -204,4 +204,23 @@ test_expect_success EXPENSIVE,LONG_IS_64BIT,UNZIP,UNZIP_ZIP64_SUPPORT,ZIPINFO \ grep $size big.lst ' +build_tree() { + perl -e ' + my $hash = $ARGV[0]; + foreach my $order (2..6) { + $first = 10 ** $order; + foreach my $i (-13..-9) { + my $name = "a" x ($first + $i); + print "100644 blob $hash\t$name\n" + } + } + ' "$1" +} + +test_expect_success 'tar archive with long paths' ' + blob=$(echo foo | git hash-object -w --stdin) && + tree=$(build_tree $blob | git mktree) && + git archive -o long_paths.tar $tree +' + test_done diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 9690dcad4fd5..147e616533cf 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -213,4 +213,19 @@ test_expect_failure 'mailinfo -b separated double [PATCH]' ' test z"$subj" = z"Subject: [other] message" ' +test_expect_success 'mailinfo handles unusual header whitespace' ' + git mailinfo /dev/null /dev/null >actual <<-\EOF && + From:Real Name + Subject: extra spaces + EOF + + cat >expect <<-\EOF && + Author: Real Name + Email: user@example.com + Subject: extra spaces + + EOF + test_cmp expect actual +' + test_done diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh index 852dcd913f1e..c1811ea0f412 100755 --- a/t/t5150-request-pull.sh +++ b/t/t5150-request-pull.sh @@ -4,6 +4,12 @@ test_description='Test workflows involving pull request.' . ./test-lib.sh +if ! test_have_prereq PERL +then + skip_all='skipping request-pull tests, perl not available' + test_done +fi + test_expect_success 'setup' ' git init --bare upstream.git && @@ -144,7 +150,6 @@ test_expect_success 'pull request after push' ' git request-pull initial origin master:for-upstream >../request ) && sed -nf read-request.sed digest && - cat digest && { read task && read repository && @@ -173,7 +178,6 @@ test_expect_success 'request asks HEAD to be pulled' ' git request-pull initial "$downstream_url" >../request ) && sed -nf read-request.sed digest && - cat digest && { read task && read repository && diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index 91d51b35f917..ad07f2f7fc26 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -6,9 +6,10 @@ test_description='pack index with 64-bit offsets and object CRC' . ./test-lib.sh -test_expect_success \ - 'setup' \ - 'rm -rf .git && +test_expect_success 'setup' ' + test_oid_init && + rawsz=$(test_oid rawsz) && + rm -rf .git && git init && git config pack.threads 1 && i=1 && @@ -32,7 +33,8 @@ test_expect_success \ echo $tree && git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/" } >obj-list && - git update-ref HEAD $commit' + git update-ref HEAD $commit +' test_expect_success \ 'pack-objects with index version 1' \ @@ -157,10 +159,11 @@ test_expect_success \ offs_101=$(index_obj_offset 1.idx $sha1_101) && nr_099=$(index_obj_nr 1.idx $sha1_099) && chmod +w ".git/objects/pack/pack-${pack1}.pack" && + recordsz=$((rawsz + 4)) && dd of=".git/objects/pack/pack-${pack1}.pack" seek=$(($offs_101 + 1)) \ if=".git/objects/pack/pack-${pack1}.idx" \ - skip=$((4 + 256 * 4 + $nr_099 * 24)) \ - bs=1 count=20 conv=notrunc && + skip=$((4 + 256 * 4 + $nr_099 * recordsz)) \ + bs=1 count=$rawsz conv=notrunc && git cat-file blob $sha1_101 > file_101_foo1' test_expect_success \ @@ -200,8 +203,8 @@ test_expect_success \ chmod +w ".git/objects/pack/pack-${pack1}.pack" && dd of=".git/objects/pack/pack-${pack1}.pack" seek=$(($offs_101 + 1)) \ if=".git/objects/pack/pack-${pack1}.idx" \ - skip=$((8 + 256 * 4 + $nr_099 * 20)) \ - bs=1 count=20 conv=notrunc && + skip=$((8 + 256 * 4 + $nr_099 * rawsz)) \ + bs=1 count=$rawsz conv=notrunc && git cat-file blob $sha1_101 > file_101_foo2' test_expect_success \ @@ -226,7 +229,7 @@ test_expect_success \ nr=$(index_obj_nr ".git/objects/pack/pack-${pack1}.idx" $obj) && chmod +w ".git/objects/pack/pack-${pack1}.idx" && printf xxxx | dd of=".git/objects/pack/pack-${pack1}.idx" conv=notrunc \ - bs=1 count=4 seek=$((8 + 256 * 4 + $(wc -l /dev/null || exit 1 done B)' ' @@ -62,13 +56,13 @@ test_expect_success 'index-pack detects REF_DELTA cycles' ' test_must_fail git index-pack --fix-thin --stdin recoverable.pack && pack_trailer recoverable.pack && - git index-pack --fix-thin --stdin tmp && - cut -d" " -f1 tmp2 && - sort actual && - git rev-list --objects HEAD >tmp && - cut -d" " -f1 tmp2 && - sort expect && + test_expect_success "counting objects via bitmap ($state)" ' + git rev-list --count --objects HEAD >expect && + git rev-list --use-bitmap-index --count --objects HEAD >actual && test_cmp expect actual ' + test_expect_success "enumerate commits ($state)" ' + git rev-list --use-bitmap-index HEAD >actual && + git rev-list HEAD >expect && + test_bitmap_traversal --no-confirm-bitmaps expect actual + ' + + test_expect_success "enumerate --objects ($state)" ' + git rev-list --objects --use-bitmap-index HEAD >actual && + git rev-list --objects HEAD >expect && + test_bitmap_traversal expect actual + ' + test_expect_success "bitmap --objects handles non-commit objects ($state)" ' git rev-list --objects --use-bitmap-index HEAD tagged-blob >actual && grep $blob actual @@ -99,6 +107,20 @@ test_expect_success 'clone from bitmapped repository' ' test_cmp expect actual ' +test_expect_success 'partial clone from bitmapped repository' ' + test_config uploadpack.allowfilter true && + git clone --no-local --bare --filter=blob:none . partial-clone.git && + ( + cd partial-clone.git && + pack=$(echo objects/pack/*.pack) && + git verify-pack -v "$pack" >have && + awk "/blob/ { print \$1 }" blobs && + # we expect this single blob because of the direct ref + git rev-parse refs/tags/tagged-blob >expect && + test_cmp expect blobs + ) +' + test_expect_success 'setup further non-bitmapped commits' ' test_commit_bulk --id=further 10 ' diff --git a/t/t5313-pack-bounds-checks.sh b/t/t5313-pack-bounds-checks.sh index f1708d415e55..2a4557efc2d6 100755 --- a/t/t5313-pack-bounds-checks.sh +++ b/t/t5313-pack-bounds-checks.sh @@ -38,16 +38,27 @@ munge () { # for the initial, and another ofs(4*nr) past that for the extended. # ofs_table () { - echo $((4 + 4 + 4*256 + 20*$1 + 4*$1)) + echo $((4 + 4 + 4*256 + $(test_oid rawsz)*$1 + 4*$1)) } extended_table () { echo $(($(ofs_table "$1") + 4*$1)) } +test_expect_success 'setup' ' + test_oid_init && + test_oid_cache <<-EOF + oid000 sha1:1485 + oid000 sha256:4222 + + oidfff sha1:74 + oidfff sha256:1350 + EOF +' + test_expect_success 'set up base packfile and variables' ' # the hash of this content starts with ff, which # makes some later computations much simpler - echo 74 >file && + echo $(test_oid oidfff) >file && git add file && git commit -m base && git repack -ad && @@ -140,10 +151,10 @@ test_expect_success 'bogus offset inside v2 extended table' ' # an extended table (if the first object were larger than 2^31). # # Note that the value is important here. We want $object as - # the second entry in sorted-sha1 order. The sha1 of 1485 starts + # the second entry in sorted-hash order. The hash of this object starts # with "000", which sorts before that of $object (which starts # with "fff"). - second=$(echo 1485 | git hash-object -w --stdin) && + second=$(test_oid oid000 | git hash-object -w --stdin) && do_pack "$object $second" --index-version=2 && # We have to make extra room for the table, so we cannot diff --git a/t/t5314-pack-cycle-detection.sh b/t/t5314-pack-cycle-detection.sh index e525466de098..0aec8619e22d 100755 --- a/t/t5314-pack-cycle-detection.sh +++ b/t/t5314-pack-cycle-detection.sh @@ -53,7 +53,7 @@ immediately after the lookup for "dummy". -# Create a pack containing the the tree $1 and blob $1:file, with +# Create a pack containing the tree $1 and blob $1:file, with # the latter stored as a delta against $2:file. # # We convince pack-objects to make the delta in the direction of our choosing diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh index 2d2f5d0229ce..dc0446574b3f 100755 --- a/t/t5317-pack-objects-filter-objects.sh +++ b/t/t5317-pack-objects-filter-objects.sh @@ -45,12 +45,7 @@ test_expect_success 'verify blob:none packfile has no blobs' ' git -C r1 index-pack ../filter.pack && git -C r1 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | - awk -f print_1.awk | - sort >observed && - - nr=$(wc -l r5/foo && git -C r5 add foo && git -C r5 commit -m "foo" && - del=$(git -C r5 rev-parse HEAD^{tree} | sed "s|..|&/|") && + git -C r5 rev-parse HEAD^{tree} >tree && + del=$(sed "s|..|&/|" tree) && rm r5/.git/objects/$del && test_must_fail git -C r5 pack-objects --revs --stdout 2>bad_tree <<-EOF && HEAD @@ -148,12 +144,7 @@ test_expect_success 'verify blob:limit=500 omits all blobs' ' git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | - awk -f print_1.awk | - sort >observed && - - nr=$(wc -l verify_result && - grep blob verify_result | - awk -f print_1.awk | - sort >observed && - - nr=$(wc -l expected && - git -C r2 pack-objects --revs --stdout --filter=blob:limit=1k >filter.pack <<-EOF && - HEAD - $(git -C r2 rev-parse HEAD:large.10000) - EOF + echo HEAD >objects && + git -C r2 rev-parse HEAD:large.10000 >>objects && + git -C r2 pack-objects --revs --stdout --filter=blob:limit=1k filter.pack && git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && @@ -377,7 +362,8 @@ test_expect_success 'verify sparse:oid=OID' ' awk -f print_2.awk ls_files_result | sort >expected && - oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) && + git -C r4 ls-files -s pattern >staged && + oid=$(awk -f print_2.awk staged) && git -C r4 pack-objects --revs --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF && HEAD EOF diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index 22cb9d664304..9bf920ae1716 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -19,15 +19,14 @@ test_expect_success 'verify graph with no graph file' ' test_expect_success 'write graph with no packs' ' cd "$TRASH_DIRECTORY/full" && - git commit-graph write --object-dir . && - test_path_is_missing info/commit-graph + git commit-graph write --object-dir $objdir && + test_path_is_missing $objdir/info/commit-graph ' -test_expect_success 'close with correct error on bad input' ' +test_expect_success 'exit with correct error on bad input to --stdin-packs' ' cd "$TRASH_DIRECTORY/full" && echo doesnotexist >in && - { git commit-graph write --stdin-packs stderr; ret=$?; } && - test "$ret" = 1 && + test_expect_code 1 git commit-graph write --stdin-packs stderr && test_i18ngrep "error adding pack" stderr ' @@ -41,6 +40,15 @@ test_expect_success 'create commits and repack' ' git repack ' +test_expect_success 'exit with correct error on bad input to --stdin-commits' ' + cd "$TRASH_DIRECTORY/full" && + echo HEAD | test_expect_code 1 git commit-graph write --stdin-commits 2>stderr && + test_i18ngrep "invalid commit object id" stderr && + # valid tree OID, but not a commit OID + git rev-parse HEAD^{tree} | test_expect_code 1 git commit-graph write --stdin-commits 2>stderr && + test_i18ngrep "invalid commit object id" stderr +' + graph_git_two_modes() { git -c core.commitGraph=true $1 >output git -c core.commitGraph=false $1 >expect @@ -77,7 +85,7 @@ graph_read_expect() { num_commits: $1 chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL EOF - git commit-graph read >output && + test-tool read-graph >output && test_cmp expect output } @@ -116,6 +124,42 @@ test_expect_success 'Add more commits' ' git repack ' +test_expect_success 'commit-graph write progress off for redirected stderr' ' + cd "$TRASH_DIRECTORY/full" && + git commit-graph write 2>err && + test_line_count = 0 err +' + +test_expect_success 'commit-graph write force progress on for stderr' ' + cd "$TRASH_DIRECTORY/full" && + GIT_PROGRESS_DELAY=0 git commit-graph write --progress 2>err && + test_file_not_empty err +' + +test_expect_success 'commit-graph write with the --no-progress option' ' + cd "$TRASH_DIRECTORY/full" && + git commit-graph write --no-progress 2>err && + test_line_count = 0 err +' + +test_expect_success 'commit-graph verify progress off for redirected stderr' ' + cd "$TRASH_DIRECTORY/full" && + git commit-graph verify 2>err && + test_line_count = 0 err +' + +test_expect_success 'commit-graph verify force progress on for stderr' ' + cd "$TRASH_DIRECTORY/full" && + GIT_PROGRESS_DELAY=0 git commit-graph verify --progress 2>err && + test_file_not_empty err +' + +test_expect_success 'commit-graph verify with the --no-progress option' ' + cd "$TRASH_DIRECTORY/full" && + git commit-graph verify --no-progress 2>err && + test_line_count = 0 err +' + # Current graph structure: # # __M3___ @@ -437,7 +481,7 @@ test_expect_success 'detect bad version' ' ' test_expect_success 'detect bad hash version' ' - corrupt_graph_and_verify $GRAPH_BYTE_HASH "\02" \ + corrupt_graph_and_verify $GRAPH_BYTE_HASH "\03" \ "hash version" ' @@ -577,4 +621,47 @@ test_expect_success 'get_commit_tree_in_graph works for non-the_repository' ' test_cmp expect actual ' +test_expect_success 'corrupt commit-graph write (broken parent)' ' + rm -rf repo && + git init repo && + ( + cd repo && + empty="$(git mktree broken <<-EOF && + tree $empty + parent $ZERO_OID + author whatever 1234 -0000 + committer whatever 1234 -0000 + + broken commit + EOF + broken="$(git hash-object -w -t commit --literally broken)" && + git commit-tree -p "$broken" -m "good commit" "$empty" >good && + test_must_fail git commit-graph write --stdin-commits \ + test_err && + test_i18ngrep "unable to parse commit" test_err + ) +' + +test_expect_success 'corrupt commit-graph write (missing tree)' ' + rm -rf repo && + git init repo && + ( + cd repo && + tree="$(git mktree broken <<-EOF && + parent $ZERO_OID + author whatever 1234 -0000 + committer whatever 1234 -0000 + + broken commit + EOF + broken="$(git hash-object -w -t commit --literally broken)" && + git commit-tree -p "$broken" -m "good" "$tree" >good && + test_must_fail git commit-graph write --stdin-commits \ + test_err && + test_i18ngrep "unable to parse commit" test_err + ) +' + test_done diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh index c72ca0439993..43a7a66c9d1b 100755 --- a/t/t5319-multi-pack-index.sh +++ b/t/t5319-multi-pack-index.sh @@ -28,6 +28,20 @@ midx_read_expect () { test_cmp expect actual } +test_expect_success 'setup' ' + test_oid_init && + test_oid_cache <<-EOF + idxoff sha1:2999 + idxoff sha256:3739 + + packnameoff sha1:652 + packnameoff sha256:940 + + fanoutoff sha1:1 + fanoutoff sha256:3 + EOF +' + test_expect_success 'write midx with no packs' ' test_when_finished rm -f pack/multi-pack-index && git multi-pack-index --object-dir=. write && @@ -147,6 +161,21 @@ test_expect_success 'write midx with two packs' ' compare_results_with_midx "two packs" +test_expect_success 'write progress off for redirected stderr' ' + git multi-pack-index --object-dir=$objdir write 2>err && + test_line_count = 0 err +' + +test_expect_success 'write force progress on for stderr' ' + git multi-pack-index --object-dir=$objdir --progress write 2>err && + test_file_not_empty err +' + +test_expect_success 'write with the --no-progress option' ' + git multi-pack-index --object-dir=$objdir --no-progress write 2>err && + test_line_count = 0 err +' + test_expect_success 'add more packs' ' for j in $(test_seq 11 20) do @@ -169,6 +198,21 @@ test_expect_success 'verify multi-pack-index success' ' git multi-pack-index verify --object-dir=$objdir ' +test_expect_success 'verify progress off for redirected stderr' ' + git multi-pack-index verify --object-dir=$objdir 2>err && + test_line_count = 0 err +' + +test_expect_success 'verify force progress on for stderr' ' + git multi-pack-index verify --object-dir=$objdir --progress 2>err && + test_file_not_empty err +' + +test_expect_success 'verify with the --no-progress option' ' + git multi-pack-index verify --object-dir=$objdir --no-progress 2>err && + test_line_count = 0 err +' + # usage: corrupt_midx_and_verify corrupt_midx_and_verify() { POS=$1 && @@ -195,7 +239,7 @@ test_expect_success 'verify bad signature' ' "multi-pack-index signature" ' -HASH_LEN=20 +HASH_LEN=$(test_oid rawsz) NUM_OBJECTS=74 MIDX_BYTE_VERSION=4 MIDX_BYTE_OID_VERSION=5 @@ -208,9 +252,9 @@ MIDX_CHUNK_LOOKUP_WIDTH=12 MIDX_OFFSET_PACKNAMES=$(($MIDX_HEADER_SIZE + \ $MIDX_NUM_CHUNKS * $MIDX_CHUNK_LOOKUP_WIDTH)) MIDX_BYTE_PACKNAME_ORDER=$(($MIDX_OFFSET_PACKNAMES + 2)) -MIDX_OFFSET_OID_FANOUT=$(($MIDX_OFFSET_PACKNAMES + 652)) +MIDX_OFFSET_OID_FANOUT=$(($MIDX_OFFSET_PACKNAMES + $(test_oid packnameoff))) MIDX_OID_FANOUT_WIDTH=4 -MIDX_BYTE_OID_FANOUT_ORDER=$((MIDX_OFFSET_OID_FANOUT + 250 * $MIDX_OID_FANOUT_WIDTH + 1)) +MIDX_BYTE_OID_FANOUT_ORDER=$((MIDX_OFFSET_OID_FANOUT + 250 * $MIDX_OID_FANOUT_WIDTH + $(test_oid fanoutoff))) MIDX_OFFSET_OID_LOOKUP=$(($MIDX_OFFSET_OID_FANOUT + 256 * $MIDX_OID_FANOUT_WIDTH)) MIDX_BYTE_OID_LOOKUP=$(($MIDX_OFFSET_OID_LOOKUP + 16 * $HASH_LEN)) MIDX_OFFSET_OBJECT_OFFSETS=$(($MIDX_OFFSET_OID_LOOKUP + $NUM_OBJECTS * $HASH_LEN)) @@ -274,16 +318,31 @@ test_expect_success 'verify incorrect pack-int-id' ' ' test_expect_success 'verify incorrect offset' ' - corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\07" $objdir \ + corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\377" $objdir \ "incorrect object offset" ' test_expect_success 'git-fsck incorrect offset' ' - corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\07" $objdir \ + corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\377" $objdir \ "incorrect object offset" \ "git -c core.multipackindex=true fsck" ' +test_expect_success 'repack progress off for redirected stderr' ' + git multi-pack-index --object-dir=$objdir repack 2>err && + test_line_count = 0 err +' + +test_expect_success 'repack force progress on for stderr' ' + git multi-pack-index --object-dir=$objdir --progress repack 2>err && + test_file_not_empty err +' + +test_expect_success 'repack with the --no-progress option' ' + git multi-pack-index --object-dir=$objdir --no-progress repack 2>err && + test_line_count = 0 err +' + test_expect_success 'repack removes multi-pack-index' ' test_path_is_file $objdir/pack/multi-pack-index && GIT_TEST_MULTI_PACK_INDEX=0 git repack -adf && @@ -342,7 +401,7 @@ test_expect_success 'force some 64-bit offsets with pack-objects' ' pack64=$(git pack-objects --index-version=2,0x40 objects64/pack/test-64 err && + test_line_count = 0 err + ) +' + +test_expect_success 'expire force progress on for stderr' ' + ( + cd dup && + git multi-pack-index --progress expire 2>err && + test_file_not_empty err + ) +' + +test_expect_success 'expire with the --no-progress option' ' + ( + cd dup && + git multi-pack-index --no-progress expire 2>err && + test_line_count = 0 err + ) +' + test_expect_success 'expire removes unreferenced packs' ' ( cd dup && diff --git a/t/t5321-pack-large-objects.sh b/t/t5321-pack-large-objects.sh index a75eab87d361..8a56d98a0e88 100755 --- a/t/t5321-pack-large-objects.sh +++ b/t/t5321-pack-large-objects.sh @@ -10,8 +10,8 @@ test_description='git pack-object with "large" deltas . "$TEST_DIRECTORY"/lib-pack.sh # Two similar-ish objects that we have computed deltas between. -A=01d7713666f4de822776c7622c10f1b07de280dc -B=e68fe8129b546b101aee9510c5328e7f21ca1d18 +A=$(test_oid packlib_7_0) +B=$(test_oid packlib_7_76) test_expect_success 'setup' ' clear_packs && diff --git a/t/t5324-split-commit-graph.sh b/t/t5324-split-commit-graph.sh index 99f4ef4c19df..53b2e6b4555d 100755 --- a/t/t5324-split-commit-graph.sh +++ b/t/t5324-split-commit-graph.sh @@ -8,9 +8,17 @@ GIT_TEST_COMMIT_GRAPH=0 test_expect_success 'setup repo' ' git init && git config core.commitGraph true && + git config gc.writeCommitGraph false && infodir=".git/objects/info" && graphdir="$infodir/commit-graphs" && - test_oid_init + test_oid_init && + test_oid_cache <<-EOM + shallow sha1:1760 + shallow sha256:2064 + + base sha1:1376 + base sha256:1496 + EOM ' graph_read_expect() { @@ -24,7 +32,7 @@ graph_read_expect() { num_commits: $1 chunks: oid_fanout oid_lookup commit_metadata EOF - git commit-graph read >output && + test-tool read-graph >output && test_cmp expect output } @@ -247,7 +255,7 @@ test_expect_success 'verify hashes along chain, even in shallow' ' cd verify && git commit-graph verify && base_file=$graphdir/graph-$(head -n 1 $graphdir/commit-graph-chain).graph && - corrupt_file "$base_file" 1760 "\01" && + corrupt_file "$base_file" $(test_oid shallow) "\01" && test_must_fail git commit-graph verify --shallow 2>test_err && grep -v "^+" test_err >err && test_i18ngrep "incorrect checksum" err @@ -274,7 +282,7 @@ test_expect_success 'warn on base graph chunk incorrect' ' cd base-chunk && git commit-graph verify && base_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph && - corrupt_file "$base_file" 1376 "\01" && + corrupt_file "$base_file" $(test_oid base) "\01" && git commit-graph verify --shallow 2>test_err && grep -v "^+" test_err >err && test_i18ngrep "commit-graph chain does not match" err @@ -319,7 +327,7 @@ test_expect_success 'add octopus merge' ' git merge commits/3 commits/4 && git branch merge/octopus && git commit-graph write --reachable --split && - git commit-graph verify 2>err && + git commit-graph verify --progress 2>err && test_line_count = 3 err && test_i18ngrep ! warning err && test_line_count = 3 $graphdir/commit-graph-chain @@ -334,6 +342,7 @@ test_expect_success 'split across alternate where alternate is not split' ' git clone --no-hardlinks . alt-split && ( cd alt-split && + rm -f .git/objects/info/commit-graph && echo "$(pwd)"/../.git/objects >.git/objects/info/alternates && test_commit 18 && git commit-graph write --reachable --split && diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index 571d620aedba..b84618c925fe 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -288,7 +288,7 @@ test_expect_success 'receive-pack de-dupes .have lines' ' $shared .have EOF - GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION= \ + GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION=0 \ git push \ --receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \ fork HEAD:foo && diff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh index 7344253bfbbc..80750a817e95 100755 --- a/t/t5407-post-rewrite-hook.sh +++ b/t/t5407-post-rewrite-hook.sh @@ -53,10 +53,10 @@ test_expect_success 'git commit --amend --no-post-rewrite' ' test ! -f post-rewrite.data ' -test_expect_success 'git rebase' ' +test_expect_success 'git rebase --apply' ' git reset --hard D && clear_hook_input && - test_must_fail git rebase --onto A B && + test_must_fail git rebase --apply --onto A B && echo C > foo && git add foo && git rebase --continue && @@ -68,10 +68,10 @@ test_expect_success 'git rebase' ' verify_hook_input ' -test_expect_success 'git rebase --skip' ' +test_expect_success 'git rebase --apply --skip' ' git reset --hard D && clear_hook_input && - test_must_fail git rebase --onto A B && + test_must_fail git rebase --apply --onto A B && test_must_fail git rebase --skip && echo D > foo && git add foo && @@ -84,10 +84,10 @@ test_expect_success 'git rebase --skip' ' verify_hook_input ' -test_expect_success 'git rebase --skip the last one' ' +test_expect_success 'git rebase --apply --skip the last one' ' git reset --hard F && clear_hook_input && - test_must_fail git rebase --onto D A && + test_must_fail git rebase --apply --onto D A && git rebase --skip && echo rebase >expected.args && cat >expected.data <<-EOF && @@ -128,7 +128,7 @@ test_expect_success 'git rebase -m --skip' ' verify_hook_input ' -test_expect_success 'git rebase with implicit use of interactive backend' ' +test_expect_success 'git rebase with implicit use of merge backend' ' git reset --hard D && clear_hook_input && test_must_fail git rebase --keep-empty --onto A B && @@ -143,7 +143,7 @@ test_expect_success 'git rebase with implicit use of interactive backend' ' verify_hook_input ' -test_expect_success 'git rebase --skip with implicit use of interactive backend' ' +test_expect_success 'git rebase --skip with implicit use of merge backend' ' git reset --hard D && clear_hook_input && test_must_fail git rebase --keep-empty --onto A B && diff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh index 2a8c44966185..5d8f401d8ece 100755 --- a/t/t5409-colorize-remote-messages.sh +++ b/t/t5409-colorize-remote-messages.sh @@ -56,14 +56,13 @@ test_expect_success 'short line' ' test_expect_success 'case-insensitive' ' git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/case-insensitive 2>output && - cat output && test_decode_color decoded && grep "error: error" decoded && grep "ERROR: also highlighted" decoded ' test_expect_success 'leading space' ' - git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/leading-space 2>output && cat output && + git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/leading-space 2>output && test_decode_color decoded && grep " error: leading space" decoded ' diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 1c71c0ec770c..baa1a99f45f8 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -440,11 +440,12 @@ test_expect_success 'setup tests for the --stdin parameter' ' ' test_expect_success 'setup fetch refs from cmdline v[12]' ' + cp -r client client0 && cp -r client client1 && cp -r client client2 ' -for version in '' 1 2 +for version in '' 0 1 2 do test_expect_success "protocol.version=$version fetch refs from cmdline" " ( @@ -638,7 +639,7 @@ test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised a git init client && # Some protocol versions (e.g. 2) support fetching # unadvertised objects, so restrict this test to v0. - test_must_fail env GIT_TEST_PROTOCOL_VERSION= git -C client fetch-pack ../server \ + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -C client fetch-pack ../server \ $(git -C server rev-parse refs/heads/master^) 2>err && test_i18ngrep "Server does not allow request for unadvertised object" err ' @@ -708,13 +709,22 @@ do # file with scheme for p in file do - test_expect_success "fetch-pack --diag-url $p://$h/$r" ' + test_expect_success !MINGW "fetch-pack --diag-url $p://$h/$r" ' check_prot_path $p://$h/$r $p "/$r" ' + test_expect_success MINGW "fetch-pack --diag-url $p://$h/$r" ' + check_prot_path $p://$h/$r $p "//$h/$r" + ' + test_expect_success MINGW "fetch-pack --diag-url $p:///$r" ' + check_prot_path $p:///$r $p "/$r" + ' # No "/~" -> "~" conversion for file - test_expect_success "fetch-pack --diag-url $p://$h/~$r" ' + test_expect_success !MINGW "fetch-pack --diag-url $p://$h/~$r" ' check_prot_path $p://$h/~$r $p "/~$r" ' + test_expect_success MINGW "fetch-pack --diag-url $p://$h/~$r" ' + check_prot_path $p://$h/~$r $p "//$h/~$r" + ' done # file without scheme for h in nohost nohost:12 [::1] [::1]:23 [ [:aa @@ -783,6 +793,44 @@ test_expect_success 'clone shallow since selects no commits' ' ) ' +# A few subtle things about the request in this test: +# +# - the server must have commit-graphs present and enabled +# +# - the history is such that our want/have share a common ancestor ("base" +# here) +# +# - we send only a single have, which is fewer than a normal client would +# send. This ensures that we don't parse "base" up front with +# parse_object(), but rather traverse to it as a parent while deciding if we +# can stop the "have" negotiation, and call parse_commit(). The former +# sees the actual object data and so always loads the three oid, whereas the +# latter will try to load it lazily. +# +# - we must use protocol v2, because it handles the "have" negotiation before +# processing the shallow directives +# +test_expect_success 'shallow since with commit graph and already-seen commit' ' + test_create_repo shallow-since-graph && + ( + cd shallow-since-graph && + test_commit base && + test_commit master && + git checkout -b other HEAD^ && + test_commit other && + git commit-graph write --reachable && + git config core.commitGraph true && + + GIT_PROTOCOL=version=2 git upload-pack . <<-EOF >/dev/null + 0012command=fetch + 00010013deepen-since 1 + 0032want $(git rev-parse other) + 0032have $(git rev-parse master) + 0000 + EOF + ) +' + test_expect_success 'shallow clone exclude tag two' ' test_create_repo shallow-exclude && ( @@ -870,7 +918,10 @@ test_expect_success 'filtering by size' ' git -C client fetch-pack --filter=blob:limit=0 ../server HEAD && # Ensure that object is not inadvertently fetched - test_must_fail git -C client cat-file -e $(git hash-object server/one.t) + commit=$(git -C server rev-parse HEAD) && + blob=$(git hash-object server/one.t) && + git -C client rev-list --objects --missing=allow-any "$commit" >oids && + ! grep "$blob" oids ' test_expect_success 'filtering by size has no effect if support for it is not advertised' ' @@ -882,7 +933,10 @@ test_expect_success 'filtering by size has no effect if support for it is not ad git -C client fetch-pack --filter=blob:limit=0 ../server HEAD 2> err && # Ensure that object is fetched - git -C client cat-file -e $(git hash-object server/one.t) && + commit=$(git -C server rev-parse HEAD) && + blob=$(git hash-object server/one.t) && + git -C client rev-list --objects --missing=allow-any "$commit" >oids && + grep "$blob" oids && test_i18ngrep "filtering not recognized by server" err ' @@ -904,9 +958,11 @@ fetch_filter_blob_limit_zero () { git -C client fetch --filter=blob:limit=0 origin HEAD:somewhere && # Ensure that commit is fetched, but blob is not - test_config -C client extensions.partialclone "arbitrary string" && - git -C client cat-file -e $(git -C "$SERVER" rev-parse two) && - test_must_fail git -C client cat-file -e $(git hash-object "$SERVER/two.t") + commit=$(git -C "$SERVER" rev-parse two) && + blob=$(git hash-object server/two.t) && + git -C client rev-list --objects --missing=allow-any "$commit" >oids && + grep "$commit" oids && + ! grep "$blob" oids } test_expect_success 'fetch with --filter=blob:limit=0' ' @@ -920,4 +976,7 @@ test_expect_success 'fetch with --filter=blob:limit=0 and HTTP' ' fetch_filter_blob_limit_zero "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server" ' +# DO NOT add non-httpd-specific tests here, because the last part of this +# test script is only executed when httpd is available and enabled. + test_done diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index fdfe179b1188..645b4c78d356 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -4,6 +4,7 @@ test_description='fetch/receive strict mode' . ./test-lib.sh test_expect_success 'setup and inject "corrupt or missing" object' ' + test_oid_init && echo hello >greetings && git add greetings && git commit -m greetings && @@ -144,11 +145,11 @@ test_expect_success 'fsck with no skipList input' ' test_expect_success 'setup sorted and unsorted skipLists' ' cat >SKIP.unsorted <<-EOF && - 0000000000000000000000000000000000000004 - 0000000000000000000000000000000000000002 + $(test_oid 004) + $(test_oid 002) $commit - 0000000000000000000000000000000000000001 - 0000000000000000000000000000000000000003 + $(test_oid 001) + $(test_oid 003) EOF sort SKIP.unsorted >SKIP.sorted ' @@ -172,14 +173,14 @@ test_expect_success 'fsck with invalid or bogus skipList input' ' test_expect_success 'fsck with other accepted skipList input (comments & empty lines)' ' cat >SKIP.with-comment <<-EOF && # Some bad commit - 0000000000000000000000000000000000000001 + $(test_oid 001) EOF test_must_fail git -c fsck.skipList=SKIP.with-comment fsck 2>err-with-comment && test_i18ngrep "missingEmail" err-with-comment && cat >SKIP.with-empty-line <<-EOF && - 0000000000000000000000000000000000000001 + $(test_oid 001) - 0000000000000000000000000000000000000002 + $(test_oid 002) EOF test_must_fail git -c fsck.skipList=SKIP.with-empty-line fsck 2>err-with-empty-line && test_i18ngrep "missingEmail" err-with-empty-line @@ -204,7 +205,7 @@ test_expect_success 'fsck with exhaustive accepted skipList input (various types echo " # Comment after whitespace" >>SKIP.exhaustive && echo "$commit # Our bad commit (with leading whitespace and trailing comment)" >>SKIP.exhaustive && echo "# Some bad commit (leading whitespace)" >>SKIP.exhaustive && - echo " 0000000000000000000000000000000000000001" >>SKIP.exhaustive && + echo " $(test_oid 001)" >>SKIP.exhaustive && git -c fsck.skipList=SKIP.exhaustive fsck 2>err && test_must_be_empty err ' diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 883b32efa024..dda81b7d07a2 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -734,15 +734,53 @@ test_expect_success 'reject adding remote with an invalid name' ' # the last two ones check if the config is updated. test_expect_success 'rename a remote' ' + test_config_global remote.pushDefault origin && git clone one four && ( cd four && + git config branch.master.pushRemote origin && git remote rename origin upstream && test -z "$(git for-each-ref refs/remotes/origin)" && test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" && test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" && test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" && - test "$(git config branch.master.remote)" = "upstream" + test "$(git config branch.master.remote)" = "upstream" && + test "$(git config branch.master.pushRemote)" = "upstream" && + test "$(git config --global remote.pushDefault)" = "origin" + ) +' + +test_expect_success 'rename a remote renames repo remote.pushDefault' ' + git clone one four.1 && + ( + cd four.1 && + git config remote.pushDefault origin && + git remote rename origin upstream && + test "$(git config --local remote.pushDefault)" = "upstream" + ) +' + +test_expect_success 'rename a remote renames repo remote.pushDefault but ignores global' ' + test_config_global remote.pushDefault other && + git clone one four.2 && + ( + cd four.2 && + git config remote.pushDefault origin && + git remote rename origin upstream && + test "$(git config --global remote.pushDefault)" = "other" && + test "$(git config --local remote.pushDefault)" = "upstream" + ) +' + +test_expect_success 'rename a remote renames repo remote.pushDefault but keeps global' ' + test_config_global remote.pushDefault origin && + git clone one four.3 && + ( + cd four.3 && + git config remote.pushDefault origin && + git remote rename origin upstream && + test "$(git config --global remote.pushDefault)" = "origin" && + test "$(git config --local remote.pushDefault)" = "upstream" ) ' @@ -784,6 +822,54 @@ test_expect_success 'rename succeeds with existing remote..prune' ' git -C four.four remote rename origin upstream ' +test_expect_success 'remove a remote' ' + test_config_global remote.pushDefault origin && + git clone one four.five && + ( + cd four.five && + git config branch.master.pushRemote origin && + git remote remove origin && + test -z "$(git for-each-ref refs/remotes/origin)" && + test_must_fail git config branch.master.remote && + test_must_fail git config branch.master.pushRemote && + test "$(git config --global remote.pushDefault)" = "origin" + ) +' + +test_expect_success 'remove a remote removes repo remote.pushDefault' ' + git clone one four.five.1 && + ( + cd four.five.1 && + git config remote.pushDefault origin && + git remote remove origin && + test_must_fail git config --local remote.pushDefault + ) +' + +test_expect_success 'remove a remote removes repo remote.pushDefault but ignores global' ' + test_config_global remote.pushDefault other && + git clone one four.five.2 && + ( + cd four.five.2 && + git config remote.pushDefault origin && + git remote remove origin && + test "$(git config --global remote.pushDefault)" = "other" && + test_must_fail git config --local remote.pushDefault + ) +' + +test_expect_success 'remove a remote removes repo remote.pushDefault but keeps global' ' + test_config_global remote.pushDefault origin && + git clone one four.five.3 && + ( + cd four.five.3 && + git config remote.pushDefault origin && + git remote remove origin && + test "$(git config --global remote.pushDefault)" = "origin" && + test_must_fail git config --local remote.pushDefault + ) +' + cat >remotes_origin <verify.out && - test "$2" = $(grep '^[0-9a-f]\{40\} ' verify.out | wc -l) + test "$2" = $(grep "^$OID_REGEX " verify.out | wc -l) } convert_bundle_to_pack () { @@ -174,6 +174,30 @@ test_expect_success 'fetch --prune --tags with refspec prunes based on refspec' git rev-parse sometag ' +test_expect_success '--refmap="" ignores configured refspec' ' + cd "$TRASH_DIRECTORY" && + git clone "$D" remote-refs && + git -C remote-refs rev-parse remotes/origin/master >old && + git -C remote-refs update-ref refs/remotes/origin/master master~1 && + git -C remote-refs rev-parse remotes/origin/master >new && + git -C remote-refs fetch --refmap= origin "+refs/heads/*:refs/hidden/origin/*" && + git -C remote-refs rev-parse remotes/origin/master >actual && + test_cmp new actual && + git -C remote-refs fetch origin && + git -C remote-refs rev-parse remotes/origin/master >actual && + test_cmp old actual +' + +test_expect_success '--refmap="" and --prune' ' + git -C remote-refs update-ref refs/remotes/origin/foo/otherbranch master && + git -C remote-refs update-ref refs/hidden/foo/otherbranch master && + git -C remote-refs fetch --prune --refmap="" origin +refs/heads/*:refs/hidden/* && + git -C remote-refs rev-parse remotes/origin/foo/otherbranch && + test_must_fail git -C remote-refs rev-parse refs/hidden/foo/otherbranch && + git -C remote-refs fetch --prune origin && + test_must_fail git -C remote-refs rev-parse remotes/origin/foo/otherbranch +' + test_expect_success 'fetch tags when there is no tags' ' cd "$D" && @@ -261,9 +285,10 @@ test_expect_success 'create bundle 1' ' ' test_expect_success 'header of bundle looks right' ' + head -n 4 "$D"/bundle1 && head -n 1 "$D"/bundle1 | grep "^#" && - head -n 2 "$D"/bundle1 | grep "^-[0-9a-f]\{40\} " && - head -n 3 "$D"/bundle1 | grep "^[0-9a-f]\{40\} " && + head -n 2 "$D"/bundle1 | grep "^-$OID_REGEX " && + head -n 3 "$D"/bundle1 | grep "^$OID_REGEX " && head -n 4 "$D"/bundle1 | grep "^$" ' @@ -289,7 +314,7 @@ test_expect_success 'bundle 1 has only 3 files ' ' test_expect_success 'unbundle 2' ' cd "$D/bundle" && git fetch ../bundle2 master:master && - test "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)" + test "tip" = "$(git log -1 --pretty=oneline master | cut -d" " -f2)" ' test_expect_success 'bundle does not prerequisite objects' ' @@ -354,7 +379,6 @@ test_expect_success 'fetch from GIT URL with a non-applying branch..merge # the strange name is: a\!'b test_expect_success 'quoting of a strangely named repo' ' test_must_fail git fetch "a\\!'\''b" > result 2>&1 && - cat result && grep "fatal: '\''a\\\\!'\''b'\''" result ' @@ -570,6 +594,35 @@ test_expect_success 'LHS of refspec follows ref disambiguation rules' ' ) ' +test_expect_success 'fetch.writeCommitGraph' ' + git clone three write && + ( + cd three && + test_commit new + ) && + ( + cd write && + git -c fetch.writeCommitGraph fetch origin && + test_path_is_file .git/objects/info/commit-graphs/commit-graph-chain + ) +' + +test_expect_success 'fetch.writeCommitGraph with submodules' ' + git clone dups super && + ( + cd super && + git submodule add "file://$TRASH_DIRECTORY/three" && + git commit -m "add submodule" + ) && + git clone "super" super-clone && + ( + cd super-clone && + rm -rf .git/objects/info && + git -c fetch.writeCommitGraph=true fetch origin && + test_path_is_file .git/objects/info/commit-graphs/commit-graph-chain + ) +' + # configured prune tests set_config_tristate () { @@ -902,6 +955,29 @@ test_expect_success C_LOCALE_OUTPUT 'fetch compact output' ' test_cmp expect actual ' +test_expect_success '--no-show-forced-updates' ' + mkdir forced-updates && + ( + cd forced-updates && + git init && + test_commit 1 && + test_commit 2 + ) && + git clone forced-updates forced-update-clone && + git clone forced-updates no-forced-update-clone && + git -C forced-updates reset --hard HEAD~1 && + ( + cd forced-update-clone && + git fetch --show-forced-updates origin 2>output && + test_i18ngrep "(forced update)" output + ) && + ( + cd no-forced-update-clone && + git fetch --no-show-forced-updates origin 2>output && + test_i18ngrep ! "(forced update)" output + ) +' + setup_negotiation_tip () { SERVER="$1" URL="$2" @@ -978,27 +1054,7 @@ test_expect_success '--negotiation-tip limits "have" lines sent with HTTP protoc check_negotiation_tip ' -test_expect_success '--no-show-forced-updates' ' - mkdir forced-updates && - ( - cd forced-updates && - git init && - test_commit 1 && - test_commit 2 - ) && - git clone forced-updates forced-update-clone && - git clone forced-updates no-forced-update-clone && - git -C forced-updates reset --hard HEAD~1 && - ( - cd forced-update-clone && - git fetch --show-forced-updates origin 2>output && - test_i18ngrep "(forced update)" output - ) && - ( - cd no-forced-update-clone && - git fetch --no-show-forced-updates origin 2>output && - ! test_i18ngrep "(forced update)" output - ) -' +# DO NOT add non-httpd-specific tests here, because the last part of this +# test script is only executed when httpd is available and enabled. test_done diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index 43e1d8d4d2a4..04b35402c7aa 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -225,49 +225,50 @@ test_expect_success 'ls-remote --symref' ' EOF # Protocol v2 supports sending symrefs for refs other than HEAD, so use # protocol v0 here. - GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref >actual && + GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref >actual && test_cmp expect actual ' test_expect_success 'ls-remote with filtered symref (refname)' ' - cat >expect <<-\EOF && + rev=$(git rev-parse HEAD) && + cat >expect <<-EOF && ref: refs/heads/master HEAD - 1bd44cb9d13204b0fe1958db0082f5028a16eb3a HEAD + $rev HEAD EOF # Protocol v2 supports sending symrefs for refs other than HEAD, so use # protocol v0 here. - GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref . HEAD >actual && + GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . HEAD >actual && test_cmp expect actual ' test_expect_failure 'ls-remote with filtered symref (--heads)' ' git symbolic-ref refs/heads/foo refs/tags/mark && - cat >expect <<-\EOF && + cat >expect <<-EOF && ref: refs/tags/mark refs/heads/foo - 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/foo - 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/master + $rev refs/heads/foo + $rev refs/heads/master EOF # Protocol v2 supports sending symrefs for refs other than HEAD, so use # protocol v0 here. - GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref --heads . >actual && + GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual && test_cmp expect actual ' test_expect_success 'ls-remote --symref omits filtered-out matches' ' - cat >expect <<-\EOF && - 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/foo - 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/master + cat >expect <<-EOF && + $rev refs/heads/foo + $rev refs/heads/master EOF # Protocol v2 supports sending symrefs for refs other than HEAD, so use # protocol v0 here. - GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref --heads . >actual && + GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual && test_cmp expect actual && - GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref . "refs/heads/*" >actual && + GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . "refs/heads/*" >actual && test_cmp expect actual ' test_lazy_prereq GIT_DAEMON ' - git env--helper --type=bool --default=true --exit-code GIT_TEST_GIT_DAEMON + test_bool_env GIT_TEST_GIT_DAEMON true ' # This test spawns a daemon, so run it only if the user would be OK with diff --git a/t/t5514-fetch-multiple.sh b/t/t5514-fetch-multiple.sh index 5426d4b5abb4..de8e2f15319b 100755 --- a/t/t5514-fetch-multiple.sh +++ b/t/t5514-fetch-multiple.sh @@ -183,4 +183,15 @@ test_expect_success 'git fetch --all --tags' ' test_cmp expect test8/output ' +test_expect_success 'parallel' ' + git remote add one ./bogus1 && + git remote add two ./bogus2 && + + test_must_fail env GIT_TRACE="$PWD/trace" \ + git fetch --jobs=2 --multiple one two 2>err && + grep "preparing to run up to 2 tasks" trace && + test_i18ngrep "could not fetch .one.*128" err && + test_i18ngrep "could not fetch .two.*128" err +' + test_done diff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh index e55d8474efb6..9d6a46ff56c9 100755 --- a/t/t5515-fetch-merge-logic.sh +++ b/t/t5515-fetch-merge-logic.sh @@ -8,18 +8,60 @@ test_description='Merge logic in fetch' # NEEDSWORK: If the overspecification of the expected result is reduced, we # might be able to run this test in all protocol versions. -GIT_TEST_PROTOCOL_VERSION= +GIT_TEST_PROTOCOL_VERSION=0 +export GIT_TEST_PROTOCOL_VERSION . ./test-lib.sh -LF=' -' +build_script () { + script="$1" && + for i in one three_file master master2 one_tree three two two2 three2 + do + echo "s/$(test_oid --hash=sha1 "$i")/$(test_oid "$i")/g" >>"$script" + done +} + +convert_expected () { + file="$1" && + script="$2" && + sed -f "$script" "$file" >"$file.tmp" && + mv "$file.tmp" "$file" +} test_expect_success setup ' GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" && GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" && export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && + test_oid_cache <<-EOF && + one sha1:8e32a6d901327a23ef831511badce7bf3bf46689 + one sha256:8739546433ab1ac72ee93088dce611210effee072b2b586ceac6dde43ebec9ce + + three_file sha1:0e3b14047d3ee365f4f2a1b673db059c3972589c + three_file sha256:bc4447d50c07497a8bfe6eef817f2364ecca9d471452e43b52756cc1a908bd32 + + master sha1:6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 + master sha256:8521c3072461fcfe8f32d67f95cc6e6b832a2db2fa29769ffc788bce85ebcd75 + + one_tree sha1:22feea448b023a2d864ef94b013735af34d238ba + one_tree sha256:6e4743f4ef2356b881dda5e91f5c7cdffe870faf350bf7b312f80a20935f5d83 + + three sha1:c61a82b60967180544e3c19f819ddbd0c9f89899 + three sha256:0cc6d1eda617ded715170786e31ba4e2d0185404ec5a3508dd0d73b324860c6a + + two sha1:525b7fb068d59950d185a8779dc957c77eed73ba + two sha256:3b21de3440cd38c2a9e9b464adb923f7054949ed4c918e1a0ac4c95cd52774db + + master2 sha1:754b754407bf032e9a2f9d5a9ad05ca79a6b228f + master2 sha256:6c7abaea8a6d8ef4d89877e68462758dc6774690fbbbb0e6d7dd57415c9abde0 + + two2 sha1:6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 + two2 sha256:87a2d3ee29c83a3dc7afd41c0606b11f67603120b910a7be7840accdc18344d4 + + three2 sha1:0567da4d5edd2ff4bb292a465ba9e64dcad9536b + three2 sha256:cceb3e8eca364fa9a0a39a1efbebecacc664af86cbbd8070571f5faeb5f0e8c3 + EOF + echo >file original && git add file && git commit -a -m One && @@ -89,7 +131,8 @@ test_expect_success setup ' git config branch.br-$remote-octopus.remote $remote && git config branch.br-$remote-octopus.merge refs/heads/one && git config --add branch.br-$remote-octopus.merge two - done + done && + build_script sed_script ' # Merge logic depends on branch properties and Pull: or .fetch lines @@ -140,6 +183,10 @@ do actual_r="$pfx-refs.$test" test_expect_success "$cmd" ' + cp "$expect_f" expect_f && + convert_expected expect_f sed_script && + cp "$expect_r" expect_r && + convert_expected expect_r sed_script && { echo "# $cmd" set x $cmd; shift @@ -155,18 +202,18 @@ do cat .git/FETCH_HEAD } >"$actual_f" && git show-ref >"$actual_r" && - if test -f "$expect_f" + if test -f "expect_f" then - test_cmp "$expect_f" "$actual_f" && + test_cmp "expect_f" "$actual_f" && rm -f "$actual_f" else # this is to help developing new tests. cp "$actual_f" "$expect_f" false fi && - if test -f "$expect_r" + if test -f "expect_r" then - test_cmp "$expect_r" "$actual_r" && + test_cmp "expect_r" "$actual_r" && rm -f "$actual_r" else # this is to help developing new tests. diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index c81ca360ac4a..9ff041a093e7 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1151,7 +1151,7 @@ test_expect_success 'fetch exact SHA1' ' # unadvertised objects, so restrict this test to v0. # fetching the hidden object should fail by default - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err && test_i18ngrep "Server does not allow request for unadvertised object" err && test_must_fail git rev-parse --verify refs/heads/copy && @@ -1210,7 +1210,7 @@ do cd shallow && # Some protocol versions (e.g. 2) support fetching # unadvertised objects, so restrict this test to v0. - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ git fetch --depth=1 ../testrepo/.git $SHA1 && git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true && git fetch --depth=1 ../testrepo/.git $SHA1 && @@ -1241,9 +1241,9 @@ do cd shallow && # Some protocol versions (e.g. 2) support fetching # unadvertised objects, so restrict this test to v0. - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ git fetch ../testrepo/.git $SHA1_3 && - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ git fetch ../testrepo/.git $SHA1_1 && git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true && git fetch ../testrepo/.git $SHA1_1 && @@ -1251,7 +1251,7 @@ do test_must_fail git cat-file commit $SHA1_2 && git fetch ../testrepo/.git $SHA1_2 && git cat-file commit $SHA1_2 && - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ git fetch ../testrepo/.git $SHA1_3 2>err && test_i18ngrep "remote error:.*not our ref.*$SHA1_3\$" err ) @@ -1291,7 +1291,7 @@ test_expect_success 'peeled advertisements are not considered ref tips' ' git -C testrepo commit --allow-empty -m two && git -C testrepo tag -m foo mytag HEAD^ && oid=$(git -C testrepo rev-parse mytag^{commit}) && - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ git fetch testrepo $oid 2>err && test_i18ngrep "Server does not allow request for unadvertised object" err ' @@ -1712,4 +1712,15 @@ test_expect_success 'updateInstead with push-to-checkout hook' ' ) ' +test_expect_success 'denyCurrentBranch and worktrees' ' + git worktree add new-wt && + git clone . cloned && + test_commit -C cloned first && + test_config receive.denyCurrentBranch refuse && + test_must_fail git -C cloned push origin HEAD:new-wt && + test_config receive.denyCurrentBranch updateInstead && + git -C cloned push origin HEAD:new-wt && + test_must_fail git -C cloned push --delete origin new-wt +' + test_done diff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh index c05a661400c1..e4edd56404fe 100755 --- a/t/t5517-push-mirror.sh +++ b/t/t5517-push-mirror.sh @@ -265,4 +265,14 @@ test_expect_success 'remote.foo.mirror=no has no effect' ' ' +test_expect_success 'push to mirrored repository with refspec fails' ' + mk_repo_pair && + ( + cd master && + echo one >foo && git add foo && git commit -m one && + git config --add remote.up.mirror true && + test_must_fail git push up master + ) +' + test_done diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index cf4cc32fd0eb..2f86fca0428c 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -5,7 +5,7 @@ test_description='pulling into void' . ./test-lib.sh modify () { - sed -e "$1" <"$2" >"$2.x" && + sed -e "$1" "$2" >"$2.x" && mv "$2.x" "$2" } @@ -15,8 +15,10 @@ test_pull_autostash () { git add new_file && git pull "$@" . copy && test_cmp_rev HEAD^ copy && - test "$(cat new_file)" = dirty && - test "$(cat file)" = "modified again" + echo dirty >expect && + test_cmp expect new_file && + echo "modified again" >expect && + test_cmp expect file } test_pull_autostash_fail () { @@ -39,8 +41,8 @@ test_expect_success 'pulling into void' ' cd cloned && git pull .. ) && - test -f file && - test -f cloned/file && + test_path_is_file file && + test_path_is_file cloned/file && test_cmp file cloned/file ' @@ -50,8 +52,8 @@ test_expect_success 'pulling into void using master:master' ' cd cloned-uho && git pull .. master:master ) && - test -f file && - test -f cloned-uho/file && + test_path_is_file file && + test_path_is_file cloned-uho/file && test_cmp file cloned-uho/file ' @@ -99,7 +101,7 @@ test_expect_success 'pulling into void must not create an octopus' ' ( cd cloned-octopus && test_must_fail git pull .. master master && - ! test -f file + test_path_is_missing file ) ' @@ -110,9 +112,11 @@ test_expect_success 'test . as a remote' ' echo updated >file && git commit -a -m updated && git checkout copy && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && git pull && - test "$(cat file)" = updated && + echo updated >expect && + test_cmp expect file && git reflog -1 >reflog.actual && sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy && echo "OBJID HEAD@{0}: pull: Fast-forward" >reflog.expected && @@ -125,9 +129,11 @@ test_expect_success 'the default remote . should not break explicit pull' ' git commit -a -m modified && git checkout copy && git reset --hard HEAD^ && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && git pull . second && - test "$(cat file)" = modified && + echo modified >expect && + test_cmp expect file && git reflog -1 >reflog.actual && sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy && echo "OBJID HEAD@{0}: pull . second: Fast-forward" >reflog.expected && @@ -137,10 +143,11 @@ test_expect_success 'the default remote . should not break explicit pull' ' test_expect_success 'fail if wildcard spec does not match any refs' ' git checkout -b test copy^ && test_when_finished "git checkout -f copy && git branch -D test" && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && test_must_fail git pull . "refs/nonexisting1/*:refs/nonexisting2/*" 2>err && test_i18ngrep "no candidates for merging" err && - test "$(cat file)" = file + test_cmp expect file ' test_expect_success 'fail if no branches specified with non-default remote' ' @@ -148,11 +155,12 @@ test_expect_success 'fail if no branches specified with non-default remote' ' test_when_finished "git remote remove test_remote" && git checkout -b test copy^ && test_when_finished "git checkout -f copy && git branch -D test" && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && test_config branch.test.remote origin && test_must_fail git pull test_remote 2>err && test_i18ngrep "specify a branch on the command line" err && - test "$(cat file)" = file + test_cmp expect file ' test_expect_success 'fail if not on a branch' ' @@ -160,10 +168,11 @@ test_expect_success 'fail if not on a branch' ' test_when_finished "git remote remove origin" && git checkout HEAD^ && test_when_finished "git checkout -f copy" && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && test_must_fail git pull 2>err && test_i18ngrep "not currently on a branch" err && - test "$(cat file)" = file + test_cmp expect file ' test_expect_success 'fail if no configuration for current branch' ' @@ -172,10 +181,11 @@ test_expect_success 'fail if no configuration for current branch' ' git checkout -b test copy^ && test_when_finished "git checkout -f copy && git branch -D test" && test_config branch.test.remote test_remote && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && test_must_fail git pull 2>err && test_i18ngrep "no tracking information" err && - test "$(cat file)" = file + test_cmp expect file ' test_expect_success 'pull --all: fail if no configuration for current branch' ' @@ -184,10 +194,11 @@ test_expect_success 'pull --all: fail if no configuration for current branch' ' git checkout -b test copy^ && test_when_finished "git checkout -f copy && git branch -D test" && test_config branch.test.remote test_remote && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && test_must_fail git pull --all 2>err && test_i18ngrep "There is no tracking information" err && - test "$(cat file)" = file + test_cmp expect file ' test_expect_success 'fail if upstream branch does not exist' ' @@ -195,26 +206,31 @@ test_expect_success 'fail if upstream branch does not exist' ' test_when_finished "git checkout -f copy && git branch -D test" && test_config branch.test.remote . && test_config branch.test.merge refs/heads/nonexisting && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && test_must_fail git pull 2>err && test_i18ngrep "no such ref was fetched" err && - test "$(cat file)" = file + test_cmp expect file ' test_expect_success 'fail if the index has unresolved entries' ' git checkout -b third second^ && test_when_finished "git checkout -f copy && git branch -D third" && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && test_commit modified2 file && - test -z "$(git ls-files -u)" && + git ls-files -u >unmerged && + test_must_be_empty unmerged && test_must_fail git pull . second && - test -n "$(git ls-files -u)" && + git ls-files -u >unmerged && + test_file_not_empty unmerged && cp file expected && test_must_fail git pull . second 2>err && test_i18ngrep "Pulling is not possible because you have unmerged files." err && test_cmp expected file && git add file && - test -z "$(git ls-files -u)" && + git ls-files -u >unmerged && + test_must_be_empty unmerged && test_must_fail git pull . second 2>err && test_i18ngrep "You have not concluded your merge" err && test_cmp expected file @@ -223,47 +239,66 @@ test_expect_success 'fail if the index has unresolved entries' ' test_expect_success 'fast-forwards working tree if branch head is updated' ' git checkout -b third second^ && test_when_finished "git checkout -f copy && git branch -D third" && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && git pull . second:third 2>err && test_i18ngrep "fetch updated the current branch head" err && - test "$(cat file)" = modified && - test "$(git rev-parse third)" = "$(git rev-parse second)" + echo modified >expect && + test_cmp expect file && + test_cmp_rev third second ' test_expect_success 'fast-forward fails with conflicting work tree' ' git checkout -b third second^ && test_when_finished "git checkout -f copy && git branch -D third" && - test "$(cat file)" = file && + echo file >expect && + test_cmp expect file && echo conflict >file && test_must_fail git pull . second:third 2>err && test_i18ngrep "Cannot fast-forward your working tree" err && - test "$(cat file)" = conflict && - test "$(git rev-parse third)" = "$(git rev-parse second)" + echo conflict >expect && + test_cmp expect file && + test_cmp_rev third second ' test_expect_success '--rebase' ' git branch to-rebase && - echo modified again > file && + echo modified again >file && git commit -m file file && git checkout to-rebase && - echo new > file2 && + echo new >file2 && git add file2 && git commit -m "new file" && git tag before-rebase && git pull --rebase . copy && - test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" && - test new = "$(git show HEAD:file2)" + test_cmp_rev HEAD^ copy && + echo new >expect && + git show HEAD:file2 >actual && + test_cmp expect actual ' -test_expect_success '--rebase fast forward' ' +test_expect_success '--rebase (merge) fast forward' ' git reset --hard before-rebase && git checkout -b ff && echo another modification >file && git commit -m third file && git checkout to-rebase && - git pull --rebase . ff && - test "$(git rev-parse HEAD)" = "$(git rev-parse ff)" && + git -c rebase.backend=merge pull --rebase . ff && + test_cmp_rev HEAD ff && + + # The above only validates the result. Did we actually bypass rebase? + git reflog -1 >reflog.actual && + sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy && + echo "OBJID HEAD@{0}: pull --rebase . ff: Fast-forward" >reflog.expected && + test_cmp reflog.expected reflog.fuzzy +' + +test_expect_success '--rebase (am) fast forward' ' + git reset --hard before-rebase && + + git -c rebase.backend=apply pull --rebase . ff && + test_cmp_rev HEAD ff && # The above only validates the result. Did we actually bypass rebase? git reflog -1 >reflog.actual && @@ -287,7 +322,7 @@ test_expect_success '--rebase --autostash fast forward' ' git checkout behind && echo dirty >file && git pull --rebase --autostash . to-rebase-ff && - test "$(git rev-parse HEAD)" = "$(git rev-parse to-rebase-ff)" + test_cmp_rev HEAD to-rebase-ff ' test_expect_success '--rebase with conflicts shows advice' ' @@ -305,7 +340,7 @@ test_expect_success '--rebase with conflicts shows advice' ' test_tick && git commit -m "Create conflict" seq.txt && test_must_fail git pull --rebase . seq 2>err >out && - test_i18ngrep "Resolve all conflicts manually" out + test_i18ngrep "Resolve all conflicts manually" err ' test_expect_success 'failed --rebase shows advice' ' @@ -319,15 +354,17 @@ test_expect_success 'failed --rebase shows advice' ' git checkout -f -b fails-to-rebase HEAD^ && test_commit v2-without-cr file "2" file2-lf && test_must_fail git pull --rebase . diverging 2>err >out && - test_i18ngrep "Resolve all conflicts manually" out + test_i18ngrep "Resolve all conflicts manually" err ' test_expect_success '--rebase fails with multiple branches' ' git reset --hard before-rebase && test_must_fail git pull --rebase . copy master 2>err && - test "$(git rev-parse HEAD)" = "$(git rev-parse before-rebase)" && + test_cmp_rev HEAD before-rebase && test_i18ngrep "Cannot rebase onto multiple branches" err && - test modified = "$(git show HEAD:file)" + echo modified >expect && + git show HEAD:file >actual && + test_cmp expect actual ' test_expect_success 'pull --rebase succeeds with dirty working directory and rebase.autostash set' ' @@ -377,8 +414,10 @@ test_expect_success 'pull.rebase' ' git reset --hard before-rebase && test_config pull.rebase true && git pull . copy && - test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" && - test new = "$(git show HEAD:file2)" + test_cmp_rev HEAD^ copy && + echo new >expect && + git show HEAD:file2 >actual && + test_cmp expect actual ' test_expect_success 'pull --autostash & pull.rebase=true' ' @@ -395,8 +434,10 @@ test_expect_success 'branch.to-rebase.rebase' ' git reset --hard before-rebase && test_config branch.to-rebase.rebase true && git pull . copy && - test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" && - test new = "$(git show HEAD:file2)" + test_cmp_rev HEAD^ copy && + echo new >expect && + git show HEAD:file2 >actual && + test_cmp expect actual ' test_expect_success 'branch.to-rebase.rebase should override pull.rebase' ' @@ -404,23 +445,29 @@ test_expect_success 'branch.to-rebase.rebase should override pull.rebase' ' test_config pull.rebase true && test_config branch.to-rebase.rebase false && git pull . copy && - test "$(git rev-parse HEAD^)" != "$(git rev-parse copy)" && - test new = "$(git show HEAD:file2)" + test_cmp_rev ! HEAD^ copy && + echo new >expect && + git show HEAD:file2 >actual && + test_cmp expect actual ' -test_expect_success "pull --rebase warns on --verify-signatures" ' +test_expect_success 'pull --rebase warns on --verify-signatures' ' git reset --hard before-rebase && git pull --rebase --verify-signatures . copy 2>err && - test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" && - test new = "$(git show HEAD:file2)" && + test_cmp_rev HEAD^ copy && + echo new >expect && + git show HEAD:file2 >actual && + test_cmp expect actual && test_i18ngrep "ignoring --verify-signatures for rebase" err ' -test_expect_success "pull --rebase does not warn on --no-verify-signatures" ' +test_expect_success 'pull --rebase does not warn on --no-verify-signatures' ' git reset --hard before-rebase && git pull --rebase --no-verify-signatures . copy 2>err && - test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" && - test new = "$(git show HEAD:file2)" && + test_cmp_rev HEAD^ copy && + echo new >expect && + git show HEAD:file2 >actual && + test_cmp expect actual && test_i18ngrep ! "verify-signatures" err ' @@ -440,25 +487,31 @@ test_expect_success 'pull.rebase=false create a new merge commit' ' git reset --hard before-preserve-rebase && test_config pull.rebase false && git pull . copy && - test "$(git rev-parse HEAD^1)" = "$(git rev-parse before-preserve-rebase)" && - test "$(git rev-parse HEAD^2)" = "$(git rev-parse copy)" && - test file3 = "$(git show HEAD:file3.t)" + test_cmp_rev HEAD^1 before-preserve-rebase && + test_cmp_rev HEAD^2 copy && + echo file3 >expect && + git show HEAD:file3.t >actual && + test_cmp expect actual ' test_expect_success 'pull.rebase=true flattens keep-merge' ' git reset --hard before-preserve-rebase && test_config pull.rebase true && git pull . copy && - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" && - test file3 = "$(git show HEAD:file3.t)" + test_cmp_rev HEAD^^ copy && + echo file3 >expect && + git show HEAD:file3.t >actual && + test_cmp expect actual ' test_expect_success 'pull.rebase=1 is treated as true and flattens keep-merge' ' git reset --hard before-preserve-rebase && test_config pull.rebase 1 && git pull . copy && - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" && - test file3 = "$(git show HEAD:file3.t)" + test_cmp_rev HEAD^^ copy && + echo file3 >expect && + git show HEAD:file3.t >actual && + test_cmp expect actual ' test_expect_success REBASE_P \ @@ -466,8 +519,8 @@ test_expect_success REBASE_P \ git reset --hard before-preserve-rebase && test_config pull.rebase preserve && git pull . copy && - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" && - test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)" + test_cmp_rev HEAD^^ copy && + test_cmp_rev HEAD^2 keep-merge ' test_expect_success 'pull.rebase=interactive' ' @@ -478,7 +531,8 @@ test_expect_success 'pull.rebase=interactive' ' test_set_editor "$TRASH_DIRECTORY/fake-editor" && test_when_finished "test_might_fail git rebase --abort" && test_must_fail git pull --rebase=interactive . copy && - test "I was here" = "$(cat fake.out)" + echo "I was here" >expect && + test_cmp expect fake.out ' test_expect_success 'pull --rebase=i' ' @@ -489,30 +543,35 @@ test_expect_success 'pull --rebase=i' ' test_set_editor "$TRASH_DIRECTORY/fake-editor" && test_when_finished "test_might_fail git rebase --abort" && test_must_fail git pull --rebase=i . copy && - test "I was here, too" = "$(cat fake.out)" + echo "I was here, too" >expect && + test_cmp expect fake.out ' test_expect_success 'pull.rebase=invalid fails' ' git reset --hard before-preserve-rebase && test_config pull.rebase invalid && - ! git pull . copy + test_must_fail git pull . copy ' test_expect_success '--rebase=false create a new merge commit' ' git reset --hard before-preserve-rebase && test_config pull.rebase true && git pull --rebase=false . copy && - test "$(git rev-parse HEAD^1)" = "$(git rev-parse before-preserve-rebase)" && - test "$(git rev-parse HEAD^2)" = "$(git rev-parse copy)" && - test file3 = "$(git show HEAD:file3.t)" + test_cmp_rev HEAD^1 before-preserve-rebase && + test_cmp_rev HEAD^2 copy && + echo file3 >expect && + git show HEAD:file3.t >actual && + test_cmp expect actual ' test_expect_success '--rebase=true rebases and flattens keep-merge' ' git reset --hard before-preserve-rebase && test_config pull.rebase preserve && git pull --rebase=true . copy && - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" && - test file3 = "$(git show HEAD:file3.t)" + test_cmp_rev HEAD^^ copy && + echo file3 >expect && + git show HEAD:file3.t >actual && + test_cmp expect actual ' test_expect_success REBASE_P \ @@ -520,58 +579,62 @@ test_expect_success REBASE_P \ git reset --hard before-preserve-rebase && test_config pull.rebase true && git pull --rebase=preserve . copy && - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" && - test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)" + test_cmp_rev HEAD^^ copy && + test_cmp_rev HEAD^2 keep-merge ' test_expect_success '--rebase=invalid fails' ' git reset --hard before-preserve-rebase && - ! git pull --rebase=invalid . copy + test_must_fail git pull --rebase=invalid . copy ' test_expect_success '--rebase overrides pull.rebase=preserve and flattens keep-merge' ' git reset --hard before-preserve-rebase && test_config pull.rebase preserve && git pull --rebase . copy && - test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" && - test file3 = "$(git show HEAD:file3.t)" + test_cmp_rev HEAD^^ copy && + echo file3 >expect && + git show HEAD:file3.t >actual && + test_cmp expect actual ' test_expect_success '--rebase with rebased upstream' ' - git remote add -f me . && git checkout copy && git tag copy-orig && git reset --hard HEAD^ && - echo conflicting modification > file && + echo conflicting modification >file && git commit -m conflict file && git checkout to-rebase && - echo file > file2 && + echo file >file2 && git commit -m to-rebase file2 && git tag to-rebase-orig && git pull --rebase me copy && - test "conflicting modification" = "$(cat file)" && - test file = "$(cat file2)" - + echo "conflicting modification" >expect && + test_cmp expect file && + echo file >expect && + test_cmp expect file2 ' test_expect_success '--rebase -f with rebased upstream' ' test_when_finished "test_might_fail git rebase --abort" && git reset --hard to-rebase-orig && git pull --rebase -f me copy && - test "conflicting modification" = "$(cat file)" && - test file = "$(cat file2)" + echo "conflicting modification" >expect && + test_cmp expect file && + echo file >expect && + test_cmp expect file2 ' test_expect_success '--rebase with rebased default upstream' ' - git update-ref refs/remotes/me/copy copy-orig && git checkout --track -b to-rebase2 me/copy && git reset --hard to-rebase-orig && git pull --rebase && - test "conflicting modification" = "$(cat file)" && - test file = "$(cat file2)" - + echo "conflicting modification" >expect && + test_cmp expect file && + echo file >expect && + test_cmp expect file2 ' test_expect_success 'rebased upstream + fetch + pull --rebase' ' @@ -582,13 +645,14 @@ test_expect_success 'rebased upstream + fetch + pull --rebase' ' git reset --hard to-rebase-orig && git fetch && git pull --rebase && - test "conflicting modification" = "$(cat file)" && - test file = "$(cat file2)" + echo "conflicting modification" >expect && + test_cmp expect file && + echo file >expect && + test_cmp expect file2 ' test_expect_success 'pull --rebase dies early with dirty working directory' ' - git checkout to-rebase && git update-ref refs/remotes/me/copy copy^ && COPY="$(git rev-parse --verify me/copy)" && @@ -596,23 +660,23 @@ test_expect_success 'pull --rebase dies early with dirty working directory' ' test_config branch.to-rebase.remote me && test_config branch.to-rebase.merge refs/heads/copy && test_config branch.to-rebase.rebase true && - echo dirty >> file && + echo dirty >>file && git add file && test_must_fail git pull && - test "$COPY" = "$(git rev-parse --verify me/copy)" && + test_cmp_rev "$COPY" me/copy && git checkout HEAD -- file && git pull && - test "$COPY" != "$(git rev-parse --verify me/copy)" - + test_cmp_rev ! "$COPY" me/copy ' test_expect_success 'pull --rebase works on branch yet to be born' ' git rev-parse master >expect && mkdir empty_repo && - (cd empty_repo && - git init && - git pull --rebase .. master && - git rev-parse HEAD >../actual + ( + cd empty_repo && + git init && + git pull --rebase .. master && + git rev-parse HEAD >../actual ) && test_cmp expect actual ' @@ -624,10 +688,14 @@ test_expect_success 'pull --rebase fails on unborn branch with staged changes' ' cd empty_repo2 && echo staged-file >staged-file && git add staged-file && - test "$(git ls-files)" = staged-file && + echo staged-file >expect && + git ls-files >actual && + test_cmp expect actual && test_must_fail git pull --rebase .. master 2>err && - test "$(git ls-files)" = staged-file && - test "$(git show :staged-file)" = staged-file && + git ls-files >actual && + test_cmp expect actual && + git show :staged-file >actual && + test_cmp expect actual && test_i18ngrep "unborn branch with changes added to the index" err ) ' @@ -638,7 +706,8 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' ' ( cd corrupt && test_commit one && - obj=$(git rev-parse --verify HEAD | sed "s#^..#&/#") && + git rev-parse --verify HEAD >head && + obj=$(sed "s#^..#&/#" head) && rm -f .git/objects/$obj && test_must_fail git pull --rebase ) @@ -646,66 +715,79 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' ' test_expect_success 'setup for detecting upstreamed changes' ' mkdir src && - (cd src && - git init && - printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff && - git add stuff && - git commit -m "Initial revision" + ( + cd src && + git init && + printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff && + git add stuff && + git commit -m "Initial revision" ) && git clone src dst && - (cd src && - modify s/5/43/ stuff && - git commit -a -m "5->43" && - modify s/6/42/ stuff && - git commit -a -m "Make it bigger" + ( + cd src && + modify s/5/43/ stuff && + git commit -a -m "5->43" && + modify s/6/42/ stuff && + git commit -a -m "Make it bigger" ) && - (cd dst && - modify s/5/43/ stuff && - git commit -a -m "Independent discovery of 5->43" + ( + cd dst && + modify s/5/43/ stuff && + git commit -a -m "Independent discovery of 5->43" ) ' test_expect_success 'git pull --rebase detects upstreamed changes' ' - (cd dst && - git pull --rebase && - test -z "$(git ls-files -u)" + ( + cd dst && + git pull --rebase && + git ls-files -u >untracked && + test_must_be_empty untracked ) ' test_expect_success 'setup for avoiding reapplying old patches' ' - (cd dst && - test_might_fail git rebase --abort && - git reset --hard origin/master + ( + cd dst && + test_might_fail git rebase --abort && + git reset --hard origin/master ) && git clone --bare src src-replace.git && rm -rf src && mv src-replace.git src && - (cd dst && - modify s/2/22/ stuff && - git commit -a -m "Change 2" && - modify s/3/33/ stuff && - git commit -a -m "Change 3" && - modify s/4/44/ stuff && - git commit -a -m "Change 4" && - git push && - - modify s/44/55/ stuff && - git commit --amend -a -m "Modified Change 4" + ( + cd dst && + modify s/2/22/ stuff && + git commit -a -m "Change 2" && + modify s/3/33/ stuff && + git commit -a -m "Change 3" && + modify s/4/44/ stuff && + git commit -a -m "Change 4" && + git push && + + modify s/44/55/ stuff && + git commit --amend -a -m "Modified Change 4" ) ' test_expect_success 'git pull --rebase does not reapply old patches' ' - (cd dst && - test_must_fail git pull --rebase && - test 1 = $(find .git/rebase-apply -name "000*" | wc -l) + ( + cd dst && + test_must_fail git pull --rebase && + cat .git/rebase-merge/done .git/rebase-merge/git-rebase-todo >work && + grep -v -e \# -e ^$ work >patches && + test_line_count = 1 patches && + rm -f work ) ' test_expect_success 'git pull --rebase against local branch' ' git checkout -b copy2 to-rebase-orig && git pull --rebase . to-rebase && - test "conflicting modification" = "$(cat file)" && - test file = "$(cat file2)" + echo "conflicting modification" >expect && + test_cmp expect file && + echo file >expect && + test_cmp expect file2 ' test_done diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh index 44309566f134..4d1e0c363ea1 100755 --- a/t/t5528-push-default.sh +++ b/t/t5528-push-default.sh @@ -163,7 +163,7 @@ test_pushdefault_workflow success current master # update parent1's foo (which is our upstream) test_pushdefault_workflow success upstream foo -# upsream is foo which is not the name of the current branch +# upstream is foo which is not the name of the current branch test_pushdefault_workflow failure simple master # master and foo are updated diff --git a/t/t5530-upload-pack-error.sh b/t/t5530-upload-pack-error.sh index a1d3031d40dc..4ce9a9f70411 100755 --- a/t/t5530-upload-pack-error.sh +++ b/t/t5530-upload-pack-error.sh @@ -14,7 +14,7 @@ corrupt_repo () { } test_expect_success 'setup and corrupt repository' ' - + test_oid_init && echo file >file && git add file && git rev-parse :file && @@ -31,9 +31,10 @@ test_expect_success 'fsck fails' ' ' test_expect_success 'upload-pack fails due to error in pack-objects packing' ' - - printf "0032want %s\n00000009done\n0000" \ - $(git rev-parse HEAD) >input && + head=$(git rev-parse HEAD) && + hexsz=$(test_oid hexsz) && + printf "%04xwant %s\n00000009done\n0000" \ + $(($hexsz + 10)) $head >input && test_must_fail git upload-pack . /dev/null 2>output.err && test_i18ngrep "unable to read" output.err && test_i18ngrep "pack-objects died" output.err @@ -51,16 +52,17 @@ test_expect_success 'fsck fails' ' ' test_expect_success 'upload-pack fails due to error in rev-list' ' - printf "0032want %s\n0034shallow %s00000009done\n0000" \ - $(git rev-parse HEAD) $(git rev-parse HEAD^) >input && + printf "%04xwant %s\n%04xshallow %s00000009done\n0000" \ + $(($hexsz + 10)) $(git rev-parse HEAD) \ + $(($hexsz + 12)) $(git rev-parse HEAD^) >input && test_must_fail git upload-pack . /dev/null 2>output.err && grep "bad tree object" output.err ' test_expect_success 'upload-pack fails due to bad want (no object)' ' - printf "0045want %s multi_ack_detailed\n00000009done\n0000" \ - "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" >input && + printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \ + $(($hexsz + 29)) $(test_oid deadbeef) >input && test_must_fail git upload-pack . output 2>output.err && grep "not our ref" output.err && grep "ERR" output && @@ -70,8 +72,8 @@ test_expect_success 'upload-pack fails due to bad want (no object)' ' test_expect_success 'upload-pack fails due to bad want (not tip)' ' oid=$(echo an object we have | git hash-object -w --stdin) && - printf "0045want %s multi_ack_detailed\n00000009done\n0000" \ - "$oid" >input && + printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \ + $(($hexsz + 29)) "$oid" >input && test_must_fail git upload-pack . output 2>output.err && grep "not our ref" output.err && grep "ERR" output && @@ -80,8 +82,8 @@ test_expect_success 'upload-pack fails due to bad want (not tip)' ' test_expect_success 'upload-pack fails due to error in pack-objects enumeration' ' - printf "0032want %s\n00000009done\n0000" \ - $(git rev-parse HEAD) >input && + printf "%04xwant %s\n00000009done\n0000" \ + $((hexsz + 10)) $(git rev-parse HEAD) >input && test_must_fail git upload-pack . /dev/null 2>output.err && grep "bad tree object" output.err && grep "pack-objects died" output.err diff --git a/t/t5535-fetch-push-symref.sh b/t/t5535-fetch-push-symref.sh index 8ed58d27f243..e8f6d233ffb8 100755 --- a/t/t5535-fetch-push-symref.sh +++ b/t/t5535-fetch-push-symref.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='avoiding conflicting update thru symref aliasing' +test_description='avoiding conflicting update through symref aliasing' . ./test-lib.sh diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh index 66f0b64d3927..4f681dbbe11c 100755 --- a/t/t5537-fetch-shallow.sh +++ b/t/t5537-fetch-shallow.sh @@ -15,7 +15,11 @@ test_expect_success 'setup' ' commit 2 && commit 3 && commit 4 && - git config --global transfer.fsckObjects true + git config --global transfer.fsckObjects true && + test_oid_cache <<-EOF + perl sha1:s/0034shallow %s/0036unshallow %s/ + perl sha256:s/004cshallow %s/004eunshallow %s/ + EOF ' test_expect_success 'setup shallow clone' ' @@ -233,26 +237,29 @@ test_expect_success 'shallow fetches check connectivity before writing shallow f git -C "$REPO" config protocol.version 2 && git -C client config protocol.version 2 && - git -C client fetch --depth=2 "$HTTPD_URL/one_time_sed/repo" master:a_branch && + git -C client fetch --depth=2 "$HTTPD_URL/one_time_perl/repo" master:a_branch && # Craft a situation in which the server sends back an unshallow request # with an empty packfile. This is done by refetching with a shorter # depth (to ensure that the packfile is empty), and overwriting the # shallow line in the response with the unshallow line we want. - printf "s/0034shallow %s/0036unshallow %s/" \ + printf "$(test_oid perl)" \ "$(git -C "$REPO" rev-parse HEAD)" \ "$(git -C "$REPO" rev-parse HEAD^)" \ - >"$HTTPD_ROOT_PATH/one-time-sed" && + >"$HTTPD_ROOT_PATH/one-time-perl" && test_must_fail env GIT_TEST_SIDEBAND_ALL=0 git -C client \ - fetch --depth=1 "$HTTPD_URL/one_time_sed/repo" \ + fetch --depth=1 "$HTTPD_URL/one_time_perl/repo" \ master:a_branch && - # Ensure that the one-time-sed script was used. - ! test -e "$HTTPD_ROOT_PATH/one-time-sed" && + # Ensure that the one-time-perl script was used. + ! test -e "$HTTPD_ROOT_PATH/one-time-perl" && # Ensure that the resulting repo is consistent, despite our failure to # fetch. git -C client fsck ' +# DO NOT add non-httpd-specific tests here, because the last part of this +# test script is only executed when httpd is available and enabled. + test_done diff --git a/t/t5539-fetch-http-shallow.sh b/t/t5539-fetch-http-shallow.sh index b4ad81f00635..c0d02dee893f 100755 --- a/t/t5539-fetch-http-shallow.sh +++ b/t/t5539-fetch-http-shallow.sh @@ -69,7 +69,7 @@ test_expect_success 'no shallow lines after receiving ACK ready' ' test_commit new-too && # NEEDSWORK: If the overspecification of the expected result is reduced, we # might be able to run this test in all protocol versions. - GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION= \ + GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION=0 \ git fetch --depth=2 && grep "fetch-pack< ACK .* ready" ../trace && ! grep "fetch-pack> done" ../trace diff --git a/t/t5540-http-push-webdav.sh b/t/t5540-http-push-webdav.sh index a094fd5e7133..d476c335098e 100755 --- a/t/t5540-http-push-webdav.sh +++ b/t/t5540-http-push-webdav.sh @@ -134,15 +134,13 @@ test_expect_success 'MKCOL sends directory names with trailing slashes' ' x1="[0-9a-f]" x2="$x1$x1" -x5="$x1$x1$x1$x1$x1" -x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1" -x40="$x38$x2" +xtrunc=$(echo $OID_REGEX | sed -e "s/\[0-9a-f\]\[0-9a-f\]//") test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' ' sed \ -e "s/PUT /OP /" \ -e "s/MOVE /OP /" \ - -e "s|/objects/$x2/${x38}_$x40|WANTED_PATH_REQUEST|" \ + -e "s|/objects/$x2/${xtrunc}_$OID_REGEX|WANTED_PATH_REQUEST|" \ "$HTTPD_ROOT_PATH"/access.log | grep -e "\"OP .*WANTED_PATH_REQUEST HTTP/[.0-9]*\" 20[0-9] " diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index b86ddb60f2ea..23be8ce92d67 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -49,7 +49,7 @@ test_expect_success 'no empty path components' ' # NEEDSWORK: If the overspecification of the expected result is reduced, we # might be able to run this test in all protocol versions. - if test -z "$GIT_TEST_PROTOCOL_VERSION" + if test "$GIT_TEST_PROTOCOL_VERSION" = 0 then check_access_log exp fi @@ -135,7 +135,7 @@ EOF test_expect_success 'used receive-pack service' ' # NEEDSWORK: If the overspecification of the expected result is reduced, we # might be able to run this test in all protocol versions. - if test -z "$GIT_TEST_PROTOCOL_VERSION" + if test "$GIT_TEST_PROTOCOL_VERSION" = 0 then check_access_log exp fi @@ -184,11 +184,12 @@ test_expect_success 'push --atomic also prevents branch creation, reports collat test_config -C "$d" http.receivepack true && up="$HTTPD_URL"/smart/atomic-branches.git && - # Tell "$up" about two branches for now + # Tell "$up" about three branches for now test_commit atomic1 && test_commit atomic2 && git branch collateral && - git push "$up" master collateral && + git branch other && + git push "$up" master collateral other && # collateral is a valid push, but should be failed by atomic push git checkout collateral && @@ -226,6 +227,41 @@ test_expect_success 'push --atomic also prevents branch creation, reports collat grep "^ ! .*rejected.* collateral -> collateral .*atomic push failed" output ' +test_expect_success 'push --atomic fails on server-side errors' ' + # Use previously set up repository + d=$HTTPD_DOCUMENT_ROOT_PATH/atomic-branches.git && + test_config -C "$d" http.receivepack true && + up="$HTTPD_URL"/smart/atomic-branches.git && + + # break ref updates for other on the remote site + mkdir "$d/refs/heads/other.lock" && + + # add the new commit to other + git branch -f other collateral && + + # --atomic should cause entire push to be rejected + test_must_fail git push --atomic "$up" atomic other 2>output && + + # the new branch should not have been created upstream + test_must_fail git -C "$d" show-ref --verify refs/heads/atomic && + + # upstream should still reflect atomic2, the last thing we pushed + # successfully + git rev-parse atomic2 >expected && + # ...to other. + git -C "$d" rev-parse refs/heads/other >actual && + test_cmp expected actual && + + # the new branch should not have been created upstream + test_must_fail git -C "$d" show-ref --verify refs/heads/atomic && + + # the failed refs should be indicated to the user + grep "^ ! .*rejected.* other -> other .*atomic transaction failed" output && + + # the collateral failure refs should be indicated to the user + grep "^ ! .*rejected.* atomic -> atomic .*atomic transaction failed" output +' + test_expect_success 'push --all can push to empty repo' ' d=$HTTPD_DOCUMENT_ROOT_PATH/empty-all.git && git init --bare "$d" && @@ -262,7 +298,7 @@ test_expect_success TTY 'push shows progress when stderr is a tty' ' cd "$ROOT_PATH"/test_repo_clone && test_commit noisy && test_terminal git push >output 2>&1 && - test_i18ngrep "Writing objects" output + test_i18ngrep "^Writing objects" output ' test_expect_success TTY 'push --quiet silences status and progress' ' @@ -277,7 +313,7 @@ test_expect_success TTY 'push --no-progress silences progress but not status' ' test_commit no-progress && test_terminal git push --no-progress >output 2>&1 && test_i18ngrep "^To http" output && - test_i18ngrep ! "Writing objects" output + test_i18ngrep ! "^Writing objects" output ' test_expect_success 'push --progress shows progress to non-tty' ' @@ -285,7 +321,7 @@ test_expect_success 'push --progress shows progress to non-tty' ' test_commit progress && git push --progress >output 2>&1 && test_i18ngrep "^To http" output && - test_i18ngrep "Writing objects" output + test_i18ngrep "^Writing objects" output ' test_expect_success 'http push gives sane defaults to reflog' ' diff --git a/t/t5545-push-options.sh b/t/t5545-push-options.sh index 6d1d59c9b1af..38e6f7340e74 100755 --- a/t/t5545-push-options.sh +++ b/t/t5545-push-options.sh @@ -115,7 +115,7 @@ test_expect_success 'push options and submodules' ' git -C parent submodule add ../upstream workbench && git -C parent/workbench remote add up ../../upstream && - git -C parent commit -m "add submoule" && + git -C parent commit -m "add submodule" && test_commit -C parent/workbench two && git -C parent add workbench && @@ -278,4 +278,7 @@ test_expect_success 'push options keep quoted characters intact (http)' ' test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/pre-receive.push_options ' +# DO NOT add non-httpd-specific tests here, because the last part of this +# test script is only executed when httpd is available and enabled. + test_done diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh index b811d89cfd6d..ea2688bde59c 100755 --- a/t/t5550-http-fetch-dumb.sh +++ b/t/t5550-http-fetch-dumb.sh @@ -321,11 +321,17 @@ test_expect_success 'git client does not send an empty Accept-Language' ' ' test_expect_success 'remote-http complains cleanly about malformed urls' ' - # do not actually issue "list" or other commands, as we do not - # want to rely on what curl would actually do with such a broken - # URL. This is just about making sure we do not segfault during - # initialization. - test_must_fail git remote-http http::/example.com/repo.git + test_must_fail git remote-http http::/example.com/repo.git 2>stderr && + test_i18ngrep "url has no scheme" stderr +' + +# NEEDSWORK: Writing commands to git-remote-curl can race against the latter +# erroring out, producing SIGPIPE. Remove "ok=sigpipe" once transport-helper has +# learned to handle early remote helper failures more cleanly. +test_expect_success 'remote-http complains cleanly about empty scheme' ' + test_must_fail ok=sigpipe git ls-remote \ + http::${HTTPD_URL#http}/dumb/repo.git 2>stderr && + test_i18ngrep "url has no scheme" stderr ' test_expect_success 'redirects can be forbidden/allowed' ' diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh index e38e54386795..6788aefaceb8 100755 --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@ -43,7 +43,7 @@ test_expect_success 'clone http repository' ' < Cache-Control: no-cache, max-age=0, must-revalidate < Content-Type: application/x-git-upload-pack-result EOF - GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION= \ + GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION=0 \ git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err && test_cmp file clone/file && tr '\''\015'\'' Q Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \ actual >actual.smudged && @@ -113,7 +113,7 @@ test_expect_success 'used upload-pack service' ' # NEEDSWORK: If the overspecification of the expected result is reduced, we # might be able to run this test in all protocol versions. - if test -z "$GIT_TEST_PROTOCOL_VERSION" + if test "$GIT_TEST_PROTOCOL_VERSION" = 0 then check_access_log exp fi @@ -241,7 +241,7 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set # NEEDSWORK: If the overspecification of the expected result is reduced, we # might be able to run this test in all protocol versions. - if test -z "$GIT_TEST_PROTOCOL_VERSION" + if test "$GIT_TEST_PROTOCOL_VERSION" = 0 then tail -3 cookies.txt | sort >cookies_tail.txt && test_cmp expect_cookies.txt cookies_tail.txt @@ -336,7 +336,7 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' ' git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" && # Some protocol versions (e.g. 2) support fetching # unadvertised objects, so restrict this test to v0. - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" ' @@ -358,7 +358,7 @@ test_expect_success 'test allowanysha1inwant with unreachable' ' git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" && # Some protocol versions (e.g. 2) support fetching # unadvertised objects, so restrict this test to v0. - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" && git -C "$server" config uploadpack.allowanysha1inwant 1 && diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh index 8a14be51a132..156c70404083 100755 --- a/t/t5552-skipping-fetch-negotiator.sh +++ b/t/t5552-skipping-fetch-negotiator.sh @@ -60,29 +60,6 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc have_not_sent c6 c4 c3 ' -test_expect_success 'unknown fetch.negotiationAlgorithm values error out' ' - rm -rf server client trace && - git init server && - test_commit -C server to_fetch && - - git init client && - test_commit -C client on_client && - git -C client checkout on_client && - - test_config -C client fetch.negotiationAlgorithm invalid && - test_must_fail git -C client fetch "$(pwd)/server" 2>err && - test_i18ngrep "unknown fetch negotiation algorithm" err && - - # Explicit "default" value - test_config -C client fetch.negotiationAlgorithm default && - git -C client -c fetch.negotiationAlgorithm=default fetch "$(pwd)/server" && - - # Implementation detail: If there is nothing to fetch, we will not error out - test_config -C client fetch.negotiationAlgorithm invalid && - git -C client fetch "$(pwd)/server" 2>err && - test_i18ngrep ! "unknown fetch negotiation algorithm" err -' - test_expect_success 'when two skips collide, favor the larger one' ' rm -rf server client trace && git init server && @@ -130,7 +107,11 @@ test_expect_success 'use ref advertisement to filter out commits' ' # The ref advertisement itself is filtered when protocol v2 is used, so # use v0. - GIT_TEST_PROTOCOL_VERSION= trace_fetch client origin to_fetch && + ( + GIT_TEST_PROTOCOL_VERSION=0 && + export GIT_TEST_PROTOCOL_VERSION && + trace_fetch client origin to_fetch + ) && have_sent c5 c4^ c2side && have_not_sent c4 c4^^ c4^^^ ' @@ -192,7 +173,17 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC test_commit -C server commit-on-b1 && test_config -C client fetch.negotiationalgorithm skipping && - trace_fetch client "$(pwd)/server" to_fetch && + + # NEEDSWORK: The number of "have"s sent depends on whether the transport + # is stateful. If the overspecification of the result were reduced, this + # test could be used for both stateful and stateless transports. + ( + # Force protocol v0, in which local transport is stateful (in + # protocol v2 it is stateless). + GIT_TEST_PROTOCOL_VERSION=0 && + export GIT_TEST_PROTOCOL_VERSION && + trace_fetch client "$(pwd)/server" to_fetch + ) && grep " fetch" trace && # fetch-pack sends 2 requests each containing 16 "have" lines before diff --git a/t/t5553-set-upstream.sh b/t/t5553-set-upstream.sh new file mode 100755 index 000000000000..81975ad8f9eb --- /dev/null +++ b/t/t5553-set-upstream.sh @@ -0,0 +1,178 @@ +#!/bin/sh + +test_description='"git fetch/pull --set-upstream" basic tests.' +. ./test-lib.sh + +check_config () { + printf "%s\n" "$2" "$3" >"expect.$1" && + { + git config "branch.$1.remote" && git config "branch.$1.merge" + } >"actual.$1" && + test_cmp "expect.$1" "actual.$1" +} + +check_config_missing () { + test_expect_code 1 git config "branch.$1.remote" && + test_expect_code 1 git config "branch.$1.merge" +} + +clear_config () { + for branch in "$@"; do + test_might_fail git config --unset-all "branch.$branch.remote" + test_might_fail git config --unset-all "branch.$branch.merge" + done +} + +ensure_fresh_upstream () { + rm -rf parent && git init --bare parent +} + +test_expect_success 'setup bare parent fetch' ' + ensure_fresh_upstream && + git remote add upstream parent +' + +test_expect_success 'setup commit on master and other fetch' ' + test_commit one && + git push upstream master && + git checkout -b other && + test_commit two && + git push upstream other +' + +# tests for fetch --set-upstream + +test_expect_success 'fetch --set-upstream does not set upstream w/o branch' ' + clear_config master other && + git checkout master && + git fetch --set-upstream upstream && + check_config_missing master && + check_config_missing other +' + +test_expect_success 'fetch --set-upstream upstream master sets branch master but not other' ' + clear_config master other && + git fetch --set-upstream upstream master && + check_config master upstream refs/heads/master && + check_config_missing other +' + +test_expect_success 'fetch --set-upstream upstream other sets branch other' ' + clear_config master other && + git fetch --set-upstream upstream other && + check_config master upstream refs/heads/other && + check_config_missing other +' + +test_expect_success 'fetch --set-upstream master:other does not set the branch other2' ' + clear_config other2 && + git fetch --set-upstream upstream master:other2 && + check_config_missing other2 +' + +test_expect_success 'fetch --set-upstream http://nosuchdomain.example.com fails with invalid url' ' + # master explicitly not cleared, we check that it is not touched from previous value + clear_config other other2 && + test_must_fail git fetch --set-upstream http://nosuchdomain.example.com && + check_config master upstream refs/heads/other && + check_config_missing other && + check_config_missing other2 +' + +test_expect_success 'fetch --set-upstream with valid URL sets upstream to URL' ' + clear_config other other2 && + url="file://'"$PWD"'" && + git fetch --set-upstream "$url" && + check_config master "$url" HEAD && + check_config_missing other && + check_config_missing other2 +' + +# tests for pull --set-upstream + +test_expect_success 'setup bare parent pull' ' + git remote rm upstream && + ensure_fresh_upstream && + git remote add upstream parent +' + +test_expect_success 'setup commit on master and other pull' ' + test_commit three && + git push --tags upstream master && + test_commit four && + git push upstream other +' + +test_expect_success 'pull --set-upstream upstream master sets branch master but not other' ' + clear_config master other && + git pull --set-upstream upstream master && + check_config master upstream refs/heads/master && + check_config_missing other +' + +test_expect_success 'pull --set-upstream master:other2 does not set the branch other2' ' + clear_config other2 && + git pull --set-upstream upstream master:other2 && + check_config_missing other2 +' + +test_expect_success 'pull --set-upstream upstream other sets branch master' ' + clear_config master other && + git pull --set-upstream upstream other && + check_config master upstream refs/heads/other && + check_config_missing other +' + +test_expect_success 'pull --set-upstream upstream tag does not set the tag' ' + clear_config three && + git pull --tags --set-upstream upstream three && + check_config_missing three +' + +test_expect_success 'pull --set-upstream http://nosuchdomain.example.com fails with invalid url' ' + # master explicitly not cleared, we check that it is not touched from previous value + clear_config other other2 three && + test_must_fail git pull --set-upstream http://nosuchdomain.example.com && + check_config master upstream refs/heads/other && + check_config_missing other && + check_config_missing other2 && + check_config_missing three +' + +test_expect_success 'pull --set-upstream upstream HEAD sets branch HEAD' ' + clear_config master other && + git pull --set-upstream upstream HEAD && + check_config master upstream HEAD && + git checkout other && + git pull --set-upstream upstream HEAD && + check_config other upstream HEAD +' + +test_expect_success 'pull --set-upstream upstream with more than one branch does nothing' ' + clear_config master three && + git pull --set-upstream upstream master three && + check_config_missing master && + check_config_missing three +' + +test_expect_success 'pull --set-upstream with valid URL sets upstream to URL' ' + clear_config master other other2 && + git checkout master && + url="file://'"$PWD"'" && + git pull --set-upstream "$url" && + check_config master "$url" HEAD && + check_config_missing other && + check_config_missing other2 +' + +test_expect_success 'pull --set-upstream with valid URL and branch sets branch' ' + clear_config master other other2 && + git checkout master && + url="file://'"$PWD"'" && + git pull --set-upstream "$url" master && + check_config master "$url" refs/heads/master && + check_config_missing other && + check_config_missing other2 +' + +test_done diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh index f0f425b2cf57..4a110b307ee5 100755 --- a/t/t5562-http-backend-content-length.sh +++ b/t/t5562-http-backend-content-length.sh @@ -59,7 +59,7 @@ test_expect_success 'setup' ' printf done | packetize >>fetch_body && test_copy_bytes 10 fetch_body.trunc && hash_next=$(git commit-tree -p HEAD -m next HEAD^{tree}) && - printf "%s %s refs/heads/newbranch\\0report-status\\n" "$_z40" "$hash_next" | packetize >push_body && + printf "%s %s refs/heads/newbranch\\0report-status\\n" "$ZERO_OID" "$hash_next" | packetize >push_body && printf 0000 >>push_body && echo "$hash_next" | git pack-objects --stdout >>push_body && test_copy_bytes 10 push_body.trunc && diff --git a/t/t5573-pull-verify-signatures.sh b/t/t5573-pull-verify-signatures.sh index 3e9876e19713..a53dd8550d0b 100755 --- a/t/t5573-pull-verify-signatures.sh +++ b/t/t5573-pull-verify-signatures.sh @@ -60,6 +60,27 @@ test_expect_success GPG 'pull commit with untrusted signature with --verify-sign test_i18ngrep "has an untrusted GPG signature" pullerror ' +test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures and minTrustLevel=ultimate' ' + test_when_finished "git reset --hard && git checkout initial" && + test_config gpg.minTrustLevel ultimate && + test_must_fail git pull --ff-only --verify-signatures untrusted 2>pullerror && + test_i18ngrep "has an untrusted GPG signature" pullerror +' + +test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures and minTrustLevel=marginal' ' + test_when_finished "git reset --hard && git checkout initial" && + test_config gpg.minTrustLevel marginal && + test_must_fail git pull --ff-only --verify-signatures untrusted 2>pullerror && + test_i18ngrep "has an untrusted GPG signature" pullerror +' + +test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures and minTrustLevel=undefined' ' + test_when_finished "git reset --hard && git checkout initial" && + test_config gpg.minTrustLevel undefined && + git pull --ff-only --verify-signatures untrusted >pulloutput && + test_i18ngrep "has a good GPG signature" pulloutput +' + test_expect_success GPG 'pull signed commit with --verify-signatures' ' test_when_finished "git reset --hard && git checkout initial" && git pull --verify-signatures signed >pulloutput && @@ -79,10 +100,53 @@ test_expect_success GPG 'pull commit with bad signature with --no-verify-signatu ' test_expect_success GPG 'pull unsigned commit into unborn branch' ' + test_when_finished "rm -rf empty-repo" && git init empty-repo && test_must_fail \ git -C empty-repo pull --verify-signatures .. 2>pullerror && test_i18ngrep "does not have a GPG signature" pullerror ' +test_expect_success GPG 'pull commit into unborn branch with bad signature and --verify-signatures' ' + test_when_finished "rm -rf empty-repo" && + git init empty-repo && + test_must_fail \ + git -C empty-repo pull --ff-only --verify-signatures ../bad 2>pullerror && + test_i18ngrep "has a bad GPG signature" pullerror +' + +test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures' ' + test_when_finished "rm -rf empty-repo" && + git init empty-repo && + test_must_fail \ + git -C empty-repo pull --ff-only --verify-signatures ../untrusted 2>pullerror && + test_i18ngrep "has an untrusted GPG signature" pullerror +' + +test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures and minTrustLevel=ultimate' ' + test_when_finished "rm -rf empty-repo" && + git init empty-repo && + test_config_global gpg.minTrustLevel ultimate && + test_must_fail \ + git -C empty-repo pull --ff-only --verify-signatures ../untrusted 2>pullerror && + test_i18ngrep "has an untrusted GPG signature" pullerror +' + +test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures and minTrustLevel=marginal' ' + test_when_finished "rm -rf empty-repo" && + git init empty-repo && + test_config_global gpg.minTrustLevel marginal && + test_must_fail \ + git -C empty-repo pull --ff-only --verify-signatures ../untrusted 2>pullerror && + test_i18ngrep "has an untrusted GPG signature" pullerror +' + +test_expect_success GPG 'pull commit into unborn branch with untrusted signature and --verify-signatures and minTrustLevel=undefined' ' + test_when_finished "rm -rf empty-repo" && + git init empty-repo && + test_config_global gpg.minTrustLevel undefined && + git -C empty-repo pull --ff-only --verify-signatures ../untrusted >pulloutput && + test_i18ngrep "has a good GPG signature" pulloutput +' + test_done diff --git a/t/t5580-clone-push-unc.sh b/t/t5580-clone-push-unc.sh deleted file mode 100755 index b3c8a92450bc..000000000000 --- a/t/t5580-clone-push-unc.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -test_description='various Windows-only path tests' -. ./test-lib.sh - -if test_have_prereq CYGWIN -then - alias winpwd='cygpath -aw .' -elif test_have_prereq MINGW -then - alias winpwd=pwd -else - skip_all='skipping Windows-only path tests' - test_done -fi - -UNCPATH="$(winpwd)" -case "$UNCPATH" in -[A-Z]:*) - # Use administrative share e.g. \\localhost\C$\git-sdk-64\usr\src\git - # (we use forward slashes here because MSYS2 and Git accept them, and - # they are easier on the eyes) - UNCPATH="//localhost/${UNCPATH%%:*}\$/${UNCPATH#?:}" - test -d "$UNCPATH" || { - skip_all='could not access administrative share; skipping' - test_done - } - ;; -*) - skip_all='skipping UNC path tests, cannot determine current path as UNC' - test_done - ;; -esac - -test_expect_success setup ' - test_commit initial -' - -test_expect_success clone ' - git clone "file://$UNCPATH" clone -' - -test_expect_success 'clone with backslashed path' ' - BACKSLASHED="$(echo "$UNCPATH" | tr / \\\\)" && - git clone "$BACKSLASHED" backslashed -' - -test_expect_success push ' - ( - cd clone && - git checkout -b to-push && - test_commit to-push && - git push origin HEAD - ) && - rev="$(git -C clone rev-parse --verify refs/heads/to-push)" && - test "$rev" = "$(git rev-parse --verify refs/heads/to-push)" -' - -test_expect_success MINGW 'remote nick cannot contain backslashes' ' - BACKSLASHED="$(winpwd | tr / \\\\)" && - git ls-remote "$BACKSLASHED" >out 2>err && - test_i18ngrep ! "unable to access" err -' - -test_expect_success 'unc alternates' ' - tree="$(git rev-parse HEAD:)" && - mkdir test-unc-alternate && - ( - cd test-unc-alternate && - git init && - test_must_fail git show $tree && - echo "$UNCPATH/.git/objects" >.git/objects/info/alternates && - git show $tree - ) -' - -test_done diff --git a/t/t5580-unc-paths.sh b/t/t5580-unc-paths.sh new file mode 100755 index 000000000000..cf768b3a2790 --- /dev/null +++ b/t/t5580-unc-paths.sh @@ -0,0 +1,89 @@ +#!/bin/sh + +test_description='various Windows-only path tests' +. ./test-lib.sh + +if test_have_prereq CYGWIN +then + alias winpwd='cygpath -aw .' +elif test_have_prereq MINGW +then + alias winpwd=pwd +else + skip_all='skipping Windows-only path tests' + test_done +fi + +UNCPATH="$(winpwd)" +case "$UNCPATH" in +[A-Z]:*) + # Use administrative share e.g. \\localhost\C$\git-sdk-64\usr\src\git + # (we use forward slashes here because MSYS2 and Git accept them, and + # they are easier on the eyes) + UNCPATH="//localhost/${UNCPATH%%:*}\$/${UNCPATH#?:}" + test -d "$UNCPATH" || { + skip_all='could not access administrative share; skipping' + test_done + } + ;; +*) + skip_all='skipping UNC path tests, cannot determine current path as UNC' + test_done + ;; +esac + +test_expect_success setup ' + test_commit initial +' + +test_expect_success clone ' + git clone "file://$UNCPATH" clone +' + +test_expect_success 'clone without file://' ' + git clone "$UNCPATH" clone-without-file +' + +test_expect_success 'clone with backslashed path' ' + BACKSLASHED="$(echo "$UNCPATH" | tr / \\\\)" && + git clone "$BACKSLASHED" backslashed +' + +test_expect_success fetch ' + git init to-fetch && + ( + cd to-fetch && + git fetch "$UNCPATH" master + ) +' + +test_expect_success push ' + ( + cd clone && + git checkout -b to-push && + test_commit to-push && + git push origin HEAD + ) && + rev="$(git -C clone rev-parse --verify refs/heads/to-push)" && + test "$rev" = "$(git rev-parse --verify refs/heads/to-push)" +' + +test_expect_success MINGW 'remote nick cannot contain backslashes' ' + BACKSLASHED="$(winpwd | tr / \\\\)" && + git ls-remote "$BACKSLASHED" 2>err && + test_i18ngrep ! "unable to access" err +' + +test_expect_success 'unc alternates' ' + tree="$(git rev-parse HEAD:)" && + mkdir test-unc-alternate && + ( + cd test-unc-alternate && + git init && + test_must_fail git show $tree && + echo "$UNCPATH/.git/objects" >.git/objects/info/alternates && + git show $tree + ) +' + +test_done diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index 37d76808d4a7..84ea2a3eb707 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -434,7 +434,6 @@ test_expect_success 'double quoted plink.exe in GIT_SSH_COMMAND' ' expect_ssh "-v -P 123" myhost src ' -SQ="'" test_expect_success 'single quoted plink.exe in GIT_SSH_COMMAND' ' copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" && GIT_SSH_COMMAND="$SQ$TRASH_DIRECTORY/plink.exe$SQ -v" \ @@ -636,10 +635,10 @@ partial_clone_server () { rm -rf "$SERVER" client && test_create_repo "$SERVER" && test_commit -C "$SERVER" one && - HASH1=$(git hash-object "$SERVER/one.t") && + HASH1=$(git -C "$SERVER" hash-object one.t) && git -C "$SERVER" revert HEAD && test_commit -C "$SERVER" two && - HASH2=$(git hash-object "$SERVER/two.t") && + HASH2=$(git -C "$SERVER" hash-object two.t) && test_config -C "$SERVER" uploadpack.allowfilter 1 && test_config -C "$SERVER" uploadpack.allowanysha1inwant 1 } @@ -654,7 +653,8 @@ partial_clone () { git -C client fsck && # Ensure that unneeded blobs are not inadvertently fetched. - test_config -C client extensions.partialclone "not a remote" && + test_config -C client remote.origin.promisor "false" && + git -C client config --unset remote.origin.partialclonefilter && test_must_fail git -C client cat-file -e "$HASH1" && # But this blob was fetched, because clone performs an initial checkout @@ -739,4 +739,7 @@ test_expect_success 'partial clone using HTTP' ' partial_clone "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server" ' +# DO NOT add non-httpd-specific tests here, because the last part of this +# test script is only executed when httpd is available and enabled. + test_done diff --git a/t/t5604-clone-reference.sh b/t/t5604-clone-reference.sh index 4894237ab805..0c74b4e21a3e 100755 --- a/t/t5604-clone-reference.sh +++ b/t/t5604-clone-reference.sh @@ -326,15 +326,16 @@ test_expect_success SYMLINKS 'clone repo with symlinked or unknown files at obje for raw in $(ls T*.raw) do sed -e "s!/../!/Y/!; s![0-9a-f]\{38,\}!Z!" -e "/commit-graph/d" \ - -e "/multi-pack-index/d" <$raw >$raw.de-sha || return 1 + -e "/multi-pack-index/d" <$raw >$raw.de-sha-1 && + sort $raw.de-sha-1 >$raw.de-sha || return 1 done && cat >expected-files <<-EOF && ./Y/Z ./Y/Z + ./Y/Z ./a-loose-dir/Z ./an-object - ./Y/Z ./info/packs ./pack/pack-Z.idx ./pack/pack-Z.pack diff --git a/t/t5607-clone-bundle.sh b/t/t5607-clone-bundle.sh index 2a0fb15cf175..9108ff6fbd6f 100755 --- a/t/t5607-clone-bundle.sh +++ b/t/t5607-clone-bundle.sh @@ -64,7 +64,7 @@ test_expect_success 'ridiculously long subject in boundary' ' test -s heads && git fetch long-subject-bundle.bdl && sed -n "/^-/{p;q;}" long-subject-bundle.bdl >boundary && - grep "^-[0-9a-f]\\{40\\} " boundary + grep "^-$OID_REGEX " boundary ' test_expect_success 'prerequisites with an empty commit message' ' @@ -83,4 +83,15 @@ test_expect_success 'failed bundle creation does not leave cruft' ' test_path_is_missing fail.bundle.lock ' +test_expect_success 'fetch SHA-1 from bundle' ' + test_create_repo foo && + test_commit -C foo x && + git -C foo bundle create tip.bundle -1 master && + git -C foo rev-parse HEAD >hash && + + # Exercise to ensure that fetching a SHA-1 from a bundle works with no + # errors + git fetch --no-tags foo/tip.bundle "$(cat hash)" +' + test_done diff --git a/t/t5608-clone-2gb.sh b/t/t5608-clone-2gb.sh index 2c6bc07344cc..eee084288841 100755 --- a/t/t5608-clone-2gb.sh +++ b/t/t5608-clone-2gb.sh @@ -3,7 +3,7 @@ test_description='Test cloning a repository larger than 2 gigabyte' . ./test-lib.sh -if test -z "$GIT_TEST_CLONE_2GB" +if ! test_bool_env GIT_TEST_CLONE_2GB false then say 'Skipping expensive 2GB clone test; enable it with GIT_TEST_CLONE_2GB=t' else diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh index b91ef548f86b..77bb91e97692 100755 --- a/t/t5616-partial-clone.sh +++ b/t/t5616-partial-clone.sh @@ -42,8 +42,16 @@ test_expect_success 'do partial clone 1' ' test_cmp expect_1.oids observed.oids && test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" && - test "$(git -C pc1 config --local extensions.partialclone)" = "origin" && - test "$(git -C pc1 config --local core.partialclonefilter)" = "blob:none" + test "$(git -C pc1 config --local remote.origin.promisor)" = "true" && + test "$(git -C pc1 config --local remote.origin.partialclonefilter)" = "blob:none" +' + +test_expect_success 'verify that .promisor file contains refs fetched' ' + ls pc1/.git/objects/pack/pack-*.promisor >promisorlist && + test_line_count = 1 promisorlist && + git -C srv.bare rev-list HEAD >headhash && + grep "$(cat headhash) HEAD" $(cat promisorlist) && + grep "$(cat headhash) refs/heads/master" $(cat promisorlist) ' # checkout master to force dynamic object fetch of blobs at HEAD. @@ -208,6 +216,25 @@ test_expect_success 'use fsck before and after manually fetching a missing subtr test_cmp unique_types.expected unique_types.observed ' +test_expect_success 'implicitly construct combine: filter with repeated flags' ' + GIT_TRACE=$(pwd)/trace git clone --bare \ + --filter=blob:none --filter=tree:1 \ + "file://$(pwd)/srv.bare" pc2 && + grep "trace:.* git pack-objects .*--filter=combine:blob:none+tree:1" \ + trace && + git -C pc2 rev-list --objects --missing=allow-any HEAD >objects && + + # We should have gotten some root trees. + grep " $" objects && + # Should not have gotten any non-root trees or blobs. + ! grep " ." objects && + + xargs -n 1 git -C pc2 cat-file -t types && + sort -u types >unique_types.actual && + test_write_lines commit tree >unique_types.expected && + test_cmp unique_types.expected unique_types.actual +' + test_expect_success 'partial clone fetches blobs pointed to by refs even if normally filtered out' ' rm -rf src dst && git init src && @@ -241,6 +268,153 @@ test_expect_success 'fetch what is specified on CLI even if already promised' ' ! grep "?$(cat blob)" missing_after ' +test_expect_success 'setup src repo for sparse filter' ' + git init sparse-src && + git -C sparse-src config --local uploadpack.allowfilter 1 && + git -C sparse-src config --local uploadpack.allowanysha1inwant 1 && + test_commit -C sparse-src one && + test_commit -C sparse-src two && + echo /one.t >sparse-src/only-one && + git -C sparse-src add . && + git -C sparse-src commit -m "add sparse checkout files" +' + +test_expect_success 'partial clone with sparse filter succeeds' ' + rm -rf dst.git && + git clone --no-local --bare \ + --filter=sparse:oid=master:only-one \ + sparse-src dst.git && + ( + cd dst.git && + git rev-list --objects --missing=print HEAD >out && + grep "^$(git rev-parse HEAD:one.t)" out && + grep "^?$(git rev-parse HEAD:two.t)" out + ) +' + +test_expect_success 'partial clone with unresolvable sparse filter fails cleanly' ' + rm -rf dst.git && + test_must_fail git clone --no-local --bare \ + --filter=sparse:oid=master:no-such-name \ + sparse-src dst.git 2>err && + test_i18ngrep "unable to access sparse blob in .master:no-such-name" err && + test_must_fail git clone --no-local --bare \ + --filter=sparse:oid=master \ + sparse-src dst.git 2>err && + test_i18ngrep "unable to parse sparse filter data in" err +' + +setup_triangle () { + rm -rf big-blob.txt server client promisor-remote && + + printf "line %d\n" $(test_seq 1 100) >big-blob.txt && + + # Create a server with 2 commits: a commit with a big tree and a child + # commit with an incremental change. Also, create a partial clone + # client that only contains the first commit. + git init server && + git -C server config --local uploadpack.allowfilter 1 && + for i in $(test_seq 1 100) + do + echo "make the tree big" >server/file$i && + git -C server add file$i + done && + git -C server commit -m "initial" && + git clone --bare --filter=tree:0 "file://$(pwd)/server" client && + echo another line >>server/file1 && + git -C server commit -am "incremental change" && + + # Create a promisor remote that only contains the tree and blob from + # the first commit. + git init promisor-remote && + git -C server config --local uploadpack.allowanysha1inwant 1 && + TREE_HASH=$(git -C server rev-parse HEAD~1^{tree}) && + git -C promisor-remote fetch --keep "file://$(pwd)/server" "$TREE_HASH" && + git -C promisor-remote count-objects -v >object-count && + test_i18ngrep "count: 0" object-count && + test_i18ngrep "in-pack: 2" object-count && + + # Set it as the promisor remote of client. Thus, whenever + # the client lazy fetches, the lazy fetch will succeed only if it is + # for this tree or blob. + test_commit -C promisor-remote one && # so that ref advertisement is not empty + git -C promisor-remote config --local uploadpack.allowanysha1inwant 1 && + git -C client remote set-url origin "file://$(pwd)/promisor-remote" +} + +# NEEDSWORK: The tests beginning with "fetch lazy-fetches" below only +# test that "fetch" avoid fetching trees and blobs, but not commits or +# tags. Revisit this if Git is ever taught to support partial clones +# with commits and/or tags filtered out. + +test_expect_success 'fetch lazy-fetches only to resolve deltas' ' + setup_triangle && + + # Exercise to make sure it works. Git will not fetch anything from the + # promisor remote other than for the big tree (because it needs to + # resolve the delta). + GIT_TRACE_PACKET="$(pwd)/trace" git -C client \ + fetch "file://$(pwd)/server" master && + + # Verify the assumption that the client needed to fetch the delta base + # to resolve the delta. + git -C server rev-parse HEAD~1^{tree} >hash && + grep "want $(cat hash)" trace +' + +test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' ' + setup_triangle && + + git -C server config --local protocol.version 2 && + git -C client config --local protocol.version 2 && + git -C promisor-remote config --local protocol.version 2 && + + # Exercise to make sure it works. Git will not fetch anything from the + # promisor remote other than for the big blob (because it needs to + # resolve the delta). + GIT_TRACE_PACKET="$(pwd)/trace" git -C client \ + fetch "file://$(pwd)/server" master && + + # Verify that protocol version 2 was used. + grep "fetch< version 2" trace && + + # Verify the assumption that the client needed to fetch the delta base + # to resolve the delta. + git -C server rev-parse HEAD~1^{tree} >hash && + grep "want $(cat hash)" trace +' + +# The following two tests must be in this order, or else +# the first will not fail. It is important that the srv.bare +# repository did not have tags during clone, but has tags +# in the fetch. + +test_expect_failure 'verify fetch succeeds when asking for new tags' ' + git clone --filter=blob:none "file://$(pwd)/srv.bare" tag-test && + for i in I J K + do + test_commit -C src $i && + git -C src branch $i || return 1 + done && + git -C srv.bare fetch --tags origin +refs/heads/*:refs/heads/* && + git -C tag-test -c protocol.version=2 fetch --tags origin +' + +test_expect_success 'verify fetch downloads only one pack when updating refs' ' + git clone --filter=blob:none "file://$(pwd)/srv.bare" pack-test && + ls pack-test/.git/objects/pack/*pack >pack-list && + test_line_count = 2 pack-list && + for i in A B C + do + test_commit -C src $i && + git -C src branch $i || return 1 + done && + git -C srv.bare fetch origin +refs/heads/*:refs/heads/* && + git -C pack-test fetch origin && + ls pack-test/.git/objects/pack/*pack >pack-list && + test_line_count = 3 pack-list +' + . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -255,14 +429,18 @@ intersperse () { sed 's/\(..\)/'$1'\1/g' } -# Create a one-time-sed command to replace the existing packfile with $1. +# Create a one-time-perl command to replace the existing packfile with $1. replace_packfile () { # The protocol requires that the packfile be sent in sideband 1, hence # the extra \x01 byte at the beginning. - printf "1,/packfile/!c %04x\\\\x01%s0000" \ - "$(($(wc -c <$1) + 5))" \ - "$(hex_unpack <$1 | intersperse '\\x')" \ - >"$HTTPD_ROOT_PATH/one-time-sed" + cp $1 "$HTTPD_ROOT_PATH/one-time-pack" && + echo 'if (/packfile/) { + print; + my $length = -s "one-time-pack"; + printf "%04x\x01", $length + 5; + print `cat one-time-pack` . "0000"; + last + }' >"$HTTPD_ROOT_PATH/one-time-perl" } test_expect_success 'upon cloning, check that all refs point to objects' ' @@ -286,16 +464,16 @@ test_expect_success 'upon cloning, check that all refs point to objects' ' # \x01 byte at the beginning. replace_packfile incomplete.pack && - # Use protocol v2 because the sed command looks for the "packfile" + # Use protocol v2 because the perl command looks for the "packfile" # section header. test_config -C "$SERVER" protocol.version 2 && test_must_fail git -c protocol.version=2 clone \ - --filter=blob:none $HTTPD_URL/one_time_sed/server repo 2>err && + --filter=blob:none $HTTPD_URL/one_time_perl/server repo 2>err && test_i18ngrep "did not send all necessary objects" err && - # Ensure that the one-time-sed script was used. - ! test -e "$HTTPD_ROOT_PATH/one-time-sed" + # Ensure that the one-time-perl script was used. + ! test -e "$HTTPD_ROOT_PATH/one-time-perl" ' test_expect_success 'when partial cloning, tolerate server not sending target of tag' ' @@ -326,17 +504,17 @@ test_expect_success 'when partial cloning, tolerate server not sending target of # \x01 byte at the beginning. replace_packfile incomplete.pack && - # Use protocol v2 because the sed command looks for the "packfile" + # Use protocol v2 because the perl command looks for the "packfile" # section header. test_config -C "$SERVER" protocol.version 2 && # Exercise to make sure it works. git -c protocol.version=2 clone \ - --filter=blob:none $HTTPD_URL/one_time_sed/server repo 2> err && + --filter=blob:none $HTTPD_URL/one_time_perl/server repo 2> err && ! grep "missing object referenced by" err && - # Ensure that the one-time-sed script was used. - ! test -e "$HTTPD_ROOT_PATH/one-time-sed" + # Ensure that the one-time-perl script was used. + ! test -e "$HTTPD_ROOT_PATH/one-time-perl" ' test_expect_success 'tolerate server sending REF_DELTA against missing promisor objects' ' @@ -359,7 +537,7 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor # Clone. The client has deltabase_have but not deltabase_missing. git -c protocol.version=2 clone --no-checkout \ - --filter=blob:none $HTTPD_URL/one_time_sed/server repo && + --filter=blob:none $HTTPD_URL/one_time_perl/server repo && git -C repo hash-object -w -- "$SERVER/have.txt" && # Sanity check to ensure that the client does not have @@ -400,7 +578,7 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor replace_packfile thin.pack && - # Use protocol v2 because the sed command looks for the "packfile" + # Use protocol v2 because the perl command looks for the "packfile" # section header. test_config -C "$SERVER" protocol.version 2 && @@ -413,8 +591,11 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor grep "want $(cat deltabase_missing)" trace && ! grep "want $(cat deltabase_have)" trace && - # Ensure that the one-time-sed script was used. - ! test -e "$HTTPD_ROOT_PATH/one-time-sed" + # Ensure that the one-time-perl script was used. + ! test -e "$HTTPD_ROOT_PATH/one-time-perl" ' +# DO NOT add non-httpd-specific tests here, because the last part of this +# test script is only executed when httpd is available and enabled. + test_done diff --git a/t/t5617-clone-submodules-remote.sh b/t/t5617-clone-submodules-remote.sh index 37fcce9c40c9..1a041df10bee 100755 --- a/t/t5617-clone-submodules-remote.sh +++ b/t/t5617-clone-submodules-remote.sh @@ -14,7 +14,8 @@ test_expect_success 'setup' ' cd sub && git init && test_commit subcommit1 && - git tag sub_when_added_to_super + git tag sub_when_added_to_super && + git branch other ) && git submodule add "file://$pwd/sub" sub && git commit -m "add submodule" && @@ -51,4 +52,14 @@ test_expect_success 'check the default is --no-remote-submodules' ' ) ' +test_expect_success 'clone with --single-branch' ' + test_when_finished "rm -rf super_clone" && + git clone --recurse-submodules --single-branch "file://$pwd/." super_clone && + ( + cd super_clone/sub && + git rev-parse --verify origin/master && + test_must_fail git rev-parse --verify origin/other + ) +' + test_done diff --git a/t/t5700-protocol-v1.sh b/t/t5700-protocol-v1.sh index 7c9511c593c1..022901b9eb6f 100755 --- a/t/t5700-protocol-v1.sh +++ b/t/t5700-protocol-v1.sh @@ -5,7 +5,8 @@ test_description='test git wire-protocol transition' TEST_NO_CREATE_REPO=1 # This is a protocol-specific test. -GIT_TEST_PROTOCOL_VERSION= +GIT_TEST_PROTOCOL_VERSION=0 +export GIT_TEST_PROTOCOL_VERSION . ./test-lib.sh @@ -292,4 +293,7 @@ test_expect_success 'push with http:// using protocol v1' ' grep "git< version 1" log ' +# DO NOT add non-httpd-specific tests here, because the last part of this +# test script is only executed when httpd is available and enabled. + test_done diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 011b81d4fc27..5039e66dc47c 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -32,7 +32,7 @@ test_expect_success 'list refs with git:// using protocol v2' ' test_cmp expect actual ' -test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' ' +test_expect_success 'ref advertisement is filtered with ls-remote using protocol v2' ' test_when_finished "rm -f log" && GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ @@ -154,7 +154,7 @@ test_expect_success 'list refs with file:// using protocol v2' ' test_cmp expect actual ' -test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' ' +test_expect_success 'ref advertisement is filtered with ls-remote using protocol v2' ' test_when_finished "rm -f log" && GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \ @@ -225,7 +225,7 @@ test_expect_success 'fetch with file:// using protocol v2' ' grep "fetch< version 2" log ' -test_expect_success 'ref advertisment is filtered during fetch using protocol v2' ' +test_expect_success 'ref advertisement is filtered during fetch using protocol v2' ' test_when_finished "rm -f log" && test_commit -C file_parent three && @@ -631,6 +631,19 @@ test_expect_success 'fetch with http:// using protocol v2' ' grep "git< version 2" log ' +test_expect_success 'fetch with http:// by hash without tag following with protocol v2 does not list refs' ' + test_when_finished "rm -f log" && + + test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two_a && + git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" rev-parse two_a >two_a_hash && + + GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \ + fetch --no-tags origin $(cat two_a_hash) && + + grep "fetch< version 2" log && + ! grep "fetch> command=ls-refs" log +' + test_expect_success 'fetch from namespaced repo respects namespaces' ' test_when_finished "rm -f log" && @@ -652,6 +665,18 @@ test_expect_success 'fetch from namespaced repo respects namespaces' ' test_cmp expect actual ' +test_expect_success 'ls-remote with v2 http sends only one POST' ' + test_when_finished "rm -f log" && + + git ls-remote "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" >expect && + GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \ + ls-remote "$HTTPD_URL/smart/http_parent" >actual && + test_cmp expect actual && + + grep "Send header: POST" log >posts && + test_line_count = 1 posts +' + test_expect_success 'push with http:// and a config of v2 does not request v2' ' test_when_finished "rm -f log" && # Till v2 for push is designed, make sure that if a client has @@ -669,9 +694,9 @@ test_expect_success 'push with http:// and a config of v2 does not request v2' ' git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s client_branch >expect && test_cmp expect actual && - # Client didnt request to use protocol v2 + # Client did not request to use protocol v2 ! grep "Git-Protocol: version=2" log && - # Server didnt respond using protocol v2 + # Server did not respond using protocol v2 ! grep "git< version 2" log ' @@ -687,11 +712,11 @@ test_expect_success 'when server sends "ready", expect DELIM' ' # After "ready" in the acknowledgments section, pretend that a FLUSH # (0000) was sent instead of a DELIM (0001). - printf "/ready/,$ s/0001/0000/" \ - >"$HTTPD_ROOT_PATH/one-time-sed" && + printf "\$ready = 1 if /ready/; \$ready && s/0001/0000/" \ + >"$HTTPD_ROOT_PATH/one-time-perl" && test_must_fail git -C http_child -c protocol.version=2 \ - fetch "$HTTPD_URL/one_time_sed/http_parent" 2> err && + fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err && test_i18ngrep "expected packfile to be sent after .ready." err ' @@ -712,15 +737,18 @@ test_expect_success 'when server does not send "ready", expect FLUSH' ' # After the acknowledgments section, pretend that a DELIM # (0001) was sent instead of a FLUSH (0000). - printf "/acknowledgments/,$ s/0000/0001/" \ - >"$HTTPD_ROOT_PATH/one-time-sed" && + printf "\$ack = 1 if /acknowledgments/; \$ack && s/0000/0001/" \ + >"$HTTPD_ROOT_PATH/one-time-perl" && test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" git -C http_child \ -c protocol.version=2 \ - fetch "$HTTPD_URL/one_time_sed/http_parent" 2> err && + fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err && grep "fetch< .*acknowledgments" log && ! grep "fetch< .*ready" log && test_i18ngrep "expected no other sections to be sent after no .ready." err ' +# DO NOT add non-httpd-specific tests here, because the last part of this +# test script is only executed when httpd is available and enabled. + test_done diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh index de4b6106ef4a..7fba3063bf91 100755 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@ -18,14 +18,16 @@ get_actual_commits () { p }' o.pack && git index-pack o.pack && - git verify-pack -v o.idx | grep commit | cut -c-40 | sort >actual_commits + git verify-pack -v o.idx >objs && + grep commit objs | cut -d" " -f1 | sort >actual_commits } check_output () { get_actual_refs && test_cmp expected_refs actual_refs && get_actual_commits && - test_cmp expected_commits actual_commits + sort expected_commits >sorted_commits && + test_cmp sorted_commits actual_commits } # c(o/foo) d(o/bar) @@ -35,6 +37,7 @@ check_output () { # \ | / # a test_expect_success 'setup repository' ' + test_oid_init && test_commit a && git checkout -b o/foo && test_commit b && @@ -75,17 +78,19 @@ test_expect_success 'invalid want-ref line' ' ' test_expect_success 'basic want-ref' ' + oid=$(git rev-parse f) && cat >expected_refs <<-EOF && - $(git rev-parse f) refs/heads/master + $oid refs/heads/master EOF - git rev-parse f | sort >expected_commits && + git rev-parse f >expected_commits && + oid=$(git rev-parse a) && test-tool pkt-line pack >in <<-EOF && command=fetch 0001 no-progress want-ref refs/heads/master - have $(git rev-parse a) + have $oid done 0000 EOF @@ -95,19 +100,22 @@ test_expect_success 'basic want-ref' ' ' test_expect_success 'multiple want-ref lines' ' + oid_c=$(git rev-parse c) && + oid_d=$(git rev-parse d) && cat >expected_refs <<-EOF && - $(git rev-parse c) refs/heads/o/foo - $(git rev-parse d) refs/heads/o/bar + $oid_c refs/heads/o/foo + $oid_d refs/heads/o/bar EOF - git rev-parse c d | sort >expected_commits && + git rev-parse c d >expected_commits && + oid=$(git rev-parse b) && test-tool pkt-line pack >in <<-EOF && command=fetch 0001 no-progress want-ref refs/heads/o/foo want-ref refs/heads/o/bar - have $(git rev-parse b) + have $oid done 0000 EOF @@ -117,10 +125,11 @@ test_expect_success 'multiple want-ref lines' ' ' test_expect_success 'mix want and want-ref' ' + oid=$(git rev-parse f) && cat >expected_refs <<-EOF && - $(git rev-parse f) refs/heads/master + $oid refs/heads/master EOF - git rev-parse e f | sort >expected_commits && + git rev-parse e f >expected_commits && test-tool pkt-line pack >in <<-EOF && command=fetch @@ -138,17 +147,19 @@ test_expect_success 'mix want and want-ref' ' ' test_expect_success 'want-ref with ref we already have commit for' ' + oid=$(git rev-parse c) && cat >expected_refs <<-EOF && - $(git rev-parse c) refs/heads/o/foo + $oid refs/heads/o/foo EOF >expected_commits && + oid=$(git rev-parse c) && test-tool pkt-line pack >in <<-EOF && command=fetch 0001 no-progress want-ref refs/heads/o/foo - have $(git rev-parse c) + have $oid done 0000 EOF @@ -157,106 +168,6 @@ test_expect_success 'want-ref with ref we already have commit for' ' check_output ' -. "$TEST_DIRECTORY"/lib-httpd.sh -start_httpd - -REPO="$HTTPD_DOCUMENT_ROOT_PATH/repo" -LOCAL_PRISTINE="$(pwd)/local_pristine" - -test_expect_success 'setup repos for change-while-negotiating test' ' - ( - git init "$REPO" && - cd "$REPO" && - >.git/git-daemon-export-ok && - test_commit m1 && - git tag -d m1 && - - # Local repo with many commits (so that negotiation will take - # more than 1 request/response pair) - git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" && - cd "$LOCAL_PRISTINE" && - git checkout -b side && - test_commit_bulk --id=s 33 && - - # Add novel commits to upstream - git checkout master && - cd "$REPO" && - test_commit m2 && - test_commit m3 && - git tag -d m2 m3 - ) && - git -C "$LOCAL_PRISTINE" remote set-url origin "http://127.0.0.1:$LIB_HTTPD_PORT/one_time_sed/repo" && - git -C "$LOCAL_PRISTINE" config protocol.version 2 -' - -inconsistency () { - # Simulate that the server initially reports $2 as the ref - # corresponding to $1, and after that, $1 as the ref corresponding to - # $1. This corresponds to the real-life situation where the server's - # repository appears to change during negotiation, for example, when - # different servers in a load-balancing arrangement serve (stateless) - # RPCs during a single negotiation. - printf "s/%s/%s/" \ - $(git -C "$REPO" rev-parse $1 | tr -d "\n") \ - $(git -C "$REPO" rev-parse $2 | tr -d "\n") \ - >"$HTTPD_ROOT_PATH/one-time-sed" -} - -test_expect_success 'server is initially ahead - no ref in want' ' - git -C "$REPO" config uploadpack.allowRefInWant false && - rm -rf local && - cp -r "$LOCAL_PRISTINE" local && - inconsistency master 1234567890123456789012345678901234567890 && - test_must_fail git -C local fetch 2>err && - test_i18ngrep "fatal: remote error: upload-pack: not our ref" err -' - -test_expect_success 'server is initially ahead - ref in want' ' - git -C "$REPO" config uploadpack.allowRefInWant true && - rm -rf local && - cp -r "$LOCAL_PRISTINE" local && - inconsistency master 1234567890123456789012345678901234567890 && - git -C local fetch && - - git -C "$REPO" rev-parse --verify master >expected && - git -C local rev-parse --verify refs/remotes/origin/master >actual && - test_cmp expected actual -' - -test_expect_success 'server is initially behind - no ref in want' ' - git -C "$REPO" config uploadpack.allowRefInWant false && - rm -rf local && - cp -r "$LOCAL_PRISTINE" local && - inconsistency master "master^" && - git -C local fetch && - - git -C "$REPO" rev-parse --verify "master^" >expected && - git -C local rev-parse --verify refs/remotes/origin/master >actual && - test_cmp expected actual -' - -test_expect_success 'server is initially behind - ref in want' ' - git -C "$REPO" config uploadpack.allowRefInWant true && - rm -rf local && - cp -r "$LOCAL_PRISTINE" local && - inconsistency master "master^" && - git -C local fetch && - - git -C "$REPO" rev-parse --verify "master" >expected && - git -C local rev-parse --verify refs/remotes/origin/master >actual && - test_cmp expected actual -' - -test_expect_success 'server loses a ref - ref in want' ' - git -C "$REPO" config uploadpack.allowRefInWant true && - rm -rf local && - cp -r "$LOCAL_PRISTINE" local && - echo "s/master/raster/" >"$HTTPD_ROOT_PATH/one-time-sed" && - test_must_fail git -C local fetch 2>err && - - test_i18ngrep "fatal: remote error: unknown ref refs/heads/raster" err -' - REPO="$(pwd)/repo" LOCAL_PRISTINE="$(pwd)/local_pristine" @@ -311,13 +222,14 @@ test_expect_success 'fetching with exact OID' ' rm -rf local && cp -r "$LOCAL_PRISTINE" local && + oid=$(git -C "$REPO" rev-parse d) && GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \ - $(git -C "$REPO" rev-parse d):refs/heads/actual && + "$oid":refs/heads/actual && git -C "$REPO" rev-parse "d" >expected && git -C local rev-parse refs/heads/actual >actual && test_cmp expected actual && - grep "want $(git -C "$REPO" rev-parse d)" log + grep "want $oid" log ' test_expect_success 'fetching multiple refs' ' @@ -339,13 +251,14 @@ test_expect_success 'fetching ref and exact OID' ' rm -rf local && cp -r "$LOCAL_PRISTINE" local && + oid=$(git -C "$REPO" rev-parse b) && GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \ - master $(git -C "$REPO" rev-parse b):refs/heads/actual && + master "$oid":refs/heads/actual && git -C "$REPO" rev-parse "master" "b" >expected && git -C local rev-parse refs/remotes/origin/master refs/heads/actual >actual && test_cmp expected actual && - grep "want $(git -C "$REPO" rev-parse b)" log && + grep "want $oid" log && grep "want-ref refs/heads/master" log ' @@ -372,4 +285,107 @@ test_expect_success 'fetching with wildcard that matches multiple refs' ' grep "want-ref refs/heads/o/bar" log ' +. "$TEST_DIRECTORY"/lib-httpd.sh +start_httpd + +REPO="$HTTPD_DOCUMENT_ROOT_PATH/repo" +LOCAL_PRISTINE="$(pwd)/local_pristine" + +test_expect_success 'setup repos for change-while-negotiating test' ' + ( + git init "$REPO" && + cd "$REPO" && + >.git/git-daemon-export-ok && + test_commit m1 && + git tag -d m1 && + + # Local repo with many commits (so that negotiation will take + # more than 1 request/response pair) + rm -rf "$LOCAL_PRISTINE" && + git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" && + cd "$LOCAL_PRISTINE" && + git checkout -b side && + test_commit_bulk --id=s 33 && + + # Add novel commits to upstream + git checkout master && + cd "$REPO" && + test_commit m2 && + test_commit m3 && + git tag -d m2 m3 + ) && + git -C "$LOCAL_PRISTINE" remote set-url origin "http://127.0.0.1:$LIB_HTTPD_PORT/one_time_perl/repo" && + git -C "$LOCAL_PRISTINE" config protocol.version 2 +' + +inconsistency () { + # Simulate that the server initially reports $2 as the ref + # corresponding to $1, and after that, $1 as the ref corresponding to + # $1. This corresponds to the real-life situation where the server's + # repository appears to change during negotiation, for example, when + # different servers in a load-balancing arrangement serve (stateless) + # RPCs during a single negotiation. + oid1=$(git -C "$REPO" rev-parse $1) && + oid2=$(git -C "$REPO" rev-parse $2) && + echo "s/$oid1/$oid2/" >"$HTTPD_ROOT_PATH/one-time-perl" +} + +test_expect_success 'server is initially ahead - no ref in want' ' + git -C "$REPO" config uploadpack.allowRefInWant false && + rm -rf local && + cp -r "$LOCAL_PRISTINE" local && + inconsistency master $(test_oid numeric) && + test_must_fail git -C local fetch 2>err && + test_i18ngrep "fatal: remote error: upload-pack: not our ref" err +' + +test_expect_success 'server is initially ahead - ref in want' ' + git -C "$REPO" config uploadpack.allowRefInWant true && + rm -rf local && + cp -r "$LOCAL_PRISTINE" local && + inconsistency master $(test_oid numeric) && + git -C local fetch && + + git -C "$REPO" rev-parse --verify master >expected && + git -C local rev-parse --verify refs/remotes/origin/master >actual && + test_cmp expected actual +' + +test_expect_success 'server is initially behind - no ref in want' ' + git -C "$REPO" config uploadpack.allowRefInWant false && + rm -rf local && + cp -r "$LOCAL_PRISTINE" local && + inconsistency master "master^" && + git -C local fetch && + + git -C "$REPO" rev-parse --verify "master^" >expected && + git -C local rev-parse --verify refs/remotes/origin/master >actual && + test_cmp expected actual +' + +test_expect_success 'server is initially behind - ref in want' ' + git -C "$REPO" config uploadpack.allowRefInWant true && + rm -rf local && + cp -r "$LOCAL_PRISTINE" local && + inconsistency master "master^" && + git -C local fetch && + + git -C "$REPO" rev-parse --verify "master" >expected && + git -C local rev-parse --verify refs/remotes/origin/master >actual && + test_cmp expected actual +' + +test_expect_success 'server loses a ref - ref in want' ' + git -C "$REPO" config uploadpack.allowRefInWant true && + rm -rf local && + cp -r "$LOCAL_PRISTINE" local && + echo "s/master/raster/" >"$HTTPD_ROOT_PATH/one-time-perl" && + test_must_fail git -C local fetch 2>err && + + test_i18ngrep "fatal: remote error: unknown ref refs/heads/raster" err +' + +# DO NOT add non-httpd-specific tests here, because the last part of this +# test script is only executed when httpd is available and enabled. + test_done diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh index 2d6c4a281edb..121e5c6edb0a 100755 --- a/t/t5801-remote-helpers.sh +++ b/t/t5801-remote-helpers.sh @@ -247,7 +247,6 @@ clean_mark () { test_expect_success 'proper failure checks for fetching' ' (cd local && test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git fetch 2>error && - cat error && test_i18ngrep -q "error while running fast-import" error ) ' diff --git a/t/t6000-rev-list-misc.sh b/t/t6000-rev-list-misc.sh index 52a9e38d66f3..3dc1ad8f7199 100755 --- a/t/t6000-rev-list-misc.sh +++ b/t/t6000-rev-list-misc.sh @@ -104,13 +104,16 @@ test_expect_success 'rev-list can show index objects' ' # - we do not show the root tree; since we updated the index, it # does not have a valid cache tree # - cat >expect <<-\EOF && - 8e4020bb5a8d8c873b25de15933e75cc0fc275df one - d9d3a7417b9605cfd88ee6306b28dadc29e6ab08 only-in-index - 9200b628cf9dc883a85a7abc8d6e6730baee589c two - EOF echo only-in-index >only-in-index && test_when_finished "git reset --hard" && + rev1=$(git rev-parse HEAD:one) && + rev2=$(git rev-parse HEAD:two) && + revi=$(git hash-object only-in-index) && + cat >expect <<-EOF && + $rev1 one + $revi only-in-index + $rev2 two + EOF git add only-in-index && git rev-list --objects --indexed-objects >actual && test_cmp expect actual @@ -140,4 +143,24 @@ test_expect_success '--header shows a NUL after each commit' ' test_cmp expect actual ' +test_expect_success 'rev-list --end-of-options' ' + git update-ref refs/heads/--output=yikes HEAD && + git rev-list --end-of-options --output=yikes >actual && + test_path_is_missing yikes && + git rev-list HEAD >expect && + test_cmp expect actual +' + +test_expect_success 'rev-list --count' ' + count=$(git rev-list --count HEAD) && + git rev-list HEAD >actual && + test_line_count = $count actual +' + +test_expect_success 'rev-list --count --objects' ' + count=$(git rev-list --count --objects HEAD) && + git rev-list --objects HEAD >actual && + test_line_count = $count actual +' + test_done diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index da113d975b16..7e82e43a634a 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -32,6 +32,7 @@ changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding) truncate_count=20 test_expect_success 'setup' ' + test_oid_init && : >foo && git add foo && git config i18n.commitEncoding $test_encoding && @@ -109,31 +110,35 @@ commit $head1 EOF # we don't test relative here -test_format author %an%n%ae%n%ad%n%aD%n%at <actual && len=$(wc -c expect && + echo "$GIT_COMMITTER_NAME:$GIT_COMMITTER_EMAIL" >expect && git log -g -1 --format="%gn:%ge" >actual && test_cmp expect actual ' test_expect_success 'oneline with empty message' ' - git commit -m "dummy" --allow-empty && - git commit -m "dummy" --allow-empty && - git filter-branch --msg-filter "sed -e s/dummy//" HEAD^^.. && + git commit --allow-empty --cleanup=verbatim -m "$LF" && + git commit --allow-empty --allow-empty-message && git rev-list --oneline HEAD >test.txt && test_line_count = 5 test.txt && git rev-list --oneline --graph HEAD >testg.txt && diff --git a/t/t6011-rev-list-with-bad-commit.sh b/t/t6011-rev-list-with-bad-commit.sh index 545b461e51d4..bad02cf5b83d 100755 --- a/t/t6011-rev-list-with-bad-commit.sh +++ b/t/t6011-rev-list-with-bad-commit.sh @@ -42,7 +42,7 @@ test_expect_success 'corrupt second commit object' \ ' test_expect_success 'rev-list should fail' ' - test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git rev-list --all > /dev/null + test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list --all > /dev/null ' test_expect_success 'git repack _MUST_ fail' \ diff --git a/t/t6016-rev-list-graph-simplify-history.sh b/t/t6016-rev-list-graph-simplify-history.sh index f7181d1d6a14..f5e6e92f5b30 100755 --- a/t/t6016-rev-list-graph-simplify-history.sh +++ b/t/t6016-rev-list-graph-simplify-history.sh @@ -67,11 +67,10 @@ test_expect_success '--graph --all' ' echo "| * $C4" >> expected && echo "| * $C3" >> expected && echo "* | $A5" >> expected && - echo "| | " >> expected && - echo "| \\ " >> expected && - echo "*-. \\ $A4" >> expected && - echo "|\\ \\ \\ " >> expected && - echo "| | |/ " >> expected && + echo "| | " >> expected && + echo "| \\ " >> expected && + echo "*-. | $A4" >> expected && + echo "|\\ \\| " >> expected && echo "| | * $C2" >> expected && echo "| | * $C1" >> expected && echo "| * | $B2" >> expected && @@ -97,11 +96,10 @@ test_expect_success '--graph --simplify-by-decoration' ' echo "| * $C4" >> expected && echo "| * $C3" >> expected && echo "* | $A5" >> expected && - echo "| | " >> expected && - echo "| \\ " >> expected && - echo "*-. \\ $A4" >> expected && - echo "|\\ \\ \\ " >> expected && - echo "| | |/ " >> expected && + echo "| | " >> expected && + echo "| \\ " >> expected && + echo "*-. | $A4" >> expected && + echo "|\\ \\| " >> expected && echo "| | * $C2" >> expected && echo "| | * $C1" >> expected && echo "| * | $B2" >> expected && @@ -131,9 +129,8 @@ test_expect_success '--graph --simplify-by-decoration prune branch B' ' echo "| * $C4" >> expected && echo "| * $C3" >> expected && echo "* | $A5" >> expected && - echo "* | $A4" >> expected && - echo "|\\ \\ " >> expected && - echo "| |/ " >> expected && + echo "* | $A4" >> expected && + echo "|\\| " >> expected && echo "| * $C2" >> expected && echo "| * $C1" >> expected && echo "* | $A3" >> expected && @@ -151,9 +148,8 @@ test_expect_success '--graph --full-history -- bar.txt' ' echo "|\\ " >> expected && echo "| * $C4" >> expected && echo "* | $A5" >> expected && - echo "* | $A4" >> expected && - echo "|\\ \\ " >> expected && - echo "| |/ " >> expected && + echo "* | $A4" >> expected && + echo "|\\| " >> expected && echo "* | $A3" >> expected && echo "|/ " >> expected && echo "* $A2" >> expected && @@ -255,7 +251,7 @@ test_expect_success '--graph --boundary ^C3' ' echo "* | | | $A3" >> expected && echo "o | | | $A2" >> expected && echo "|/ / / " >> expected && - echo "o | | $A1" >> expected && + echo "o / / $A1" >> expected && echo " / / " >> expected && echo "| o $C3" >> expected && echo "|/ " >> expected && diff --git a/t/t6019-rev-list-ancestry-path.sh b/t/t6019-rev-list-ancestry-path.sh index beadaf6cca05..353f84313f33 100755 --- a/t/t6019-rev-list-ancestry-path.sh +++ b/t/t6019-rev-list-ancestry-path.sh @@ -143,14 +143,14 @@ test_expect_success 'setup criss-cross' ' test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' ' (cd criss-cross && git rev-list --ancestry-path xcb..xbc > actual && - test -z "$(cat actual)") + test_must_be_empty actual) ' # no commits in repository descend from cb test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' ' (cd criss-cross && git rev-list --ancestry-path --all ^xcb > actual && - test -z "$(cat actual)") + test_must_be_empty actual) ' test_done diff --git a/t/t6020-merge-df.sh b/t/t6020-merge-df.sh index 46b506b3b7b6..400a4cd13928 100755 --- a/t/t6020-merge-df.sh +++ b/t/t6020-merge-df.sh @@ -83,9 +83,9 @@ test_expect_success 'modify/delete + directory/file conflict' ' test 4 -eq $(git ls-files -u | wc -l) && test 1 -eq $(git ls-files -o | wc -l) && - test -f letters/file && - test -f letters.txt && - test -f letters~modify + test_path_is_file letters/file && + test_path_is_file letters.txt && + test_path_is_file letters~modify ' test_expect_success 'modify/delete + directory/file conflict; other way' ' @@ -99,9 +99,52 @@ test_expect_success 'modify/delete + directory/file conflict; other way' ' test 4 -eq $(git ls-files -u | wc -l) && test 1 -eq $(git ls-files -o | wc -l) && - test -f letters/file && - test -f letters.txt && - test -f letters~HEAD + test_path_is_file letters/file && + test_path_is_file letters.txt && + test_path_is_file letters~HEAD +' + +test_expect_success 'Simple merge in repo with interesting pathnames' ' + # Simple lexicographic ordering of files and directories would be: + # foo + # foo/bar + # foo/bar-2 + # foo/bar/baz + # foo/bar-2/baz + # The fact that foo/bar-2 appears between foo/bar and foo/bar/baz + # can trip up some codepaths, and is the point of this test. + test_create_repo name-ordering && + ( + cd name-ordering && + + mkdir -p foo/bar && + mkdir -p foo/bar-2 && + >foo/bar/baz && + >foo/bar-2/baz && + git add . && + git commit -m initial && + + git branch main && + git branch other && + + git checkout other && + echo other >foo/bar-2/baz && + git add -u && + git commit -m other && + + git checkout main && + echo main >foo/bar/baz && + git add -u && + git commit -m main && + + git merge other && + git ls-files -s >out && + test_line_count = 2 out && + git rev-parse :0:foo/bar/baz :0:foo/bar-2/baz >actual && + git rev-parse HEAD~1:foo/bar/baz other:foo/bar-2/baz >expect && + test_cmp expect actual + ) + ' test_done diff --git a/t/t6021-merge-criss-cross.sh b/t/t6021-merge-criss-cross.sh index 213deecab1e8..9d5e992878fa 100755 --- a/t/t6021-merge-criss-cross.sh +++ b/t/t6021-merge-criss-cross.sh @@ -3,94 +3,65 @@ # Copyright (c) 2005 Fredrik Kuivinen # -# See http://marc.info/?l=git&m=111463358500362&w=2 for a +# See https://lore.kernel.org/git/Pine.LNX.4.44.0504271254120.4678-100000@wax.eds.org/ for a # nice description of what this is about. test_description='Test criss-cross merge' . ./test-lib.sh -test_expect_success 'prepare repository' \ -'echo "1 -2 -3 -4 -5 -6 -7 -8 -9" > file && -git add file && -git commit -m "Initial commit" file && -git branch A && -git branch B && -git checkout A && -echo "1 -2 -3 -4 -5 -6 -7 -8 changed in B8, branch A -9" > file && -git commit -m "B8" file && -git checkout B && -echo "1 -2 -3 changed in C3, branch B -4 -5 -6 -7 -8 -9 -" > file && -git commit -m "C3" file && -git branch C3 && -git merge -m "pre E3 merge" A && -echo "1 -2 -3 changed in E3, branch B. New file size -4 -5 -6 -7 -8 changed in B8, branch A -9 -" > file && -git commit -m "E3" file && -git checkout A && -git merge -m "pre D8 merge" C3 && -echo "1 -2 -3 changed in C3, branch B -4 -5 -6 -7 -8 changed in D8, branch A. New file size 2 -9" > file && -git commit -m D8 file' - -test_expect_success 'Criss-cross merge' 'git merge -m "final merge" B' - -cat > file-expect <file && + git add file && + git commit -m "Initial commit" file && + + git branch A && + git branch B && + git checkout A && + + test_write_lines 1 2 3 4 5 6 7 "8 changed in B8, branch A" 9 >file && + git commit -m "B8" file && + git checkout B && + + test_write_lines 1 2 "3 changed in C3, branch B" 4 5 6 7 8 9 >file && + git commit -m "C3" file && + git branch C3 && + + git merge -m "pre E3 merge" A && + + test_write_lines 1 2 "3 changed in E3, branch B. New file size" 4 5 6 7 "8 changed in B8, branch A" 9 >file && + git commit -m "E3" file && + + git checkout A && + git merge -m "pre D8 merge" C3 && + test_write_lines 1 2 "3 changed in C3, branch B" 4 5 6 7 "8 changed in D8, branch A. New file size 2" 9 >file && + + git commit -m D8 file +' + +test_expect_success 'Criss-cross merge' ' + git merge -m "final merge" B +' + +test_expect_success 'Criss-cross merge result' ' + cat <<-\EOF >file-expect && + 1 + 2 + 3 changed in E3, branch B. New file size + 4 + 5 + 6 + 7 + 8 changed in D8, branch A. New file size 2 + 9 + EOF + + test_cmp file-expect file +' + +test_expect_success 'Criss-cross merge fails (-s resolve)' ' + git reset --hard A^ && + test_must_fail git merge -s resolve -m "final merge" B +' test_done diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 53cc9b2ffbdb..bbbba3dcbf0d 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -8,94 +8,94 @@ modify () { mv "$2.x" "$2" } -test_expect_success setup \ -' -cat >A <<\EOF && -a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -c cccccccccccccccccccccccccccccccccccccccccccccccc -d dddddddddddddddddddddddddddddddddddddddddddddddd -e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee -f ffffffffffffffffffffffffffffffffffffffffffffffff -g gggggggggggggggggggggggggggggggggggggggggggggggg -h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh -i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii -j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj -k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk -l llllllllllllllllllllllllllllllllllllllllllllllll -m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm -n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn -o oooooooooooooooooooooooooooooooooooooooooooooooo -EOF - -cat >M <<\EOF && -A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB -C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC -D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD -E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE -F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG -H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH -I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ -K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK -L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL -M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM -N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO -EOF - -git add A M && -git commit -m "initial has A and M" && -git branch white && -git branch red && -git branch blue && -git branch yellow && -git branch change && -git branch change+rename && - -sed -e "/^g /s/.*/g : master changes a line/" A+ && -mv A+ A && -git commit -a -m "master updates A" && - -git checkout yellow && -rm -f M && -git commit -a -m "yellow removes M" && - -git checkout white && -sed -e "/^g /s/.*/g : white changes a line/" B && -sed -e "/^G /s/.*/G : colored branch changes a line/" N && -rm -f A M && -git update-index --add --remove A B M N && -git commit -m "white renames A->B, M->N" && - -git checkout red && -sed -e "/^g /s/.*/g : red changes a line/" B && -sed -e "/^G /s/.*/G : colored branch changes a line/" N && -rm -f A M && -git update-index --add --remove A B M N && -git commit -m "red renames A->B, M->N" && - -git checkout blue && -sed -e "/^g /s/.*/g : blue changes a line/" C && -sed -e "/^G /s/.*/G : colored branch changes a line/" N && -rm -f A M && -git update-index --add --remove A C M N && -git commit -m "blue renames A->C, M->N" && - -git checkout change && -sed -e "/^g /s/.*/g : changed line/" A+ && -mv A+ A && -git commit -q -a -m "changed" && - -git checkout change+rename && -sed -e "/^g /s/.*/g : changed line/" B && -rm A && -git update-index --add B && -git commit -q -a -m "changed and renamed" && - -git checkout master' +test_expect_success 'setup' ' + cat >A <<-\EOF && + a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + c cccccccccccccccccccccccccccccccccccccccccccccccc + d dddddddddddddddddddddddddddddddddddddddddddddddd + e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + f ffffffffffffffffffffffffffffffffffffffffffffffff + g gggggggggggggggggggggggggggggggggggggggggggggggg + h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh + i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii + j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj + k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk + l llllllllllllllllllllllllllllllllllllllllllllllll + m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn + o oooooooooooooooooooooooooooooooooooooooooooooooo + EOF + + cat >M <<-\EOF && + A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB + C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC + D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD + E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE + F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG + H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH + I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII + J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ + K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK + L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL + M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM + N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN + O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO + EOF + + git add A M && + git commit -m "initial has A and M" && + git branch white && + git branch red && + git branch blue && + git branch yellow && + git branch change && + git branch change+rename && + + sed -e "/^g /s/.*/g : master changes a line/" A+ && + mv A+ A && + git commit -a -m "master updates A" && + + git checkout yellow && + rm -f M && + git commit -a -m "yellow removes M" && + + git checkout white && + sed -e "/^g /s/.*/g : white changes a line/" B && + sed -e "/^G /s/.*/G : colored branch changes a line/" N && + rm -f A M && + git update-index --add --remove A B M N && + git commit -m "white renames A->B, M->N" && + + git checkout red && + sed -e "/^g /s/.*/g : red changes a line/" B && + sed -e "/^G /s/.*/G : colored branch changes a line/" N && + rm -f A M && + git update-index --add --remove A B M N && + git commit -m "red renames A->B, M->N" && + + git checkout blue && + sed -e "/^g /s/.*/g : blue changes a line/" C && + sed -e "/^G /s/.*/G : colored branch changes a line/" N && + rm -f A M && + git update-index --add --remove A C M N && + git commit -m "blue renames A->C, M->N" && + + git checkout change && + sed -e "/^g /s/.*/g : changed line/" A+ && + mv A+ A && + git commit -q -a -m "changed" && + + git checkout change+rename && + sed -e "/^g /s/.*/g : changed line/" B && + rm A && + git update-index --add B && + git commit -q -a -m "changed and renamed" && + + git checkout master +' test_expect_success 'pull renaming branch into unrenaming one' \ ' @@ -242,12 +242,24 @@ test_expect_success 'merge of identical changes in a renamed file' ' rm -f A M N && git reset --hard && git checkout change+rename && + + test-tool chmtime --get -3600 B >old-mtime && GIT_MERGE_VERBOSITY=3 git merge change >out && - test_i18ngrep "^Skipped B" out && + + test-tool chmtime --get B >new-mtime && + test_cmp old-mtime new-mtime && + git reset --hard HEAD^ && git checkout change && + + # A will be renamed to B; we check mtimes and file presence + test_path_is_missing B && + test-tool chmtime --get -3600 A >old-mtime && GIT_MERGE_VERBOSITY=3 git merge change+rename >out && - test_i18ngrep ! "^Skipped B" out + + test_path_is_missing A && + test-tool chmtime --get B >new-mtime && + test $(cat old-mtime) -lt $(cat new-mtime) ' test_expect_success 'setup for rename + d/f conflicts' ' @@ -288,14 +300,15 @@ test_expect_success 'setup for rename + d/f conflicts' ' git commit -m "Conflicting change" ' -printf "1\n2\n3\n4\n5555\n6\n7\n8\n9\n10\n11\n" >expected - test_expect_success 'Rename+D/F conflict; renamed file merges + dir not in way' ' git reset --hard && git checkout -q renamed-file-has-no-conflicts^0 && + git merge --strategy=recursive dir-not-in-way && + git diff --quiet && - test -f dir && + test_path_is_file dir && + test_write_lines 1 2 3 4 5555 6 7 8 9 10 11 >expected && test_cmp expected dir ' @@ -315,8 +328,8 @@ test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' ' test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && - test -f dir/file-in-the-way && - test -f dir~HEAD && + test_path_is_file dir/file-in-the-way && + test_path_is_file dir~HEAD && test_cmp expected dir~HEAD ' @@ -337,29 +350,11 @@ test_expect_success 'Same as previous, but merged other way' ' test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && - test -f dir/file-in-the-way && - test -f dir~renamed-file-has-no-conflicts && + test_path_is_file dir/file-in-the-way && + test_path_is_file dir~renamed-file-has-no-conflicts && test_cmp expected dir~renamed-file-has-no-conflicts ' -cat >expected <<\EOF && -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -<<<<<<< HEAD:dir -12 -======= -11 ->>>>>>> dir-not-in-way:sub/file -EOF - test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in way' ' git reset --hard && rm -rf dir~* && @@ -372,7 +367,24 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && - test -f dir && + test_path_is_file dir && + cat >expected <<-\EOF && + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + <<<<<<< HEAD:dir + 12 + ======= + 11 + >>>>>>> dir-not-in-way:sub/file + EOF test_cmp expected dir ' @@ -391,29 +403,11 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in t test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && - test -f dir/file-in-the-way && - test -f dir~HEAD && + test_path_is_file dir/file-in-the-way && + test_path_is_file dir~HEAD && test_cmp expected dir~HEAD ' -cat >expected <<\EOF && -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -<<<<<<< HEAD:sub/file -11 -======= -12 ->>>>>>> renamed-file-has-conflicts:dir -EOF - test_expect_success 'Same as previous, but merged other way' ' git reset --hard && rm -rf dir~* && @@ -427,8 +421,25 @@ test_expect_success 'Same as previous, but merged other way' ' test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && - test -f dir/file-in-the-way && - test -f dir~renamed-file-has-conflicts && + test_path_is_file dir/file-in-the-way && + test_path_is_file dir~renamed-file-has-conflicts && + cat >expected <<-\EOF && + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + <<<<<<< HEAD:sub/file + 11 + ======= + 12 + >>>>>>> renamed-file-has-conflicts:dir + EOF test_cmp expected dir~renamed-file-has-conflicts ' @@ -464,9 +475,9 @@ test_expect_success 'both rename source and destination involved in D/F conflict test_must_fail git diff --quiet && - test -f destdir/foo && - test -f one && - test -f destdir~HEAD && + test_path_is_file destdir/foo && + test_path_is_file one && + test_path_is_file destdir~HEAD && test "stuff" = "$(cat destdir~HEAD)" ' @@ -507,9 +518,9 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked test 4 -eq $(find . | grep -v .git | wc -l) && - test -d one && - test -f one~rename-two && - test -f two && + test_path_is_dir one && + test_path_is_file one~rename-two && + test_path_is_file two && test "other" = $(cat one~rename-two) && test "stuff" = $(cat two) ' @@ -527,8 +538,8 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean sta test 3 -eq $(find . | grep -v .git | wc -l) && - test -f one && - test -f two && + test_path_is_file one && + test_path_is_file two && test "other" = $(cat one) && test "stuff" = $(cat two) ' @@ -568,11 +579,11 @@ test_expect_success 'check handling of differently renamed file with D/F conflic test 1 -eq "$(git ls-files -u original | wc -l)" && test 2 -eq "$(git ls-files -o | wc -l)" && - test -f one/file && - test -f two/file && - test -f one~HEAD && - test -f two~second-rename && - ! test -f original + test_path_is_file one/file && + test_path_is_file two/file && + test_path_is_file one~HEAD && + test_path_is_file two~second-rename && + test_path_is_missing original ' test_expect_success 'setup rename one file to two; directories moving out of the way' ' @@ -607,9 +618,9 @@ test_expect_success 'check handling of differently renamed file with D/F conflic test 1 -eq "$(git ls-files -u original | wc -l)" && test 0 -eq "$(git ls-files -o | wc -l)" && - test -f one && - test -f two && - ! test -f original + test_path_is_file one && + test_path_is_file two && + test_path_is_missing original ' test_expect_success 'setup avoid unnecessary update, normal rename' ' @@ -635,7 +646,7 @@ test_expect_success 'setup avoid unnecessary update, normal rename' ' test_expect_success 'avoid unnecessary update, normal rename' ' git checkout -q avoid-unnecessary-update-1^0 && - test-tool chmtime --get =1000000000 rename >expect && + test-tool chmtime --get -3600 rename >expect && git merge merge-branch-1 && test-tool chmtime --get rename >actual && test_cmp expect actual # "rename" should have stayed intact @@ -667,7 +678,7 @@ test_expect_success 'setup to test avoiding unnecessary update, with D/F conflic test_expect_success 'avoid unnecessary update, with D/F conflict' ' git checkout -q avoid-unnecessary-update-2^0 && - test-tool chmtime --get =1000000000 df >expect && + test-tool chmtime --get -3600 df >expect && git merge merge-branch-2 && test-tool chmtime --get df >actual && test_cmp expect actual # "df" should have stayed intact @@ -698,7 +709,7 @@ test_expect_success 'setup avoid unnecessary update, dir->(file,nothing)' ' test_expect_success 'avoid unnecessary update, dir->(file,nothing)' ' git checkout -q master^0 && - test-tool chmtime --get =1000000000 df >expect && + test-tool chmtime --get -3600 df >expect && git merge side && test-tool chmtime --get df >actual && test_cmp expect actual # "df" should have stayed intact @@ -727,7 +738,7 @@ test_expect_success 'setup avoid unnecessary update, modify/delete' ' test_expect_success 'avoid unnecessary update, modify/delete' ' git checkout -q master^0 && - test-tool chmtime --get =1000000000 file >expect && + test-tool chmtime --get -3600 file >expect && test_must_fail git merge side && test-tool chmtime --get file >actual && test_cmp expect actual # "file" should have stayed intact @@ -755,7 +766,7 @@ test_expect_success 'setup avoid unnecessary update, rename/add-dest' ' test_expect_success 'avoid unnecessary update, rename/add-dest' ' git checkout -q master^0 && - test-tool chmtime --get =1000000000 newfile >expect && + test-tool chmtime --get -3600 newfile >expect && git merge side && test-tool chmtime --get newfile >actual && test_cmp expect actual # "file" should have stayed intact @@ -810,48 +821,48 @@ test_expect_success 'setup for use of extended merge markers' ' git commit -mC ' -cat >expected <<\EOF && -1 -2 -3 -4 -5 -6 -7 -8 -<<<<<<< HEAD:renamed_file -9 -======= -8.5 ->>>>>>> master^0:original_file -EOF - test_expect_success 'merge master into rename has correct extended markers' ' git checkout rename^0 && test_must_fail git merge -s recursive master^0 && + + cat >expected <<-\EOF && + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + <<<<<<< HEAD:renamed_file + 9 + ======= + 8.5 + >>>>>>> master^0:original_file + EOF test_cmp expected renamed_file ' -cat >expected <<\EOF && -1 -2 -3 -4 -5 -6 -7 -8 -<<<<<<< HEAD:original_file -8.5 -======= -9 ->>>>>>> rename^0:renamed_file -EOF - test_expect_success 'merge rename into master has correct extended markers' ' git reset --hard && git checkout master^0 && test_must_fail git merge -s recursive rename^0 && + + cat >expected <<-\EOF && + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + <<<<<<< HEAD:original_file + 8.5 + ======= + 9 + >>>>>>> rename^0:renamed_file + EOF test_cmp expected renamed_file ' diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index 51ee887a7763..2f421d967abe 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -3,56 +3,59 @@ test_description='RCS merge replacement: merge-file' . ./test-lib.sh -cat > orig.txt << EOF -Dominus regit me, -et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -EOF - -cat > new1.txt << EOF -Dominus regit me, -et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -Nam et si ambulavero in medio umbrae mortis, -non timebo mala, quoniam tu mecum es: -virga tua et baculus tuus ipsa me consolata sunt. -EOF - -cat > new2.txt << EOF -Dominus regit me, et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -EOF - -cat > new3.txt << EOF -DOMINUS regit me, -et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -EOF - -cat > new4.txt << EOF -Dominus regit me, et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -EOF -printf "propter nomen suum." >> new4.txt +test_expect_success 'setup' ' + cat >orig.txt <<-\EOF && + Dominus regit me, + et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + EOF + + cat >new1.txt <<-\EOF && + Dominus regit me, + et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + Nam et si ambulavero in medio umbrae mortis, + non timebo mala, quoniam tu mecum es: + virga tua et baculus tuus ipsa me consolata sunt. + EOF + + cat >new2.txt <<-\EOF && + Dominus regit me, et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + EOF + + cat >new3.txt <<-\EOF && + DOMINUS regit me, + et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + EOF + + cat >new4.txt <<-\EOF && + Dominus regit me, et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + EOF + + printf "propter nomen suum." >>new4.txt +' test_expect_success 'merge with no changes' ' cp orig.txt test.txt && @@ -60,9 +63,10 @@ test_expect_success 'merge with no changes' ' test_cmp test.txt orig.txt ' -cp new1.txt test.txt -test_expect_success "merge without conflict" \ - "git merge-file test.txt orig.txt new2.txt" +test_expect_success "merge without conflict" ' + cp new1.txt test.txt && + git merge-file test.txt orig.txt new2.txt +' test_expect_success 'works in subdirectory' ' mkdir dir && @@ -73,151 +77,176 @@ test_expect_success 'works in subdirectory' ' test_path_is_missing a.txt ' -cp new1.txt test.txt -test_expect_success "merge without conflict (--quiet)" \ - "git merge-file --quiet test.txt orig.txt new2.txt" - -cp new1.txt test2.txt -test_expect_failure "merge without conflict (missing LF at EOF)" \ - "git merge-file test2.txt orig.txt new4.txt" - -test_expect_failure "merge result added missing LF" \ - "test_cmp test.txt test2.txt" - -cp new4.txt test3.txt -test_expect_success "merge without conflict (missing LF at EOF, away from change in the other file)" \ - "git merge-file --quiet test3.txt new2.txt new3.txt" - -cat > expect.txt << EOF -DOMINUS regit me, -et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -EOF -printf "propter nomen suum." >> expect.txt - -test_expect_success "merge does not add LF away of change" \ - "test_cmp expect.txt test3.txt" - -cp test.txt backup.txt -test_expect_success "merge with conflicts" \ - "test_must_fail git merge-file test.txt orig.txt new3.txt" - -cat > expect.txt << EOF -<<<<<<< test.txt -Dominus regit me, et nihil mihi deerit. -======= -DOMINUS regit me, -et nihil mihi deerit. ->>>>>>> new3.txt -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -Nam et si ambulavero in medio umbrae mortis, -non timebo mala, quoniam tu mecum es: -virga tua et baculus tuus ipsa me consolata sunt. -EOF - -test_expect_success "expected conflict markers" "test_cmp expect.txt test.txt" - -cp backup.txt test.txt - -cat > expect.txt << EOF -Dominus regit me, et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -Nam et si ambulavero in medio umbrae mortis, -non timebo mala, quoniam tu mecum es: -virga tua et baculus tuus ipsa me consolata sunt. -EOF -test_expect_success "merge conflicting with --ours" \ - "git merge-file --ours test.txt orig.txt new3.txt && test_cmp expect.txt test.txt" -cp backup.txt test.txt - -cat > expect.txt << EOF -DOMINUS regit me, -et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -Nam et si ambulavero in medio umbrae mortis, -non timebo mala, quoniam tu mecum es: -virga tua et baculus tuus ipsa me consolata sunt. -EOF -test_expect_success "merge conflicting with --theirs" \ - "git merge-file --theirs test.txt orig.txt new3.txt && test_cmp expect.txt test.txt" -cp backup.txt test.txt - -cat > expect.txt << EOF -Dominus regit me, et nihil mihi deerit. -DOMINUS regit me, -et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -Nam et si ambulavero in medio umbrae mortis, -non timebo mala, quoniam tu mecum es: -virga tua et baculus tuus ipsa me consolata sunt. -EOF -test_expect_success "merge conflicting with --union" \ - "git merge-file --union test.txt orig.txt new3.txt && test_cmp expect.txt test.txt" -cp backup.txt test.txt - -test_expect_success "merge with conflicts, using -L" \ - "test_must_fail git merge-file -L 1 -L 2 test.txt orig.txt new3.txt" - -cat > expect.txt << EOF -<<<<<<< 1 -Dominus regit me, et nihil mihi deerit. -======= -DOMINUS regit me, -et nihil mihi deerit. ->>>>>>> new3.txt -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -Nam et si ambulavero in medio umbrae mortis, -non timebo mala, quoniam tu mecum es: -virga tua et baculus tuus ipsa me consolata sunt. -EOF - -test_expect_success "expected conflict markers, with -L" \ - "test_cmp expect.txt test.txt" - -sed "s/ tu / TU /" < new1.txt > new5.txt -test_expect_success "conflict in removed tail" \ - "test_must_fail git merge-file -p orig.txt new1.txt new5.txt > out" - -cat > expect << EOF -Dominus regit me, -et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -<<<<<<< orig.txt -======= -Nam et si ambulavero in medio umbrae mortis, -non timebo mala, quoniam TU mecum es: -virga tua et baculus tuus ipsa me consolata sunt. ->>>>>>> new5.txt -EOF - -test_expect_success "expected conflict markers" "test_cmp expect out" +test_expect_success "merge without conflict (--quiet)" ' + cp new1.txt test.txt && + git merge-file --quiet test.txt orig.txt new2.txt +' + +test_expect_failure "merge without conflict (missing LF at EOF)" ' + cp new1.txt test2.txt && + git merge-file test2.txt orig.txt new4.txt +' + +test_expect_failure "merge result added missing LF" ' + test_cmp test.txt test2.txt +' + +test_expect_success "merge without conflict (missing LF at EOF, away from change in the other file)" ' + cp new4.txt test3.txt && + git merge-file --quiet test3.txt new2.txt new3.txt +' + +test_expect_success "merge does not add LF away of change" ' + cat >expect.txt <<-\EOF && + DOMINUS regit me, + et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + EOF + printf "propter nomen suum." >>expect.txt && + + test_cmp expect.txt test3.txt +' + +test_expect_success "merge with conflicts" ' + cp test.txt backup.txt && + test_must_fail git merge-file test.txt orig.txt new3.txt +' + +test_expect_success "expected conflict markers" ' + cat >expect.txt <<-\EOF && + <<<<<<< test.txt + Dominus regit me, et nihil mihi deerit. + ======= + DOMINUS regit me, + et nihil mihi deerit. + >>>>>>> new3.txt + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + Nam et si ambulavero in medio umbrae mortis, + non timebo mala, quoniam tu mecum es: + virga tua et baculus tuus ipsa me consolata sunt. + EOF + + test_cmp expect.txt test.txt +' + +test_expect_success "merge conflicting with --ours" ' + cp backup.txt test.txt && + + cat >expect.txt <<-\EOF && + Dominus regit me, et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + Nam et si ambulavero in medio umbrae mortis, + non timebo mala, quoniam tu mecum es: + virga tua et baculus tuus ipsa me consolata sunt. + EOF + + git merge-file --ours test.txt orig.txt new3.txt && + test_cmp expect.txt test.txt +' + +test_expect_success "merge conflicting with --theirs" ' + cp backup.txt test.txt && + + cat >expect.txt <<-\EOF && + DOMINUS regit me, + et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + Nam et si ambulavero in medio umbrae mortis, + non timebo mala, quoniam tu mecum es: + virga tua et baculus tuus ipsa me consolata sunt. + EOF + + git merge-file --theirs test.txt orig.txt new3.txt && + test_cmp expect.txt test.txt +' + +test_expect_success "merge conflicting with --union" ' + cp backup.txt test.txt && + + cat >expect.txt <<-\EOF && + Dominus regit me, et nihil mihi deerit. + DOMINUS regit me, + et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + Nam et si ambulavero in medio umbrae mortis, + non timebo mala, quoniam tu mecum es: + virga tua et baculus tuus ipsa me consolata sunt. + EOF + + git merge-file --union test.txt orig.txt new3.txt && + test_cmp expect.txt test.txt +' + +test_expect_success "merge with conflicts, using -L" ' + cp backup.txt test.txt && + + test_must_fail git merge-file -L 1 -L 2 test.txt orig.txt new3.txt +' + +test_expect_success "expected conflict markers, with -L" ' + cat >expect.txt <<-\EOF && + <<<<<<< 1 + Dominus regit me, et nihil mihi deerit. + ======= + DOMINUS regit me, + et nihil mihi deerit. + >>>>>>> new3.txt + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + Nam et si ambulavero in medio umbrae mortis, + non timebo mala, quoniam tu mecum es: + virga tua et baculus tuus ipsa me consolata sunt. + EOF + + test_cmp expect.txt test.txt +' + +test_expect_success "conflict in removed tail" ' + sed "s/ tu / TU /" new5.txt && + test_must_fail git merge-file -p orig.txt new1.txt new5.txt >out +' + +test_expect_success "expected conflict markers" ' + cat >expect <<-\EOF && + Dominus regit me, + et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + <<<<<<< orig.txt + ======= + Nam et si ambulavero in medio umbrae mortis, + non timebo mala, quoniam TU mecum es: + virga tua et baculus tuus ipsa me consolata sunt. + >>>>>>> new5.txt + EOF + + test_cmp expect out +' test_expect_success 'binary files cannot be merged' ' test_must_fail git merge-file -p \ @@ -225,59 +254,55 @@ test_expect_success 'binary files cannot be merged' ' grep "Cannot merge binary files" merge.err ' -sed -e "s/deerit.\$/deerit;/" -e "s/me;\$/me./" < new5.txt > new6.txt -sed -e "s/deerit.\$/deerit,/" -e "s/me;\$/me,/" < new5.txt > new7.txt - test_expect_success 'MERGE_ZEALOUS simplifies non-conflicts' ' + sed -e "s/deerit.\$/deerit;/" -e "s/me;\$/me./" new6.txt && + sed -e "s/deerit.\$/deerit,/" -e "s/me;\$/me,/" new7.txt && test_must_fail git merge-file -p new6.txt new5.txt new7.txt > output && - test 1 = $(grep ======= < output | wc -l) - + test 1 = $(grep ======= new8.txt -sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit --/" < new7.txt | tr '%' '\012' > new9.txt - test_expect_success 'ZEALOUS_ALNUM' ' + sed -e "s/deerit./&%%%%/" -e "s/locavit,/locavit;/" new8.txt && + sed -e "s/deerit./&%%%%/" -e "s/locavit,/locavit --/" new9.txt && test_must_fail git merge-file -p \ - new8.txt new5.txt new9.txt > merge.out && - test 1 = $(grep ======= < merge.out | wc -l) - + new8.txt new5.txt new9.txt >merge.out && + test 1 = $(grep ======= expect <<\EOF -Dominus regit me, -<<<<<<< new8.txt -et nihil mihi deerit; +test_expect_success '"diff3 -m" style output (1)' ' + cat >expect <<-\EOF && + Dominus regit me, + <<<<<<< new8.txt + et nihil mihi deerit; -In loco pascuae ibi me collocavit; -super aquam refectionis educavit me. -||||||| new5.txt -et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -======= -et nihil mihi deerit, + In loco pascuae ibi me collocavit; + super aquam refectionis educavit me. + ||||||| new5.txt + et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + ======= + et nihil mihi deerit, -In loco pascuae ibi me collocavit -- -super aquam refectionis educavit me, ->>>>>>> new9.txt -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -Nam et si ambulavero in medio umbrae mortis, -non timebo mala, quoniam TU mecum es: -virga tua et baculus tuus ipsa me consolata sunt. -EOF + In loco pascuae ibi me collocavit -- + super aquam refectionis educavit me, + >>>>>>> new9.txt + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + Nam et si ambulavero in medio umbrae mortis, + non timebo mala, quoniam TU mecum es: + virga tua et baculus tuus ipsa me consolata sunt. + EOF -test_expect_success '"diff3 -m" style output (1)' ' test_must_fail git merge-file -p --diff3 \ new8.txt new5.txt new9.txt >actual && test_cmp expect actual @@ -290,61 +315,64 @@ test_expect_success '"diff3 -m" style output (2)' ' test_cmp expect actual ' -cat >expect <<\EOF -Dominus regit me, -<<<<<<<<<< new8.txt -et nihil mihi deerit; +test_expect_success 'marker size' ' + cat >expect <<-\EOF && + Dominus regit me, + <<<<<<<<<< new8.txt + et nihil mihi deerit; -In loco pascuae ibi me collocavit; -super aquam refectionis educavit me. -|||||||||| new5.txt -et nihil mihi deerit. -In loco pascuae ibi me collocavit, -super aquam refectionis educavit me; -========== -et nihil mihi deerit, + In loco pascuae ibi me collocavit; + super aquam refectionis educavit me. + |||||||||| new5.txt + et nihil mihi deerit. + In loco pascuae ibi me collocavit, + super aquam refectionis educavit me; + ========== + et nihil mihi deerit, -In loco pascuae ibi me collocavit -- -super aquam refectionis educavit me, ->>>>>>>>>> new9.txt -animam meam convertit, -deduxit me super semitas jusitiae, -propter nomen suum. -Nam et si ambulavero in medio umbrae mortis, -non timebo mala, quoniam TU mecum es: -virga tua et baculus tuus ipsa me consolata sunt. -EOF + In loco pascuae ibi me collocavit -- + super aquam refectionis educavit me, + >>>>>>>>>> new9.txt + animam meam convertit, + deduxit me super semitas jusitiae, + propter nomen suum. + Nam et si ambulavero in medio umbrae mortis, + non timebo mala, quoniam TU mecum es: + virga tua et baculus tuus ipsa me consolata sunt. + EOF -test_expect_success 'marker size' ' test_must_fail git merge-file -p --marker-size=10 \ new8.txt new5.txt new9.txt >actual && test_cmp expect actual ' -printf "line1\nline2\nline3" >nolf-orig.txt -printf "line1\nline2\nline3x" >nolf-diff1.txt -printf "line1\nline2\nline3y" >nolf-diff2.txt +test_expect_success 'conflict at EOF without LF resolved by --ours' ' + printf "line1\nline2\nline3" >nolf-orig.txt && + printf "line1\nline2\nline3x" >nolf-diff1.txt && + printf "line1\nline2\nline3y" >nolf-diff2.txt && -test_expect_success 'conflict at EOF without LF resolved by --ours' \ - 'git merge-file -p --ours nolf-diff1.txt nolf-orig.txt nolf-diff2.txt >output.txt && - printf "line1\nline2\nline3x" >expect.txt && - test_cmp expect.txt output.txt' + git merge-file -p --ours nolf-diff1.txt nolf-orig.txt nolf-diff2.txt >output.txt && + printf "line1\nline2\nline3x" >expect.txt && + test_cmp expect.txt output.txt +' -test_expect_success 'conflict at EOF without LF resolved by --theirs' \ - 'git merge-file -p --theirs nolf-diff1.txt nolf-orig.txt nolf-diff2.txt >output.txt && - printf "line1\nline2\nline3y" >expect.txt && - test_cmp expect.txt output.txt' +test_expect_success 'conflict at EOF without LF resolved by --theirs' ' + git merge-file -p --theirs nolf-diff1.txt nolf-orig.txt nolf-diff2.txt >output.txt && + printf "line1\nline2\nline3y" >expect.txt && + test_cmp expect.txt output.txt +' -test_expect_success 'conflict at EOF without LF resolved by --union' \ - 'git merge-file -p --union nolf-diff1.txt nolf-orig.txt nolf-diff2.txt >output.txt && - printf "line1\nline2\nline3x\nline3y" >expect.txt && - test_cmp expect.txt output.txt' +test_expect_success 'conflict at EOF without LF resolved by --union' ' + git merge-file -p --union nolf-diff1.txt nolf-orig.txt nolf-diff2.txt >output.txt && + printf "line1\nline2\nline3x\nline3y" >expect.txt && + test_cmp expect.txt output.txt +' test_expect_success 'conflict sections match existing line endings' ' printf "1\\r\\n2\\r\\n3" >crlf-orig.txt && diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh index 27c7de90ce64..332cfc53fd88 100755 --- a/t/t6024-recursive-merge.sh +++ b/t/t6024-recursive-merge.sh @@ -14,85 +14,95 @@ test_description='Test merge without common ancestors' GIT_COMMITTER_DATE="2006-12-12 23:28:00 +0100" export GIT_COMMITTER_DATE -test_expect_success "setup tests" ' -echo 1 > a1 && -git add a1 && -GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 && - -git checkout -b A master && -echo A > a1 && -GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 && - -git checkout -b B master && -echo B > a1 && -GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 && - -git checkout -b D A && -git rev-parse B > .git/MERGE_HEAD && -echo D > a1 && -git update-index a1 && -GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D && - -git symbolic-ref HEAD refs/heads/other && -echo 2 > a1 && -GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1 && - -git checkout -b C && -echo C > a1 && -GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 && - -git checkout -b E C && -git rev-parse B > .git/MERGE_HEAD && -echo E > a1 && -git update-index a1 && -GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E && - -git checkout -b G E && -git rev-parse A > .git/MERGE_HEAD && -echo G > a1 && -git update-index a1 && -GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G && - -git checkout -b F D && -git rev-parse C > .git/MERGE_HEAD && -echo F > a1 && -git update-index a1 && -GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F +test_expect_success 'setup tests' ' + echo 1 >a1 && + git add a1 && + GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 && + + git checkout -b A master && + echo A >a1 && + GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 && + + git checkout -b B master && + echo B >a1 && + GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 && + + git checkout -b D A && + git rev-parse B >.git/MERGE_HEAD && + echo D >a1 && + git update-index a1 && + GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D && + + git symbolic-ref HEAD refs/heads/other && + echo 2 >a1 && + GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1 && + + git checkout -b C && + echo C >a1 && + GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 && + + git checkout -b E C && + git rev-parse B >.git/MERGE_HEAD && + echo E >a1 && + git update-index a1 && + GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E && + + git checkout -b G E && + git rev-parse A >.git/MERGE_HEAD && + echo G >a1 && + git update-index a1 && + GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G && + + git checkout -b F D && + git rev-parse C >.git/MERGE_HEAD && + echo F >a1 && + git update-index a1 && + GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F && + + test_oid_cache <<-EOF + idxstage1 sha1:ec3fe2a791706733f2d8fa7ad45d9a9672031f5e + idxstage1 sha256:b3c8488929903aaebdeb22270cb6d36e5b8724b01ae0d4da24632f158c99676f + EOF ' test_expect_success 'combined merge conflicts' ' test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git merge -m final G ' -cat > expect << EOF -<<<<<<< HEAD -F -======= -G ->>>>>>> G -EOF +test_expect_success 'result contains a conflict' ' + cat >expect <<-\EOF && + <<<<<<< HEAD + F + ======= + G + >>>>>>> G + EOF -test_expect_success "result contains a conflict" "test_cmp expect a1" + test_cmp expect a1 +' + +test_expect_success 'virtual trees were processed' ' + git ls-files --stage >out && -git ls-files --stage > out -cat > expect << EOF -100644 ec3fe2a791706733f2d8fa7ad45d9a9672031f5e 1 a1 -100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1 -100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1 -EOF + cat >expect <<-EOF && + 100644 $(test_oid idxstage1) 1 a1 + 100644 $(git rev-parse F:a1) 2 a1 + 100644 $(git rev-parse G:a1) 3 a1 + EOF -test_expect_success "virtual trees were processed" "test_cmp expect out" + test_cmp expect out +' test_expect_success 'refuse to merge binary files' ' git reset --hard && - printf "\0" > binary-file && + printf "\0" >binary-file && git add binary-file && git commit -m binary && git checkout G && - printf "\0\0" > binary-file && + printf "\0\0" >binary-file && git add binary-file && git commit -m binary2 && - test_must_fail git merge F > merge.out 2> merge.err && + test_must_fail git merge F >merge.out 2>merge.err && grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge.err ' @@ -116,7 +126,6 @@ test_expect_success 'mark rename/delete as unmerged' ' test 1 = $(git ls-files --unmerged | wc -l) && test_must_fail git rev-parse --verify :2:a2 && git rev-parse --verify :3:a2 - ' test_done diff --git a/t/t6025-merge-symlinks.sh b/t/t6025-merge-symlinks.sh index 433c4de08f0c..6c0a90d044c5 100755 --- a/t/t6025-merge-symlinks.sh +++ b/t/t6025-merge-symlinks.sh @@ -10,52 +10,53 @@ if core.symlinks is false.' . ./test-lib.sh -test_expect_success \ -'setup' ' -git config core.symlinks false && -> file && -git add file && -git commit -m initial && -git branch b-symlink && -git branch b-file && -l=$(printf file | git hash-object -t blob -w --stdin) && -echo "120000 $l symlink" | git update-index --index-info && -git commit -m master && -git checkout b-symlink && -l=$(printf file-different | git hash-object -t blob -w --stdin) && -echo "120000 $l symlink" | git update-index --index-info && -git commit -m b-symlink && -git checkout b-file && -echo plain-file > symlink && -git add symlink && -git commit -m b-file' - -test_expect_success \ -'merge master into b-symlink, which has a different symbolic link' ' -git checkout b-symlink && -test_must_fail git merge master' - -test_expect_success \ -'the merge result must be a file' ' -test -f symlink' - -test_expect_success \ -'merge master into b-file, which has a file instead of a symbolic link' ' -git reset --hard && git checkout b-file && -test_must_fail git merge master' - -test_expect_success \ -'the merge result must be a file' ' -test -f symlink' - -test_expect_success \ -'merge b-file, which has a file instead of a symbolic link, into master' ' -git reset --hard && -git checkout master && -test_must_fail git merge b-file' - -test_expect_success \ -'the merge result must be a file' ' -test -f symlink' +test_expect_success 'setup' ' + git config core.symlinks false && + >file && + git add file && + git commit -m initial && + git branch b-symlink && + git branch b-file && + l=$(printf file | git hash-object -t blob -w --stdin) && + echo "120000 $l symlink" | git update-index --index-info && + git commit -m master && + git checkout b-symlink && + l=$(printf file-different | git hash-object -t blob -w --stdin) && + echo "120000 $l symlink" | git update-index --index-info && + git commit -m b-symlink && + git checkout b-file && + echo plain-file >symlink && + git add symlink && + git commit -m b-file +' + +test_expect_success 'merge master into b-symlink, which has a different symbolic link' ' + git checkout b-symlink && + test_must_fail git merge master +' + +test_expect_success 'the merge result must be a file' ' + test_path_is_file symlink +' + +test_expect_success 'merge master into b-file, which has a file instead of a symbolic link' ' + git reset --hard && + git checkout b-file && + test_must_fail git merge master +' + +test_expect_success 'the merge result must be a file' ' + test_path_is_file symlink +' + +test_expect_success 'merge b-file, which has a file instead of a symbolic link, into master' ' + git reset --hard && + git checkout master && + test_must_fail git merge b-file +' + +test_expect_success 'the merge result must be a file' ' + test_path_is_file symlink +' test_done diff --git a/t/t6026-merge-attr.sh b/t/t6026-merge-attr.sh index 8f9b48a4937b..5900358ce9c0 100755 --- a/t/t6026-merge-attr.sh +++ b/t/t6026-merge-attr.sh @@ -32,7 +32,29 @@ test_expect_success setup ' test_tick && git commit -m Side && - git tag anchor + git tag anchor && + + cat >./custom-merge <<-\EOF && + #!/bin/sh + + orig="$1" ours="$2" theirs="$3" exit="$4" path=$5 + ( + echo "orig is $orig" + echo "ours is $ours" + echo "theirs is $theirs" + echo "path is $path" + echo "=== orig ===" + cat "$orig" + echo "=== ours ===" + cat "$ours" + echo "=== theirs ===" + cat "$theirs" + ) >"$ours+" + cat "$ours+" >"$ours" + rm -f "$ours+" + exit "$exit" + EOF + chmod +x ./custom-merge ' test_expect_success merge ' @@ -82,28 +104,6 @@ test_expect_success 'retry the merge with longer context' ' grep "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" actual ' -cat >./custom-merge <<\EOF -#!/bin/sh - -orig="$1" ours="$2" theirs="$3" exit="$4" path=$5 -( - echo "orig is $orig" - echo "ours is $ours" - echo "theirs is $theirs" - echo "path is $path" - echo "=== orig ===" - cat "$orig" - echo "=== ours ===" - cat "$ours" - echo "=== theirs ===" - cat "$theirs" -) >"$ours+" -cat "$ours+" >"$ours" -rm -f "$ours+" -exit "$exit" -EOF -chmod +x ./custom-merge - test_expect_success 'custom merge backend' ' echo "* merge=union" >.gitattributes && diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index bdc42e9440cb..821a0c88cf02 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -482,7 +482,7 @@ test_expect_success 'optimized merge base checks' ' git bisect good > my_bisect_log2.txt && test -f ".git/BISECT_ANCESTORS_OK" && test "$HASH6" = $(git rev-parse --verify HEAD) && - git bisect bad > my_bisect_log3.txt && + git bisect bad && git bisect good "$A_HASH" > my_bisect_log4.txt && test_i18ngrep "merge base must be tested" my_bisect_log4.txt && test_must_fail test -f ".git/BISECT_ANCESTORS_OK" diff --git a/t/t6034-merge-rename-nocruft.sh b/t/t6034-merge-rename-nocruft.sh index 89871aa5b044..a25e7304604e 100755 --- a/t/t6034-merge-rename-nocruft.sh +++ b/t/t6034-merge-rename-nocruft.sh @@ -3,74 +3,73 @@ test_description='Merge-recursive merging renames' . ./test-lib.sh -test_expect_success setup \ -' -cat >A <<\EOF && -a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -c cccccccccccccccccccccccccccccccccccccccccccccccc -d dddddddddddddddddddddddddddddddddddddddddddddddd -e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee -f ffffffffffffffffffffffffffffffffffffffffffffffff -g gggggggggggggggggggggggggggggggggggggggggggggggg -h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh -i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii -j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj -k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk -l llllllllllllllllllllllllllllllllllllllllllllllll -m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm -n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn -o oooooooooooooooooooooooooooooooooooooooooooooooo -EOF +test_expect_success 'setup' ' + cat >A <<-\EOF && + a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + c cccccccccccccccccccccccccccccccccccccccccccccccc + d dddddddddddddddddddddddddddddddddddddddddddddddd + e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + f ffffffffffffffffffffffffffffffffffffffffffffffff + g gggggggggggggggggggggggggggggggggggggggggggggggg + h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh + i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii + j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj + k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk + l llllllllllllllllllllllllllllllllllllllllllllllll + m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm + n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn + o oooooooooooooooooooooooooooooooooooooooooooooooo + EOF -cat >M <<\EOF && -A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB -C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC -D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD -E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE -F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG -H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH -I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ -K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK -L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL -M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM -N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO -EOF + cat >M <<-\EOF && + A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB + C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC + D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD + E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE + F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG + H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH + I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII + J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ + K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK + L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL + M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM + N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN + O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO + EOF -git add A M && -git commit -m "initial has A and M" && -git branch white && -git branch red && -git branch blue && + git add A M && + git commit -m "initial has A and M" && + git branch white && + git branch red && + git branch blue && -git checkout white && -sed -e "/^g /s/.*/g : white changes a line/" B && -sed -e "/^G /s/.*/G : colored branch changes a line/" N && -rm -f A M && -git update-index --add --remove A B M N && -git commit -m "white renames A->B, M->N" && + git checkout white && + sed -e "/^g /s/.*/g : white changes a line/" B && + sed -e "/^G /s/.*/G : colored branch changes a line/" N && + rm -f A M && + git update-index --add --remove A B M N && + git commit -m "white renames A->B, M->N" && -git checkout red && -echo created by red >R && -git update-index --add R && -git commit -m "red creates R" && + git checkout red && + echo created by red >R && + git update-index --add R && + git commit -m "red creates R" && -git checkout blue && -sed -e "/^o /s/.*/g : blue changes a line/" B && -rm -f A && -mv B A && -git update-index A && -git commit -m "blue modify A" && + git checkout blue && + sed -e "/^o /s/.*/g : blue changes a line/" B && + rm -f A && + mv B A && + git update-index A && + git commit -m "blue modify A" && -git checkout master' + git checkout master +' # This test broke in 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae -test_expect_success 'merge white into red (A->B,M->N)' \ -' +test_expect_success 'merge white into red (A->B,M->N)' ' git checkout -b red-white red && git merge white && git write-tree && @@ -82,8 +81,7 @@ test_expect_success 'merge white into red (A->B,M->N)' \ ' # This test broke in 8371234ecaaf6e14fe3f2082a855eff1bbd79ae9 -test_expect_success 'merge blue into white (A->B, mod A, A untracked)' \ -' +test_expect_success 'merge blue into white (A->B, mod A, A untracked)' ' git checkout -b white-blue white && echo dirty >A && git merge blue && diff --git a/t/t6035-merge-dir-to-symlink.sh b/t/t6035-merge-dir-to-symlink.sh index 9324ea441621..2eddcc7664e8 100755 --- a/t/t6035-merge-dir-to-symlink.sh +++ b/t/t6035-merge-dir-to-symlink.sh @@ -31,19 +31,19 @@ test_expect_success 'a/b-2/c/d is kept when clobbering symlink b' ' git rm --cached a/b && git commit -m "untracked symlink remains" && git checkout -f start^0 && - test -f a/b-2/c/d + test_path_is_file a/b-2/c/d ' test_expect_success 'checkout should not have deleted a/b-2/c/d' ' git checkout HEAD^0 && git reset --hard master && git checkout start^0 && - test -f a/b-2/c/d + test_path_is_file a/b-2/c/d ' test_expect_success 'setup for merge test' ' git reset --hard && - test -f a/b-2/c/d && + test_path_is_file a/b-2/c/d && echo x > a/x && git add a/x && git commit -m x && @@ -54,7 +54,7 @@ test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (resolv git reset --hard && git checkout baseline^0 && git merge -s resolve master && - test -f a/b-2/c/d + test_path_is_file a/b-2/c/d ' test_expect_success SYMLINKS 'a/b was resolved as symlink' ' @@ -65,7 +65,7 @@ test_expect_success 'Handle D/F conflict, do not lose a/b-2/c/d in merge (recurs git reset --hard && git checkout baseline^0 && git merge -s recursive master && - test -f a/b-2/c/d + test_path_is_file a/b-2/c/d ' test_expect_success SYMLINKS 'a/b was resolved as symlink' ' @@ -76,7 +76,7 @@ test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (resolv git reset --hard && git checkout master^0 && git merge -s resolve baseline^0 && - test -f a/b-2/c/d + test_path_is_file a/b-2/c/d ' test_expect_success SYMLINKS 'a/b was resolved as symlink' ' @@ -87,7 +87,7 @@ test_expect_success 'Handle F/D conflict, do not lose a/b-2/c/d in merge (recurs git reset --hard && git checkout master^0 && git merge -s recursive baseline^0 && - test -f a/b-2/c/d + test_path_is_file a/b-2/c/d ' test_expect_success SYMLINKS 'a/b was resolved as symlink' ' @@ -99,8 +99,8 @@ test_expect_failure 'do not lose untracked in merge (resolve)' ' git checkout baseline^0 && >a/b/c/e && test_must_fail git merge -s resolve master && - test -f a/b/c/e && - test -f a/b-2/c/d + test_path_is_file a/b/c/e && + test_path_is_file a/b-2/c/d ' test_expect_success 'do not lose untracked in merge (recursive)' ' @@ -108,8 +108,8 @@ test_expect_success 'do not lose untracked in merge (recursive)' ' git checkout baseline^0 && >a/b/c/e && test_must_fail git merge -s recursive master && - test -f a/b/c/e && - test -f a/b-2/c/d + test_path_is_file a/b/c/e && + test_path_is_file a/b-2/c/d ' test_expect_success 'do not lose modifications in merge (resolve)' ' @@ -140,7 +140,7 @@ test_expect_success 'merge should not have D/F conflicts (resolve)' ' git reset --hard && git checkout baseline^0 && git merge -s resolve test2 && - test -f a/b/c/d + test_path_is_file a/b/c/d ' test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' ' @@ -151,7 +151,7 @@ test_expect_success 'merge should not have D/F conflicts (recursive)' ' git reset --hard && git checkout baseline^0 && git merge -s recursive test2 && - test -f a/b/c/d + test_path_is_file a/b/c/d ' test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' ' @@ -162,7 +162,7 @@ test_expect_success 'merge should not have F/D conflicts (recursive)' ' git reset --hard && git checkout -b foo test2 && git merge -s recursive baseline^0 && - test -f a/b/c/d + test_path_is_file a/b/c/d ' test_expect_success SYMLINKS 'a/b-2 was resolved as symlink' ' diff --git a/t/t6036-recursive-corner-cases.sh b/t/t6036-recursive-corner-cases.sh index d23b948f27f1..b3bf46261786 100755 --- a/t/t6036-recursive-corner-cases.sh +++ b/t/t6036-recursive-corner-cases.sh @@ -60,9 +60,9 @@ test_expect_success 'merge simple rename+criss-cross with no modifications' ' test_must_fail git merge -s recursive R2^0 && git ls-files -s >out && - test_line_count = 2 out && + test_line_count = 5 out && git ls-files -u >out && - test_line_count = 2 out && + test_line_count = 3 out && git ls-files -o >out && test_line_count = 1 out && @@ -133,9 +133,9 @@ test_expect_success 'merge criss-cross + rename merges with basic modification' test_must_fail git merge -s recursive R2^0 && git ls-files -s >out && - test_line_count = 2 out && + test_line_count = 5 out && git ls-files -u >out && - test_line_count = 2 out && + test_line_count = 3 out && git ls-files -o >out && test_line_count = 1 out && @@ -218,8 +218,18 @@ test_expect_success 'git detects differently handled merges conflict' ' git ls-files -o >out && test_line_count = 1 out && - git rev-parse >expect \ - C:new_a D:new_a E:new_a && + git cat-file -p C:new_a >ours && + git cat-file -p C:a >theirs && + >empty && + test_must_fail git merge-file \ + -L "Temporary merge branch 1" \ + -L "" \ + -L "Temporary merge branch 2" \ + ours empty theirs && + sed -e "s/^\([<=>]\)/\1\1\1/" ours >ours-tweaked && + git hash-object ours-tweaked >expect && + git rev-parse >>expect \ + D:new_a E:new_a && git rev-parse >actual \ :1:new_a :2:new_a :3:new_a && test_cmp expect actual && @@ -257,7 +267,8 @@ test_expect_success 'git detects differently handled merges conflict, swapped' ' ctime=$(git log --no-walk --date=raw --format=%cd C | awk "{print \$1}") && newctime=$(($btime+1)) && git fast-export --no-data --all | sed -e s/$ctime/$newctime/ | git fast-import --force --quiet && - # End of differences; rest is copy-paste of last test + # End of most differences; rest is copy-paste of last test, + # other than swapping C:a and C:new_a due to order switch git checkout D^0 && test_must_fail git merge -s recursive E^0 && @@ -269,8 +280,18 @@ test_expect_success 'git detects differently handled merges conflict, swapped' ' git ls-files -o >out && test_line_count = 1 out && - git rev-parse >expect \ - C:new_a D:new_a E:new_a && + git cat-file -p C:a >ours && + git cat-file -p C:new_a >theirs && + >empty && + test_must_fail git merge-file \ + -L "Temporary merge branch 1" \ + -L "" \ + -L "Temporary merge branch 2" \ + ours empty theirs && + sed -e "s/^\([<=>]\)/\1\1\1/" ours >ours-tweaked && + git hash-object ours-tweaked >expect && + git rev-parse >>expect \ + D:new_a E:new_a && git rev-parse >actual \ :1:new_a :2:new_a :3:new_a && test_cmp expect actual && @@ -1532,7 +1553,7 @@ test_expect_success 'setup nested conflicts' ' mv -f b_R1 b && mv -f a_R1 a && git add b a && - test_tick && git commit -m "verson R1 of files" && + test_tick && git commit -m "version R1 of files" && git tag R1 && # Create first merge on left side @@ -1562,6 +1583,7 @@ test_expect_success 'check nested conflicts' ' cd nested_conflicts && git clean -f && + MASTER=$(git rev-parse --short master) && git checkout L2^0 && # Merge must fail; there is a conflict @@ -1582,7 +1604,7 @@ test_expect_success 'check nested conflicts' ' git cat-file -p R1:a >theirs && test_must_fail git merge-file --diff3 \ -L "Temporary merge branch 1" \ - -L "merged common ancestors" \ + -L "$MASTER" \ -L "Temporary merge branch 2" \ ours \ base \ @@ -1594,7 +1616,7 @@ test_expect_success 'check nested conflicts' ' git cat-file -p R1:b >theirs && test_must_fail git merge-file --diff3 \ -L "Temporary merge branch 1" \ - -L "merged common ancestors" \ + -L "$MASTER" \ -L "Temporary merge branch 2" \ ours \ base \ @@ -1695,7 +1717,7 @@ test_expect_success 'setup virtual merge base with nested conflicts' ' git checkout R && echo right >>content && git add content && - test_tick && git commit -m "verson R1 of content" && + test_tick && git commit -m "version R1 of content" && git tag R1 && # Create L2 @@ -1732,6 +1754,7 @@ test_expect_success 'check virtual merge base with nested conflicts' ' ( cd virtual_merge_base_has_nested_conflicts && + MASTER=$(git rev-parse --short master) && git checkout L3^0 && # Merge must fail; there is a conflict @@ -1760,7 +1783,7 @@ test_expect_success 'check virtual merge base with nested conflicts' ' cp left merged-once && test_must_fail git merge-file --diff3 \ -L "Temporary merge branch 1" \ - -L "merged common ancestors" \ + -L "$MASTER" \ -L "Temporary merge branch 2" \ merged-once \ base \ diff --git a/t/t6042-merge-rename-corner-cases.sh b/t/t6042-merge-rename-corner-cases.sh index c5b57f40c3d1..b047cf1c1c37 100755 --- a/t/t6042-merge-rename-corner-cases.sh +++ b/t/t6042-merge-rename-corner-cases.sh @@ -5,7 +5,7 @@ test_description="recursive merge corner cases w/ renames but not criss-crosses" . ./test-lib.sh -test_expect_success 'setup rename/delete + untracked file' ' +test_setup_rename_delete_untracked () { test_create_repo rename-delete-untracked && ( cd rename-delete-untracked && @@ -29,9 +29,10 @@ test_expect_success 'setup rename/delete + untracked file' ' git commit -m track-people-instead-of-objects && echo "Myyy PRECIOUSSS" >ring ) -' +} test_expect_success "Does git preserve Gollum's precious artifact?" ' + test_setup_rename_delete_untracked && ( cd rename-delete-untracked && @@ -49,7 +50,7 @@ test_expect_success "Does git preserve Gollum's precious artifact?" ' # # We should be able to merge B & C cleanly -test_expect_success 'setup rename/modify/add-source conflict' ' +test_setup_rename_modify_add_source () { test_create_repo rename-modify-add-source && ( cd rename-modify-add-source && @@ -70,9 +71,10 @@ test_expect_success 'setup rename/modify/add-source conflict' ' git add a && git commit -m C ) -' +} test_expect_failure 'rename/modify/add-source conflict resolvable' ' + test_setup_rename_modify_add_source && ( cd rename-modify-add-source && @@ -88,7 +90,7 @@ test_expect_failure 'rename/modify/add-source conflict resolvable' ' ) ' -test_expect_success 'setup resolvable conflict missed if rename missed' ' +test_setup_break_detection_1 () { test_create_repo break-detection-1 && ( cd break-detection-1 && @@ -110,9 +112,10 @@ test_expect_success 'setup resolvable conflict missed if rename missed' ' git add a && git commit -m C ) -' +} test_expect_failure 'conflict caused if rename not detected' ' + test_setup_break_detection_1 && ( cd break-detection-1 && @@ -135,7 +138,7 @@ test_expect_failure 'conflict caused if rename not detected' ' ) ' -test_expect_success 'setup conflict resolved wrong if rename missed' ' +test_setup_break_detection_2 () { test_create_repo break-detection-2 && ( cd break-detection-2 && @@ -160,9 +163,10 @@ test_expect_success 'setup conflict resolved wrong if rename missed' ' git add a && git commit -m E ) -' +} test_expect_failure 'missed conflict if rename not detected' ' + test_setup_break_detection_2 && ( cd break-detection-2 && @@ -182,7 +186,7 @@ test_expect_failure 'missed conflict if rename not detected' ' # Commit B: rename a->b # Commit C: rename a->b, add unrelated a -test_expect_success 'setup undetected rename/add-source causes data loss' ' +test_setup_break_detection_3 () { test_create_repo break-detection-3 && ( cd break-detection-3 && @@ -202,9 +206,10 @@ test_expect_success 'setup undetected rename/add-source causes data loss' ' git add a && git commit -m C ) -' +} test_expect_failure 'detect rename/add-source and preserve all data' ' + test_setup_break_detection_3 && ( cd break-detection-3 && @@ -231,6 +236,7 @@ test_expect_failure 'detect rename/add-source and preserve all data' ' ' test_expect_failure 'detect rename/add-source and preserve all data, merge other way' ' + test_setup_break_detection_3 && ( cd break-detection-3 && @@ -256,10 +262,10 @@ test_expect_failure 'detect rename/add-source and preserve all data, merge other ) ' -test_expect_success 'setup content merge + rename/directory conflict' ' - test_create_repo rename-directory-1 && +test_setup_rename_directory () { + test_create_repo rename-directory-$1 && ( - cd rename-directory-1 && + cd rename-directory-$1 && printf "1\n2\n3\n4\n5\n6\n" >file && git add file && @@ -290,11 +296,12 @@ test_expect_success 'setup content merge + rename/directory conflict' ' test_tick && git commit -m left ) -' +} test_expect_success 'rename/directory conflict + clean content merge' ' + test_setup_rename_directory 1a && ( - cd rename-directory-1 && + cd rename-directory-1a && git checkout left-clean^0 && @@ -320,8 +327,9 @@ test_expect_success 'rename/directory conflict + clean content merge' ' ' test_expect_success 'rename/directory conflict + content merge conflict' ' + test_setup_rename_directory 1b && ( - cd rename-directory-1 && + cd rename-directory-1b && git reset --hard && git clean -fdqx && @@ -358,7 +366,7 @@ test_expect_success 'rename/directory conflict + content merge conflict' ' ) ' -test_expect_success 'setup content merge + rename/directory conflict w/ disappearing dir' ' +test_setup_rename_directory_2 () { test_create_repo rename-directory-2 && ( cd rename-directory-2 && @@ -385,9 +393,10 @@ test_expect_success 'setup content merge + rename/directory conflict w/ disappea test_tick && git commit -m left ) -' +} test_expect_success 'disappearing dir in rename/directory conflict handled' ' + test_setup_rename_directory_2 && ( cd rename-directory-2 && @@ -416,10 +425,10 @@ test_expect_success 'disappearing dir in rename/directory conflict handled' ' # Commit A: rename a->b, modifying b too # Commit B: modify a, add different b -test_expect_success 'setup rename-with-content-merge vs. add' ' - test_create_repo rename-with-content-merge-and-add && +test_setup_rename_with_content_merge_and_add () { + test_create_repo rename-with-content-merge-and-add-$1 && ( - cd rename-with-content-merge-and-add && + cd rename-with-content-merge-and-add-$1 && test_seq 1 5 >a && git add a && @@ -438,11 +447,12 @@ test_expect_success 'setup rename-with-content-merge vs. add' ' git add a b && git commit -m B ) -' +} test_expect_success 'handle rename-with-content-merge vs. add' ' + test_setup_rename_with_content_merge_and_add AB && ( - cd rename-with-content-merge-and-add && + cd rename-with-content-merge-and-add-AB && git checkout A^0 && @@ -483,8 +493,9 @@ test_expect_success 'handle rename-with-content-merge vs. add' ' ' test_expect_success 'handle rename-with-content-merge vs. add, merge other way' ' + test_setup_rename_with_content_merge_and_add BA && ( - cd rename-with-content-merge-and-add && + cd rename-with-content-merge-and-add-BA && git reset --hard && git clean -fdx && @@ -539,7 +550,7 @@ test_expect_success 'handle rename-with-content-merge vs. add, merge other way' # * The working copy should have two files, both of form c~; does it? # * Nothing else should be present. Is anything? -test_expect_success 'setup rename/rename (2to1) + modify/modify' ' +test_setup_rename_rename_2to1 () { test_create_repo rename-rename-2to1 && ( cd rename-rename-2to1 && @@ -562,9 +573,10 @@ test_expect_success 'setup rename/rename (2to1) + modify/modify' ' git add a && git commit -m C ) -' +} test_expect_success 'handle rename/rename (2to1) conflict correctly' ' + test_setup_rename_rename_2to1 && ( cd rename-rename-2to1 && @@ -610,7 +622,7 @@ test_expect_success 'handle rename/rename (2to1) conflict correctly' ' # Commit A: new file: a # Commit B: rename a->b # Commit C: rename a->c -test_expect_success 'setup simple rename/rename (1to2) conflict' ' +test_setup_rename_rename_1to2 () { test_create_repo rename-rename-1to2 && ( cd rename-rename-1to2 && @@ -631,9 +643,10 @@ test_expect_success 'setup simple rename/rename (1to2) conflict' ' test_tick && git commit -m C ) -' +} test_expect_success 'merge has correct working tree contents' ' + test_setup_rename_rename_1to2 && ( cd rename-rename-1to2 && @@ -667,7 +680,7 @@ test_expect_success 'merge has correct working tree contents' ' # # Merging of B & C should NOT be clean; there's a rename/rename conflict -test_expect_success 'setup rename/rename(1to2)/add-source conflict' ' +test_setup_rename_rename_1to2_add_source_1 () { test_create_repo rename-rename-1to2-add-source-1 && ( cd rename-rename-1to2-add-source-1 && @@ -687,9 +700,10 @@ test_expect_success 'setup rename/rename(1to2)/add-source conflict' ' git add a && git commit -m C ) -' +} test_expect_failure 'detect conflict with rename/rename(1to2)/add-source merge' ' + test_setup_rename_rename_1to2_add_source_1 && ( cd rename-rename-1to2-add-source-1 && @@ -714,7 +728,7 @@ test_expect_failure 'detect conflict with rename/rename(1to2)/add-source merge' ) ' -test_expect_success 'setup rename/rename(1to2)/add-source resolvable conflict' ' +test_setup_rename_rename_1to2_add_source_2 () { test_create_repo rename-rename-1to2-add-source-2 && ( cd rename-rename-1to2-add-source-2 && @@ -737,9 +751,10 @@ test_expect_success 'setup rename/rename(1to2)/add-source resolvable conflict' ' test_tick && git commit -m two ) -' +} test_expect_failure 'rename/rename/add-source still tracks new a file' ' + test_setup_rename_rename_1to2_add_source_2 && ( cd rename-rename-1to2-add-source-2 && @@ -759,7 +774,7 @@ test_expect_failure 'rename/rename/add-source still tracks new a file' ' ) ' -test_expect_success 'setup rename/rename(1to2)/add-dest conflict' ' +test_setup_rename_rename_1to2_add_dest () { test_create_repo rename-rename-1to2-add-dest && ( cd rename-rename-1to2-add-dest && @@ -784,9 +799,10 @@ test_expect_success 'setup rename/rename(1to2)/add-dest conflict' ' test_tick && git commit -m two ) -' +} test_expect_success 'rename/rename/add-dest merge still knows about conflicting file versions' ' + test_setup_rename_rename_1to2_add_dest && ( cd rename-rename-1to2-add-dest && @@ -838,7 +854,7 @@ test_expect_success 'rename/rename/add-dest merge still knows about conflicting # Commit B: rename foo->bar # Expected: CONFLICT (rename/add/delete), two-way merged bar -test_expect_success 'rad-setup: rename/add/delete conflict' ' +test_setup_rad () { test_create_repo rad && ( cd rad && @@ -860,9 +876,10 @@ test_expect_success 'rad-setup: rename/add/delete conflict' ' git mv foo bar && git commit -m "rename foo to bar" ) -' +} test_expect_failure 'rad-check: rename/add/delete conflict' ' + test_setup_rad && ( cd rad && @@ -904,7 +921,7 @@ test_expect_failure 'rad-check: rename/add/delete conflict' ' # Commit B: rename bar->baz, rm foo # Expected: CONFLICT (rename/rename/delete/delete), two-way merged baz -test_expect_success 'rrdd-setup: rename/rename(2to1)/delete/delete conflict' ' +test_setup_rrdd () { test_create_repo rrdd && ( cd rrdd && @@ -927,9 +944,10 @@ test_expect_success 'rrdd-setup: rename/rename(2to1)/delete/delete conflict' ' git rm foo && git commit -m "Rename bar, remove foo" ) -' +} test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' ' + test_setup_rrdd && ( cd rrdd && @@ -973,7 +991,7 @@ test_expect_failure 'rrdd-check: rename/rename(2to1)/delete/delete conflict' ' # Expected: six CONFLICT(rename/rename) messages, each path in two of the # multi-way merged contents found in two, four, six -test_expect_success 'mod6-setup: chains of rename/rename(1to2) and rename/rename(2to1)' ' +test_setup_mod6 () { test_create_repo mod6 && ( cd mod6 && @@ -1009,9 +1027,10 @@ test_expect_success 'mod6-setup: chains of rename/rename(1to2) and rename/rename test_tick && git commit -m "B" ) -' +} test_expect_failure 'mod6-check: chains of rename/rename(1to2) and rename/rename(2to1)' ' + test_setup_mod6 && ( cd mod6 && @@ -1108,7 +1127,8 @@ test_conflicts_with_adds_and_renames() { # files. Is it present? # 4) There should not be any three~* files in the working # tree - test_expect_success "setup simple $sideL/$sideR conflict" ' + test_setup_collision_conflict () { + #test_expect_success "setup simple $sideL/$sideR conflict" ' test_create_repo simple_${sideL}_${sideR} && ( cd simple_${sideL}_${sideR} && @@ -1185,9 +1205,11 @@ test_conflicts_with_adds_and_renames() { fi && test_tick && git commit -m R ) - ' + #' + } test_expect_success "check simple $sideL/$sideR conflict" ' + test_setup_collision_conflict && ( cd simple_${sideL}_${sideR} && @@ -1254,7 +1276,7 @@ test_conflicts_with_adds_and_renames add add # # So, we have four different conflicting files that all end up at path # 'three'. -test_expect_success 'setup nested conflicts from rename/rename(2to1)' ' +test_setup_nested_conflicts_from_rename_rename () { test_create_repo nested_conflicts_from_rename_rename && ( cd nested_conflicts_from_rename_rename && @@ -1305,9 +1327,10 @@ test_expect_success 'setup nested conflicts from rename/rename(2to1)' ' git add one three && test_tick && git commit -m german ) -' +} test_expect_success 'check nested conflicts from rename/rename(2to1)' ' + test_setup_nested_conflicts_from_rename_rename && ( cd nested_conflicts_from_rename_rename && diff --git a/t/t6043-merge-rename-directories.sh b/t/t6043-merge-rename-directories.sh index c966147d5d73..83792c5ef1f5 100755 --- a/t/t6043-merge-rename-directories.sh +++ b/t/t6043-merge-rename-directories.sh @@ -38,7 +38,7 @@ test_description="recursive merge with directory renames" # Commit B: z/{b,c,d,e/f} # Expected: y/{b,c,d,e/f} -test_expect_success '1a-setup: Simple directory rename detection' ' +test_setup_1a () { test_create_repo 1a && ( cd 1a && @@ -67,9 +67,10 @@ test_expect_success '1a-setup: Simple directory rename detection' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '1a-check: Simple directory rename detection' ' +test_expect_success '1a: Simple directory rename detection' ' + test_setup_1a && ( cd 1a && @@ -103,7 +104,7 @@ test_expect_success '1a-check: Simple directory rename detection' ' # Commit B: y/{b,c,d} # Expected: y/{b,c,d,e} -test_expect_success '1b-setup: Merge a directory with another' ' +test_setup_1b () { test_create_repo 1b && ( cd 1b && @@ -134,9 +135,10 @@ test_expect_success '1b-setup: Merge a directory with another' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '1b-check: Merge a directory with another' ' +test_expect_success '1b: Merge a directory with another' ' + test_setup_1b && ( cd 1b && @@ -165,7 +167,7 @@ test_expect_success '1b-check: Merge a directory with another' ' # Commit B: z/{b,c,d} # Expected: y/{b,c,d} (because x/d -> z/d -> y/d) -test_expect_success '1c-setup: Transitive renaming' ' +test_setup_1c () { test_create_repo 1c && ( cd 1c && @@ -193,9 +195,10 @@ test_expect_success '1c-setup: Transitive renaming' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '1c-check: Transitive renaming' ' +test_expect_success '1c: Transitive renaming' ' + test_setup_1c && ( cd 1c && @@ -227,7 +230,7 @@ test_expect_success '1c-check: Transitive renaming' ' # Note: y/m & z/n should definitely move into x. By the same token, both # y/wham_1 & z/wham_2 should too...giving us a conflict. -test_expect_success '1d-setup: Directory renames cause a rename/rename(2to1) conflict' ' +test_setup_1d () { test_create_repo 1d && ( cd 1d && @@ -262,9 +265,10 @@ test_expect_success '1d-setup: Directory renames cause a rename/rename(2to1) con test_tick && git commit -m "B" ) -' +} -test_expect_success '1d-check: Directory renames cause a rename/rename(2to1) conflict' ' +test_expect_success '1d: Directory renames cause a rename/rename(2to1) conflict' ' + test_setup_1d && ( cd 1d && @@ -313,7 +317,7 @@ test_expect_success '1d-check: Directory renames cause a rename/rename(2to1) con # Commit B: z/{oldb,oldc,d} # Expected: y/{newb,newc,d} -test_expect_success '1e-setup: Renamed directory, with all files being renamed too' ' +test_setup_1e () { test_create_repo 1e && ( cd 1e && @@ -342,9 +346,10 @@ test_expect_success '1e-setup: Renamed directory, with all files being renamed t test_tick && git commit -m "B" ) -' +} -test_expect_success '1e-check: Renamed directory, with all files being renamed too' ' +test_expect_success '1e: Renamed directory, with all files being renamed too' ' + test_setup_1e && ( cd 1e && @@ -371,7 +376,7 @@ test_expect_success '1e-check: Renamed directory, with all files being renamed t # Commit B: y/{b,c}, x/{d,e,f} # Expected: y/{b,c}, x/{d,e,f,g} -test_expect_success '1f-setup: Split a directory into two other directories' ' +test_setup_1f () { test_create_repo 1f && ( cd 1f && @@ -408,9 +413,10 @@ test_expect_success '1f-setup: Split a directory into two other directories' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '1f-check: Split a directory into two other directories' ' +test_expect_success '1f: Split a directory into two other directories' ' + test_setup_1f && ( cd 1f && @@ -459,7 +465,7 @@ test_expect_success '1f-check: Split a directory into two other directories' ' # Commit A: y/b, w/c # Commit B: z/{b,c,d} # Expected: y/b, w/c, z/d, with warning about z/ -> (y/ vs. w/) conflict -test_expect_success '2a-setup: Directory split into two on one side, with equal numbers of paths' ' +test_setup_2a () { test_create_repo 2a && ( cd 2a && @@ -489,9 +495,10 @@ test_expect_success '2a-setup: Directory split into two on one side, with equal test_tick && git commit -m "B" ) -' +} -test_expect_success '2a-check: Directory split into two on one side, with equal numbers of paths' ' +test_expect_success '2a: Directory split into two on one side, with equal numbers of paths' ' + test_setup_2a && ( cd 2a && @@ -520,7 +527,7 @@ test_expect_success '2a-check: Directory split into two on one side, with equal # Commit A: y/b, w/c # Commit B: z/{b,c}, x/d # Expected: y/b, w/c, x/d; No warning about z/ -> (y/ vs. w/) conflict -test_expect_success '2b-setup: Directory split into two on one side, with equal numbers of paths' ' +test_setup_2b () { test_create_repo 2b && ( cd 2b && @@ -551,9 +558,10 @@ test_expect_success '2b-setup: Directory split into two on one side, with equal test_tick && git commit -m "B" ) -' +} -test_expect_success '2b-check: Directory split into two on one side, with equal numbers of paths' ' +test_expect_success '2b: Directory split into two on one side, with equal numbers of paths' ' + test_setup_2b && ( cd 2b && @@ -601,7 +609,7 @@ test_expect_success '2b-check: Directory split into two on one side, with equal # Commit A: z/{b,c,d} (no change) # Commit B: y/{b,c}, x/d # Expected: y/{b,c}, x/d -test_expect_success '3a-setup: Avoid implicit rename if involved as source on other side' ' +test_setup_3a () { test_create_repo 3a && ( cd 3a && @@ -632,9 +640,10 @@ test_expect_success '3a-setup: Avoid implicit rename if involved as source on ot test_tick && git commit -m "B" ) -' +} -test_expect_success '3a-check: Avoid implicit rename if involved as source on other side' ' +test_expect_success '3a: Avoid implicit rename if involved as source on other side' ' + test_setup_3a && ( cd 3a && @@ -664,7 +673,7 @@ test_expect_success '3a-check: Avoid implicit rename if involved as source on ot # get it involved in directory rename detection. If it were, we might # end up with CONFLICT:(z/d -> y/d vs. x/d vs. w/d), i.e. a # rename/rename/rename(1to3) conflict, which is just weird. -test_expect_success '3b-setup: Avoid implicit rename if involved as source on current side' ' +test_setup_3b () { test_create_repo 3b && ( cd 3b && @@ -697,9 +706,10 @@ test_expect_success '3b-setup: Avoid implicit rename if involved as source on cu test_tick && git commit -m "B" ) -' +} -test_expect_success '3b-check: Avoid implicit rename if involved as source on current side' ' +test_expect_success '3b: Avoid implicit rename if involved as source on current side' ' + test_setup_3b && ( cd 3b && @@ -744,7 +754,7 @@ test_expect_success '3b-check: Avoid implicit rename if involved as source on cu # # What if we were to attempt to do directory rename detection when someone # "mostly" moved a directory but still left some files around, or, -# equivalently, fully renamed a directory in one commmit and then recreated +# equivalently, fully renamed a directory in one commit and then recreated # that directory in a later commit adding some new files and then tried to # merge? # @@ -786,7 +796,7 @@ test_expect_success '3b-check: Avoid implicit rename if involved as source on cu # Expected: y/{b,c,d}, z/{e,f} # NOTE: Even though most files from z moved to y, we don't want f to follow. -test_expect_success '4a-setup: Directory split, with original directory still present' ' +test_setup_4a () { test_create_repo 4a && ( cd 4a && @@ -818,9 +828,10 @@ test_expect_success '4a-setup: Directory split, with original directory still pr test_tick && git commit -m "B" ) -' +} -test_expect_success '4a-check: Directory split, with original directory still present' ' +test_expect_success '4a: Directory split, with original directory still present' ' + test_setup_4a && ( cd 4a && @@ -874,7 +885,7 @@ test_expect_success '4a-check: Directory split, with original directory still pr # of history, giving us no way to represent this conflict in the # index. -test_expect_success '5a-setup: Merge directories, other side adds files to original and target' ' +test_setup_5a () { test_create_repo 5a && ( cd 5a && @@ -907,9 +918,10 @@ test_expect_success '5a-setup: Merge directories, other side adds files to origi test_tick && git commit -m "B" ) -' +} -test_expect_success '5a-check: Merge directories, other side adds files to original and target' ' +test_expect_success '5a: Merge directories, other side adds files to original and target' ' + test_setup_5a && ( cd 5a && @@ -941,14 +953,14 @@ test_expect_success '5a-check: Merge directories, other side adds files to origi # Commit B: z/{b,c,d_1,e}, y/d_3 # Expected: y/{b,c,e}, CONFLICT(add/add: y/d_2 vs. y/d_3) # NOTE: If z/d_1 in commit B were to be involved in dir rename detection, as -# we normaly would since z/ is being renamed to y/, then this would be +# we normally would since z/ is being renamed to y/, then this would be # a rename/delete (z/d_1 -> y/d_1 vs. deleted) AND an add/add/add # conflict of y/d_1 vs. y/d_2 vs. y/d_3. Add/add/add is not # representable in the index, so the existence of y/d_3 needs to # cause us to bail on directory rename detection for that path, falling # back to git behavior without the directory rename detection. -test_expect_success '5b-setup: Rename/delete in order to get add/add/add conflict' ' +test_setup_5b () { test_create_repo 5b && ( cd 5b && @@ -981,9 +993,10 @@ test_expect_success '5b-setup: Rename/delete in order to get add/add/add conflic test_tick && git commit -m "B" ) -' +} -test_expect_success '5b-check: Rename/delete in order to get add/add/add conflict' ' +test_expect_success '5b: Rename/delete in order to get add/add/add conflict' ' + test_setup_5b && ( cd 5b && @@ -1024,7 +1037,7 @@ test_expect_success '5b-check: Rename/delete in order to get add/add/add conflic # y/d are y/d_2 and y/d_4. We still do the move from z/e to y/e, # though, because it doesn't have anything in the way. -test_expect_success '5c-setup: Transitive rename would cause rename/rename/rename/add/add/add' ' +test_setup_5c () { test_create_repo 5c && ( cd 5c && @@ -1061,9 +1074,10 @@ test_expect_success '5c-setup: Transitive rename would cause rename/rename/renam test_tick && git commit -m "B" ) -' +} -test_expect_success '5c-check: Transitive rename would cause rename/rename/rename/add/add/add' ' +test_expect_success '5c: Transitive rename would cause rename/rename/rename/add/add/add' ' + test_setup_5c && ( cd 5c && @@ -1113,7 +1127,7 @@ test_expect_success '5c-check: Transitive rename would cause rename/rename/renam # detection for z/d_2, but that doesn't prevent us from applying the # directory rename detection for z/f -> y/f. -test_expect_success '5d-setup: Directory/file/file conflict due to directory rename' ' +test_setup_5d () { test_create_repo 5d && ( cd 5d && @@ -1145,9 +1159,10 @@ test_expect_success '5d-setup: Directory/file/file conflict due to directory ren test_tick && git commit -m "B" ) -' +} -test_expect_success '5d-check: Directory/file/file conflict due to directory rename' ' +test_expect_success '5d: Directory/file/file conflict due to directory rename' ' + test_setup_5d && ( cd 5d && @@ -1205,7 +1220,7 @@ test_expect_success '5d-check: Directory/file/file conflict due to directory ren # them under y/ doesn't accidentally catch z/d and make it look like # it is also involved in a rename/delete conflict. -test_expect_success '6a-setup: Tricky rename/delete' ' +test_setup_6a () { test_create_repo 6a && ( cd 6a && @@ -1235,9 +1250,10 @@ test_expect_success '6a-setup: Tricky rename/delete' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '6a-check: Tricky rename/delete' ' +test_expect_success '6a: Tricky rename/delete' ' + test_setup_6a && ( cd 6a && @@ -1271,7 +1287,7 @@ test_expect_success '6a-check: Tricky rename/delete' ' # but B did that rename and still decided to put the file into z/, # so we probably shouldn't apply directory rename detection for it. -test_expect_success '6b-setup: Same rename done on both sides' ' +test_setup_6b () { test_create_repo 6b && ( cd 6b && @@ -1300,9 +1316,10 @@ test_expect_success '6b-setup: Same rename done on both sides' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '6b-check: Same rename done on both sides' ' +test_expect_success '6b: Same rename done on both sides' ' + test_setup_6b && ( cd 6b && @@ -1334,7 +1351,7 @@ test_expect_success '6b-check: Same rename done on both sides' ' # NOTE: Seems obvious, but just checking that the implementation doesn't # "accidentally detect a rename" and give us y/{b,c,d}. -test_expect_success '6c-setup: Rename only done on same side' ' +test_setup_6c () { test_create_repo 6c && ( cd 6c && @@ -1362,9 +1379,10 @@ test_expect_success '6c-setup: Rename only done on same side' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '6c-check: Rename only done on same side' ' +test_expect_success '6c: Rename only done on same side' ' + test_setup_6c && ( cd 6c && @@ -1396,7 +1414,7 @@ test_expect_success '6c-check: Rename only done on same side' ' # NOTE: Again, this seems obvious but just checking that the implementation # doesn't "accidentally detect a rename" and give us y/{b,c,d}. -test_expect_success '6d-setup: We do not always want transitive renaming' ' +test_setup_6d () { test_create_repo 6d && ( cd 6d && @@ -1424,9 +1442,10 @@ test_expect_success '6d-setup: We do not always want transitive renaming' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '6d-check: We do not always want transitive renaming' ' +test_expect_success '6d: We do not always want transitive renaming' ' + test_setup_6d && ( cd 6d && @@ -1458,7 +1477,7 @@ test_expect_success '6d-check: We do not always want transitive renaming' ' # doesn't "accidentally detect a rename" and give us y/{b,c} + # add/add conflict on y/d_1 vs y/d_2. -test_expect_success '6e-setup: Add/add from one side' ' +test_setup_6e () { test_create_repo 6e && ( cd 6e && @@ -1487,9 +1506,10 @@ test_expect_success '6e-setup: Add/add from one side' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '6e-check: Add/add from one side' ' +test_expect_success '6e: Add/add from one side' ' + test_setup_6e && ( cd 6e && @@ -1552,7 +1572,7 @@ test_expect_success '6e-check: Add/add from one side' ' # Expected: y/d, CONFLICT(rename/rename for both z/b and z/c) # NOTE: There's a rename of z/ here, y/ has more renames, so z/d -> y/d. -test_expect_success '7a-setup: rename-dir vs. rename-dir (NOT split evenly) PLUS add-other-file' ' +test_setup_7a () { test_create_repo 7a && ( cd 7a && @@ -1583,9 +1603,10 @@ test_expect_success '7a-setup: rename-dir vs. rename-dir (NOT split evenly) PLUS test_tick && git commit -m "B" ) -' +} -test_expect_success '7a-check: rename-dir vs. rename-dir (NOT split evenly) PLUS add-other-file' ' +test_expect_success '7a: rename-dir vs. rename-dir (NOT split evenly) PLUS add-other-file' ' + test_setup_7a && ( cd 7a && @@ -1623,7 +1644,7 @@ test_expect_success '7a-check: rename-dir vs. rename-dir (NOT split evenly) PLUS # Commit B: z/{b,c,d_1}, w/d_2 # Expected: y/{b,c}, CONFLICT(rename/rename(2to1): x/d_1, w/d_2 -> y_d) -test_expect_success '7b-setup: rename/rename(2to1), but only due to transitive rename' ' +test_setup_7b () { test_create_repo 7b && ( cd 7b && @@ -1655,9 +1676,10 @@ test_expect_success '7b-setup: rename/rename(2to1), but only due to transitive r test_tick && git commit -m "B" ) -' +} -test_expect_success '7b-check: rename/rename(2to1), but only due to transitive rename' ' +test_expect_success '7b: rename/rename(2to1), but only due to transitive rename' ' + test_setup_7b && ( cd 7b && @@ -1702,7 +1724,7 @@ test_expect_success '7b-check: rename/rename(2to1), but only due to transitive r # neither CONFLICT(x/d -> w/d vs. z/d) # nor CONFLiCT x/d -> w/d vs. y/d vs. z/d) -test_expect_success '7c-setup: rename/rename(1to...2or3); transitive rename may add complexity' ' +test_setup_7c () { test_create_repo 7c && ( cd 7c && @@ -1732,9 +1754,10 @@ test_expect_success '7c-setup: rename/rename(1to...2or3); transitive rename may test_tick && git commit -m "B" ) -' +} -test_expect_success '7c-check: rename/rename(1to...2or3); transitive rename may add complexity' ' +test_expect_success '7c: rename/rename(1to...2or3); transitive rename may add complexity' ' + test_setup_7c && ( cd 7c && @@ -1766,7 +1789,7 @@ test_expect_success '7c-check: rename/rename(1to...2or3); transitive rename may # Expected: y/{b,c}, CONFLICT(delete x/d vs rename to y/d) # NOTE: z->y so NOT CONFLICT(delete x/d vs rename to z/d) -test_expect_success '7d-setup: transitive rename involved in rename/delete; how is it reported?' ' +test_setup_7d () { test_create_repo 7d && ( cd 7d && @@ -1796,9 +1819,10 @@ test_expect_success '7d-setup: transitive rename involved in rename/delete; how test_tick && git commit -m "B" ) -' +} -test_expect_success '7d-check: transitive rename involved in rename/delete; how is it reported?' ' +test_expect_success '7d: transitive rename involved in rename/delete; how is it reported?' ' + test_setup_7d && ( cd 7d && @@ -1851,7 +1875,7 @@ test_expect_success '7d-check: transitive rename involved in rename/delete; how # see testcases 9c and 9d for further discussion of this issue and # how it's resolved. -test_expect_success '7e-setup: transitive rename in rename/delete AND dirs in the way' ' +test_setup_7e () { test_create_repo 7e && ( cd 7e && @@ -1886,9 +1910,10 @@ test_expect_success '7e-setup: transitive rename in rename/delete AND dirs in th test_tick && git commit -m "B" ) -' +} -test_expect_success '7e-check: transitive rename in rename/delete AND dirs in the way' ' +test_expect_success '7e: transitive rename in rename/delete AND dirs in the way' ' + test_setup_7e && ( cd 7e && @@ -1945,7 +1970,7 @@ test_expect_success '7e-check: transitive rename in rename/delete AND dirs in th # simple rule from section 5 prevents me from handling this as optimally as # we potentially could. -test_expect_success '8a-setup: Dual-directory rename, one into the others way' ' +test_setup_8a () { test_create_repo 8a && ( cd 8a && @@ -1977,9 +2002,10 @@ test_expect_success '8a-setup: Dual-directory rename, one into the others way' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '8a-check: Dual-directory rename, one into the others way' ' +test_expect_success '8a: Dual-directory rename, one into the others way' ' + test_setup_8a && ( cd 8a && @@ -2023,7 +2049,7 @@ test_expect_success '8a-check: Dual-directory rename, one into the others way' ' # making us fall back to pre-directory-rename-detection behavior for both # e_1 and e_2. -test_expect_success '8b-setup: Dual-directory rename, one into the others way, with conflicting filenames' ' +test_setup_8b () { test_create_repo 8b && ( cd 8b && @@ -2055,9 +2081,10 @@ test_expect_success '8b-setup: Dual-directory rename, one into the others way, w test_tick && git commit -m "B" ) -' +} -test_expect_success '8b-check: Dual-directory rename, one into the others way, with conflicting filenames' ' +test_expect_success '8b: Dual-directory rename, one into the others way, with conflicting filenames' ' + test_setup_8b && ( cd 8b && @@ -2089,14 +2116,14 @@ test_expect_success '8b-check: Dual-directory rename, one into the others way, w # # Note: It could easily be argued that the correct resolution here is # y/{b,c,e}, CONFLICT(rename/delete: z/d -> y/d vs deleted) -# and that the modifed version of d should be present in y/ after +# and that the modified version of d should be present in y/ after # the merge, just marked as conflicted. Indeed, I previously did # argue that. But applying directory renames to the side of # history where a file is merely modified results in spurious # rename/rename(1to2) conflicts -- see testcase 9h. See also # notes in 8d. -test_expect_success '8c-setup: modify/delete or rename+modify/delete?' ' +test_setup_8c () { test_create_repo 8c && ( cd 8c && @@ -2127,9 +2154,10 @@ test_expect_success '8c-setup: modify/delete or rename+modify/delete?' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '8c-check: modify/delete or rename+modify/delete' ' +test_expect_success '8c: modify/delete or rename+modify/delete' ' + test_setup_8c && ( cd 8c && @@ -2175,7 +2203,7 @@ test_expect_success '8c-check: modify/delete or rename+modify/delete' ' # during merging are supposed to be about opposite sides doing things # differently. -test_expect_success '8d-setup: rename/delete...or not?' ' +test_setup_8d () { test_create_repo 8d && ( cd 8d && @@ -2204,9 +2232,10 @@ test_expect_success '8d-setup: rename/delete...or not?' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '8d-check: rename/delete...or not?' ' +test_expect_success '8d: rename/delete...or not?' ' + test_setup_8d && ( cd 8d && @@ -2250,7 +2279,7 @@ test_expect_success '8d-check: rename/delete...or not?' ' # about the ramifications of doing that, I didn't know how to rule out # that opening other weird edge and corner cases so I just punted. -test_expect_success '8e-setup: Both sides rename, one side adds to original directory' ' +test_setup_8e () { test_create_repo 8e && ( cd 8e && @@ -2279,9 +2308,10 @@ test_expect_success '8e-setup: Both sides rename, one side adds to original dire test_tick && git commit -m "B" ) -' +} -test_expect_success '8e-check: Both sides rename, one side adds to original directory' ' +test_expect_success '8e: Both sides rename, one side adds to original directory' ' + test_setup_8e && ( cd 8e && @@ -2333,7 +2363,7 @@ test_expect_success '8e-check: Both sides rename, one side adds to original dire # of which one had the most paths going to it. A naive implementation # of that could take the new file in commit B at z/i to x/w/i or x/i. -test_expect_success '9a-setup: Inner renamed directory within outer renamed directory' ' +test_setup_9a () { test_create_repo 9a && ( cd 9a && @@ -2366,9 +2396,10 @@ test_expect_success '9a-setup: Inner renamed directory within outer renamed dire test_tick && git commit -m "B" ) -' +} -test_expect_success '9a-check: Inner renamed directory within outer renamed directory' ' +test_expect_success '9a: Inner renamed directory within outer renamed directory' ' + test_setup_9a && ( cd 9a && @@ -2404,7 +2435,7 @@ test_expect_success '9a-check: Inner renamed directory within outer renamed dire # Commit B: z/{b,c,d_3} # Expected: y/{b,c,d_merged} -test_expect_success '9b-setup: Transitive rename with content merge' ' +test_setup_9b () { test_create_repo 9b && ( cd 9b && @@ -2436,9 +2467,10 @@ test_expect_success '9b-setup: Transitive rename with content merge' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '9b-check: Transitive rename with content merge' ' +test_expect_success '9b: Transitive rename with content merge' ' + test_setup_9b && ( cd 9b && @@ -2491,7 +2523,7 @@ test_expect_success '9b-check: Transitive rename with content merge' ' # away, then ignore that particular rename from the other side of # history for any implicit directory renames. -test_expect_success '9c-setup: Doubly transitive rename?' ' +test_setup_9c () { test_create_repo 9c && ( cd 9c && @@ -2526,9 +2558,10 @@ test_expect_success '9c-setup: Doubly transitive rename?' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '9c-check: Doubly transitive rename?' ' +test_expect_success '9c: Doubly transitive rename?' ' + test_setup_9c && ( cd 9c && @@ -2579,7 +2612,7 @@ test_expect_success '9c-check: Doubly transitive rename?' ' # simple rules that are consistent with what we need for all the other # testcases and simplifies things for the user. -test_expect_success '9d-setup: N-way transitive rename?' ' +test_setup_9d () { test_create_repo 9d && ( cd 9d && @@ -2614,9 +2647,10 @@ test_expect_success '9d-setup: N-way transitive rename?' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '9d-check: N-way transitive rename?' ' +test_expect_success '9d: N-way transitive rename?' ' + test_setup_9d && ( cd 9d && @@ -2653,7 +2687,7 @@ test_expect_success '9d-check: N-way transitive rename?' ' # Expected: combined/{a,b,c,d,e,f,g,h,i,j,k,l}, CONFLICT(Nto1) warnings, # dir1/yo, dir2/yo, dir3/yo, dirN/yo -test_expect_success '9e-setup: N-to-1 whammo' ' +test_setup_9e () { test_create_repo 9e && ( cd 9e && @@ -2696,9 +2730,10 @@ test_expect_success '9e-setup: N-to-1 whammo' ' test_tick && git commit -m "B" ) -' +} -test_expect_success C_LOCALE_OUTPUT '9e-check: N-to-1 whammo' ' +test_expect_success C_LOCALE_OUTPUT '9e: N-to-1 whammo' ' + test_setup_9e && ( cd 9e && @@ -2745,7 +2780,7 @@ test_expect_success C_LOCALE_OUTPUT '9e-check: N-to-1 whammo' ' # Commit B: goal/{a,b}/$more_files, goal/c # Expected: priority/{a,b}/$more_files, priority/c -test_expect_success '9f-setup: Renamed directory that only contained immediate subdirs' ' +test_setup_9f () { test_create_repo 9f && ( cd 9f && @@ -2774,9 +2809,10 @@ test_expect_success '9f-setup: Renamed directory that only contained immediate s test_tick && git commit -m "B" ) -' +} -test_expect_success '9f-check: Renamed directory that only contained immediate subdirs' ' +test_expect_success '9f: Renamed directory that only contained immediate subdirs' ' + test_setup_9f && ( cd 9f && @@ -2809,7 +2845,7 @@ test_expect_success '9f-check: Renamed directory that only contained immediate s # Commit B: goal/{a,b}/$more_files, goal/c # Expected: priority/{alpha,bravo}/$more_files, priority/c -test_expect_success '9g-setup: Renamed directory that only contained immediate subdirs, immediate subdirs renamed' ' +test_setup_9g () { test_create_repo 9g && ( cd 9g && @@ -2841,9 +2877,9 @@ test_expect_success '9g-setup: Renamed directory that only contained immediate s test_tick && git commit -m "B" ) -' +} -test_expect_failure '9g-check: Renamed directory that only contained immediate subdirs, immediate subdirs renamed' ' +test_expect_failure '9g: Renamed directory that only contained immediate subdirs, immediate subdirs renamed' ' ( cd 9g && @@ -2877,7 +2913,7 @@ test_expect_failure '9g-check: Renamed directory that only contained immediate s # Expected: y/{b,c}, x/d_2 # NOTE: If we applied the z/ -> y/ rename to z/d, then we'd end up with # a rename/rename(1to2) conflict (z/d -> y/d vs. x/d) -test_expect_success '9h-setup: Avoid dir rename on merely modified path' ' +test_setup_9h () { test_create_repo 9h && ( cd 9h && @@ -2910,9 +2946,10 @@ test_expect_success '9h-setup: Avoid dir rename on merely modified path' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '9h-check: Avoid dir rename on merely modified path' ' +test_expect_success '9h: Avoid dir rename on merely modified path' ' + test_setup_9h && ( cd 9h && @@ -2957,7 +2994,7 @@ test_expect_success '9h-check: Avoid dir rename on merely modified path' ' # Expected: Aborted Merge + # ERROR_MSG(untracked working tree files would be overwritten by merge) -test_expect_success '10a-setup: Overwrite untracked with normal rename/delete' ' +test_setup_10a () { test_create_repo 10a && ( cd 10a && @@ -2983,9 +3020,10 @@ test_expect_success '10a-setup: Overwrite untracked with normal rename/delete' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '10a-check: Overwrite untracked with normal rename/delete' ' +test_expect_success '10a: Overwrite untracked with normal rename/delete' ' + test_setup_10a && ( cd 10a && @@ -3021,7 +3059,7 @@ test_expect_success '10a-check: Overwrite untracked with normal rename/delete' ' # z/c_1 -> z/d_1 rename recorded at stage 3 for y/d + # ERROR_MSG(refusing to lose untracked file at 'y/d') -test_expect_success '10b-setup: Overwrite untracked with dir rename + delete' ' +test_setup_10b () { test_create_repo 10b && ( cd 10b && @@ -3050,9 +3088,10 @@ test_expect_success '10b-setup: Overwrite untracked with dir rename + delete' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '10b-check: Overwrite untracked with dir rename + delete' ' +test_expect_success '10b: Overwrite untracked with dir rename + delete' ' + test_setup_10b && ( cd 10b && @@ -3098,10 +3137,10 @@ test_expect_success '10b-check: Overwrite untracked with dir rename + delete' ' # y/c~B^0 + # ERROR_MSG(Refusing to lose untracked file at y/c) -test_expect_success '10c-setup: Overwrite untracked with dir rename/rename(1to2)' ' - test_create_repo 10c && +test_setup_10c () { + test_create_repo 10c_$1 && ( - cd 10c && + cd 10c_$1 && mkdir z x && echo a >z/a && @@ -3128,11 +3167,12 @@ test_expect_success '10c-setup: Overwrite untracked with dir rename/rename(1to2) test_tick && git commit -m "B" ) -' +} -test_expect_success '10c-check: Overwrite untracked with dir rename/rename(1to2)' ' +test_expect_success '10c1: Overwrite untracked with dir rename/rename(1to2)' ' + test_setup_10c 1 && ( - cd 10c && + cd 10c_1 && git checkout A^0 && echo important >y/c && @@ -3163,9 +3203,10 @@ test_expect_success '10c-check: Overwrite untracked with dir rename/rename(1to2) ) ' -test_expect_success '10c-check: Overwrite untracked with dir rename/rename(1to2), other direction' ' +test_expect_success '10c2: Overwrite untracked with dir rename/rename(1to2), other direction' ' + test_setup_10c 2 && ( - cd 10c && + cd 10c_2 && git reset --hard && git clean -fdqx && @@ -3208,7 +3249,7 @@ test_expect_success '10c-check: Overwrite untracked with dir rename/rename(1to2) # CONFLICT(rename/rename) z/c_1 vs x/f_2 -> y/wham # ERROR_MSG(Refusing to lose untracked file at y/wham) -test_expect_success '10d-setup: Delete untracked with dir rename/rename(2to1)' ' +test_setup_10d () { test_create_repo 10d && ( cd 10d && @@ -3240,9 +3281,10 @@ test_expect_success '10d-setup: Delete untracked with dir rename/rename(2to1)' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '10d-check: Delete untracked with dir rename/rename(2to1)' ' +test_expect_success '10d: Delete untracked with dir rename/rename(2to1)' ' + test_setup_10d && ( cd 10d && @@ -3290,7 +3332,7 @@ test_expect_success '10d-check: Delete untracked with dir rename/rename(2to1)' ' # Commit B: z/{a,b,c} # Expected: y/{a,b,c} + untracked z/c -test_expect_success '10e-setup: Does git complain about untracked file that is not really in the way?' ' +test_setup_10e () { test_create_repo 10e && ( cd 10e && @@ -3317,9 +3359,9 @@ test_expect_success '10e-setup: Does git complain about untracked file that is n test_tick && git commit -m "B" ) -' +} -test_expect_failure '10e-check: Does git complain about untracked file that is not really in the way?' ' +test_expect_failure '10e: Does git complain about untracked file that is not really in the way?' ' ( cd 10e && @@ -3371,7 +3413,7 @@ test_expect_failure '10e-check: Does git complain about untracked file that is n # z/c~HEAD with contents of B:z/b_v2, # z/c with uncommitted mods on top of A:z/c_v1 -test_expect_success '11a-setup: Avoid losing dirty contents with simple rename' ' +test_setup_11a () { test_create_repo 11a && ( cd 11a && @@ -3398,9 +3440,10 @@ test_expect_success '11a-setup: Avoid losing dirty contents with simple rename' test_tick && git commit -m "B" ) -' +} -test_expect_success '11a-check: Avoid losing dirty contents with simple rename' ' +test_expect_success '11a: Avoid losing dirty contents with simple rename' ' + test_setup_11a && ( cd 11a && @@ -3441,7 +3484,7 @@ test_expect_success '11a-check: Avoid losing dirty contents with simple rename' # ERROR_MSG(Refusing to lose dirty file at z/c) -test_expect_success '11b-setup: Avoid losing dirty file involved in directory rename' ' +test_setup_11b () { test_create_repo 11b && ( cd 11b && @@ -3470,9 +3513,10 @@ test_expect_success '11b-setup: Avoid losing dirty file involved in directory re test_tick && git commit -m "B" ) -' +} -test_expect_success '11b-check: Avoid losing dirty file involved in directory rename' ' +test_expect_success '11b: Avoid losing dirty file involved in directory rename' ' + test_setup_11b && ( cd 11b && @@ -3515,7 +3559,7 @@ test_expect_success '11b-check: Avoid losing dirty file involved in directory re # Expected: Abort_msg("following files would be overwritten by merge") + # y/c left untouched (still has uncommitted mods) -test_expect_success '11c-setup: Avoid losing not-uptodate with rename + D/F conflict' ' +test_setup_11c () { test_create_repo 11c && ( cd 11c && @@ -3545,9 +3589,10 @@ test_expect_success '11c-setup: Avoid losing not-uptodate with rename + D/F conf test_tick && git commit -m "B" ) -' +} -test_expect_success '11c-check: Avoid losing not-uptodate with rename + D/F conflict' ' +test_expect_success '11c: Avoid losing not-uptodate with rename + D/F conflict' ' + test_setup_11c && ( cd 11c && @@ -3581,7 +3626,7 @@ test_expect_success '11c-check: Avoid losing not-uptodate with rename + D/F conf # Warning_Msg("Refusing to lose dirty file at z/c) + # y/{a,c~HEAD,c/d}, x/b, now-untracked z/c_v1 with uncommitted mods -test_expect_success '11d-setup: Avoid losing not-uptodate with rename + D/F conflict' ' +test_setup_11d () { test_create_repo 11d && ( cd 11d && @@ -3612,9 +3657,10 @@ test_expect_success '11d-setup: Avoid losing not-uptodate with rename + D/F conf test_tick && git commit -m "B" ) -' +} -test_expect_success '11d-check: Avoid losing not-uptodate with rename + D/F conflict' ' +test_expect_success '11d: Avoid losing not-uptodate with rename + D/F conflict' ' + test_setup_11d && ( cd 11d && @@ -3659,7 +3705,7 @@ test_expect_success '11d-check: Avoid losing not-uptodate with rename + D/F conf # y/c~HEAD has A:y/c_2 contents # y/c has dirty file from before merge -test_expect_success '11e-setup: Avoid deleting not-uptodate with dir rename/rename(1to2)/add' ' +test_setup_11e () { test_create_repo 11e && ( cd 11e && @@ -3691,9 +3737,10 @@ test_expect_success '11e-setup: Avoid deleting not-uptodate with dir rename/rena test_tick && git commit -m "B" ) -' +} -test_expect_success '11e-check: Avoid deleting not-uptodate with dir rename/rename(1to2)/add' ' +test_expect_success '11e: Avoid deleting not-uptodate with dir rename/rename(1to2)/add' ' + test_setup_11e && ( cd 11e && @@ -3744,7 +3791,7 @@ test_expect_success '11e-check: Avoid deleting not-uptodate with dir rename/rena # CONFLICT(rename/rename) x/c vs x/d -> y/wham # ERROR_MSG(Refusing to lose dirty file at y/wham) -test_expect_success '11f-setup: Avoid deleting not-uptodate with dir rename/rename(2to1)' ' +test_setup_11f () { test_create_repo 11f && ( cd 11f && @@ -3773,9 +3820,10 @@ test_expect_success '11f-setup: Avoid deleting not-uptodate with dir rename/rena test_tick && git commit -m "B" ) -' +} -test_expect_success '11f-check: Avoid deleting not-uptodate with dir rename/rename(2to1)' ' +test_expect_success '11f: Avoid deleting not-uptodate with dir rename/rename(2to1)' ' + test_setup_11f && ( cd 11f && @@ -3832,7 +3880,7 @@ test_expect_success '11f-check: Avoid deleting not-uptodate with dir rename/rena # Commit B: node1/{leaf1,leaf2,leaf5}, node2/{leaf3,leaf4,leaf6} # Expected: node1/{leaf1,leaf2,leaf5,node2/{leaf3,leaf4,leaf6}} -test_expect_success '12a-setup: Moving one directory hierarchy into another' ' +test_setup_12a () { test_create_repo 12a && ( cd 12a && @@ -3862,9 +3910,10 @@ test_expect_success '12a-setup: Moving one directory hierarchy into another' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '12a-check: Moving one directory hierarchy into another' ' +test_expect_success '12a: Moving one directory hierarchy into another' ' + test_setup_12a && ( cd 12a && @@ -3910,7 +3959,7 @@ test_expect_success '12a-check: Moving one directory hierarchy into another' ' # To which, I can do no more than shrug my shoulders and say that # even simple rules give weird results when given weird inputs. -test_expect_success '12b-setup: Moving two directory hierarchies into each other' ' +test_setup_12b () { test_create_repo 12b && ( cd 12b && @@ -3938,9 +3987,10 @@ test_expect_success '12b-setup: Moving two directory hierarchies into each other test_tick && git commit -m "B" ) -' +} -test_expect_success '12b-check: Moving two directory hierarchies into each other' ' +test_expect_success '12b: Moving two directory hierarchies into each other' ' + test_setup_12b && ( cd 12b && @@ -3976,7 +4026,7 @@ test_expect_success '12b-check: Moving two directory hierarchies into each other # NOTE: This is *exactly* like 12c, except that every path is modified on # each side of the merge. -test_expect_success '12c-setup: Moving one directory hierarchy into another w/ content merge' ' +test_setup_12c () { test_create_repo 12c && ( cd 12c && @@ -4008,9 +4058,10 @@ test_expect_success '12c-setup: Moving one directory hierarchy into another w/ c test_tick && git commit -m "B" ) -' +} -test_expect_success '12c-check: Moving one directory hierarchy into another w/ content merge' ' +test_expect_success '12c: Moving one directory hierarchy into another w/ content merge' ' + test_setup_12c && ( cd 12c && @@ -4051,6 +4102,122 @@ test_expect_success '12c-check: Moving one directory hierarchy into another w/ c ) ' +# Testcase 12d, Rename/merge of subdirectory into the root +# Commit O: a/b/subdir/foo +# Commit A: subdir/foo +# Commit B: a/b/subdir/foo, a/b/bar +# Expected: subdir/foo, bar + +test_setup_12d () { + test_create_repo 12d && + ( + cd 12d && + + mkdir -p a/b/subdir && + test_commit a/b/subdir/foo && + + git branch O && + git branch A && + git branch B && + + git checkout A && + mkdir subdir && + git mv a/b/subdir/foo.t subdir/foo.t && + test_tick && + git commit -m "A" && + + git checkout B && + test_commit a/b/bar + ) +} + +test_expect_success '12d: Rename/merge subdir into the root, variant 1' ' + test_setup_12d && + ( + cd 12d && + + git checkout A^0 && + + git -c merge.directoryRenames=true merge -s recursive B^0 && + + git ls-files -s >out && + test_line_count = 2 out && + + git rev-parse >actual \ + HEAD:subdir/foo.t HEAD:bar.t && + git rev-parse >expect \ + O:a/b/subdir/foo.t B:a/b/bar.t && + test_cmp expect actual && + + git hash-object bar.t >actual && + git rev-parse B:a/b/bar.t >expect && + test_cmp expect actual && + + test_must_fail git rev-parse HEAD:a/b/subdir/foo.t && + test_must_fail git rev-parse HEAD:a/b/bar.t && + test_path_is_missing a/ && + test_path_is_file bar.t + ) +' + +# Testcase 12e, Rename/merge of subdirectory into the root +# Commit O: a/b/foo +# Commit A: foo +# Commit B: a/b/foo, a/b/bar +# Expected: foo, bar + +test_setup_12e () { + test_create_repo 12e && + ( + cd 12e && + + mkdir -p a/b && + test_commit a/b/foo && + + git branch O && + git branch A && + git branch B && + + git checkout A && + mkdir subdir && + git mv a/b/foo.t foo.t && + test_tick && + git commit -m "A" && + + git checkout B && + test_commit a/b/bar + ) +} + +test_expect_success '12e: Rename/merge subdir into the root, variant 2' ' + test_setup_12e && + ( + cd 12e && + + git checkout A^0 && + + git -c merge.directoryRenames=true merge -s recursive B^0 && + + git ls-files -s >out && + test_line_count = 2 out && + + git rev-parse >actual \ + HEAD:foo.t HEAD:bar.t && + git rev-parse >expect \ + O:a/b/foo.t B:a/b/bar.t && + test_cmp expect actual && + + git hash-object bar.t >actual && + git rev-parse B:a/b/bar.t >expect && + test_cmp expect actual && + + test_must_fail git rev-parse HEAD:a/b/foo.t && + test_must_fail git rev-parse HEAD:a/b/bar.t && + test_path_is_missing a/ && + test_path_is_file bar.t + ) +' + ########################################################################### # SECTION 13: Checking informational and conflict messages # @@ -4068,10 +4235,10 @@ test_expect_success '12c-check: Moving one directory hierarchy into another w/ c # Commit B: z/{b,c,d,e/f} # Expected: y/{b,c,d,e/f}, with notices/conflicts for both y/d and y/e/f -test_expect_success '13a-setup: messages for newly added files' ' - test_create_repo 13a && +test_setup_13a () { + test_create_repo 13a_$1 && ( - cd 13a && + cd 13a_$1 && mkdir z && echo b >z/b && @@ -4097,11 +4264,12 @@ test_expect_success '13a-setup: messages for newly added files' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '13a-check(conflict): messages for newly added files' ' +test_expect_success '13a(conflict): messages for newly added files' ' + test_setup_13a conflict && ( - cd 13a && + cd 13a_conflict && git checkout A^0 && @@ -4121,9 +4289,10 @@ test_expect_success '13a-check(conflict): messages for newly added files' ' ) ' -test_expect_success '13a-check(info): messages for newly added files' ' +test_expect_success '13a(info): messages for newly added files' ' + test_setup_13a info && ( - cd 13a && + cd 13a_info && git reset --hard && git checkout A^0 && @@ -4153,10 +4322,10 @@ test_expect_success '13a-check(info): messages for newly added files' ' # Expected: y/{b,c,d_merged}, with two conflict messages for y/d, # one about content, and one about file location -test_expect_success '13b-setup: messages for transitive rename with conflicted content' ' - test_create_repo 13b && +test_setup_13b () { + test_create_repo 13b_$1 && ( - cd 13b && + cd 13b_$1 && mkdir x && mkdir z && @@ -4185,11 +4354,12 @@ test_expect_success '13b-setup: messages for transitive rename with conflicted c test_tick && git commit -m "B" ) -' +} -test_expect_success '13b-check(conflict): messages for transitive rename with conflicted content' ' +test_expect_success '13b(conflict): messages for transitive rename with conflicted content' ' + test_setup_13b conflict && ( - cd 13b && + cd 13b_conflict && git checkout A^0 && @@ -4207,9 +4377,10 @@ test_expect_success '13b-check(conflict): messages for transitive rename with co ) ' -test_expect_success '13b-check(info): messages for transitive rename with conflicted content' ' +test_expect_success '13b(info): messages for transitive rename with conflicted content' ' + test_setup_13b info && ( - cd 13b && + cd 13b_info && git reset --hard && git checkout A^0 && @@ -4238,10 +4409,10 @@ test_expect_success '13b-check(info): messages for transitive rename with confli # d and B had full knowledge, but that's a slippery slope as # shown in testcase 13d. -test_expect_success '13c-setup: messages for rename/rename(1to1) via transitive rename' ' - test_create_repo 13c && +test_setup_13c () { + test_create_repo 13c_$1 && ( - cd 13c && + cd 13c_$1 && mkdir x && mkdir z && @@ -4269,11 +4440,12 @@ test_expect_success '13c-setup: messages for rename/rename(1to1) via transitive test_tick && git commit -m "B" ) -' +} -test_expect_success '13c-check(conflict): messages for rename/rename(1to1) via transitive rename' ' +test_expect_success '13c(conflict): messages for rename/rename(1to1) via transitive rename' ' + test_setup_13c conflict && ( - cd 13c && + cd 13c_conflict && git checkout A^0 && @@ -4290,9 +4462,10 @@ test_expect_success '13c-check(conflict): messages for rename/rename(1to1) via t ) ' -test_expect_success '13c-check(info): messages for rename/rename(1to1) via transitive rename' ' +test_expect_success '13c(info): messages for rename/rename(1to1) via transitive rename' ' + test_setup_13c info && ( - cd 13c && + cd 13c_info && git reset --hard && git checkout A^0 && @@ -4324,10 +4497,10 @@ test_expect_success '13c-check(info): messages for rename/rename(1to1) via trans # * B renames a/y to c/y, and A renames c/->d/ => a/y -> d/y # No conflict in where a/y ends up, so put it in d/y. -test_expect_success '13d-setup: messages for rename/rename(1to1) via dual transitive rename' ' - test_create_repo 13d && +test_setup_13d () { + test_create_repo 13d_$1 && ( - cd 13d && + cd 13d_$1 && mkdir a && mkdir b && @@ -4356,11 +4529,12 @@ test_expect_success '13d-setup: messages for rename/rename(1to1) via dual transi test_tick && git commit -m "B" ) -' +} -test_expect_success '13d-check(conflict): messages for rename/rename(1to1) via dual transitive rename' ' +test_expect_success '13d(conflict): messages for rename/rename(1to1) via dual transitive rename' ' + test_setup_13d conflict && ( - cd 13d && + cd 13d_conflict && git checkout A^0 && @@ -4380,9 +4554,10 @@ test_expect_success '13d-check(conflict): messages for rename/rename(1to1) via d ) ' -test_expect_success '13d-check(info): messages for rename/rename(1to1) via dual transitive rename' ' +test_expect_success '13d(info): messages for rename/rename(1to1) via dual transitive rename' ' + test_setup_13d info && ( - cd 13d && + cd 13d_info && git reset --hard && git checkout A^0 && @@ -4448,7 +4623,7 @@ test_expect_success '13d-check(info): messages for rename/rename(1to1) via dual # in the outer merge for this special kind of setup, but it at # least avoids hitting a BUG(). # -test_expect_success '13e-setup: directory rename detection in recursive case' ' +test_setup_13e () { test_create_repo 13e && ( cd 13e && @@ -4493,9 +4668,10 @@ test_expect_success '13e-setup: directory rename detection in recursive case' ' test_tick && git commit -m "D" ) -' +} -test_expect_success '13e-check: directory rename detection in recursive case' ' +test_expect_success '13e: directory rename detection in recursive case' ' + test_setup_13e && ( cd 13e && diff --git a/t/t6046-merge-skip-unneeded-updates.sh b/t/t6046-merge-skip-unneeded-updates.sh index 3a47623ed316..1ddc9e6626b8 100755 --- a/t/t6046-merge-skip-unneeded-updates.sh +++ b/t/t6046-merge-skip-unneeded-updates.sh @@ -36,10 +36,10 @@ test_description="merge cases" # Commit B: b_3 # Expected: b_2 -test_expect_success '1a-setup: Modify(A)/Modify(B), change on B subset of A' ' - test_create_repo 1a && +test_setup_1a () { + test_create_repo 1a_$1 && ( - cd 1a && + cd 1a_$1 && test_write_lines 1 2 3 4 5 6 7 8 9 10 >b && git add b && @@ -62,26 +62,24 @@ test_expect_success '1a-setup: Modify(A)/Modify(B), change on B subset of A' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '1a-check-L: Modify(A)/Modify(B), change on B subset of A' ' - test_when_finished "git -C 1a reset --hard" && - test_when_finished "git -C 1a clean -fd" && +test_expect_success '1a-L: Modify(A)/Modify(B), change on B subset of A' ' + test_setup_1a L && ( - cd 1a && + cd 1a_L && git checkout A^0 && - test-tool chmtime =31337 b && - test-tool chmtime -v +0 b >expected-mtime && + test-tool chmtime --get -3600 b >old-mtime && GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err && - test_i18ngrep "Skipped b" out && test_must_be_empty err && - test-tool chmtime -v +0 b >actual-mtime && - test_cmp expected-mtime actual-mtime && + # Make sure b was NOT updated + test-tool chmtime --get b >new-mtime && + test_cmp old-mtime new-mtime && git ls-files -s >index_files && test_line_count = 1 index_files && @@ -96,17 +94,20 @@ test_expect_success '1a-check-L: Modify(A)/Modify(B), change on B subset of A' ' ) ' -test_expect_success '1a-check-R: Modify(A)/Modify(B), change on B subset of A' ' - test_when_finished "git -C 1a reset --hard" && - test_when_finished "git -C 1a clean -fd" && +test_expect_success '1a-R: Modify(A)/Modify(B), change on B subset of A' ' + test_setup_1a R && ( - cd 1a && + cd 1a_R && git checkout B^0 && + test-tool chmtime --get -3600 b >old-mtime && GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err && - test_i18ngrep "Auto-merging b" out && + # Make sure b WAS updated + test-tool chmtime --get b >new-mtime && + test $(cat old-mtime) -lt $(cat new-mtime) && + test_must_be_empty err && git ls-files -s >index_files && @@ -133,10 +134,10 @@ test_expect_success '1a-check-R: Modify(A)/Modify(B), change on B subset of A' ' # Commit B: c_1 # Expected: c_2 -test_expect_success '2a-setup: Modify(A)/rename(B)' ' - test_create_repo 2a && +test_setup_2a () { + test_create_repo 2a_$1 && ( - cd 2a && + cd 2a_$1 && test_seq 1 10 >b && git add b && @@ -158,20 +159,19 @@ test_expect_success '2a-setup: Modify(A)/rename(B)' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '2a-check-L: Modify/rename, merge into modify side' ' - test_when_finished "git -C 2a reset --hard" && - test_when_finished "git -C 2a clean -fd" && +test_expect_success '2a-L: Modify/rename, merge into modify side' ' + test_setup_2a L && ( - cd 2a && + cd 2a_L && git checkout A^0 && + test_path_is_missing c && GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err && - test_i18ngrep ! "Skipped c" out && - test_must_be_empty err && + test_path_is_file c && git ls-files -s >index_files && test_line_count = 1 index_files && @@ -189,17 +189,20 @@ test_expect_success '2a-check-L: Modify/rename, merge into modify side' ' ) ' -test_expect_success '2a-check-R: Modify/rename, merge into rename side' ' - test_when_finished "git -C 2a reset --hard" && - test_when_finished "git -C 2a clean -fd" && +test_expect_success '2a-R: Modify/rename, merge into rename side' ' + test_setup_2a R && ( - cd 2a && + cd 2a_R && git checkout B^0 && + test-tool chmtime --get -3600 c >old-mtime && GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err && - test_i18ngrep ! "Skipped c" out && + # Make sure c WAS updated + test-tool chmtime --get c >new-mtime && + test $(cat old-mtime) -lt $(cat new-mtime) && + test_must_be_empty err && git ls-files -s >index_files && @@ -224,10 +227,10 @@ test_expect_success '2a-check-R: Modify/rename, merge into rename side' ' # Commit B: b_3 # Expected: c_2 -test_expect_success '2b-setup: Rename+Mod(A)/Mod(B), B mods subset of A' ' - test_create_repo 2b && +test_setup_2b () { + test_create_repo 2b_$1 && ( - cd 2b && + cd 2b_$1 && test_write_lines 1 2 3 4 5 6 7 8 9 10 >b && git add b && @@ -251,26 +254,23 @@ test_expect_success '2b-setup: Rename+Mod(A)/Mod(B), B mods subset of A' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '2b-check-L: Rename+Mod(A)/Mod(B), B mods subset of A' ' - test_when_finished "git -C 2b reset --hard" && - test_when_finished "git -C 2b clean -fd" && +test_expect_success '2b-L: Rename+Mod(A)/Mod(B), B mods subset of A' ' + test_setup_2b L && ( - cd 2b && + cd 2b_L && git checkout A^0 && - test-tool chmtime =31337 c && - test-tool chmtime -v +0 c >expected-mtime && - + test-tool chmtime --get -3600 c >old-mtime && GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err && - test_i18ngrep "Skipped c" out && test_must_be_empty err && - test-tool chmtime -v +0 c >actual-mtime && - test_cmp expected-mtime actual-mtime && + # Make sure c WAS updated + test-tool chmtime --get c >new-mtime && + test_cmp old-mtime new-mtime && git ls-files -s >index_files && test_line_count = 1 index_files && @@ -288,17 +288,19 @@ test_expect_success '2b-check-L: Rename+Mod(A)/Mod(B), B mods subset of A' ' ) ' -test_expect_success '2b-check-R: Rename+Mod(A)/Mod(B), B mods subset of A' ' - test_when_finished "git -C 2b reset --hard" && - test_when_finished "git -C 2b clean -fd" && +test_expect_success '2b-R: Rename+Mod(A)/Mod(B), B mods subset of A' ' + test_setup_2b R && ( - cd 2b && + cd 2b_R && git checkout B^0 && + test_path_is_missing c && GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err && - test_i18ngrep "Auto-merging c" out && + # Make sure c now present (and thus was updated) + test_path_is_file c && + test_must_be_empty err && git ls-files -s >index_files && @@ -332,7 +334,7 @@ test_expect_success '2b-check-R: Rename+Mod(A)/Mod(B), B mods subset of A' ' # skip the update, then we're in trouble. This test verifies we do # not make that particular mistake. -test_expect_success '2c-setup: Modify b & add c VS rename b->c' ' +test_setup_2c () { test_create_repo 2c && ( cd 2c && @@ -358,21 +360,26 @@ test_expect_success '2c-setup: Modify b & add c VS rename b->c' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '2c-check: Modify b & add c VS rename b->c' ' +test_expect_success '2c: Modify b & add c VS rename b->c' ' + test_setup_2c && ( cd 2c && git checkout A^0 && + test-tool chmtime --get -3600 c >old-mtime && GIT_MERGE_VERBOSITY=3 && export GIT_MERGE_VERBOSITY && test_must_fail git merge -s recursive B^0 >out 2>err && test_i18ngrep "CONFLICT (rename/add): Rename b->c" out && - test_i18ngrep ! "Skipped c" out && - test_must_be_empty err + test_must_be_empty err && + + # Make sure c WAS updated + test-tool chmtime --get c >new-mtime && + test $(cat old-mtime) -lt $(cat new-mtime) # FIXME: rename/add conflicts are horribly broken right now; # when I get back to my patch series fixing it and @@ -428,10 +435,10 @@ test_expect_success '2c-check: Modify b & add c VS rename b->c' ' # Commit B: bq_1, bar/whatever # Expected: bar/{bq_2, whatever} -test_expect_success '3a-setup: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' - test_create_repo 3a && +test_setup_3a () { + test_create_repo 3a_$1 && ( - cd 3a && + cd 3a_$1 && mkdir foo && test_seq 1 10 >bq && @@ -456,21 +463,22 @@ test_expect_success '3a-setup: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '3a-check-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' - test_when_finished "git -C 3a reset --hard" && - test_when_finished "git -C 3a clean -fd" && +test_expect_success '3a-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' + test_setup_3a L && ( - cd 3a && + cd 3a_L && git checkout A^0 && + test_path_is_missing bar/bq && GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && - test_i18ngrep ! "Skipped bar/bq" out && test_must_be_empty err && + test_path_is_file bar/bq && + git ls-files -s >index_files && test_line_count = 2 index_files && @@ -487,19 +495,20 @@ test_expect_success '3a-check-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' ) ' -test_expect_success '3a-check-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' - test_when_finished "git -C 3a reset --hard" && - test_when_finished "git -C 3a clean -fd" && +test_expect_success '3a-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' + test_setup_3a R && ( - cd 3a && + cd 3a_R && git checkout B^0 && + test_path_is_missing bar/bq && GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err && - test_i18ngrep ! "Skipped bar/bq" out && test_must_be_empty err && + test_path_is_file bar/bq && + git ls-files -s >index_files && test_line_count = 2 index_files && @@ -522,10 +531,10 @@ test_expect_success '3a-check-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' # Commit B: bq_2, bar/whatever # Expected: bar/{bq_2, whatever} -test_expect_success '3b-setup: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' - test_create_repo 3b && +test_setup_3b () { + test_create_repo 3b_$1 && ( - cd 3b && + cd 3b_$1 && mkdir foo && test_seq 1 10 >bq && @@ -550,21 +559,22 @@ test_expect_success '3b-setup: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' test_tick && git commit -m "B" ) -' +} -test_expect_success '3b-check-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' - test_when_finished "git -C 3b reset --hard" && - test_when_finished "git -C 3b clean -fd" && +test_expect_success '3b-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' + test_setup_3b L && ( - cd 3b && + cd 3b_L && git checkout A^0 && + test_path_is_missing bar/bq && GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err && - test_i18ngrep ! "Skipped bar/bq" out && test_must_be_empty err && + test_path_is_file bar/bq && + git ls-files -s >index_files && test_line_count = 2 index_files && @@ -581,19 +591,20 @@ test_expect_success '3b-check-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' ) ' -test_expect_success '3b-check-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' - test_when_finished "git -C 3b reset --hard" && - test_when_finished "git -C 3b clean -fd" && +test_expect_success '3b-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' + test_setup_3b R && ( - cd 3b && + cd 3b_R && git checkout B^0 && + test_path_is_missing bar/bq && GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err && - test_i18ngrep ! "Skipped bar/bq" out && test_must_be_empty err && + test_path_is_file bar/bq && + git ls-files -s >index_files && test_line_count = 2 index_files && @@ -621,7 +632,7 @@ test_expect_success '3b-check-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' # Working copy: b_4 # Expected: b_2 for merge, b_4 in working copy -test_expect_success '4a-setup: Change on A, change on B subset of A, dirty mods present' ' +test_setup_4a () { test_create_repo 4a && ( cd 4a && @@ -647,7 +658,7 @@ test_expect_success '4a-setup: Change on A, change on B subset of A, dirty mods test_tick && git commit -m "B" ) -' +} # NOTE: For as long as we continue using unpack_trees() without index_only # set to true, it will error out on a case like this claiming the the locally @@ -655,25 +666,23 @@ test_expect_success '4a-setup: Change on A, change on B subset of A, dirty mods # correct requires doing the merge in-memory first, then realizing that no # updates to the file are necessary, and thus that we can just leave the path # alone. -test_expect_failure '4a-check: Change on A, change on B subset of A, dirty mods present' ' - test_when_finished "git -C 4a reset --hard" && - test_when_finished "git -C 4a clean -fd" && +test_expect_failure '4a: Change on A, change on B subset of A, dirty mods present' ' + test_setup_4a && ( cd 4a && git checkout A^0 && echo "File rewritten" >b && - test-tool chmtime =31337 b && - test-tool chmtime -v +0 b >expected-mtime && + test-tool chmtime --get -3600 b >old-mtime && GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err && - test_i18ngrep "Skipped b" out && test_must_be_empty err && - test-tool chmtime -v +0 b >actual-mtime && - test_cmp expected-mtime actual-mtime && + # Make sure b was NOT updated + test-tool chmtime --get b >new-mtime && + test_cmp old-mtime new-mtime && git ls-files -s >index_files && test_line_count = 1 index_files && @@ -695,7 +704,7 @@ test_expect_failure '4a-check: Change on A, change on B subset of A, dirty mods # Working copy: c_4 # Expected: c_2 -test_expect_success '4b-setup: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mods present' ' +test_setup_4b () { test_create_repo 4b && ( cd 4b && @@ -722,27 +731,25 @@ test_expect_success '4b-setup: Rename+Mod(A)/Mod(B), change on B subset of A, di test_tick && git commit -m "B" ) -' +} -test_expect_success '4b-check: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mods present' ' - test_when_finished "git -C 4b reset --hard" && - test_when_finished "git -C 4b clean -fd" && +test_expect_success '4b: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mods present' ' + test_setup_4b && ( cd 4b && git checkout A^0 && echo "File rewritten" >c && - test-tool chmtime =31337 c && - test-tool chmtime -v +0 c >expected-mtime && + test-tool chmtime --get -3600 c >old-mtime && GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err && - test_i18ngrep "Skipped c" out && test_must_be_empty err && - test-tool chmtime -v +0 c >actual-mtime && - test_cmp expected-mtime actual-mtime && + # Make sure c was NOT updated + test-tool chmtime --get c >new-mtime && + test_cmp old-mtime new-mtime && git ls-files -s >index_files && test_line_count = 1 index_files && diff --git a/t/t6047-diff3-conflict-markers.sh b/t/t6047-diff3-conflict-markers.sh new file mode 100755 index 000000000000..f4655bb358ff --- /dev/null +++ b/t/t6047-diff3-conflict-markers.sh @@ -0,0 +1,211 @@ +#!/bin/sh + +test_description='recursive merge diff3 style conflict markers' + +. ./test-lib.sh + +# Setup: +# L1 +# \ +# ? +# / +# R1 +# +# Where: +# L1 and R1 both have a file named 'content' but have no common history +# + +test_expect_success 'setup no merge base' ' + test_create_repo no_merge_base && + ( + cd no_merge_base && + + git checkout -b L && + test_commit A content A && + + git checkout --orphan R && + test_commit B content B + ) +' + +test_expect_success 'check no merge base' ' + ( + cd no_merge_base && + + git checkout L^0 && + + test_must_fail git -c merge.conflictstyle=diff3 merge --allow-unrelated-histories -s recursive R^0 && + + grep "|||||| empty tree" content + ) +' + +# Setup: +# L1 +# / \ +# master ? +# \ / +# R1 +# +# Where: +# L1 and R1 have modified the same file ('content') in conflicting ways +# + +test_expect_success 'setup unique merge base' ' + test_create_repo unique_merge_base && + ( + cd unique_merge_base && + + test_commit base content "1 +2 +3 +4 +5 +" && + + git branch L && + git branch R && + + git checkout L && + test_commit L content "1 +2 +3 +4 +5 +7" && + + git checkout R && + git rm content && + test_commit R renamed "1 +2 +3 +4 +5 +six" + ) +' + +test_expect_success 'check unique merge base' ' + ( + cd unique_merge_base && + + git checkout L^0 && + MASTER=$(git rev-parse --short master) && + + test_must_fail git -c merge.conflictstyle=diff3 merge -s recursive R^0 && + + grep "|||||| $MASTER:content" renamed + ) +' + +# Setup: +# L1---L2--L3 +# / \ / \ +# master X1 ? +# \ / \ / +# R1---R2--R3 +# +# Where: +# commits L1 and R1 have modified the same file in non-conflicting ways +# X1 is an auto-generated merge-base used when merging L1 and R1 +# commits L2 and R2 are merges of R1 and L1 into L1 and R1, respectively +# commits L3 and R3 both modify 'content' in conflicting ways +# + +test_expect_success 'setup multiple merge bases' ' + test_create_repo multiple_merge_bases && + ( + cd multiple_merge_bases && + + test_commit initial content "1 +2 +3 +4 +5" && + + git branch L && + git branch R && + + # Create L1 + git checkout L && + test_commit L1 content "0 +1 +2 +3 +4 +5" && + + # Create R1 + git checkout R && + test_commit R1 content "1 +2 +3 +4 +5 +6" && + + # Create L2 + git checkout L && + git merge R1 && + + # Create R2 + git checkout R && + git merge L1 && + + # Create L3 + git checkout L && + test_commit L3 content "0 +1 +2 +3 +4 +5 +A" && + + # Create R3 + git checkout R && + git rm content && + test_commit R3 renamed "0 +2 +3 +4 +5 +six" + ) +' + +test_expect_success 'check multiple merge bases' ' + ( + cd multiple_merge_bases && + + git checkout L^0 && + + test_must_fail git -c merge.conflictstyle=diff3 merge -s recursive R^0 && + + grep "|||||| merged common ancestors:content" renamed + ) +' + +test_expect_success 'rebase --merge describes parent of commit being picked' ' + test_create_repo rebase && + ( + cd rebase && + test_commit base file && + test_commit master file && + git checkout -b side HEAD^ && + test_commit side file && + test_must_fail git -c merge.conflictstyle=diff3 rebase --merge master && + grep "||||||| parent of" file + ) +' + +test_expect_success 'rebase --apply describes fake ancestor base' ' + ( + cd rebase && + git rebase --abort && + test_must_fail git -c merge.conflictstyle=diff3 rebase --apply master && + grep "||||||| constructed merge base" file + ) +' + +test_done diff --git a/t/t6102-rev-list-unexpected-objects.sh b/t/t6102-rev-list-unexpected-objects.sh index 28611c978e6c..52cde097dd5c 100755 --- a/t/t6102-rev-list-unexpected-objects.sh +++ b/t/t6102-rev-list-unexpected-objects.sh @@ -52,7 +52,7 @@ test_expect_success 'traverse unexpected non-commit parent (lone)' ' ' test_expect_success 'traverse unexpected non-commit parent (seen)' ' - test_must_fail git rev-list --objects $commit $broken_commit \ + test_must_fail git rev-list --objects $blob $broken_commit \ >output 2>&1 && test_i18ngrep "not a commit" output ' diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh index acd7f5ab80d9..de0e5a5d3646 100755 --- a/t/t6112-rev-list-filters-objects.sh +++ b/t/t6112-rev-list-filters-objects.sh @@ -278,7 +278,19 @@ test_expect_success 'verify skipping tree iteration when not collecting omits' ' test_line_count = 2 actual && # Make sure no other trees were considered besides the root. - ! grep "Skipping contents of tree [^.]" filter_trace + ! grep "Skipping contents of tree [^.]" filter_trace && + + # Try this again with "combine:". If both sub-filters are skipping + # trees, the composite filter should also skip trees. This is not + # important unless the user does combine:tree:X+tree:Y or another filter + # besides "tree:" is implemented in the future which can skip trees. + GIT_TRACE=1 git -C r3 rev-list \ + --objects --filter=combine:tree:1+tree:3 HEAD 2>filter_trace && + + # Only skip the dir1/ tree, which is shared between the two commits. + grep "Skipping contents of tree " filter_trace >actual && + test_write_lines "Skipping contents of tree dir1/..." >expected && + test_cmp expected actual ' # Test tree:# filters. @@ -330,6 +342,148 @@ test_expect_success 'verify tree:3 includes everything expected' ' test_line_count = 10 actual ' +test_expect_success 'combine:... for a simple combination' ' + git -C r3 rev-list --objects --filter=combine:tree:2+blob:none HEAD \ + >actual && + + expect_has HEAD "" && + expect_has HEAD~1 "" && + expect_has HEAD dir1 && + + # There are also 2 commit objects + test_line_count = 5 actual && + + cp actual expected && + + # Try again using repeated --filter - this is equivalent to a manual + # combine with "combine:...+..." + git -C r3 rev-list --objects --filter=combine:tree:2 \ + --filter=blob:none HEAD >actual && + + test_cmp expected actual +' + +test_expect_success 'combine:... with URL encoding' ' + git -C r3 rev-list --objects \ + --filter=combine:tree%3a2+blob:%6Eon%65 HEAD >actual && + + expect_has HEAD "" && + expect_has HEAD~1 "" && + expect_has HEAD dir1 && + + # There are also 2 commit objects + test_line_count = 5 actual +' + +expect_invalid_filter_spec () { + spec="$1" && + err="$2" && + + test_must_fail git -C r3 rev-list --objects --filter="$spec" HEAD \ + >actual 2>actual_stderr && + test_must_be_empty actual && + test_i18ngrep "$err" actual_stderr +} + +test_expect_success 'combine:... while URL-encoding things that should not be' ' + expect_invalid_filter_spec combine%3Atree:2+blob:none \ + "invalid filter-spec" +' + +test_expect_success 'combine: with nothing after the :' ' + expect_invalid_filter_spec combine: "expected something after combine:" +' + +test_expect_success 'parse error in first sub-filter in combine:' ' + expect_invalid_filter_spec combine:tree:asdf+blob:none \ + "expected .tree:." +' + +test_expect_success 'combine:... with non-encoded reserved chars' ' + expect_invalid_filter_spec combine:tree:2+sparse:@xyz \ + "must escape char in sub-filter-spec: .@." && + expect_invalid_filter_spec combine:tree:2+sparse:\` \ + "must escape char in sub-filter-spec: .\`." && + expect_invalid_filter_spec combine:tree:2+sparse:~abc \ + "must escape char in sub-filter-spec: .\~." +' + +test_expect_success 'validate err msg for "combine:+"' ' + expect_invalid_filter_spec combine:tree:2+ "expected .tree:." +' + +test_expect_success 'combine:... with edge-case hex digits: Ff Aa 0 9' ' + git -C r3 rev-list --objects --filter="combine:tree:2+bl%6Fb:n%6fne" \ + HEAD >actual && + test_line_count = 5 actual && + git -C r3 rev-list --objects --filter="combine:tree%3A2+blob%3anone" \ + HEAD >actual && + test_line_count = 5 actual && + git -C r3 rev-list --objects --filter="combine:tree:%30" HEAD >actual && + test_line_count = 2 actual && + git -C r3 rev-list --objects --filter="combine:tree:%39+blob:none" \ + HEAD >actual && + test_line_count = 5 actual +' + +test_expect_success 'add sparse pattern blobs whose paths have reserved chars' ' + cp r3/pattern r3/pattern1+renamed% && + cp r3/pattern "r3/p;at%ter+n" && + cp r3/pattern r3/^~pattern && + git -C r3 add pattern1+renamed% "p;at%ter+n" ^~pattern && + git -C r3 commit -m "add sparse pattern files with reserved chars" +' + +test_expect_success 'combine:... with more than two sub-filters' ' + git -C r3 rev-list --objects \ + --filter=combine:tree:3+blob:limit=40+sparse:oid=master:pattern \ + HEAD >actual && + + expect_has HEAD "" && + expect_has HEAD~1 "" && + expect_has HEAD~2 "" && + expect_has HEAD dir1 && + expect_has HEAD dir1/sparse1 && + expect_has HEAD dir1/sparse2 && + + # Should also have 3 commits + test_line_count = 9 actual && + + # Try again, this time making sure the last sub-filter is only + # URL-decoded once. + cp actual expect && + + git -C r3 rev-list --objects \ + --filter=combine:tree:3+blob:limit=40+sparse:oid=master:pattern1%2brenamed%25 \ + HEAD >actual && + test_cmp expect actual && + + # Use the same composite filter again, but with a pattern file name that + # requires encoding multiple characters, and use implicit filter + # combining. + test_when_finished "rm -f trace1" && + GIT_TRACE=$(pwd)/trace1 git -C r3 rev-list --objects \ + --filter=tree:3 --filter=blob:limit=40 \ + --filter=sparse:oid="master:p;at%ter+n" \ + HEAD >actual && + + test_cmp expect actual && + grep "Add to combine filter-spec: sparse:oid=master:p%3bat%25ter%2bn" \ + trace1 && + + # Repeat the above test, but this time, the characters to encode are in + # the LHS of the combined filter. + test_when_finished "rm -f trace2" && + GIT_TRACE=$(pwd)/trace2 git -C r3 rev-list --objects \ + --filter=sparse:oid=master:^~pattern \ + --filter=tree:3 --filter=blob:limit=40 \ + HEAD >actual && + + test_cmp expect actual && + grep "Add to combine filter-spec: sparse:oid=master:%5e%7epattern" \ + trace2 +' + # Test provisional omit collection logic with a repo that has objects appearing # at multiple depths - first deeper than the filter's threshold, then shallow. @@ -373,6 +527,37 @@ test_expect_success 'verify skipping tree iteration when collecting omits' ' test_cmp expect actual ' +test_expect_success 'setup r5' ' + git init r5 && + mkdir -p r5/subdir && + + echo 1 >r5/short-root && + echo 12345 >r5/long-root && + echo a >r5/subdir/short-subdir && + echo abcde >r5/subdir/long-subdir && + + git -C r5 add short-root long-root subdir && + git -C r5 commit -m "commit msg" +' + +test_expect_success 'verify collecting omits in combined: filter' ' + # Note that this test guards against the naive implementation of simply + # giving both filters the same "omits" set and expecting it to + # automatically merge them. + git -C r5 rev-list --objects --quiet --filter-print-omitted \ + --filter=combine:tree:2+blob:limit=3 HEAD >actual && + + # Expect 0 trees/commits, 3 blobs omitted (all blobs except short-root) + omitted_1=$(echo 12345 | git hash-object --stdin) && + omitted_2=$(echo a | git hash-object --stdin) && + omitted_3=$(echo abcde | git hash-object --stdin) && + + grep ~$omitted_1 actual && + grep ~$omitted_2 actual && + grep ~$omitted_3 actual && + test_line_count = 3 actual +' + # Test tree: where a tree is iterated to twice - once where a subentry is # too deep to be included, and again where the blob inside it is shallow enough # to be included. This makes sure we don't use LOFR_MARK_SEEN incorrectly (we @@ -441,11 +626,4 @@ test_expect_success 'expand blob limit in protocol' ' grep "blob:limit=1024" trace ' -test_expect_success 'expand tree depth limit in protocol' ' - GIT_TRACE_PACKET="$(pwd)/tree_trace" git -c protocol.version=2 clone \ - --filter=tree:0k "file://$(pwd)/r2" tree && - ! grep "tree:0k" tree_trace && - grep "tree:0" tree_trace -' - test_done diff --git a/t/t6113-rev-list-bitmap-filters.sh b/t/t6113-rev-list-bitmap-filters.sh new file mode 100755 index 000000000000..145603f12457 --- /dev/null +++ b/t/t6113-rev-list-bitmap-filters.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +test_description='rev-list combining bitmaps and filters' +. ./test-lib.sh + +test_expect_success 'set up bitmapped repo' ' + # one commit will have bitmaps, the other will not + test_commit one && + test_commit much-larger-blob-one && + git repack -adb && + test_commit two && + test_commit much-larger-blob-two +' + +test_expect_success 'filters fallback to non-bitmap traversal' ' + # use a path-based filter, since they are inherently incompatible with + # bitmaps (i.e., this test will never get confused by later code to + # combine the features) + filter=$(echo "!one" | git hash-object -w --stdin) && + git rev-list --objects --filter=sparse:oid=$filter HEAD >expect && + git rev-list --use-bitmap-index \ + --objects --filter=sparse:oid=$filter HEAD >actual && + test_cmp expect actual +' + +test_expect_success 'blob:none filter' ' + git rev-list --objects --filter=blob:none HEAD >expect && + git rev-list --use-bitmap-index \ + --objects --filter=blob:none HEAD >actual && + test_bitmap_traversal expect actual +' + +test_expect_success 'blob:none filter with specified blob' ' + git rev-list --objects --filter=blob:none HEAD HEAD:two.t >expect && + git rev-list --use-bitmap-index \ + --objects --filter=blob:none HEAD HEAD:two.t >actual && + test_bitmap_traversal expect actual +' + +test_expect_success 'blob:limit filter' ' + git rev-list --objects --filter=blob:limit=5 HEAD >expect && + git rev-list --use-bitmap-index \ + --objects --filter=blob:limit=5 HEAD >actual && + test_bitmap_traversal expect actual +' + +test_expect_success 'blob:limit filter with specified blob' ' + git rev-list --objects --filter=blob:limit=5 \ + HEAD HEAD:much-larger-blob-two.t >expect && + git rev-list --use-bitmap-index \ + --objects --filter=blob:limit=5 \ + HEAD HEAD:much-larger-blob-two.t >actual && + test_bitmap_traversal expect actual +' + +test_done diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index 2b883d817403..34502e3a5054 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -1,28 +1,27 @@ #!/bin/sh -test_description='test describe +test_description='test describe' + +# o---o-----o----o----o-------o----x +# \ D,R e / +# \---o-------------o-' +# \ B / +# `-o----o----o-' +# A c +# +# First parent of a merge commit is on the same line, second parent below. - B - .--------------o----o----o----x - / / / - o----o----o----o----o----. / - \ A c / - .------------o---o---o - D,R e -' . ./test-lib.sh check_describe () { expect="$1" shift - R=$(git describe "$@" 2>err.actual) - S=$? - cat err.actual >&3 - test_expect_success "describe $*" ' - test $S = 0 && + describe_opts="$@" + test_expect_success "describe $describe_opts" ' + R=$(git describe $describe_opts 2>err.actual) && case "$R" in $expect) echo happy ;; - *) echo "Oops - $R is not $expect"; + *) echo "Oops - $R is not $expect" && false ;; esac ' @@ -382,7 +381,7 @@ test_expect_success 'describe tag object' ' test_i18ngrep "fatal: test-blob-1 is neither a commit nor blob" actual ' -test_expect_failure ULIMIT_STACK_SIZE 'name-rev works in a deep repo' ' +test_expect_success ULIMIT_STACK_SIZE 'name-rev works in a deep repo' ' i=1 && while test $i -lt 8000 do @@ -424,4 +423,111 @@ test_expect_success 'describe complains about missing object' ' test_must_fail git describe $ZERO_OID ' +test_expect_success 'name-rev a rev shortly after epoch' ' + test_when_finished "git checkout master" && + + git checkout --orphan no-timestamp-underflow && + # Any date closer to epoch than the CUTOFF_DATE_SLOP constant + # in builtin/name-rev.c. + GIT_COMMITTER_DATE="@1234 +0000" \ + git commit -m "committer date shortly after epoch" && + old_commit_oid=$(git rev-parse HEAD) && + + echo "$old_commit_oid no-timestamp-underflow" >expect && + git name-rev $old_commit_oid >actual && + test_cmp expect actual +' + +# A--------------master +# \ / +# \----------M2 +# \ / +# \---M1-C +# \ / +# B +test_expect_success 'name-rev covers all conditions while looking at parents' ' + git init repo && + ( + cd repo && + + echo A >file && + git add file && + git commit -m A && + A=$(git rev-parse HEAD) && + + git checkout --detach && + echo B >file && + git commit -m B file && + B=$(git rev-parse HEAD) && + + git checkout $A && + git merge --no-ff $B && # M1 + + echo C >file && + git commit -m C file && + + git checkout $A && + git merge --no-ff HEAD@{1} && # M2 + + git checkout master && + git merge --no-ff HEAD@{1} && + + echo "$B master^2^2~1^2" >expect && + git name-rev $B >actual && + + test_cmp expect actual + ) +' + +# B +# o +# \ +# o-----o---o----x +# A +# +test_expect_success 'describe commits with disjoint bases' ' + git init disjoint1 && + ( + cd disjoint1 && + + echo o >> file && git add file && git commit -m o && + echo A >> file && git add file && git commit -m A && + git tag A -a -m A && + echo o >> file && git add file && git commit -m o && + + git checkout --orphan branch && rm file && + echo B > file2 && git add file2 && git commit -m B && + git tag B -a -m B && + git merge --no-ff --allow-unrelated-histories master -m x && + + check_describe "A-3-*" HEAD + ) +' + +# B +# o---o---o------------. +# \ +# o---o---x +# A +# +test_expect_success 'describe commits with disjoint bases 2' ' + git init disjoint2 && + ( + cd disjoint2 && + + echo A >> file && git add file && GIT_COMMITTER_DATE="2020-01-01 18:00" git commit -m A && + git tag A -a -m A && + echo o >> file && git add file && GIT_COMMITTER_DATE="2020-01-01 18:01" git commit -m o && + + git checkout --orphan branch && + echo o >> file2 && git add file2 && GIT_COMMITTER_DATE="2020-01-01 15:00" git commit -m o && + echo o >> file2 && git add file2 && GIT_COMMITTER_DATE="2020-01-01 15:01" git commit -m o && + echo B >> file2 && git add file2 && GIT_COMMITTER_DATE="2020-01-01 15:02" git commit -m B && + git tag B -a -m B && + git merge --no-ff --allow-unrelated-histories master -m x && + + check_describe "B-3-*" HEAD + ) +' + test_done diff --git a/t/t6130-pathspec-noglob.sh b/t/t6130-pathspec-noglob.sh index 37760233a560..ba7902c9cdcd 100755 --- a/t/t6130-pathspec-noglob.sh +++ b/t/t6130-pathspec-noglob.sh @@ -10,6 +10,7 @@ test_expect_success 'create commits with glob characters' ' # the name "f*" in the worktree, because it is not allowed # on Windows (the tests below do not depend on the presence # of the file in the worktree) + git config core.protectNTFS false && git update-index --add --cacheinfo 100644 "$(git rev-parse HEAD:foo)" "f*" && test_tick && git commit -m star && diff --git a/t/t6136-pathspec-in-bare.sh b/t/t6136-pathspec-in-bare.sh new file mode 100755 index 000000000000..b117251366dd --- /dev/null +++ b/t/t6136-pathspec-in-bare.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +test_description='diagnosing out-of-scope pathspec' + +. ./test-lib.sh + +test_expect_success 'setup a bare and non-bare repository' ' + test_commit file1 && + git clone --bare . bare +' + +test_expect_success 'log and ls-files in a bare repository' ' + ( + cd bare && + test_must_fail git log -- .. >out 2>err && + test_must_be_empty out && + test_i18ngrep "outside repository" err && + + test_must_fail git ls-files -- .. >out 2>err && + test_must_be_empty out && + test_i18ngrep "outside repository" err + ) +' + +test_expect_success 'log and ls-files in .git directory' ' + ( + cd .git && + test_must_fail git log -- .. >out 2>err && + test_must_be_empty out && + test_i18ngrep "outside repository" err && + + test_must_fail git ls-files -- .. >out 2>err && + test_must_be_empty out && + test_i18ngrep "outside repository" err + ) +' + +test_done diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index ab69aa176d14..9c910ce74673 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -526,6 +526,25 @@ test_expect_success 'Check ambiguous head and tag refs II (loose)' ' test_cmp expected actual ' +test_expect_success 'create tag without tagger' ' + git tag -a -m "Broken tag" taggerless && + git tag -f taggerless $(git cat-file tag taggerless | + sed -e "/^tagger /d" | + git hash-object --stdin -w -t tag) +' + +test_atom refs/tags/taggerless type 'commit' +test_atom refs/tags/taggerless tag 'taggerless' +test_atom refs/tags/taggerless tagger '' +test_atom refs/tags/taggerless taggername '' +test_atom refs/tags/taggerless taggeremail '' +test_atom refs/tags/taggerless taggerdate '' +test_atom refs/tags/taggerless committer '' +test_atom refs/tags/taggerless committername '' +test_atom refs/tags/taggerless committeremail '' +test_atom refs/tags/taggerless committerdate '' +test_atom refs/tags/taggerless subject 'Broken tag' + test_expect_success 'an unusual tag with an incomplete line' ' git tag -m "bogo" bogo && diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index c0f04dc6b0e1..0a69a6711768 100755 --- a/t/t6500-gc.sh +++ b/t/t6500-gc.sh @@ -103,14 +103,14 @@ test_expect_success 'auto gc with too many loose objects does not attempt to cre ' test_expect_success 'gc --no-quiet' ' - git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr && + GIT_PROGRESS_DELAY=0 git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr && test_must_be_empty stdout && - test_line_count = 1 stderr && test_i18ngrep "Computing commit graph generation numbers" stderr ' test_expect_success TTY 'with TTY: gc --no-quiet' ' - test_terminal git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr && + test_terminal env GIT_PROGRESS_DELAY=0 \ + git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr && test_must_be_empty stdout && test_i18ngrep "Enumerating objects" stderr && test_i18ngrep "Computing commit graph generation numbers" stderr diff --git a/t/t6501-freshen-objects.sh b/t/t6501-freshen-objects.sh index 033871ee5f35..f30b4849b64e 100755 --- a/t/t6501-freshen-objects.sh +++ b/t/t6501-freshen-objects.sh @@ -137,7 +137,7 @@ test_expect_success 'do not complain about existing broken links (commit)' ' some message EOF commit=$(git hash-object -t commit -w broken-commit) && - git gc 2>stderr && + git gc -q 2>stderr && verbose git cat-file -e $commit && test_must_be_empty stderr ' @@ -147,7 +147,7 @@ test_expect_success 'do not complain about existing broken links (tree)' ' 100644 blob 0000000000000000000000000000000000000003 foo EOF tree=$(git mktree --missing stderr && + git gc -q 2>stderr && git cat-file -e $tree && test_must_be_empty stderr ' @@ -162,7 +162,7 @@ test_expect_success 'do not complain about existing broken links (tag)' ' this is a broken tag EOF tag=$(git hash-object -t tag -w broken-tag) && - git gc 2>stderr && + git gc -q 2>stderr && git cat-file -e $tag && test_must_be_empty stderr ' diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 80eb13d94e2a..6db92bd3ba62 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -227,10 +227,10 @@ test_expect_success \ test_expect_success \ 'trying to delete two tags, existing and not, should fail in the 2nd' ' tag_exists mytag && - ! tag_exists myhead && - test_must_fail git tag -d mytag anothertag && + ! tag_exists nonexistingtag && + test_must_fail git tag -d mytag nonexistingtag && ! tag_exists mytag && - ! tag_exists myhead + ! tag_exists nonexistingtag ' test_expect_success 'trying to delete an already deleted tag should fail' \ @@ -517,7 +517,6 @@ test_expect_success \ test_expect_success \ 'trying to create tags giving both -m or -F options should fail' ' echo "message file 1" >msgfile1 && - echo "message file 2" >msgfile2 && ! tag_exists msgtag && test_must_fail git tag -m "message 1" -F msgfile1 msgtag && ! tag_exists msgtag && @@ -1420,7 +1419,7 @@ test_expect_success \ get_tag_header reuse $commit commit $time >expect echo "An annotation to be reused" >> expect test_expect_success \ - 'overwriting an annoted tag should use its previous body' ' + 'overwriting an annotated tag should use its previous body' ' git tag -a -m "An annotation to be reused" reuse && GIT_EDITOR=true git tag -f -a reuse && get_tag_msg reuse >actual && diff --git a/t/t7008-filter-branch-null-sha1.sh b/t/t7008-filter-branch-null-sha1.sh new file mode 100755 index 000000000000..9ba9f24ad2fb --- /dev/null +++ b/t/t7008-filter-branch-null-sha1.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +test_description='filter-branch removal of trees with null sha1' +. ./test-lib.sh + +test_expect_success 'setup: base commits' ' + test_commit one && + test_commit two && + test_commit three +' + +test_expect_success 'setup: a commit with a bogus null sha1 in the tree' ' + { + git ls-tree HEAD && + printf "160000 commit $ZERO_OID\\tbroken\\n" + } >broken-tree && + echo "add broken entry" >msg && + + tree=$(git mktree expect && + git filter-branch \ + --force --prune-empty \ + --index-filter "git rm --cached --ignore-unmatch broken" && + git log -1 --format=%s >actual && + test_cmp expect actual +' + +test_done diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh deleted file mode 100755 index 2d87c49b7539..000000000000 --- a/t/t7008-grep-binary.sh +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/sh - -test_description='git grep in binary files' - -. ./test-lib.sh - -nul_match () { - matches=$1 - flags=$2 - pattern=$3 - pattern_human=$(echo "$pattern" | sed 's/Q//g') - - if test "$matches" = 1 - then - test_expect_success "git grep -f f $flags '$pattern_human' a" " - printf '$pattern' | q_to_nul >f && - git grep -f f $flags a - " - elif test "$matches" = 0 - then - test_expect_success "git grep -f f $flags '$pattern_human' a" " - printf '$pattern' | q_to_nul >f && - test_must_fail git grep -f f $flags a - " - elif test "$matches" = T1 - then - test_expect_failure "git grep -f f $flags '$pattern_human' a" " - printf '$pattern' | q_to_nul >f && - git grep -f f $flags a - " - elif test "$matches" = T0 - then - test_expect_failure "git grep -f f $flags '$pattern_human' a" " - printf '$pattern' | q_to_nul >f && - test_must_fail git grep -f f $flags a - " - else - test_expect_success "PANIC: Test framework error. Unknown matches value $matches" 'false' - fi -} - -test_expect_success 'setup' " - echo 'binaryQfileQm[*]cQ*æQð' | q_to_nul >a && - git add a && - git commit -m. -" - -test_expect_success 'git grep ina a' ' - echo Binary file a matches >expect && - git grep ina a >actual && - test_cmp expect actual -' - -test_expect_success 'git grep -ah ina a' ' - git grep -ah ina a >actual && - test_cmp a actual -' - -test_expect_success 'git grep -I ina a' ' - test_must_fail git grep -I ina a >actual && - test_must_be_empty actual -' - -test_expect_success 'git grep -c ina a' ' - echo a:1 >expect && - git grep -c ina a >actual && - test_cmp expect actual -' - -test_expect_success 'git grep -l ina a' ' - echo a >expect && - git grep -l ina a >actual && - test_cmp expect actual -' - -test_expect_success 'git grep -L bar a' ' - echo a >expect && - git grep -L bar a >actual && - test_cmp expect actual -' - -test_expect_success 'git grep -q ina a' ' - git grep -q ina a >actual && - test_must_be_empty actual -' - -test_expect_success 'git grep -F ile a' ' - git grep -F ile a -' - -test_expect_success 'git grep -Fi iLE a' ' - git grep -Fi iLE a -' - -# This test actually passes on platforms where regexec() supports the -# flag REG_STARTEND. -test_expect_success 'git grep ile a' ' - git grep ile a -' - -test_expect_failure 'git grep .fi a' ' - git grep .fi a -' - -nul_match 1 '-F' 'yQf' -nul_match 0 '-F' 'yQx' -nul_match 1 '-Fi' 'YQf' -nul_match 0 '-Fi' 'YQx' -nul_match 1 '' 'yQf' -nul_match 0 '' 'yQx' -nul_match 1 '' 'æQð' -nul_match 1 '-F' 'eQm[*]c' -nul_match 1 '-Fi' 'EQM[*]C' - -# Regex patterns that would match but shouldn't with -F -nul_match 0 '-F' 'yQ[f]' -nul_match 0 '-F' '[y]Qf' -nul_match 0 '-Fi' 'YQ[F]' -nul_match 0 '-Fi' '[Y]QF' -nul_match 0 '-F' 'æQ[ð]' -nul_match 0 '-F' '[æ]Qð' -nul_match 0 '-Fi' 'ÆQ[Ð]' -nul_match 0 '-Fi' '[Æ]QÐ' - -# kwset is disabled on -i & non-ASCII. No way to match non-ASCII \0 -# patterns case-insensitively. -nul_match T1 '-i' 'ÆQÐ' - -# \0 implicitly disables regexes. This is an undocumented internal -# limitation. -nul_match T1 '' 'yQ[f]' -nul_match T1 '' '[y]Qf' -nul_match T1 '-i' 'YQ[F]' -nul_match T1 '-i' '[Y]Qf' -nul_match T1 '' 'æQ[ð]' -nul_match T1 '' '[æ]Qð' -nul_match T1 '-i' 'ÆQ[Ð]' - -# ... because of \0 implicitly disabling regexes regexes that -# should/shouldn't match don't do the right thing. -nul_match T1 '' 'eQm.*cQ' -nul_match T1 '-i' 'EQM.*cQ' -nul_match T0 '' 'eQm[*]c' -nul_match T0 '-i' 'EQM[*]C' - -# Due to the REG_STARTEND extension when kwset() is disabled on -i & -# non-ASCII the string will be matched in its entirety, but the -# pattern will be cut off at the first \0. -nul_match 0 '-i' 'NOMATCHQð' -nul_match T0 '-i' '[Æ]QNOMATCH' -nul_match T0 '-i' '[æ]QNOMATCH' -# Matches, but for the wrong reasons, just stops at [æ] -nul_match 1 '-i' '[Æ]Qð' -nul_match 1 '-i' '[æ]Qð' - -# Ensure that the matcher doesn't regress to something that stops at -# \0 -nul_match 0 '-F' 'yQ[f]' -nul_match 0 '-Fi' 'YQ[F]' -nul_match 0 '' 'yQNOMATCH' -nul_match 0 '' 'QNOMATCH' -nul_match 0 '-i' 'YQNOMATCH' -nul_match 0 '-i' 'QNOMATCH' -nul_match 0 '-F' 'æQ[ð]' -nul_match 0 '-Fi' 'ÆQ[Ð]' -nul_match 0 '' 'yQNÓMATCH' -nul_match 0 '' 'QNÓMATCH' -nul_match 0 '-i' 'YQNÓMATCH' -nul_match 0 '-i' 'QNÓMATCH' - -test_expect_success 'grep respects binary diff attribute' ' - echo text >t && - git add t && - echo t:text >expect && - git grep text t >actual && - test_cmp expect actual && - echo "t -diff" >.gitattributes && - echo "Binary file t matches" >expect && - git grep text t >actual && - test_cmp expect actual -' - -test_expect_success 'grep --cached respects binary diff attribute' ' - git grep --cached text t >actual && - test_cmp expect actual -' - -test_expect_success 'grep --cached respects binary diff attribute (2)' ' - git add .gitattributes && - rm .gitattributes && - git grep --cached text t >actual && - test_when_finished "git rm --cached .gitattributes" && - test_when_finished "git checkout .gitattributes" && - test_cmp expect actual -' - -test_expect_success 'grep revision respects binary diff attribute' ' - git commit -m new && - echo "Binary file HEAD:t matches" >expect && - git grep text HEAD -- t >actual && - test_when_finished "git reset HEAD^" && - test_cmp expect actual -' - -test_expect_success 'grep respects not-binary diff attribute' ' - echo binQary | q_to_nul >b && - git add b && - echo "Binary file b matches" >expect && - git grep bin b >actual && - test_cmp expect actual && - echo "b diff" >.gitattributes && - echo "b:binQary" >expect && - git grep bin b >actual.raw && - nul_to_q actual && - test_cmp expect actual -' - -cat >nul_to_q_textconv <<'EOF' -#!/bin/sh -"$PERL_PATH" -pe 'y/\000/Q/' < "$1" -EOF -chmod +x nul_to_q_textconv - -test_expect_success 'setup textconv filters' ' - echo a diff=foo >.gitattributes && - git config diff.foo.textconv "\"$(pwd)\""/nul_to_q_textconv -' - -test_expect_success 'grep does not honor textconv' ' - test_must_fail git grep Qfile -' - -test_expect_success 'grep --textconv honors textconv' ' - echo "a:binaryQfileQm[*]cQ*æQð" >expect && - git grep --textconv Qfile >actual && - test_cmp expect actual -' - -test_expect_success 'grep --no-textconv does not honor textconv' ' - test_must_fail git grep --no-textconv Qfile -' - -test_expect_success 'grep --textconv blob honors textconv' ' - echo "HEAD:a:binaryQfileQm[*]cQ*æQð" >expect && - git grep --textconv Qfile HEAD:a >actual && - test_cmp expect actual -' - -test_done diff --git a/t/t7009-filter-branch-null-sha1.sh b/t/t7009-filter-branch-null-sha1.sh deleted file mode 100755 index 9ba9f24ad2fb..000000000000 --- a/t/t7009-filter-branch-null-sha1.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -test_description='filter-branch removal of trees with null sha1' -. ./test-lib.sh - -test_expect_success 'setup: base commits' ' - test_commit one && - test_commit two && - test_commit three -' - -test_expect_success 'setup: a commit with a bogus null sha1 in the tree' ' - { - git ls-tree HEAD && - printf "160000 commit $ZERO_OID\\tbroken\\n" - } >broken-tree && - echo "add broken entry" >msg && - - tree=$(git mktree expect && - git filter-branch \ - --force --prune-empty \ - --index-filter "git rm --cached --ignore-unmatch broken" && - git log -1 --format=%s >actual && - test_cmp expect actual -' - -test_done diff --git a/t/t7012-skip-worktree-writing.sh b/t/t7012-skip-worktree-writing.sh index 9d1abe50eff6..7476781979c3 100755 --- a/t/t7012-skip-worktree-writing.sh +++ b/t/t7012-skip-worktree-writing.sh @@ -134,6 +134,21 @@ test_expect_success 'git-clean, dirty case' ' test_i18ncmp expected result ' +test_expect_success '--ignore-skip-worktree-entries leaves worktree alone' ' + test_commit keep-me && + git update-index --skip-worktree keep-me.t && + rm keep-me.t && + + : ignoring the worktree && + git update-index --remove --ignore-skip-worktree-entries keep-me.t && + git diff-index --cached --exit-code HEAD && + + : not ignoring the worktree, a deletion is staged && + git update-index --remove keep-me.t && + test_must_fail git diff-index --cached --exit-code HEAD \ + --diff-filter=D -- keep-me.t +' + #TODO test_expect_failure 'git-apply adds file' false #TODO test_expect_failure 'git-apply updates file' false #TODO test_expect_failure 'git-apply removes file' false diff --git a/t/t7030-verify-tag.sh b/t/t7030-verify-tag.sh index 041e319e79aa..5c5bc32ccb13 100755 --- a/t/t7030-verify-tag.sh +++ b/t/t7030-verify-tag.sh @@ -44,8 +44,8 @@ test_expect_success GPG 'create signed tags' ' test_expect_success GPGSM 'create signed tags x509 ' ' test_config gpg.format x509 && test_config user.signingkey $GIT_COMMITTER_EMAIL && - echo 9 >file && test_tick && git commit -a -m "nineth gpgsm-signed" && - git tag -s -m nineth nineth-signed-x509 + echo 9 >file && test_tick && git commit -a -m "ninth gpgsm-signed" && + git tag -s -m ninth ninth-signed-x509 ' test_expect_success GPG 'verify and show signatures' ' @@ -80,10 +80,34 @@ test_expect_success GPG 'verify and show signatures' ' ' test_expect_success GPGSM 'verify and show signatures x509' ' - git verify-tag nineth-signed-x509 2>actual && + git verify-tag ninth-signed-x509 2>actual && grep "Good signature from" actual && ! grep "BAD signature from" actual && - echo nineth-signed-x509 OK + echo ninth-signed-x509 OK +' + +test_expect_success GPGSM 'verify and show signatures x509 with low minTrustLevel' ' + test_config gpg.minTrustLevel undefined && + git verify-tag ninth-signed-x509 2>actual && + grep "Good signature from" actual && + ! grep "BAD signature from" actual && + echo ninth-signed-x509 OK +' + +test_expect_success GPGSM 'verify and show signatures x509 with matching minTrustLevel' ' + test_config gpg.minTrustLevel fully && + git verify-tag ninth-signed-x509 2>actual && + grep "Good signature from" actual && + ! grep "BAD signature from" actual && + echo ninth-signed-x509 OK +' + +test_expect_success GPGSM 'verify and show signatures x509 with high minTrustLevel' ' + test_config gpg.minTrustLevel ultimate && + test_must_fail git verify-tag ninth-signed-x509 2>actual && + grep "Good signature from" actual && + ! grep "BAD signature from" actual && + echo ninth-signed-x509 OK ' test_expect_success GPG 'detect fudged signature' ' @@ -127,10 +151,10 @@ test_expect_success GPG 'verify signatures with --raw' ' ' test_expect_success GPGSM 'verify signatures with --raw x509' ' - git verify-tag --raw nineth-signed-x509 2>actual && + git verify-tag --raw ninth-signed-x509 2>actual && grep "GOODSIG" actual && ! grep "BADSIG" actual && - echo nineth-signed-x509 OK + echo ninth-signed-x509 OK ' test_expect_success GPG 'verify multiple tags' ' @@ -147,7 +171,7 @@ test_expect_success GPG 'verify multiple tags' ' ' test_expect_success GPGSM 'verify multiple tags x509' ' - tags="seventh-signed nineth-signed-x509" && + tags="seventh-signed ninth-signed-x509" && for i in $tags do git verify-tag -v --raw $i || return 1 diff --git a/t/t7061-wtstatus-ignore.sh b/t/t7061-wtstatus-ignore.sh index 0c394cf995cb..e4cf5484f97a 100755 --- a/t/t7061-wtstatus-ignore.sh +++ b/t/t7061-wtstatus-ignore.sh @@ -43,11 +43,16 @@ test_expect_success 'status untracked directory with --ignored -u' ' test_cmp expected actual ' cat >expected <<\EOF -?? untracked/uncommitted +?? untracked/ !! untracked/ignored EOF -test_expect_success 'status prefixed untracked directory with --ignored' ' +test_expect_success 'status of untracked directory with --ignored works with or without prefix' ' + git status --porcelain --ignored >tmp && + grep untracked/ tmp >actual && + rm tmp && + test_cmp expected actual && + git status --porcelain --ignored untracked/ >actual && test_cmp expected actual ' diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh index bd10a96727c5..fc2a6cf5c7a4 100755 --- a/t/t7105-reset-patch.sh +++ b/t/t7105-reset-patch.sh @@ -38,6 +38,27 @@ test_expect_success PERL 'git reset -p HEAD^' ' test_i18ngrep "Apply" output ' +test_expect_success PERL 'git reset -p HEAD^^{tree}' ' + test_write_lines n y | git reset -p HEAD^^{tree} >output && + verify_state dir/foo work parent && + verify_saved_state bar && + test_i18ngrep "Apply" output +' + +test_expect_success PERL 'git reset -p HEAD^:dir/foo (blob fails)' ' + set_and_save_state dir/foo work work && + test_must_fail git reset -p HEAD^:dir/foo && + verify_saved_state dir/foo && + verify_saved_state bar +' + +test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' ' + set_and_save_state dir/foo work work && + test_must_fail git reset -p aaaaaaaa && + verify_saved_state dir/foo && + verify_saved_state bar +' + # The idea in the rest is that bar sorts first, so we always say 'y' # first and if the path limiter fails it'll apply to bar instead of # dir/foo. There's always an extra 'n' to reject edits to dir/foo in diff --git a/t/t7107-reset-pathspec-file.sh b/t/t7107-reset-pathspec-file.sh new file mode 100755 index 000000000000..cad3a9de9efc --- /dev/null +++ b/t/t7107-reset-pathspec-file.sh @@ -0,0 +1,173 @@ +#!/bin/sh + +test_description='reset --pathspec-from-file' + +. ./test-lib.sh + +test_tick + +test_expect_success setup ' + echo A >fileA.t && + echo B >fileB.t && + echo C >fileC.t && + echo D >fileD.t && + git add . && + git commit --include . -m "Commit" && + git tag checkpoint +' + +restore_checkpoint () { + git reset --hard checkpoint +} + +verify_expect () { + git status --porcelain -- fileA.t fileB.t fileC.t fileD.t >actual && + test_cmp expect actual +} + +test_expect_success '--pathspec-from-file from stdin' ' + restore_checkpoint && + + git rm fileA.t && + echo fileA.t | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + EOF + verify_expect +' + +test_expect_success '--pathspec-from-file from file' ' + restore_checkpoint && + + git rm fileA.t && + echo fileA.t >list && + git reset --pathspec-from-file=list && + + cat >expect <<-\EOF && + D fileA.t + EOF + verify_expect +' + +test_expect_success 'NUL delimiters' ' + restore_checkpoint && + + git rm fileA.t fileB.t && + printf "fileA.t\0fileB.t\0" | git reset --pathspec-from-file=- --pathspec-file-nul && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + EOF + verify_expect +' + +test_expect_success 'LF delimiters' ' + restore_checkpoint && + + git rm fileA.t fileB.t && + printf "fileA.t\nfileB.t\n" | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + EOF + verify_expect +' + +test_expect_success 'no trailing delimiter' ' + restore_checkpoint && + + git rm fileA.t fileB.t && + printf "fileA.t\nfileB.t" | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + EOF + verify_expect +' + +test_expect_success 'CRLF delimiters' ' + restore_checkpoint && + + git rm fileA.t fileB.t && + printf "fileA.t\r\nfileB.t\r\n" | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + EOF + verify_expect +' + +test_expect_success 'quotes' ' + restore_checkpoint && + + cat >list <<-\EOF && + "file\101.t" + EOF + + git rm fileA.t && + git reset --pathspec-from-file=list && + + cat >expect <<-\EOF && + D fileA.t + EOF + verify_expect +' + +test_expect_success 'quotes not compatible with --pathspec-file-nul' ' + restore_checkpoint && + + cat >list <<-\EOF && + "file\101.t" + EOF + + # Note: "git reset" has not yet learned to fail on wrong pathspecs + git reset --pathspec-from-file=list --pathspec-file-nul && + + cat >expect <<-\EOF && + D fileA.t + EOF + test_must_fail verify_expect +' + +test_expect_success 'only touches what was listed' ' + restore_checkpoint && + + git rm fileA.t fileB.t fileC.t fileD.t && + printf "fileB.t\nfileC.t\n" | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + D fileC.t + D fileD.t + EOF + verify_expect +' + +test_expect_success 'error conditions' ' + restore_checkpoint && + echo fileA.t >list && + git rm fileA.t && + + test_must_fail git reset --pathspec-from-file=list --patch 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err && + + test_must_fail git reset --pathspec-from-file=list -- fileA.t 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err && + + test_must_fail git reset --pathspec-file-nul 2>err && + test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err && + + test_must_fail git reset --soft --pathspec-from-file=list 2>err && + test_i18ngrep -e "fatal: Cannot do soft reset with paths" err && + + test_must_fail git reset --hard --pathspec-from-file=list 2>err && + test_i18ngrep -e "fatal: Cannot do hard reset with paths" err +' + +test_done diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index a2c45d1902ac..cb5e34d94c3a 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -117,6 +117,7 @@ test_expect_success C_LOCALE_OUTPUT 'git clean with relative prefix' ' would_clean=$( cd docs && git clean -n ../src | + grep part3 | sed -n -e "s|^Would remove ||p" ) && verbose test "$would_clean" = ../src/part3.c @@ -129,6 +130,7 @@ test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' ' would_clean=$( cd docs && git clean -n "$(pwd)/../src" | + grep part3 | sed -n -e "s|^Would remove ||p" ) && verbose test "$would_clean" = ../src/part3.c @@ -547,7 +549,7 @@ test_expect_failure 'nested (non-empty) bare repositories should be cleaned even test_path_is_missing strange_bare ' -test_expect_success 'giving path in nested git work tree will remove it' ' +test_expect_success 'giving path in nested git work tree will NOT remove it' ' rm -fr repo && mkdir repo && ( @@ -559,7 +561,7 @@ test_expect_success 'giving path in nested git work tree will remove it' ' git clean -f -d repo/bar/baz && test_path_is_file repo/.git/HEAD && test_path_is_dir repo/bar/ && - test_path_is_missing repo/bar/baz + test_path_is_file repo/bar/baz/hello.world ' test_expect_success 'giving path to nested .git will not remove it' ' @@ -577,7 +579,7 @@ test_expect_success 'giving path to nested .git will not remove it' ' test_path_is_dir untracked/ ' -test_expect_success 'giving path to nested .git/ will remove contents' ' +test_expect_success 'giving path to nested .git/ will NOT remove contents' ' rm -fr repo untracked && mkdir repo untracked && ( @@ -587,7 +589,7 @@ test_expect_success 'giving path to nested .git/ will remove contents' ' ) && git clean -f -d repo/.git/ && test_path_is_dir repo/.git && - test_dir_is_empty repo/.git && + test_path_is_file repo/.git/HEAD && test_path_is_dir untracked/ ' @@ -669,6 +671,60 @@ test_expect_success 'git clean -d skips untracked dirs containing ignored files' test_path_is_missing foo/b/bb ' +test_expect_success 'git clean -d skips nested repo containing ignored files' ' + test_when_finished "rm -rf nested-repo-with-ignored-file" && + + git init nested-repo-with-ignored-file && + ( + cd nested-repo-with-ignored-file && + >file && + git add file && + git commit -m Initial && + + # This file is ignored by a .gitignore rule in the outer repo + # added in the previous test. + >ignoreme + ) && + + git clean -fd && + + test_path_is_file nested-repo-with-ignored-file/.git/index && + test_path_is_file nested-repo-with-ignored-file/ignoreme && + test_path_is_file nested-repo-with-ignored-file/file +' + +test_expect_success 'git clean handles being told what to clean' ' + mkdir -p d1 d2 && + touch d1/ut d2/ut && + git clean -f */ut && + test_path_is_missing d1/ut && + test_path_is_missing d2/ut +' + +test_expect_success 'git clean handles being told what to clean, with -d' ' + mkdir -p d1 d2 && + touch d1/ut d2/ut && + git clean -ffd */ut && + test_path_is_missing d1/ut && + test_path_is_missing d2/ut +' + +test_expect_success 'git clean works if a glob is passed without -d' ' + mkdir -p d1 d2 && + touch d1/ut d2/ut && + git clean -f "*ut" && + test_path_is_missing d1/ut && + test_path_is_missing d2/ut +' + +test_expect_success 'git clean works if a glob is passed with -d' ' + mkdir -p d1 d2 && + touch d1/ut d2/ut && + git clean -ffd "*ut" && + test_path_is_missing d1/ut && + test_path_is_missing d2/ut +' + test_expect_success MINGW 'handle clean & core.longpaths = false nicely' ' test_config core.longpaths false && a50=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && @@ -681,4 +737,13 @@ test_expect_success MINGW 'handle clean & core.longpaths = false nicely' ' test_i18ngrep "too long" .git/err ' +test_expect_success 'clean untracked paths by pathspec' ' + git init untracked && + mkdir untracked/dir && + echo >untracked/dir/file.txt && + git -C untracked clean -f dir/file.txt && + ls untracked/dir >actual && + test_must_be_empty actual +' + test_done diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index a208cb26e1df..e3e2aab3b0a1 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -55,6 +55,21 @@ test_expect_success 'add aborts on repository with no commits' ' test_i18ncmp expect actual ' +test_expect_success 'status should ignore inner git repo when not added' ' + rm -fr inner && + mkdir inner && + ( + cd inner && + git init && + >t && + git add t && + git commit -m "initial" + ) && + test_must_fail git submodule status inner 2>output.err && + rm -fr inner && + test_i18ngrep "^error: .*did not match any file(s) known to git" output.err +' + test_expect_success 'setup - repository in init subdirectory' ' mkdir init && ( @@ -156,9 +171,11 @@ test_expect_success 'submodule add to .gitignored path fails' ' ( cd addtest-ignore && cat <<-\EOF >expect && - The following path is ignored by one of your .gitignore files: + The following paths are ignored by one of your .gitignore files: submod - Use -f if you really want to add it. + hint: Use -f if you really want to add them. + hint: Turn this message off by running + hint: "git config advice.addIgnoredFile false" EOF # Does not use test_commit due to the ignore echo "*" > .gitignore && @@ -191,6 +208,17 @@ test_expect_success 'submodule add to reconfigure existing submodule with --forc ) ' +test_expect_success 'submodule add relays add --dry-run stderr' ' + test_when_finished "rm -rf addtest/.git/index.lock" && + ( + cd addtest && + : >.git/index.lock && + ! git submodule add "$submodurl" sub-while-locked 2>output.err && + test_i18ngrep "^fatal: .*index\.lock" output.err && + test_path_is_missing sub-while-locked + ) +' + test_expect_success 'submodule add --branch' ' echo "refs/heads/initial" >expect-head && cat <<-\EOF >expect-heads && @@ -356,6 +384,28 @@ test_expect_success 'status should only print one line' ' test_line_count = 1 lines ' +test_expect_success 'status from subdirectory should have the same SHA1' ' + test_when_finished "rmdir addtest/subdir" && + ( + cd addtest && + mkdir subdir && + git submodule status >output && + awk "{print \$1}" expect && + cd subdir && + git submodule status >../output && + awk "{print \$1}" <../output >../actual && + test_cmp ../expect ../actual && + git -C ../submod checkout HEAD^ && + git submodule status >../output && + awk "{print \$1}" <../output >../actual2 && + cd .. && + git submodule status >output && + awk "{print \$1}" expect2 && + test_cmp expect2 actual2 && + ! test_cmp actual actual2 + ) +' + test_expect_success 'setup - fetch commit name from submodule' ' rev1=$(cd .subrepo && git rev-parse HEAD) && printf "rev1: %s\n" "$rev1" && @@ -377,6 +427,14 @@ test_expect_success 'init should register submodule url in .git/config' ' test_cmp expect url ' +test_expect_success 'status should still be "missing" after initializing' ' + rm -fr init && + mkdir init && + git submodule status >lines && + rm -fr init && + grep "^-$rev1" lines +' + test_failure_with_unknown_submodule () { test_must_fail git submodule $1 no-such-submodule 2>output.err && test_i18ngrep "^error: .*no-such-submodule" output.err @@ -527,7 +585,6 @@ test_expect_success 'update --init' ' test_must_fail git config submodule.example.url && git submodule update init 2> update.out && - cat update.out && test_i18ngrep "not initialized" update.out && test_must_fail git rev-parse --resolve-git-dir init/.git && @@ -545,7 +602,6 @@ test_expect_success 'update --init from subdirectory' ' ( cd sub && git submodule update ../init 2>update.out && - cat update.out && test_i18ngrep "not initialized" update.out && test_must_fail git rev-parse --resolve-git-dir ../init/.git && diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index c973278300a5..4fb447a143e6 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -158,7 +158,6 @@ test_expect_success 'submodule update --init from and of subdirectory' ' test_i18ncmp expect2 actual2 ' -apos="'"; test_expect_success 'submodule update does not fetch already present commits' ' (cd submodule && echo line3 >> file && @@ -168,7 +167,7 @@ test_expect_success 'submodule update does not fetch already present commits' ' ) && (cd super/submodule && head=$(git rev-parse --verify HEAD) && - echo "Submodule path ${apos}submodule$apos: checked out $apos$head$apos" > ../../expected && + echo "Submodule path ${SQ}submodule$SQ: checked out $SQ$head$SQ" > ../../expected && git reset --hard HEAD~1 ) && (cd super && @@ -407,12 +406,26 @@ test_expect_success 'submodule update - command in .git/config' ' ) ' -test_expect_success 'submodule update - command in .gitmodules is ignored' ' +test_expect_success 'submodule update - command in .gitmodules is rejected' ' test_when_finished "git -C super reset --hard HEAD^" && git -C super config -f .gitmodules submodule.submodule.update "!false" && git -C super commit -a -m "add command to .gitmodules file" && git -C super/submodule reset --hard $submodulesha1^ && - git -C super submodule update submodule + test_must_fail git -C super submodule update submodule +' + +test_expect_success 'fsck detects command in .gitmodules' ' + git init command-in-gitmodules && + ( + cd command-in-gitmodules && + git submodule add ../submodule submodule && + test_commit adding-submodule && + + git config -f .gitmodules submodule.submodule.update "!false" && + git add .gitmodules && + test_commit configuring-update && + test_must_fail git fsck + ) ' cat << EOF >expect @@ -481,6 +494,9 @@ test_expect_success 'recursive submodule update - command in .git/config catches ' test_expect_success 'submodule init does not copy command into .git/config' ' + test_when_finished "git -C super update-index --force-remove submodule1" && + test_when_finished git config -f super/.gitmodules \ + --remove-section submodule.submodule1 && (cd super && git ls-files -s submodule >out && H=$(cut -d" " -f2 out) && @@ -489,10 +505,9 @@ test_expect_success 'submodule init does not copy command into .git/config' ' git config -f .gitmodules submodule.submodule1.path submodule1 && git config -f .gitmodules submodule.submodule1.url ../submodule && git config -f .gitmodules submodule.submodule1.update !false && - git submodule init submodule1 && - echo "none" >expect && - git config submodule.submodule1.update >actual && - test_cmp expect actual + test_must_fail git submodule init submodule1 && + test_expect_code 1 git config submodule.submodule1.update >actual && + test_must_be_empty actual ) ' @@ -945,7 +960,7 @@ test_expect_success 'submodule update clone shallow submodule outside of depth' mv -f .gitmodules.tmp .gitmodules && # Some protocol versions (e.g. 2) support fetching # unadvertised objects, so restrict this test to v0. - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ git submodule update --init --depth=1 2>actual && test_i18ngrep "Direct fetching of that commit failed." actual && git -C ../submodule config uploadpack.allowReachableSHA1InWant true && diff --git a/t/t7410-submodule-checkout-to.sh b/t/t7410-submodule-checkout-to.sh deleted file mode 100755 index f1b492ebc46a..000000000000 --- a/t/t7410-submodule-checkout-to.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -test_description='Combination of submodules and multiple workdirs' - -. ./test-lib.sh - -base_path=$(pwd -P) - -test_expect_success 'setup: make origin' ' - mkdir -p origin/sub && - ( - cd origin/sub && git init && - echo file1 >file1 && - git add file1 && - git commit -m file1 - ) && - mkdir -p origin/main && - ( - cd origin/main && git init && - git submodule add ../sub && - git commit -m "add sub" - ) && - ( - cd origin/sub && - echo file1updated >file1 && - git add file1 && - git commit -m "file1 updated" - ) && - git -C origin/main/sub pull && - ( - cd origin/main && - git add sub && - git commit -m "sub updated" - ) -' - -test_expect_success 'setup: clone' ' - mkdir clone && - git -C clone clone --recursive "$base_path/origin/main" -' - -rev1_hash_main=$(git --git-dir=origin/main/.git show --pretty=format:%h -q "HEAD~1") -rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q "HEAD~1") - -test_expect_success 'checkout main' ' - mkdir default_checkout && - git -C clone/main worktree add "$base_path/default_checkout/main" "$rev1_hash_main" -' - -test_expect_failure 'can see submodule diffs just after checkout' ' - git -C default_checkout/main diff --submodule master"^!" >out && - grep "file1 updated" out -' - -test_expect_success 'checkout main and initialize independent clones' ' - mkdir fully_cloned_submodule && - git -C clone/main worktree add "$base_path/fully_cloned_submodule/main" "$rev1_hash_main" && - git -C fully_cloned_submodule/main submodule update -' - -test_expect_success 'can see submodule diffs after independent cloning' ' - git -C fully_cloned_submodule/main diff --submodule master"^!" >out && - grep "file1 updated" out -' - -test_expect_success 'checkout sub manually' ' - mkdir linked_submodule && - git -C clone/main worktree add "$base_path/linked_submodule/main" "$rev1_hash_main" && - git -C clone/main/sub worktree add "$base_path/linked_submodule/main/sub" "$rev1_hash_sub" -' - -test_expect_success 'can see submodule diffs after manual checkout of linked submodule' ' - git -C linked_submodule/main diff --submodule master"^!" >out && - grep "file1 updated" out -' - -test_done diff --git a/t/t7415-submodule-names.sh b/t/t7415-submodule-names.sh index 49a37efe9c1d..f70368bc2e9d 100755 --- a/t/t7415-submodule-names.sh +++ b/t/t7415-submodule-names.sh @@ -191,4 +191,61 @@ test_expect_success 'fsck detects corrupt .gitmodules' ' ) ' +test_expect_success MINGW 'prevent git~1 squatting on Windows' ' + git init squatting && + ( + cd squatting && + mkdir a && + touch a/..git && + git add a/..git && + test_tick && + git commit -m initial && + + modules="$(test_write_lines \ + "[submodule \"b.\"]" "url = ." "path = c" \ + "[submodule \"b\"]" "url = ." "path = d\\\\a" | + git hash-object -w --stdin)" && + rev="$(git rev-parse --verify HEAD)" && + hash="$(echo x | git hash-object -w --stdin)" && + test_must_fail git update-index --add \ + --cacheinfo 160000,$rev,d\\a 2>err && + test_i18ngrep "Invalid path" err && + git -c core.protectNTFS=false update-index --add \ + --cacheinfo 100644,$modules,.gitmodules \ + --cacheinfo 160000,$rev,c \ + --cacheinfo 160000,$rev,d\\a \ + --cacheinfo 100644,$hash,d./a/x \ + --cacheinfo 100644,$hash,d./a/..git && + test_tick && + git -c core.protectNTFS=false commit -m "module" + ) && + test_must_fail git -c core.protectNTFS=false \ + clone --recurse-submodules squatting squatting-clone 2>err && + test_i18ngrep -e "directory not empty" -e "not an empty directory" err && + ! grep gitdir squatting-clone/d/a/git~2 +' + +test_expect_success 'git dirs of sibling submodules must not be nested' ' + git init nested && + test_commit -C nested nested && + ( + cd nested && + cat >.gitmodules <<-EOF && + [submodule "hippo"] + url = . + path = thing1 + [submodule "hippo/hooks"] + url = . + path = thing2 + EOF + git clone . thing1 && + git clone . thing2 && + git add .gitmodules thing1 thing2 && + test_tick && + git commit -m nested + ) && + test_must_fail git clone --recurse-submodules nested clone 2>err && + test_i18ngrep "is inside git dir" err +' + test_done diff --git a/t/t7416-submodule-dash-url.sh b/t/t7416-submodule-dash-url.sh index 1cd2c1c1ea2d..eec96e0ba9e3 100755 --- a/t/t7416-submodule-dash-url.sh +++ b/t/t7416-submodule-dash-url.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='check handling of .gitmodule url with dash' +test_description='check handling of disallowed .gitmodule urls' . ./test-lib.sh test_expect_success 'create submodule with protected dash in url' ' @@ -46,4 +46,159 @@ test_expect_success 'fsck rejects unprotected dash' ' grep gitmodulesUrl err ' +test_expect_success 'trailing backslash is handled correctly' ' + git init testmodule && + test_commit -C testmodule c && + git submodule add ./testmodule && + : ensure that the name ends in a double backslash && + sed -e "s|\\(submodule \"testmodule\\)\"|\\1\\\\\\\\\"|" \ + -e "s|url = .*|url = \" --should-not-be-an-option\"|" \ + <.gitmodules >.new && + mv .new .gitmodules && + git commit -am "Add testmodule" && + test_must_fail git clone --verbose --recurse-submodules . dolly 2>err && + test_i18ngrep ! "unknown option" err +' + +test_expect_success 'fsck rejects missing URL scheme' ' + git checkout --orphan missing-scheme && + cat >.gitmodules <<-\EOF && + [submodule "foo"] + url = http::one.example.com/foo.git + EOF + git add .gitmodules && + test_tick && + git commit -m "gitmodules with missing URL scheme" && + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + test_must_fail git push dst HEAD 2>err && + grep gitmodulesUrl err +' + +test_expect_success 'fsck rejects relative URL resolving to missing scheme' ' + git checkout --orphan relative-missing-scheme && + cat >.gitmodules <<-\EOF && + [submodule "foo"] + url = "..\\../.\\../:one.example.com/foo.git" + EOF + git add .gitmodules && + test_tick && + git commit -m "gitmodules with relative URL that strips off scheme" && + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + test_must_fail git push dst HEAD 2>err && + grep gitmodulesUrl err +' + +test_expect_success 'fsck rejects empty URL scheme' ' + git checkout --orphan empty-scheme && + cat >.gitmodules <<-\EOF && + [submodule "foo"] + url = http::://one.example.com/foo.git + EOF + git add .gitmodules && + test_tick && + git commit -m "gitmodules with empty URL scheme" && + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + test_must_fail git push dst HEAD 2>err && + grep gitmodulesUrl err +' + +test_expect_success 'fsck rejects relative URL resolving to empty scheme' ' + git checkout --orphan relative-empty-scheme && + cat >.gitmodules <<-\EOF && + [submodule "foo"] + url = ../../../:://one.example.com/foo.git + EOF + git add .gitmodules && + test_tick && + git commit -m "relative gitmodules URL resolving to empty scheme" && + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + test_must_fail git push dst HEAD 2>err && + grep gitmodulesUrl err +' + +test_expect_success 'fsck rejects empty hostname' ' + git checkout --orphan empty-host && + cat >.gitmodules <<-\EOF && + [submodule "foo"] + url = http:///one.example.com/foo.git + EOF + git add .gitmodules && + test_tick && + git commit -m "gitmodules with extra slashes" && + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + test_must_fail git push dst HEAD 2>err && + grep gitmodulesUrl err +' + +test_expect_success 'fsck rejects relative url that produced empty hostname' ' + git checkout --orphan messy-relative && + cat >.gitmodules <<-\EOF && + [submodule "foo"] + url = ../../..//one.example.com/foo.git + EOF + git add .gitmodules && + test_tick && + git commit -m "gitmodules abusing relative_path" && + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + test_must_fail git push dst HEAD 2>err && + grep gitmodulesUrl err +' + +test_expect_success 'fsck permits embedded newline with unrecognized scheme' ' + git checkout --orphan newscheme && + cat >.gitmodules <<-\EOF && + [submodule "foo"] + url = "data://acjbkd%0akajfdickajkd" + EOF + git add .gitmodules && + git commit -m "gitmodules with unrecognized scheme" && + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + git push dst HEAD +' + +test_expect_success 'fsck rejects embedded newline in url' ' + # create an orphan branch to avoid existing .gitmodules objects + git checkout --orphan newline && + cat >.gitmodules <<-\EOF && + [submodule "foo"] + url = "https://one.example.com?%0ahost=two.example.com/foo.git" + EOF + git add .gitmodules && + git commit -m "gitmodules with newline" && + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + test_must_fail git push dst HEAD 2>err && + grep gitmodulesUrl err +' + +test_expect_success 'fsck rejects embedded newline in relative url' ' + git checkout --orphan relative-newline && + cat >.gitmodules <<-\EOF && + [submodule "foo"] + url = "./%0ahost=two.example.com/foo.git" + EOF + git add .gitmodules && + git commit -m "relative url with newline" && + test_when_finished "rm -rf dst" && + git init --bare dst && + git -C dst config transfer.fsckObjects true && + test_must_fail git push dst HEAD 2>err && + grep gitmodulesUrl err +' + test_done diff --git a/t/t7417-submodule-path-url.sh b/t/t7417-submodule-path-url.sh index 756af8c4d6fb..f7e7e94d7b6c 100755 --- a/t/t7417-submodule-path-url.sh +++ b/t/t7417-submodule-path-url.sh @@ -25,4 +25,21 @@ test_expect_success 'fsck rejects unprotected dash' ' grep gitmodulesPath err ' +test_expect_success MINGW 'submodule paths disallows trailing spaces' ' + git init super && + test_must_fail git -C super submodule add ../upstream "sub " && + + : add "sub", then rename "sub" to "sub ", the hard way && + git -C super submodule add ../upstream sub && + tree=$(git -C super write-tree) && + git -C super ls-tree $tree >tree && + sed "s/sub/sub /" tree.new && + tree=$(git -C super mktree err && + test_i18ngrep "sub " err +' + test_done diff --git a/t/t7419-submodule-set-branch.sh b/t/t7419-submodule-set-branch.sh index c4b370ea8533..fd25f786a365 100755 --- a/t/t7419-submodule-set-branch.sh +++ b/t/t7419-submodule-set-branch.sh @@ -34,7 +34,7 @@ test_expect_success 'submodule config cache setup' ' test_expect_success 'ensure submodule branch is unset' ' (cd super && - test_must_fail grep branch .gitmodules + ! grep branch .gitmodules ) ' @@ -54,7 +54,7 @@ test_expect_success 'test submodule set-branch --branch' ' test_expect_success 'test submodule set-branch --default' ' (cd super && git submodule set-branch --default submodule && - test_must_fail grep branch .gitmodules && + ! grep branch .gitmodules && git submodule update --remote && cat <<-\EOF >expect && a @@ -80,7 +80,7 @@ test_expect_success 'test submodule set-branch -b' ' test_expect_success 'test submodule set-branch -d' ' (cd super && git submodule set-branch -d submodule && - test_must_fail grep branch .gitmodules && + ! grep branch .gitmodules && git submodule update --remote && cat <<-\EOF >expect && a diff --git a/t/t7420-submodule-set-url.sh b/t/t7420-submodule-set-url.sh new file mode 100755 index 000000000000..ef0cb6e8e185 --- /dev/null +++ b/t/t7420-submodule-set-url.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (c) 2019 Denton Liu +# + +test_description='Test submodules set-url subcommand + +This test verifies that the set-url subcommand of git-submodule is working +as expected. +' + +TEST_NO_CREATE_REPO=1 +. ./test-lib.sh + +test_expect_success 'submodule config cache setup' ' + mkdir submodule && + ( + cd submodule && + git init && + echo a >file && + git add file && + git commit -ma + ) && + mkdir super && + ( + cd super && + git init && + git submodule add ../submodule && + git commit -m "add submodule" + ) +' + +test_expect_success 'test submodule set-url' ' + # add a commit and move the submodule (change the url) + ( + cd submodule && + echo b >>file && + git add file && + git commit -mb + ) && + mv submodule newsubmodule && + + git -C newsubmodule show >expect && + ( + cd super && + test_must_fail git submodule update --remote && + git submodule set-url submodule ../newsubmodule && + grep -F "url = ../newsubmodule" .gitmodules && + git submodule update --remote + ) && + git -C super/submodule show >actual && + test_cmp expect actual +' + +test_done diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh index 46a5cd4b7395..6d19ece05dd3 100755 --- a/t/t7500-commit-template-squash-signoff.sh +++ b/t/t7500-commit-template-squash-signoff.sh @@ -382,4 +382,13 @@ test_expect_success 'check commit with unstaged rename and copy' ' ) ' +test_expect_success 'commit without staging files fails and displays hints' ' + echo "initial" >file && + git add file && + git commit -m initial && + echo "changes" >>file && + test_must_fail git commit -m update >actual && + test_i18ngrep "no changes added to commit (use \"git add\" and/or \"git commit -a\")" actual +' + test_done diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh index f1349af56edd..110b4bf459bf 100755 --- a/t/t7501-commit-basic-functionality.sh +++ b/t/t7501-commit-basic-functionality.sh @@ -150,7 +150,7 @@ test_expect_success 'setup: commit message from file' ' test_expect_success 'amend commit' ' cat >editor <<-\EOF && #!/bin/sh - sed -e "s/a file/an amend commit/g" < "$1" > "$1-" + sed -e "s/a file/an amend commit/g" <"$1" >"$1-" mv "$1-" "$1" EOF chmod 755 editor && @@ -263,7 +263,7 @@ test_expect_success 'using message from other commit' ' test_expect_success 'editing message from other commit' ' cat >editor <<-\EOF && #!/bin/sh - sed -e "s/amend/older/g" < "$1" > "$1-" + sed -e "s/amend/older/g" <"$1" >"$1-" mv "$1-" "$1" EOF chmod 755 editor && @@ -285,9 +285,8 @@ test_expect_success 'overriding author from command line' ' ' test_expect_success PERL 'interactive add' ' - echo 7 | - git commit --interactive | - grep "What now" + echo 7 | test_must_fail git commit --interactive >out && + grep "What now" out ' test_expect_success PERL "commit --interactive doesn't change index if editor aborts" ' @@ -362,12 +361,12 @@ test_expect_success 'amend commit to fix author' ' oldtick=$GIT_AUTHOR_DATE && test_tick && git reset --hard && - git cat-file -p HEAD | + git cat-file -p HEAD >commit && sed -e "s/author.*/author $author $oldtick/" \ - -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \ - expected && + -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \ + commit >expected && git commit --amend --author="$author" && - git cat-file -p HEAD > current && + git cat-file -p HEAD >current && test_cmp expected current ' @@ -377,12 +376,12 @@ test_expect_success 'amend commit to fix date' ' test_tick && newtick=$GIT_AUTHOR_DATE && git reset --hard && - git cat-file -p HEAD | + git cat-file -p HEAD >commit && sed -e "s/author.*/author $author $newtick/" \ - -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \ - expected && + -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \ + commit >expected && git commit --amend --date="$newtick" && - git cat-file -p HEAD > current && + git cat-file -p HEAD >current && test_cmp expected current ' @@ -409,12 +408,13 @@ test_expect_success 'sign off (1)' ' echo 1 >positive && git add positive && git commit -s -m "thank you" && - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo thank you && echo && - git var GIT_COMMITTER_IDENT | - sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" + git var GIT_COMMITTER_IDENT >ident && + sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident ) >expected && test_cmp expected actual @@ -428,13 +428,14 @@ test_expect_success 'sign off (2)' ' git commit -s -m "thank you $existing" && - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo thank you && echo && echo $existing && - git var GIT_COMMITTER_IDENT | - sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" + git var GIT_COMMITTER_IDENT >ident && + sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident ) >expected && test_cmp expected actual @@ -448,13 +449,14 @@ test_expect_success 'signoff gap' ' git commit -s -m "welcome $alt" && - git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo welcome && echo && echo $alt && - git var GIT_COMMITTER_IDENT | - sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" + git var GIT_COMMITTER_IDENT >ident && + sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident ) >expected && test_cmp expected actual ' @@ -468,15 +470,16 @@ test_expect_success 'signoff gap 2' ' We have now $alt" && - git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo welcome && echo && echo We have now && echo $alt && echo && - git var GIT_COMMITTER_IDENT | - sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" + git var GIT_COMMITTER_IDENT >ident && + sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident ) >expected && test_cmp expected actual ' @@ -489,7 +492,8 @@ test_expect_success 'signoff respects trailer config' ' non-trailer line Myfooter: x" && - git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo subject && echo && @@ -506,7 +510,8 @@ Myfooter: x" && non-trailer line Myfooter: x" && - git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo subject && echo && @@ -538,7 +543,8 @@ test_expect_success 'multiple -m' ' >negative && git add negative && git commit -m "one" -m "two" -m "three" && - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo one && echo && @@ -555,23 +561,25 @@ test_expect_success 'amend commit to fix author' ' oldtick=$GIT_AUTHOR_DATE && test_tick && git reset --hard && - git cat-file -p HEAD | + git cat-file -p HEAD >commit && sed -e "s/author.*/author $author $oldtick/" \ - -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \ - expected && + -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \ + commit >expected && git commit --amend --author="$author" && - git cat-file -p HEAD > current && + git cat-file -p HEAD >current && test_cmp expected current ' test_expect_success 'git commit with dirty index' ' - echo tacocat > elif && - echo tehlulz > chz && + echo tacocat >elif && + echo tehlulz >chz && git add chz && git commit elif -m "tacocat is a palindrome" && - git show --stat | grep elif && - git diff --cached | grep chz + git show --stat >stat && + grep elif stat && + git diff --cached >diff && + grep chz diff ' test_expect_success 'same tree (single parent)' ' @@ -584,7 +592,8 @@ test_expect_success 'same tree (single parent)' ' test_expect_success 'same tree (single parent) --allow-empty' ' git commit --allow-empty -m "forced empty" && - git cat-file commit HEAD | grep forced + git cat-file commit HEAD >commit && + grep forced commit ' diff --git a/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh b/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh new file mode 100755 index 000000000000..b3485450a205 --- /dev/null +++ b/t/t7503-pre-commit-and-pre-merge-commit-hooks.sh @@ -0,0 +1,281 @@ +#!/bin/sh + +test_description='pre-commit and pre-merge-commit hooks' + +. ./test-lib.sh + +HOOKDIR="$(git rev-parse --git-dir)/hooks" +PRECOMMIT="$HOOKDIR/pre-commit" +PREMERGE="$HOOKDIR/pre-merge-commit" + +# Prepare sample scripts that write their $0 to actual_hooks +test_expect_success 'sample script setup' ' + mkdir -p "$HOOKDIR" && + write_script "$HOOKDIR/success.sample" <<-\EOF && + echo $0 >>actual_hooks + exit 0 + EOF + write_script "$HOOKDIR/fail.sample" <<-\EOF && + echo $0 >>actual_hooks + exit 1 + EOF + write_script "$HOOKDIR/non-exec.sample" <<-\EOF && + echo $0 >>actual_hooks + exit 1 + EOF + chmod -x "$HOOKDIR/non-exec.sample" && + write_script "$HOOKDIR/require-prefix.sample" <<-\EOF && + echo $0 >>actual_hooks + test $GIT_PREFIX = "success/" + EOF + write_script "$HOOKDIR/check-author.sample" <<-\EOF + echo $0 >>actual_hooks + test "$GIT_AUTHOR_NAME" = "New Author" && + test "$GIT_AUTHOR_EMAIL" = "newauthor@example.com" + EOF +' + +test_expect_success 'root commit' ' + echo "root" >file && + git add file && + git commit -m "zeroth" && + git checkout -b side && + echo "foo" >foo && + git add foo && + git commit -m "make it non-ff" && + git branch side-orig side && + git checkout master +' + +test_expect_success 'setup conflicting branches' ' + test_when_finished "git checkout master" && + git checkout -b conflicting-a master && + echo a >conflicting && + git add conflicting && + git commit -m conflicting-a && + git checkout -b conflicting-b master && + echo b >conflicting && + git add conflicting && + git commit -m conflicting-b +' + +test_expect_success 'with no hook' ' + test_when_finished "rm -f actual_hooks" && + echo "foo" >file && + git add file && + git commit -m "first" && + test_path_is_missing actual_hooks +' + +test_expect_success 'with no hook (merge)' ' + test_when_finished "rm -f actual_hooks" && + git branch -f side side-orig && + git checkout side && + git merge -m "merge master" master && + git checkout master && + test_path_is_missing actual_hooks +' + +test_expect_success '--no-verify with no hook' ' + test_when_finished "rm -f actual_hooks" && + echo "bar" >file && + git add file && + git commit --no-verify -m "bar" && + test_path_is_missing actual_hooks +' + +test_expect_success '--no-verify with no hook (merge)' ' + test_when_finished "rm -f actual_hooks" && + git branch -f side side-orig && + git checkout side && + git merge --no-verify -m "merge master" master && + git checkout master && + test_path_is_missing actual_hooks +' + +test_expect_success 'with succeeding hook' ' + test_when_finished "rm -f \"$PRECOMMIT\" expected_hooks actual_hooks" && + cp "$HOOKDIR/success.sample" "$PRECOMMIT" && + echo "$PRECOMMIT" >expected_hooks && + echo "more" >>file && + git add file && + git commit -m "more" && + test_cmp expected_hooks actual_hooks +' + +test_expect_success 'with succeeding hook (merge)' ' + test_when_finished "rm -f \"$PREMERGE\" expected_hooks actual_hooks" && + cp "$HOOKDIR/success.sample" "$PREMERGE" && + echo "$PREMERGE" >expected_hooks && + git checkout side && + git merge -m "merge master" master && + git checkout master && + test_cmp expected_hooks actual_hooks +' + +test_expect_success 'automatic merge fails; both hooks are available' ' + test_when_finished "rm -f \"$PREMERGE\" \"$PRECOMMIT\"" && + test_when_finished "rm -f expected_hooks actual_hooks" && + test_when_finished "git checkout master" && + cp "$HOOKDIR/success.sample" "$PREMERGE" && + cp "$HOOKDIR/success.sample" "$PRECOMMIT" && + + git checkout conflicting-a && + test_must_fail git merge -m "merge conflicting-b" conflicting-b && + test_path_is_missing actual_hooks && + + echo "$PRECOMMIT" >expected_hooks && + echo a+b >conflicting && + git add conflicting && + git commit -m "resolve conflict" && + test_cmp expected_hooks actual_hooks +' + +test_expect_success '--no-verify with succeeding hook' ' + test_when_finished "rm -f \"$PRECOMMIT\" actual_hooks" && + cp "$HOOKDIR/success.sample" "$PRECOMMIT" && + echo "even more" >>file && + git add file && + git commit --no-verify -m "even more" && + test_path_is_missing actual_hooks +' + +test_expect_success '--no-verify with succeeding hook (merge)' ' + test_when_finished "rm -f \"$PREMERGE\" actual_hooks" && + cp "$HOOKDIR/success.sample" "$PREMERGE" && + git branch -f side side-orig && + git checkout side && + git merge --no-verify -m "merge master" master && + git checkout master && + test_path_is_missing actual_hooks +' + +test_expect_success 'with failing hook' ' + test_when_finished "rm -f \"$PRECOMMIT\" expected_hooks actual_hooks" && + cp "$HOOKDIR/fail.sample" "$PRECOMMIT" && + echo "$PRECOMMIT" >expected_hooks && + echo "another" >>file && + git add file && + test_must_fail git commit -m "another" && + test_cmp expected_hooks actual_hooks +' + +test_expect_success '--no-verify with failing hook' ' + test_when_finished "rm -f \"$PRECOMMIT\" actual_hooks" && + cp "$HOOKDIR/fail.sample" "$PRECOMMIT" && + echo "stuff" >>file && + git add file && + git commit --no-verify -m "stuff" && + test_path_is_missing actual_hooks +' + +test_expect_success 'with failing hook (merge)' ' + test_when_finished "rm -f \"$PREMERGE\" expected_hooks actual_hooks" && + cp "$HOOKDIR/fail.sample" "$PREMERGE" && + echo "$PREMERGE" >expected_hooks && + git checkout side && + test_must_fail git merge -m "merge master" master && + git checkout master && + test_cmp expected_hooks actual_hooks +' + +test_expect_success '--no-verify with failing hook (merge)' ' + test_when_finished "rm -f \"$PREMERGE\" actual_hooks" && + cp "$HOOKDIR/fail.sample" "$PREMERGE" && + git branch -f side side-orig && + git checkout side && + git merge --no-verify -m "merge master" master && + git checkout master && + test_path_is_missing actual_hooks +' + +test_expect_success POSIXPERM 'with non-executable hook' ' + test_when_finished "rm -f \"$PRECOMMIT\" actual_hooks" && + cp "$HOOKDIR/non-exec.sample" "$PRECOMMIT" && + echo "content" >>file && + git add file && + git commit -m "content" && + test_path_is_missing actual_hooks +' + +test_expect_success POSIXPERM '--no-verify with non-executable hook' ' + test_when_finished "rm -f \"$PRECOMMIT\" actual_hooks" && + cp "$HOOKDIR/non-exec.sample" "$PRECOMMIT" && + echo "more content" >>file && + git add file && + git commit --no-verify -m "more content" && + test_path_is_missing actual_hooks +' + +test_expect_success POSIXPERM 'with non-executable hook (merge)' ' + test_when_finished "rm -f \"$PREMERGE\" actual_hooks" && + cp "$HOOKDIR/non-exec.sample" "$PREMERGE" && + git branch -f side side-orig && + git checkout side && + git merge -m "merge master" master && + git checkout master && + test_path_is_missing actual_hooks +' + +test_expect_success POSIXPERM '--no-verify with non-executable hook (merge)' ' + test_when_finished "rm -f \"$PREMERGE\" actual_hooks" && + cp "$HOOKDIR/non-exec.sample" "$PREMERGE" && + git branch -f side side-orig && + git checkout side && + git merge --no-verify -m "merge master" master && + git checkout master && + test_path_is_missing actual_hooks +' + +test_expect_success 'with hook requiring GIT_PREFIX' ' + test_when_finished "rm -rf \"$PRECOMMIT\" expected_hooks actual_hooks success" && + cp "$HOOKDIR/require-prefix.sample" "$PRECOMMIT" && + echo "$PRECOMMIT" >expected_hooks && + echo "more content" >>file && + git add file && + mkdir success && + ( + cd success && + git commit -m "hook requires GIT_PREFIX = success/" + ) && + test_cmp expected_hooks actual_hooks +' + +test_expect_success 'with failing hook requiring GIT_PREFIX' ' + test_when_finished "rm -rf \"$PRECOMMIT\" expected_hooks actual_hooks fail" && + cp "$HOOKDIR/require-prefix.sample" "$PRECOMMIT" && + echo "$PRECOMMIT" >expected_hooks && + echo "more content" >>file && + git add file && + mkdir fail && + ( + cd fail && + test_must_fail git commit -m "hook must fail" + ) && + git checkout -- file && + test_cmp expected_hooks actual_hooks +' + +test_expect_success 'check the author in hook' ' + test_when_finished "rm -f \"$PRECOMMIT\" expected_hooks actual_hooks" && + cp "$HOOKDIR/check-author.sample" "$PRECOMMIT" && + cat >expected_hooks <<-EOF && + $PRECOMMIT + $PRECOMMIT + $PRECOMMIT + EOF + test_must_fail git commit --allow-empty -m "by a.u.thor" && + ( + GIT_AUTHOR_NAME="New Author" && + GIT_AUTHOR_EMAIL="newauthor@example.com" && + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL && + git commit --allow-empty -m "by new.author via env" && + git show -s + ) && + git commit --author="New Author " \ + --allow-empty -m "by new.author via command line" && + git show -s && + test_cmp expected_hooks actual_hooks +' + +test_done diff --git a/t/t7503-pre-commit-hook.sh b/t/t7503-pre-commit-hook.sh deleted file mode 100755 index 984889b39d3f..000000000000 --- a/t/t7503-pre-commit-hook.sh +++ /dev/null @@ -1,139 +0,0 @@ -#!/bin/sh - -test_description='pre-commit hook' - -. ./test-lib.sh - -test_expect_success 'with no hook' ' - - echo "foo" > file && - git add file && - git commit -m "first" - -' - -test_expect_success '--no-verify with no hook' ' - - echo "bar" > file && - git add file && - git commit --no-verify -m "bar" - -' - -# now install hook that always succeeds -HOOKDIR="$(git rev-parse --git-dir)/hooks" -HOOK="$HOOKDIR/pre-commit" -mkdir -p "$HOOKDIR" -cat > "$HOOK" <> file && - git add file && - git commit -m "more" - -' - -test_expect_success '--no-verify with succeeding hook' ' - - echo "even more" >> file && - git add file && - git commit --no-verify -m "even more" - -' - -# now a hook that fails -cat > "$HOOK" <> file && - git add file && - test_must_fail git commit -m "another" - -' - -test_expect_success '--no-verify with failing hook' ' - - echo "stuff" >> file && - git add file && - git commit --no-verify -m "stuff" - -' - -chmod -x "$HOOK" -test_expect_success POSIXPERM 'with non-executable hook' ' - - echo "content" >> file && - git add file && - git commit -m "content" - -' - -test_expect_success POSIXPERM '--no-verify with non-executable hook' ' - - echo "more content" >> file && - git add file && - git commit --no-verify -m "more content" - -' -chmod +x "$HOOK" - -# a hook that checks $GIT_PREFIX and succeeds inside the -# success/ subdirectory only -cat > "$HOOK" <> file && - git add file && - mkdir success && - ( - cd success && - git commit -m "hook requires GIT_PREFIX = success/" - ) && - rmdir success -' - -test_expect_success 'with failing hook requiring GIT_PREFIX' ' - - echo "more content" >> file && - git add file && - mkdir fail && - ( - cd fail && - test_must_fail git commit -m "hook must fail" - ) && - rmdir fail && - git checkout -- file -' - -test_expect_success 'check the author in hook' ' - write_script "$HOOK" <<-\EOF && - test "$GIT_AUTHOR_NAME" = "New Author" && - test "$GIT_AUTHOR_EMAIL" = "newauthor@example.com" - EOF - test_must_fail git commit --allow-empty -m "by a.u.thor" && - ( - GIT_AUTHOR_NAME="New Author" && - GIT_AUTHOR_EMAIL="newauthor@example.com" && - export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL && - git commit --allow-empty -m "by new.author via env" && - git show -s - ) && - git commit --author="New Author " \ - --allow-empty -m "by new.author via command line" && - git show -s -' - -test_done diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh index ba8bd1b51497..94f85cdf8317 100755 --- a/t/t7505-prepare-commit-msg-hook.sh +++ b/t/t7505-prepare-commit-msg-hook.sh @@ -241,13 +241,7 @@ test_rebase () { git add b && git rebase --continue ) && - if test "$mode" = -p # reword amended after pick - then - n=18 - else - n=17 - fi && - git log --pretty=%s -g -n$n HEAD@{1} >actual && + git log --pretty=%s -g -n18 HEAD@{1} >actual && test_cmp "$TEST_DIRECTORY/t7505/expected-rebase${mode:--i}" actual ' } diff --git a/t/t7505/expected-rebase-i b/t/t7505/expected-rebase-i index c514bdbb9422..93bada596e25 100644 --- a/t/t7505/expected-rebase-i +++ b/t/t7505/expected-rebase-i @@ -7,7 +7,8 @@ message (no editor) [edit rebase-10] message [fixup rebase-9] message (no editor) [fixup rebase-8] message (no editor) [squash rebase-7] -message [reword rebase-6] +HEAD [reword rebase-6] +message (no editor) [reword rebase-6] message [squash rebase-5] message (no editor) [fixup rebase-4] message (no editor) [pick rebase-3] diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 4e676cdce8d6..482ce3510edd 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -1571,7 +1571,7 @@ test_expect_success '"status.showStash=true" weaker than "--no-show-stash"' ' test_cmp expected_without_stash actual ' -test_expect_success 'no additionnal info if no stash entries' ' +test_expect_success 'no additional info if no stash entries' ' git stash clear && git -c status.showStash=true status >actual && test_cmp expected_without_stash actual diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index 682b23a06818..0c06d22a0079 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -109,6 +109,21 @@ test_expect_success GPG 'verify-commit exits success on untrusted signature' ' grep "not certified" actual ' +test_expect_success GPG 'verify-commit exits success with matching minTrustLevel' ' + test_config gpg.minTrustLevel ultimate && + git verify-commit sixth-signed +' + +test_expect_success GPG 'verify-commit exits success with low minTrustLevel' ' + test_config gpg.minTrustLevel fully && + git verify-commit sixth-signed +' + +test_expect_success GPG 'verify-commit exits failure with high minTrustLevel' ' + test_config gpg.minTrustLevel ultimate && + test_must_fail git verify-commit eighth-signed-alt +' + test_expect_success GPG 'verify signatures with --raw' ' ( for commit in initial second merge fourth-signed fifth-signed sixth-signed seventh-signed @@ -219,6 +234,30 @@ test_expect_success GPG 'show untrusted signature with custom format' ' test_cmp expect actual ' +test_expect_success GPG 'show untrusted signature with undefined trust level' ' + cat >expect <<-\EOF && + undefined + 65A0EEA02E30CAD7 + Eris Discordia + F8364A59E07FFE9F4D63005A65A0EEA02E30CAD7 + D4BE22311AD3131E5EDA29A461092E85B7227189 + EOF + git log -1 --format="%GT%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual && + test_cmp expect actual +' + +test_expect_success GPG 'show untrusted signature with ultimate trust level' ' + cat >expect <<-\EOF && + ultimate + 13B6F51ECDDE430D + C O Mitter + 73D758744BE721698EC54E8713B6F51ECDDE430D + 73D758744BE721698EC54E8713B6F51ECDDE430D + EOF + git log -1 --format="%GT%n%GK%n%GS%n%GF%n%GP" sixth-signed >actual && + test_cmp expect actual +' + test_expect_success GPG 'show unknown signature with custom format' ' cat >expect <<-\EOF && E diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh index e01c285cbf8f..29518e0949bf 100755 --- a/t/t7512-status-help.sh +++ b/t/t7512-status-help.sh @@ -71,10 +71,10 @@ test_expect_success 'prepare for rebase conflicts' ' ' -test_expect_success 'status when rebase in progress before resolving conflicts' ' +test_expect_success 'status when rebase --apply in progress before resolving conflicts' ' test_when_finished "git rebase --abort" && ONTO=$(git rev-parse --short HEAD^^) && - test_must_fail git rebase HEAD^ --onto HEAD^^ && + test_must_fail git rebase --apply HEAD^ --onto HEAD^^ && cat >expected <main.txt && git add main.txt && cat >expected <expected <\"" && cat complex_message_body >expected && diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index 81a375fa0ff9..fbfdcca00077 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -32,11 +32,12 @@ write_integration_script () { echo "$0: exactly 2 arguments expected" exit 2 fi - if test "$1" != 1 + if test "$1" != 2 then echo "Unsupported core.fsmonitor hook version." >&2 exit 1 fi + printf "last_update_token\0" printf "untracked\0" printf "dir1/untracked\0" printf "dir2/untracked\0" @@ -106,6 +107,9 @@ EOF # test that "update-index --fsmonitor-valid" sets the fsmonitor valid bit test_expect_success 'update-index --fsmonitor-valid" sets the fsmonitor valid bit' ' + write_script .git/hooks/fsmonitor-test<<-\EOF && + printf "last_update_token\0" + EOF git update-index --fsmonitor && git update-index --fsmonitor-valid dir1/modified && git update-index --fsmonitor-valid dir2/modified && @@ -164,6 +168,9 @@ EOF # test that newly added files are marked valid test_expect_success 'newly added files are marked valid' ' + write_script .git/hooks/fsmonitor-test<<-\EOF && + printf "last_update_token\0" + EOF git add new && git add dir1/new && git add dir2/new && @@ -203,6 +210,7 @@ EOF # test that *only* files returned by the integration script get flagged as invalid test_expect_success '*only* files returned by the integration script get flagged as invalid' ' write_script .git/hooks/fsmonitor-test<<-\EOF && + printf "last_update_token\0" printf "dir1/modified\0" EOF clean_repo && @@ -218,11 +226,12 @@ test_expect_success '*only* files returned by the integration script get flagged # Ensure commands that call refresh_index() to move the index back in time # properly invalidate the fsmonitor cache test_expect_success 'refresh_index() invalidates fsmonitor cache' ' - write_script .git/hooks/fsmonitor-test<<-\EOF && - EOF clean_repo && dirty_repo && + write_integration_script && git add . && + write_script .git/hooks/fsmonitor-test<<-\EOF && + EOF git commit -m "to reset" && git reset HEAD~1 && git status >actual && @@ -271,6 +280,7 @@ do # (if enabled) files unless it is told about them. test_expect_success "status doesn't detect unreported modifications" ' write_script .git/hooks/fsmonitor-test<<-\EOF && + printf "last_update_token\0" :>marker EOF clean_repo && @@ -294,7 +304,7 @@ do done done -# test that splitting the index dosn't interfere +# test that splitting the index doesn't interfere test_expect_success 'splitting the index results in the same state' ' write_integration_script && dirty_repo && @@ -354,4 +364,23 @@ test_expect_success 'discard_index() also discards fsmonitor info' ' test_cmp expect actual ' +# Test unstaging entries that: +# - Are not flagged with CE_FSMONITOR_VALID +# - Have a position in the index >= the number of entries present in the index +# after unstaging. +test_expect_success 'status succeeds after staging/unstaging' ' + test_create_repo fsmonitor-stage-unstage && + ( + cd fsmonitor-stage-unstage && + test_commit initial && + git update-index --fsmonitor && + removed=$(test_seq 1 100 | sed "s/^/z/") && + touch $removed && + git add $removed && + git config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-env" && + FSMONITOR_LIST="$removed" git restore -S $removed && + FSMONITOR_LIST="$removed" git status + ) +' + test_done diff --git a/t/t7519/fsmonitor-all b/t/t7519/fsmonitor-all index 691bc94dc2c8..94ab66bd3d86 100755 --- a/t/t7519/fsmonitor-all +++ b/t/t7519/fsmonitor-all @@ -17,7 +17,6 @@ fi if test "$1" != 1 then - echo "Unsupported core.fsmonitor hook version." >&2 exit 1 fi diff --git a/t/t7519/fsmonitor-all-v2 b/t/t7519/fsmonitor-all-v2 new file mode 100755 index 000000000000..061907e88b65 --- /dev/null +++ b/t/t7519/fsmonitor-all-v2 @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use strict; +use warnings; +# +# An test hook script to integrate with git to test fsmonitor. +# +# The hook is passed a version (currently 2) and since token +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +#echo "$0 $*" >&2 +my ($version, $last_update_token) = @ARGV; + +if ($version ne 2) { + print "Unsupported query-fsmonitor hook version '$version'.\n"; + exit 1; +} + +print "last_update_token\0/\0" diff --git a/t/t7519/fsmonitor-env b/t/t7519/fsmonitor-env new file mode 100755 index 000000000000..8f1f7ab164e1 --- /dev/null +++ b/t/t7519/fsmonitor-env @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An test hook script to integrate with git to test fsmonitor. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +#echo "$0 $*" >&2 + +if test "$#" -ne 2 +then + echo "$0: exactly 2 arguments expected" >&2 + exit 2 +fi + +if test "$1" != 1 +then + echo "Unsupported core.fsmonitor hook version." >&2 + exit 1 +fi + +printf '%s\n' $FSMONITOR_LIST diff --git a/t/t7519/fsmonitor-watchman b/t/t7519/fsmonitor-watchman index 5514edcf68be..264b9daf834e 100755 --- a/t/t7519/fsmonitor-watchman +++ b/t/t7519/fsmonitor-watchman @@ -23,10 +23,10 @@ my ($version, $time) = @ARGV; if ($version == 1) { # convert nanoseconds to seconds - $time = int $time / 1000000000; + # subtract one second to make sure watchman will return all changes + $time = int ($time / 1000000000) - 1; } else { - die "Unsupported query-fsmonitor hook version '$version'.\n" . - "Falling back to scanning...\n"; + exit 1; } my $git_work_tree; @@ -54,18 +54,12 @@ sub launch_watchman { # # To accomplish this, we're using the "since" generator to use the # recency index to select candidate nodes and "fields" to limit the - # output to file names only. Then we're using the "expression" term to - # further constrain the results. - # - # The category of transient files that we want to ignore will have a - # creation clock (cclock) newer than $time_t value and will also not - # currently exist. + # output to file names only. my $query = <<" END"; ["query", "$git_work_tree", { "since": $time, - "fields": ["name"], - "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + "fields": ["name"] }] END diff --git a/t/t7519/fsmonitor-watchman-v2 b/t/t7519/fsmonitor-watchman-v2 new file mode 100755 index 000000000000..14ed0aa42de0 --- /dev/null +++ b/t/t7519/fsmonitor-watchman-v2 @@ -0,0 +1,173 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 2) and last update token +# formatted as a string and outputs to stdout a new update token and +# all files that have been modified since the update token. Paths must +# be relative to the root of the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $last_update_token) = @ARGV; + +# Uncomment for debugging +# print STDERR "$0 $version $last_update_token\n"; + +# Check the hook interface version +if ($version ne 2) { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree = get_working_dir(); + +my $retry = 1; + +my $json_pkg; +eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; +} or do { + require JSON::PP; + $json_pkg = "JSON::PP"; +}; + +launch_watchman(); + +sub launch_watchman { + my $o = watchman_query(); + if (is_work_tree_watched($o)) { + output_result($o->{clock}, @{$o->{files}}); + } +} + +sub output_result { + my ($clockid, @files) = @_; + + # Uncomment for debugging watchman output + # open (my $fh, ">", ".git/watchman-output.out"); + # binmode $fh, ":utf8"; + # print $fh "$clockid\n@files\n"; + # close $fh; + + binmode STDOUT, ":utf8"; + print $clockid; + print "\0"; + local $, = "\0"; + print @files; +} + +sub watchman_clock { + my $response = qx/watchman clock "$git_work_tree"/; + die "Failed to get clock id on '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + return $json_pkg->new->utf8->decode($response); +} + +sub watchman_query { + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $last_update_token but not from the .git folder. + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + if (substr($last_update_token, 0, 1) eq "c") { + $last_update_token = "\"$last_update_token\""; + } + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $last_update_token, + "fields": ["name"], + "expression": ["not", ["dirname", ".git"]] + }] + END + + # Uncomment for debugging the watchman query + # open (my $fh, ">", ".git/watchman-query.json"); + # print $fh $query; + # close $fh; + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + # Uncomment for debugging the watch response + # open ($fh, ">", ".git/watchman-response.json"); + # print $fh $response; + # close $fh; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + return $json_pkg->new->utf8->decode($response); +} + +sub is_work_tree_watched { + my ($output) = @_; + my $error = $output->{error}; + if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) { + $retry--; + my $response = qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + $output = $json_pkg->new->utf8->decode($response); + $error = $output->{error}; + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + # Uncomment for debugging watchman output + # open (my $fh, ">", ".git/watchman-output.out"); + # close $fh; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + my $o = watchman_clock(); + $error = $output->{error}; + + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + output_result($o->{clock}, ("/")); + $last_update_token = $o->{clock}; + + eval { launch_watchman() }; + return 0; + } + + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + return 1; +} + +sub get_working_dir { + my $working_dir; + if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $working_dir = Win32::GetCwd(); + $working_dir =~ tr/\\/\//; + } else { + require Cwd; + $working_dir = Cwd::cwd(); + } + + return $working_dir; +} diff --git a/t/t7526-commit-pathspec-file.sh b/t/t7526-commit-pathspec-file.sh new file mode 100755 index 000000000000..5fbe47ebcd02 --- /dev/null +++ b/t/t7526-commit-pathspec-file.sh @@ -0,0 +1,164 @@ +#!/bin/sh + +test_description='commit --pathspec-from-file' + +. ./test-lib.sh + +test_tick + +test_expect_success setup ' + test_commit file0 && + git tag checkpoint && + + echo A >fileA.t && + echo B >fileB.t && + echo C >fileC.t && + echo D >fileD.t && + git add fileA.t fileB.t fileC.t fileD.t +' + +restore_checkpoint () { + git reset --soft checkpoint +} + +verify_expect () { + git diff-tree --no-commit-id --name-status -r HEAD >actual && + test_cmp expect actual +} + +test_expect_success '--pathspec-from-file from stdin' ' + restore_checkpoint && + + echo fileA.t | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect +' + +test_expect_success '--pathspec-from-file from file' ' + restore_checkpoint && + + echo fileA.t >list && + git commit --pathspec-from-file=list -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect +' + +test_expect_success 'NUL delimiters' ' + restore_checkpoint && + + printf "fileA.t\0fileB.t\0" | git commit --pathspec-from-file=- --pathspec-file-nul -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'LF delimiters' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t\n" | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'no trailing delimiter' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t" | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'CRLF delimiters' ' + restore_checkpoint && + + printf "fileA.t\r\nfileB.t\r\n" | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'quotes' ' + restore_checkpoint && + + cat >list <<-\EOF && + "file\101.t" + EOF + + git commit --pathspec-from-file=list -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect expect +' + +test_expect_success 'quotes not compatible with --pathspec-file-nul' ' + restore_checkpoint && + + cat >list <<-\EOF && + "file\101.t" + EOF + + test_must_fail git commit --pathspec-from-file=list --pathspec-file-nul -m "Commit" +' + +test_expect_success 'only touches what was listed' ' + restore_checkpoint && + + printf "fileB.t\nfileC.t\n" | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileB.t + A fileC.t + EOF + verify_expect +' + +test_expect_success 'error conditions' ' + restore_checkpoint && + echo fileA.t >list && + >empty_list && + + test_must_fail git commit --pathspec-from-file=list --interactive -m "Commit" 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err && + + test_must_fail git commit --pathspec-from-file=list --patch -m "Commit" 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err && + + test_must_fail git commit --pathspec-from-file=list --all -m "Commit" 2>err && + test_i18ngrep -e "--pathspec-from-file with -a does not make sense" err && + + test_must_fail git commit --pathspec-from-file=list -m "Commit" -- fileA.t 2>err && + test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err && + + test_must_fail git commit --pathspec-file-nul -m "Commit" 2>err && + test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err && + + test_must_fail git commit --pathspec-from-file=empty_list --include -m "Commit" 2>err && + test_i18ngrep -e "No paths with --include/--only does not make sense." err && + + test_must_fail git commit --pathspec-from-file=empty_list --only -m "Commit" 2>err && + test_i18ngrep -e "No paths with --include/--only does not make sense." err +' + +test_done diff --git a/t/t7612-merge-verify-signatures.sh b/t/t7612-merge-verify-signatures.sh index d99218a725c5..a426f3a89aa7 100755 --- a/t/t7612-merge-verify-signatures.sh +++ b/t/t7612-merge-verify-signatures.sh @@ -66,6 +66,20 @@ test_expect_success GPG 'merge commit with untrusted signature with verification test_i18ngrep "has an untrusted GPG signature" mergeerror ' +test_expect_success GPG 'merge commit with untrusted signature with verification and high minTrustLevel' ' + test_when_finished "git reset --hard && git checkout initial" && + test_config gpg.minTrustLevel marginal && + test_must_fail git merge --ff-only --verify-signatures side-untrusted 2>mergeerror && + test_i18ngrep "has an untrusted GPG signature" mergeerror +' + +test_expect_success GPG 'merge commit with untrusted signature with verification and low minTrustLevel' ' + test_when_finished "git reset --hard && git checkout initial" && + test_config gpg.minTrustLevel undefined && + git merge --ff-only --verify-signatures side-untrusted >mergeoutput && + test_i18ngrep "has a good GPG signature" mergeoutput +' + test_expect_success GPG 'merge commit with untrusted signature with merge.verifySignatures=true' ' test_when_finished "git reset --hard && git checkout initial" && test_config merge.verifySignatures true && @@ -73,6 +87,14 @@ test_expect_success GPG 'merge commit with untrusted signature with merge.verify test_i18ngrep "has an untrusted GPG signature" mergeerror ' +test_expect_success GPG 'merge commit with untrusted signature with merge.verifySignatures=true and minTrustLevel' ' + test_when_finished "git reset --hard && git checkout initial" && + test_config merge.verifySignatures true && + test_config gpg.minTrustLevel marginal && + test_must_fail git merge --ff-only side-untrusted 2>mergeerror && + test_i18ngrep "has an untrusted GPG signature" mergeerror +' + test_expect_success GPG 'merge signed commit with verification' ' test_when_finished "git reset --hard && git checkout initial" && git merge --verbose --ff-only --verify-signatures side-signed >mergeoutput && diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 4e855bc21b45..25b235c06303 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -4,129 +4,104 @@ test_description='git repack works correctly' . ./test-lib.sh -commit_and_pack() { - test_commit "$@" >/dev/null && - SHA1=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack &2 && + incrpackid=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack orig.raw && + sed -n -e "s/^\($OID_REGEX\).*/\1/p" orig.raw | sort >orig && + git verify-pack -v $myidx >dest.raw && + cut -d" " -f1 dest.raw | sort >dest && + comm -23 orig dest >missing && + test_must_be_empty missing +} + +# we expect $packid and $oid to be defined +test_has_duplicate_object () { + want_duplicate_object="$1" + found_duplicate_object=false + for p in .git/objects/pack/*.idx + do + idx=$(basename $p) + test "pack-$packid.idx" = "$idx" && continue + git verify-pack -v $p >packlist || return $? + if grep "^$oid" packlist + then + found_duplicate_object=true + echo "DUPLICATE OBJECT FOUND" + break + fi + done && + test "$want_duplicate_object" = "$found_duplicate_object" } test_expect_success 'objects in packs marked .keep are not repacked' ' - echo content1 > file1 && - echo content2 > file2 && + echo content1 >file1 && + echo content2 >file2 && git add . && test_tick && git commit -m initial_commit && # Create two packs # The first pack will contain all of the objects except one - git rev-list --objects --all | grep -v file2 | - git pack-objects pack > /dev/null && + git rev-list --objects --all >objs && + grep -v file2 objs | git pack-objects pack && # The second pack will contain the excluded object - packsha1=$(git rev-list --objects --all | grep file2 | - git pack-objects pack) && - >pack-$packsha1.keep && - objsha1=$(git verify-pack -v pack-$packsha1.idx | head -n 1 | - sed -e "s/^\([0-9a-f]\{40\}\).*/\1/") && + packid=$(grep file2 objs | git pack-objects pack) && + >pack-$packid.keep && + git verify-pack -v pack-$packid.idx >packlist && + oid=$(head -n 1 packlist | sed -e "s/^\($OID_REGEX\).*/\1/") && mv pack-* .git/objects/pack/ && git repack -A -d -l && git prune-packed && - for p in .git/objects/pack/*.idx; do - idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1"; then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test -z "$found_duplicate_object" + test_has_duplicate_object false ' test_expect_success 'writing bitmaps via command-line can duplicate .keep objects' ' - # build on $objsha1, $packsha1, and .keep state from previous + # build on $oid, $packid, and .keep state from previous git repack -Adbl && - test_when_finished "found_duplicate_object=" && - for p in .git/objects/pack/*.idx; do - idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1"; then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test "$found_duplicate_object" = 1 + test_has_duplicate_object true ' test_expect_success 'writing bitmaps via config can duplicate .keep objects' ' - # build on $objsha1, $packsha1, and .keep state from previous + # build on $oid, $packid, and .keep state from previous git -c repack.writebitmaps=true repack -Adl && - test_when_finished "found_duplicate_object=" && - for p in .git/objects/pack/*.idx; do - idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1"; then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test "$found_duplicate_object" = 1 + test_has_duplicate_object true ' test_expect_success 'loose objects in alternate ODB are not repacked' ' mkdir alt_objects && - echo $(pwd)/alt_objects > .git/objects/info/alternates && - echo content3 > file3 && - objsha1=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) && + echo $(pwd)/alt_objects >.git/objects/info/alternates && + echo content3 >file3 && + oid=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) && git add file3 && test_tick && git commit -m commit_file3 && git repack -a -d -l && git prune-packed && - for p in .git/objects/pack/*.idx; do - if git verify-pack -v $p | egrep "^$objsha1"; then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test -z "$found_duplicate_object" + test_has_duplicate_object false ' test_expect_success 'packed obs in alt ODB are repacked even when local repo is packless' ' mkdir alt_objects/pack && mv .git/objects/pack/* alt_objects/pack && git repack -a && - myidx=$(ls -1 .git/objects/pack/*.idx) && - test -f "$myidx" && - for p in alt_objects/pack/*.idx; do - git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest; do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then - echo "Missing object in local pack: $sha1" - return 1 - fi - done + test_no_missing_in_packs ' test_expect_success 'packed obs in alt ODB are repacked when local repo has packs' ' rm -f .git/objects/pack/* && - echo new_content >> file1 && + echo new_content >>file1 && git add file1 && test_tick && git commit -m more_content && git repack && git repack -a -d && - myidx=$(ls -1 .git/objects/pack/*.idx) && - test -f "$myidx" && - for p in alt_objects/pack/*.idx; do - git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest; do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then - echo "Missing object in local pack: $sha1" - return 1 - fi - done + test_no_missing_in_packs ' test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' @@ -134,7 +109,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' for p in alt_objects/pack/*.pack do base_name=$(basename $p .pack) && - if test -f alt_objects/pack/$base_name.keep + if test_path_is_file alt_objects/pack/$base_name.keep then rm alt_objects/pack/$base_name.keep else @@ -142,22 +117,13 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' fi done && git repack -a -d && - myidx=$(ls -1 .git/objects/pack/*.idx) && - test -f "$myidx" && - for p in alt_objects/pack/*.idx; do - git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest; do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then - echo "Missing object in local pack: $sha1" - return 1 - fi - done + test_no_missing_in_packs ' test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' rm -f alt_objects/pack/*.keep && mv .git/objects/pack/* alt_objects/pack/ && - csha1=$(git rev-parse HEAD^{commit}) && + coid=$(git rev-parse HEAD^{commit}) && git reset --hard HEAD^ && test_tick && git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all && @@ -167,15 +133,15 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' --unpack-unreachable .git/objects/info/alternates && - test_must_fail git show $csha1 + git verify-pack -v -- .git/objects/pack/*.idx >packlist && + ! grep "^$coid " packlist && + echo >.git/objects/info/alternates && + test_must_fail git show $coid ' test_expect_success 'local packed unreachable obs that exist in alternate ODB are not loosened' ' - echo $(pwd)/alt_objects > .git/objects/info/alternates && - echo "$csha1" | git pack-objects --non-empty --all --reflog pack && + echo $(pwd)/alt_objects >.git/objects/info/alternates && + echo "$coid" | git pack-objects --non-empty --all --reflog pack && rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && # The pack-objects call on the next line is equivalent to @@ -184,10 +150,10 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar --unpack-unreachable .git/objects/info/alternates && - test_must_fail git show $csha1 + git verify-pack -v -- .git/objects/pack/*.idx >packlist && + ! grep "^$coid " && + echo >.git/objects/info/alternates && + test_must_fail git show $coid ' test_expect_success 'objects made unreachable by grafts only are kept' ' @@ -196,7 +162,7 @@ test_expect_success 'objects made unreachable by grafts only are kept' ' H0=$(git rev-parse HEAD) && H1=$(git rev-parse HEAD^) && H2=$(git rev-parse HEAD^^) && - echo "$H0 $H2" > .git/info/grafts && + echo "$H0 $H2" >.git/info/grafts && git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all && git repack -a -d && git cat-file -t $H1 @@ -235,7 +201,7 @@ test_expect_success 'incremental repack does not complain' ' test_expect_success 'bitmaps can be disabled on bare repos' ' git -c repack.writeBitmaps=false -C bare.git repack -ad && - bitmap=$(ls bare.git/objects/pack/*.bitmap 2>/dev/null || :) && + bitmap=$(ls bare.git/objects/pack/*.bitmap || :) && test -z "$bitmap" ' diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 6bac9ed180e7..29b92907e2ad 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -125,15 +125,14 @@ test_expect_success 'difftool stops on error with --trust-exit-code' ' test_when_finished "rm -f for-diff .git/fail-right-file" && test_when_finished "git reset -- for-diff" && write_script .git/fail-right-file <<-\EOF && - echo "$2" + echo failed exit 1 EOF >for-diff && git add for-diff && - echo file >expect && test_must_fail git difftool -y --trust-exit-code \ --extcmd .git/fail-right-file branch >actual && - test_cmp expect actual + test_line_count = 1 actual ' test_expect_success 'difftool honors exit status if command not found' ' diff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh index d1ebfd88c7a9..a98785da7955 100755 --- a/t/t7811-grep-open.sh +++ b/t/t7811-grep-open.sh @@ -113,7 +113,6 @@ test_expect_success 'modified file' ' subdir/grep.c unrelated EOF - >empty && echo "enum grep_pat_token" >unrelated && test_when_finished "git checkout HEAD unrelated" && diff --git a/t/t7812-grep-icase-non-ascii.sh b/t/t7812-grep-icase-non-ascii.sh index 0c685d35986e..03dba6685ab7 100755 --- a/t/t7812-grep-icase-non-ascii.sh +++ b/t/t7812-grep-icase-non-ascii.sh @@ -53,4 +53,35 @@ test_expect_success REGEX_LOCALE 'pickaxe -i on non-ascii' ' test_cmp expected actual ' +test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: setup invalid UTF-8 data' ' + printf "\\200\\n" >invalid-0x80 && + echo "ævar" >expected && + cat expected >>invalid-0x80 && + git add invalid-0x80 +' + +test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UTF-8 data' ' + git grep -h "var" invalid-0x80 >actual && + test_cmp expected actual && + git grep -h "(*NO_JIT)var" invalid-0x80 >actual && + test_cmp expected actual +' + +test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data' ' + git grep -h "æ" invalid-0x80 >actual && + test_cmp expected actual && + git grep -h "(*NO_JIT)æ" invalid-0x80 >actual && + test_cmp expected actual +' + +test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' ' + test_might_fail git grep -hi "Æ" invalid-0x80 >actual && + if test -s actual + then + test_cmp expected actual + fi && + test_must_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual && + ! test_cmp expected actual +' + test_done diff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh index a11366b4cee4..828cb3ba5818 100755 --- a/t/t7814-grep-recurse-submodules.sh +++ b/t/t7814-grep-recurse-submodules.sh @@ -345,7 +345,16 @@ test_incompatible_with_recurse_submodules () } test_incompatible_with_recurse_submodules --untracked -test_incompatible_with_recurse_submodules --no-index + +test_expect_success 'grep --recurse-submodules --no-index ignores --recurse-submodules' ' + git grep --recurse-submodules --no-index -e "^(.|.)[\d]" >actual && + cat >expect <<-\EOF && + a:(1|2)d(3|4) + submodule/a:(1|2)d(3|4) + submodule/sub/a:(1|2)d(3|4) + EOF + test_cmp expect actual +' test_expect_success 'grep --recurse-submodules should pass the pattern type along' ' # Fixed @@ -408,4 +417,25 @@ test_expect_success 'grep --recurse-submodules with submodules without .gitmodul test_cmp expect actual ' +reset_and_clean () { + git reset --hard && + git clean -fd && + git submodule foreach --recursive 'git reset --hard' && + git submodule foreach --recursive 'git clean -fd' +} + +test_expect_success 'grep --recurse-submodules without --cached considers worktree modifications' ' + reset_and_clean && + echo "A modified line in submodule" >>submodule/a && + echo "submodule/a:A modified line in submodule" >expect && + git grep --recurse-submodules "A modified line in submodule" >actual && + test_cmp expect actual +' + +test_expect_success 'grep --recurse-submodules with --cached ignores worktree modifications' ' + reset_and_clean && + echo "A modified line in submodule" >>submodule/a && + test_must_fail git grep --recurse-submodules --cached "A modified line in submodule" >actual 2>&1 && + test_must_be_empty actual +' test_done diff --git a/t/t7815-grep-binary.sh b/t/t7815-grep-binary.sh new file mode 100755 index 000000000000..90ebb64f46eb --- /dev/null +++ b/t/t7815-grep-binary.sh @@ -0,0 +1,148 @@ +#!/bin/sh + +test_description='git grep in binary files' + +. ./test-lib.sh + +test_expect_success 'setup' " + echo 'binaryQfileQm[*]cQ*æQð' | q_to_nul >a && + git add a && + git commit -m. +" + +test_expect_success 'git grep ina a' ' + echo Binary file a matches >expect && + git grep ina a >actual && + test_cmp expect actual +' + +test_expect_success 'git grep -ah ina a' ' + git grep -ah ina a >actual && + test_cmp a actual +' + +test_expect_success 'git grep -I ina a' ' + test_must_fail git grep -I ina a >actual && + test_must_be_empty actual +' + +test_expect_success 'git grep -c ina a' ' + echo a:1 >expect && + git grep -c ina a >actual && + test_cmp expect actual +' + +test_expect_success 'git grep -l ina a' ' + echo a >expect && + git grep -l ina a >actual && + test_cmp expect actual +' + +test_expect_success 'git grep -L bar a' ' + echo a >expect && + git grep -L bar a >actual && + test_cmp expect actual +' + +test_expect_success 'git grep -q ina a' ' + git grep -q ina a >actual && + test_must_be_empty actual +' + +test_expect_success 'git grep -F ile a' ' + git grep -F ile a +' + +test_expect_success 'git grep -Fi iLE a' ' + git grep -Fi iLE a +' + +# This test actually passes on platforms where regexec() supports the +# flag REG_STARTEND. +test_expect_success 'git grep ile a' ' + git grep ile a +' + +test_expect_failure 'git grep .fi a' ' + git grep .fi a +' + +test_expect_success 'grep respects binary diff attribute' ' + echo text >t && + git add t && + echo t:text >expect && + git grep text t >actual && + test_cmp expect actual && + echo "t -diff" >.gitattributes && + echo "Binary file t matches" >expect && + git grep text t >actual && + test_cmp expect actual +' + +test_expect_success 'grep --cached respects binary diff attribute' ' + git grep --cached text t >actual && + test_cmp expect actual +' + +test_expect_success 'grep --cached respects binary diff attribute (2)' ' + git add .gitattributes && + rm .gitattributes && + git grep --cached text t >actual && + test_when_finished "git rm --cached .gitattributes" && + test_when_finished "git checkout .gitattributes" && + test_cmp expect actual +' + +test_expect_success 'grep revision respects binary diff attribute' ' + git commit -m new && + echo "Binary file HEAD:t matches" >expect && + git grep text HEAD -- t >actual && + test_when_finished "git reset HEAD^" && + test_cmp expect actual +' + +test_expect_success 'grep respects not-binary diff attribute' ' + echo binQary | q_to_nul >b && + git add b && + echo "Binary file b matches" >expect && + git grep bin b >actual && + test_cmp expect actual && + echo "b diff" >.gitattributes && + echo "b:binQary" >expect && + git grep bin b >actual.raw && + nul_to_q actual && + test_cmp expect actual +' + +cat >nul_to_q_textconv <<'EOF' +#!/bin/sh +"$PERL_PATH" -pe 'y/\000/Q/' < "$1" +EOF +chmod +x nul_to_q_textconv + +test_expect_success 'setup textconv filters' ' + echo a diff=foo >.gitattributes && + git config diff.foo.textconv "\"$(pwd)\""/nul_to_q_textconv +' + +test_expect_success 'grep does not honor textconv' ' + test_must_fail git grep Qfile +' + +test_expect_success 'grep --textconv honors textconv' ' + echo "a:binaryQfileQm[*]cQ*æQð" >expect && + git grep --textconv Qfile >actual && + test_cmp expect actual +' + +test_expect_success 'grep --no-textconv does not honor textconv' ' + test_must_fail git grep --no-textconv Qfile +' + +test_expect_success 'grep --textconv blob honors textconv' ' + echo "HEAD:a:binaryQfileQm[*]cQ*æQð" >expect && + git grep --textconv Qfile HEAD:a >actual && + test_cmp expect actual +' + +test_done diff --git a/t/t7816-grep-binary-pattern.sh b/t/t7816-grep-binary-pattern.sh new file mode 100755 index 000000000000..60bab291e49c --- /dev/null +++ b/t/t7816-grep-binary-pattern.sh @@ -0,0 +1,127 @@ +#!/bin/sh + +test_description='git grep with a binary pattern files' + +. ./lib-gettext.sh + +nul_match_internal () { + matches=$1 + prereqs=$2 + lc_all=$3 + extra_flags=$4 + flags=$5 + pattern=$6 + pattern_human=$(echo "$pattern" | sed 's/Q//g') + + if test "$matches" = 1 + then + test_expect_success $prereqs "LC_ALL='$lc_all' git grep $extra_flags -f f $flags '$pattern_human' a" " + printf '$pattern' | q_to_nul >f && + LC_ALL='$lc_all' git grep $extra_flags -f f $flags a + " + elif test "$matches" = 0 + then + test_expect_success $prereqs "LC_ALL='$lc_all' git grep $extra_flags -f f $flags '$pattern_human' a" " + >stderr && + printf '$pattern' | q_to_nul >f && + test_must_fail env LC_ALL=\"$lc_all\" git grep $extra_flags -f f $flags a 2>stderr && + test_i18ngrep ! 'This is only supported with -P under PCRE v2' stderr + " + elif test "$matches" = P + then + test_expect_success $prereqs "error, PCRE v2 only: LC_ALL='$lc_all' git grep -f f $flags '$pattern_human' a" " + >stderr && + printf '$pattern' | q_to_nul >f && + test_must_fail env LC_ALL=\"$lc_all\" git grep -f f $flags a 2>stderr && + test_i18ngrep 'This is only supported with -P under PCRE v2' stderr + " + else + test_expect_success "PANIC: Test framework error. Unknown matches value $matches" 'false' + fi +} + +nul_match () { + matches=$1 + matches_pcre2=$2 + matches_pcre2_locale=$3 + flags=$4 + pattern=$5 + pattern_human=$(echo "$pattern" | sed 's/Q//g') + + nul_match_internal "$matches" "" "C" "" "$flags" "$pattern" + nul_match_internal "$matches_pcre2" "LIBPCRE2" "C" "-P" "$flags" "$pattern" + nul_match_internal "$matches_pcre2_locale" "LIBPCRE2,GETTEXT_LOCALE" "$is_IS_locale" "-P" "$flags" "$pattern" +} + +test_expect_success 'setup' " + echo 'binaryQfileQm[*]cQ*æQð' | q_to_nul >a && + git add a && + git commit -m. +" + +# Simple fixed-string matching that can use kwset (no -i && non-ASCII) +nul_match P P P '-F' 'yQf' +nul_match P P P '-F' 'yQx' +nul_match P P P '-Fi' 'YQf' +nul_match P P P '-Fi' 'YQx' +nul_match P P 1 '' 'yQf' +nul_match P P 0 '' 'yQx' +nul_match P P 1 '' 'æQð' +nul_match P P P '-F' 'eQm[*]c' +nul_match P P P '-Fi' 'EQM[*]C' + +# Regex patterns that would match but shouldn't with -F +nul_match P P P '-F' 'yQ[f]' +nul_match P P P '-F' '[y]Qf' +nul_match P P P '-Fi' 'YQ[F]' +nul_match P P P '-Fi' '[Y]QF' +nul_match P P P '-F' 'æQ[ð]' +nul_match P P P '-F' '[æ]Qð' + +# The -F kwset codepath can't handle -i && non-ASCII... +nul_match P 1 1 '-i' '[æ]Qð' + +# ...PCRE v2 only matches non-ASCII with -i casefolding under UTF-8 +# semantics +nul_match P P P '-Fi' 'ÆQ[Ð]' +nul_match P 0 1 '-i' 'ÆQ[Ð]' +nul_match P 0 1 '-i' '[Æ]QÐ' +nul_match P 0 1 '-i' '[Æ]Qð' +nul_match P 0 1 '-i' 'ÆQÐ' + +# \0 in regexes can only work with -P & PCRE v2 +nul_match P P 1 '' 'yQ[f]' +nul_match P P 1 '' '[y]Qf' +nul_match P P 1 '-i' 'YQ[F]' +nul_match P P 1 '-i' '[Y]Qf' +nul_match P P 1 '' 'æQ[ð]' +nul_match P P 1 '' '[æ]Qð' +nul_match P P 1 '-i' 'ÆQ[Ð]' +nul_match P P 1 '' 'eQm.*cQ' +nul_match P P 1 '-i' 'EQM.*cQ' +nul_match P P 0 '' 'eQm[*]c' +nul_match P P 0 '-i' 'EQM[*]C' + +# Assert that we're using REG_STARTEND and the pattern doesn't match +# just because it's cut off at the first \0. +nul_match P P 0 '-i' 'NOMATCHQð' +nul_match P P 0 '-i' '[Æ]QNOMATCH' +nul_match P P 0 '-i' '[æ]QNOMATCH' + +# Ensure that the matcher doesn't regress to something that stops at +# \0 +nul_match P P P '-F' 'yQ[f]' +nul_match P P P '-Fi' 'YQ[F]' +nul_match P P 0 '' 'yQNOMATCH' +nul_match P P 0 '' 'QNOMATCH' +nul_match P P 0 '-i' 'YQNOMATCH' +nul_match P P 0 '-i' 'QNOMATCH' +nul_match P P P '-F' 'æQ[ð]' +nul_match P P P '-Fi' 'ÆQ[Ð]' +nul_match P P 1 '-i' 'ÆQ[Ð]' +nul_match P P 0 '' 'yQNÓMATCH' +nul_match P P 0 '' 'QNÓMATCH' +nul_match P P 0 '-i' 'YQNÓMATCH' +nul_match P P 0 '-i' 'QNÓMATCH' + +test_done diff --git a/t/t8003-blame-corner-cases.sh b/t/t8003-blame-corner-cases.sh index 1c5fb1d1f8c9..9130b887d2cc 100755 --- a/t/t8003-blame-corner-cases.sh +++ b/t/t8003-blame-corner-cases.sh @@ -173,7 +173,6 @@ test_expect_success 'blame during cherry-pick with file rename conflict' ' git show HEAD@{1}:rodent > rodent && git add rodent && git blame -f -C -C1 rodent | sed -e "$pick_fc" >current && - cat current && cat >expected <<-\EOF && mouse-Initial mouse-Second diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 997f90b42b3e..90f61c340095 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1194,8 +1194,8 @@ test_expect_success $PREREQ 'in-reply-to but no threading' ' --to=nobody@example.com \ --in-reply-to="" \ --no-thread \ - $patches | - grep "In-Reply-To: " + $patches >out && + grep "In-Reply-To: " out ' test_expect_success $PREREQ 'no in-reply-to and no threading' ' @@ -1260,7 +1260,7 @@ test_expect_success $PREREQ 'sendemail.identity: --no-identity clears previous i grep "To: default@example.com" stdout ' -test_expect_success $PREREQ 'sendemail.identity: bool identity variable existance overrides' ' +test_expect_success $PREREQ 'sendemail.identity: bool identity variable existence overrides' ' git -c sendemail.identity=cloud \ -c sendemail.xmailer=true \ -c sendemail.cloud.xmailer=false \ @@ -2066,7 +2066,7 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' ' TO1=$(echo "QTo 1 " | q_to_tab) && TO2=$(echo "QZto2" | qz_to_tab_space) && CC1=$(echo "cc1" | append_cr) && - BCC1=$(echo "Q bcc1@example.com Q" | q_to_nul) && + BCC1=$(echo " bcc1@example.com Q" | q_to_nul) && git send-email \ --dry-run \ --from=" Example " \ diff --git a/t/t9010-svn-fe.sh b/t/t9010-svn-fe.sh index 0b20b07e6898..c90fdc5c8940 100755 --- a/t/t9010-svn-fe.sh +++ b/t/t9010-svn-fe.sh @@ -53,8 +53,6 @@ text_no_props () { printf "%s\n" "$text" } ->empty - test_expect_success 'empty dump' ' reinit_git && echo "SVN-fs-dump-format-version: 2" >input && @@ -208,7 +206,7 @@ test_expect_failure 'timestamp and empty file' ' test_cmp expect.date actual.date && test_cmp expect.files actual.files && git checkout HEAD empty-file && - test_cmp empty file + test_must_be_empty file ' test_expect_success 'directory with files' ' diff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh index dbe8deac0d2f..aec45bca3b7b 100755 --- a/t/t9106-git-svn-commit-diff-clobber.sh +++ b/t/t9106-git-svn-commit-diff-clobber.sh @@ -92,7 +92,8 @@ test_expect_success 'multiple dcommit from git svn will not clobber svn' " test_expect_success 'check that rebase really failed' ' - test -d .git/rebase-apply + git status >output && + grep currently.rebasing output ' test_expect_success 'resolve, continue the rebase and dcommit' " diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh index 45773ee560da..0a9f1ef366db 100755 --- a/t/t9116-git-svn-log.sh +++ b/t/t9116-git-svn-log.sh @@ -43,14 +43,18 @@ test_expect_success 'setup repository and import' ' test_expect_success 'run log' " git reset --hard origin/a && - git svn log -r2 origin/trunk | grep ^r2 && - git svn log -r4 origin/trunk | grep ^r4 && - git svn log -r3 | grep ^r3 + git svn log -r2 origin/trunk >out && + grep ^r2 out && + git svn log -r4 origin/trunk >out && + grep ^r4 out && + git svn log -r3 >out && + grep ^r3 out " test_expect_success 'run log against a from trunk' " git reset --hard origin/trunk && - git svn log -r3 origin/a | grep ^r3 + git svn log -r3 origin/a >out && + grep ^r3 out " printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4 diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 141b7fa35e74..3e41c58a1368 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -85,6 +85,36 @@ test_expect_success 'A: create pack from stdin' ' An annotated tag that annotates a blob. EOF + tag to-be-deleted + from :3 + data <expect <<-EOF && :2 $(git rev-parse --verify master:file2) :3 $(git rev-parse --verify master:file3) :4 $(git rev-parse --verify master:file4) :5 $(git rev-parse --verify master^0) + :6 $(git cat-file tag nested | grep object | cut -d" " -f 2) + :7 $(git rev-parse --verify nested) + :8 $(git rev-parse --verify master^0) EOF test_cmp expect marks.out ' @@ -1010,7 +1047,6 @@ test_expect_success 'M: rename root to subdirectory' ' EOF git fast-import actual && - cat actual && compare_diff_raw expect actual ' @@ -2106,12 +2142,27 @@ test_expect_success 'R: abort on receiving feature after data command' ' test_must_fail git fast-import git.marks && + echo "feature import-marks=git.marks" >input && + test_must_fail git fast-import input && + test_must_fail git fast-import git.marks && + >git2.marks && cat >input <<-EOF && feature import-marks=git.marks feature import-marks=git2.marks EOF + test_must_fail git fast-import --allow-unsafe-features input && test_must_fail git fast-import input <<-\EOF && + feature export-marks=feature-sub/git.marks + blob + mark :1 + data 3 + hi + + EOF + git fast-import --allow-unsafe-features \ + --export-marks=cmdline-sub/other.marks expect && echo ":2 $blob" >>expect && - git fast-import --export-marks=io.marks <<-\EOF && + git fast-import --export-marks=io.marks \ + --allow-unsafe-features <<-\EOF && feature import-marks-if-exists=io.marks blob mark :2 @@ -2216,7 +2279,8 @@ test_expect_success 'R: feature import-marks-if-exists' ' echo ":3 $blob" >>expect && git fast-import --import-marks=io.marks \ - --export-marks=io.marks <<-\EOF && + --export-marks=io.marks \ + --allow-unsafe-features <<-\EOF && feature import-marks-if-exists=not_io.marks blob mark :3 @@ -2227,7 +2291,8 @@ test_expect_success 'R: feature import-marks-if-exists' ' test_cmp expect io.marks && git fast-import --import-marks-if-exists=not_io.marks \ - --export-marks=io.marks <<-\EOF && + --export-marks=io.marks \ + --allow-unsafe-features <<-\EOF && feature import-marks-if-exists=io.marks EOF test_must_be_empty io.marks @@ -2239,7 +2304,7 @@ test_expect_success 'R: import to output marks works without any content' ' feature export-marks=marks.new EOF - cat input | git fast-import && + git fast-import --allow-unsafe-features one.marks && tail -n +3 marks.out > two.marks && - git fast-import --import-marks=one.marks --import-marks=two.marks expect.response && rm -f blobs && - cat >frontend <<-\FRONTEND_END && - #!/bin/sh - FRONTEND_END mkfifo blobs && ( @@ -2557,7 +2620,7 @@ test_expect_success 'R: quiet option results in no stats being output' ' EOF - cat input | git fast-import 2> output && + git fast-import 2>output err && cat-blob :403x EOF - cat err && test_i18ngrep "after mark" err ' @@ -2966,7 +3018,6 @@ test_expect_success 'S: ls with garbage after mark must fail' ' test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && ls :302x hello.c EOF - cat err && test_i18ngrep "space after mark" err ' @@ -2975,7 +3026,6 @@ test_expect_success 'S: ls with garbage after sha1 must fail' ' test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && ls ${sha1}x hello.c EOF - cat err && test_i18ngrep "space after tree-ish" err ' @@ -3140,13 +3190,22 @@ background_import_then_checkpoint () { exec 9<>V.output rm V.output - git fast-import $options <&8 >&9 & - echo $! >V.pid + ( + git fast-import $options <&8 >&9 & + echo $! >&9 + wait $! + echo >&2 "background fast-import terminated too early with exit code $?" + # Un-block the read loop in the main shell process. + echo >&9 UNEXPECTED + ) & + sh_pid=$! + read fi_pid <&9 # We don't mind if fast-import has already died by the time the test # ends. test_when_finished " exec 8>&-; exec 9>&-; - kill $(cat V.pid) && wait $(cat V.pid) + kill $sh_pid && wait $sh_pid + kill $fi_pid && wait $fi_pid true" # Start in the background to ensure we adhere strictly to (blocking) @@ -3166,6 +3225,9 @@ background_import_then_checkpoint () { then error=0 break + elif test "$output" = "UNEXPECTED" + then + break fi # otherwise ignore cruft echo >&2 "cruft: $output" @@ -3178,7 +3240,7 @@ background_import_then_checkpoint () { } background_import_still_running () { - if ! kill -0 "$(cat V.pid)" + if ! kill -0 "$fi_pid" then echo >&2 "background fast-import terminated too early" false diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh index dadc70b7d570..ca223dca9888 100755 --- a/t/t9301-fast-import-notes.sh +++ b/t/t9301-fast-import-notes.sh @@ -275,7 +275,7 @@ $whitespace third note for first commit EXPECT_END -test_expect_success 'add concatentation notes with M command' ' +test_expect_success 'add concatenation notes with M command' ' git fast-import actual && diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index b4004e05c2a7..690c90fb8290 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -53,6 +53,33 @@ test_expect_success 'fast-export | fast-import' ' ' +test_expect_success 'fast-export ^muss^{commit} muss' ' + git fast-export --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual && + cat >expected <<-EOF && + tag muss + from $(git rev-parse --verify muss^{commit}) + $(git cat-file tag muss | grep tagger) + data 9 + valentin + + EOF + test_cmp expected actual +' + +test_expect_success 'fast-export --mark-tags ^muss^{commit} muss' ' + git fast-export --mark-tags --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual && + cat >expected <<-EOF && + tag muss + mark :1 + from $(git rev-parse --verify muss^{commit}) + $(git cat-file tag muss | grep tagger) + data 9 + valentin + + EOF + test_cmp expected actual +' + test_expect_success 'fast-export master~2..master' ' git fast-export master~2..master >actual && @@ -513,10 +540,41 @@ test_expect_success 'tree_tag' ' ' # NEEDSWORK: not just check return status, but validate the output +# Note that these tests DO NOTHING other than print a warning that +# they are omitting the one tag we asked them to export (because the +# tags resolve to a tree). They exist just to make sure we do not +# abort but instead just warn. test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' +test_expect_success 'handling tags of blobs' ' + git tag -a -m "Tag of a blob" blobtag $(git rev-parse master:file) && + git fast-export blobtag >actual && + cat >expect <<-EOF && + blob + mark :1 + data 9 + die Luft + + tag blobtag + from :1 + tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data 14 + Tag of a blob + + EOF + test_cmp expect actual +' + +test_expect_success 'handling nested tags' ' + git tag -a -m "This is a nested tag" nested muss && + git fast-export --mark-tags nested >output && + grep "^from $ZERO_OID$" output && + grep "^tag nested$" output >tag_lines && + test_line_count = 2 tag_lines +' + test_expect_success 'directory becomes symlink' ' git init dirtosymlink && git init result && @@ -542,9 +600,10 @@ test_expect_success 'directory becomes symlink' ' test_expect_success 'fast-export quotes pathnames' ' git init crazy-paths && + test_config -C crazy-paths core.protectNTFS false && (cd crazy-paths && blob=$(echo foo | git hash-object -w --stdin) && - git update-index --add \ + git -c core.protectNTFS=false update-index --add \ --cacheinfo 100644 $blob "$(printf "path with\\nnewline")" \ --cacheinfo 100644 $blob "path with \"quote\"" \ --cacheinfo 100644 $blob "path with \\backslash" \ @@ -567,17 +626,15 @@ test_expect_success 'fast-export quotes pathnames' ' ' test_expect_success 'test bidirectionality' ' - >marks-cur && - >marks-new && git init marks-test && - git fast-export --export-marks=marks-cur --import-marks=marks-cur --branches | \ - git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks=marks-new && + git fast-export --export-marks=marks-cur --import-marks-if-exists=marks-cur --branches | \ + git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks-if-exists=marks-new && (cd marks-test && git reset --hard && echo Wohlauf > file && git commit -a -m "back in time") && - git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks=marks-new --branches | \ - git fast-import --export-marks=marks-cur --import-marks=marks-cur + git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks-if-exists=marks-new --branches | \ + git fast-import --export-marks=marks-cur --import-marks-if-exists=marks-cur ' cat > expected << EOF diff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh index 0796a438bc77..e38cbc97d38e 100755 --- a/t/t9502-gitweb-standalone-parse-output.sh +++ b/t/t9502-gitweb-standalone-parse-output.sh @@ -188,8 +188,8 @@ test_expect_success 'forks: project_index lists all projects (incl. forks)' ' ' xss() { - echo >&2 "Checking $1..." && - gitweb_run "$1" && + echo >&2 "Checking $*..." && + gitweb_run "$@" && if grep "$TAG" gitweb.body; then echo >&2 "xss: $TAG should have been quoted in output" return 1 @@ -200,7 +200,8 @@ xss() { test_expect_success 'xss checks' ' TAG="" && xss "a=rss&p=$TAG" && - xss "a=rss&p=foo.git&f=$TAG" + xss "a=rss&p=foo.git&f=$TAG" && + xss "" "$TAG+" ' test_done diff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh index 5856563068c7..c98c1dfc2308 100755 --- a/t/t9800-git-p4-basic.sh +++ b/t/t9800-git-p4-basic.sh @@ -202,7 +202,6 @@ test_expect_success 'exit when p4 fails to produce marshaled output' ' export PATH && test_expect_code 1 git p4 clone --dest="$git" //depot >errs 2>&1 ) && - cat errs && test_i18ngrep ! Traceback errs ' diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 3cff1fce1b74..9c9710d8c7b8 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -407,7 +407,7 @@ test_expect_success 'reinit depot' ' ' # -# What happens when two files of the same name are overlayed together? +# What happens when two files of the same name are overlaid together? # The last-listed file should take preference. # # //depot diff --git a/t/t9810-git-p4-rcs.sh b/t/t9810-git-p4-rcs.sh index 57b533dc6fba..e3836888ec8b 100755 --- a/t/t9810-git-p4-rcs.sh +++ b/t/t9810-git-p4-rcs.sh @@ -294,7 +294,6 @@ test_expect_success 'cope with rcs keyword file deletion' ' echo "\$Revision\$" >kwdelfile.c && p4 add -t ktext kwdelfile.c && p4 submit -d "Add file to be deleted" && - cat kwdelfile.c && grep 1 kwdelfile.c ) && git p4 clone --dest="$git" //depot && diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 75512c340366..5505e5aa249e 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -28,10 +28,10 @@ complete () # # (2) A test makes sure that common subcommands are included in the # completion for "git ", and a plumbing is excluded. "add", -# "filter-branch" and "ls-files" are listed for this. +# "rebase" and "ls-files" are listed for this. -GIT_TESTING_ALL_COMMAND_LIST='add checkout check-attr filter-branch ls-files' -GIT_TESTING_PORCELAIN_COMMAND_LIST='add checkout filter-branch' +GIT_TESTING_ALL_COMMAND_LIST='add checkout check-attr rebase ls-files' +GIT_TESTING_PORCELAIN_COMMAND_LIST='add checkout rebase' . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" @@ -378,7 +378,7 @@ test_expect_success '__gitdir - finds repo' ' ' -test_expect_success '__gitdir - returns error when cant find repo' ' +test_expect_success '__gitdir - returns error when cannot find repo' ' ( __git_dir="non-existing" && test_must_fail __gitdir >"$actual" @@ -945,7 +945,7 @@ test_expect_success 'setup for filtering matching refs' ' rm -f .git/FETCH_HEAD ' -test_expect_success '__git_refs - dont filter refs unless told so' ' +test_expect_success '__git_refs - do not filter refs unless told so' ' cat >expected <<-EOF && HEAD master @@ -1257,7 +1257,7 @@ test_path_completion () # In the following tests calling this function we only # care about how __git_complete_index_file() deals with # unusual characters in path names. By requesting only - # untracked files we dont have to bother adding any + # untracked files we do not have to bother adding any # paths to the index in those tests. __git_complete_index_file --others && print_comp @@ -1363,6 +1363,63 @@ test_expect_success 'teardown after path completion tests' ' BS\\dir '$'separators\034in\035dir'' ' +test_expect_success '__git_find_on_cmdline - single match' ' + echo list >expect && + ( + words=(git command --opt list) && + cword=${#words[@]} && + __git_find_on_cmdline "add list remove" >actual + ) && + test_cmp expect actual +' + +test_expect_success '__git_find_on_cmdline - multiple matches' ' + echo remove >expect && + ( + words=(git command -o --opt remove list add) && + cword=${#words[@]} && + __git_find_on_cmdline "add list remove" >actual + ) && + test_cmp expect actual +' + +test_expect_success '__git_find_on_cmdline - no match' ' + ( + words=(git command --opt branch) && + cword=${#words[@]} && + __git_find_on_cmdline "add list remove" >actual + ) && + test_must_be_empty actual +' + +test_expect_success '__git_find_on_cmdline - single match with index' ' + echo "3 list" >expect && + ( + words=(git command --opt list) && + cword=${#words[@]} && + __git_find_on_cmdline --show-idx "add list remove" >actual + ) && + test_cmp expect actual +' + +test_expect_success '__git_find_on_cmdline - multiple matches with index' ' + echo "4 remove" >expect && + ( + words=(git command -o --opt remove list add) && + cword=${#words[@]} && + __git_find_on_cmdline --show-idx "add list remove" >actual + ) && + test_cmp expect actual +' + +test_expect_success '__git_find_on_cmdline - no match with index' ' + ( + words=(git command --opt branch) && + cword=${#words[@]} && + __git_find_on_cmdline --show-idx "add list remove" >actual + ) && + test_must_be_empty actual +' test_expect_success '__git_get_config_variables' ' cat >expect <<-EOF && @@ -1392,12 +1449,12 @@ test_expect_success 'basic' ' # built-in grep -q "^add \$" out && # script - grep -q "^filter-branch \$" out && + grep -q "^rebase \$" out && # plumbing ! grep -q "^ls-files \$" out && - run_completion "git f" && - ! grep -q -v "^f" out + run_completion "git r" && + ! grep -q -v "^r" out ' test_expect_success 'double dash "git" itself' ' @@ -1438,6 +1495,8 @@ test_expect_success 'double dash "git checkout"' ' --no-guess Z --no-... Z --overlay Z + --pathspec-file-nul Z + --pathspec-from-file=Z EOF ' @@ -1548,7 +1607,10 @@ test_expect_success 'complete tree filename with metacharacters' ' ' test_expect_success PERL 'send-email' ' - test_completion "git send-email --cov" "--cover-letter " && + test_completion "git send-email --cov" <<-\EOF && + --cover-from-description=Z + --cover-letter Z + EOF test_completion "git send-email ma" "master " ' @@ -1698,6 +1760,69 @@ do ' done +test_expect_success 'git config - section' ' + test_completion "git config br" <<-\EOF + branch.Z + browser.Z + EOF +' + +test_expect_success 'git config - variable name' ' + test_completion "git config log.d" <<-\EOF + log.date Z + log.decorate Z + EOF +' + +test_expect_success 'git config - value' ' + test_completion "git config color.pager " <<-\EOF + false Z + true Z + EOF +' + +test_expect_success 'git -c - section' ' + test_completion "git -c br" <<-\EOF + branch.Z + browser.Z + EOF +' + +test_expect_success 'git -c - variable name' ' + test_completion "git -c log.d" <<-\EOF + log.date=Z + log.decorate=Z + EOF +' + +test_expect_success 'git -c - value' ' + test_completion "git -c color.pager=" <<-\EOF + false Z + true Z + EOF +' + +test_expect_success 'git clone --config= - section' ' + test_completion "git clone --config=br" <<-\EOF + branch.Z + browser.Z + EOF +' + +test_expect_success 'git clone --config= - variable name' ' + test_completion "git clone --config=log.d" <<-\EOF + log.date=Z + log.decorate=Z + EOF +' + +test_expect_success 'git clone --config= - value' ' + test_completion "git clone --config=color.pager=" <<-\EOF + false Z + true Z + EOF +' + test_expect_success 'sourcing the completion script clears cached commands' ' __git_compute_all_commands && verbose test -n "$__git_all_commands" && diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index 88bc733ad691..ab5da2cabc40 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -163,7 +163,7 @@ test_expect_success 'prompt - inside bare repository' ' ' test_expect_success 'prompt - interactive rebase' ' - printf " (b1|REBASE-i 2/3)" >expected && + printf " (b1|REBASE 2/3)" >expected && write_script fake_editor.sh <<-\EOF && echo "exec echo" >"$1" echo "edit $(git log -1 --format="%h")" >>"$1" @@ -180,7 +180,7 @@ test_expect_success 'prompt - interactive rebase' ' ' test_expect_success 'prompt - rebase merge' ' - printf " (b2|REBASE-i 1/3)" >expected && + printf " (b2|REBASE 1/3)" >expected && git checkout b2 && test_when_finished "git checkout master" && test_must_fail git rebase --merge b1 b2 && @@ -189,11 +189,11 @@ test_expect_success 'prompt - rebase merge' ' test_cmp expected "$actual" ' -test_expect_success 'prompt - rebase' ' +test_expect_success 'prompt - rebase am' ' printf " (b2|REBASE 1/3)" >expected && git checkout b2 && test_when_finished "git checkout master" && - test_must_fail git rebase b1 b2 && + test_must_fail git rebase --apply b1 b2 && test_when_finished "git rebase --abort" && __git_ps1 >"$actual" && test_cmp expected "$actual" diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index e0b3f28d3a96..352c213d52e2 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -228,9 +228,11 @@ test_commit () { # can be a tag pointing to the commit-to-merge. test_merge () { + label="$1" && + shift && test_tick && - git merge -m "$1" "$2" && - git tag "$1" + git merge -m "$label" "$@" && + git tag "$label" } # Efficiently create commits, each with a unique number (from 1 to @@ -306,7 +308,7 @@ test_commit_bulk () { total=$1 add_from= - if git -C "$indir" rev-parse --verify "$ref" + if git -C "$indir" rev-parse --quiet --verify "$ref" then add_from=t fi @@ -580,7 +582,7 @@ test_expect_failure () { export test_prereq if ! test_skip "$@" then - say >&3 "checking known breakage: $2" + say >&3 "checking known breakage of $TEST_NUMBER.$test_count '$1': $2" if test_run_ "$2" expecting_failure then test_known_broken_ok_ "$1" @@ -600,7 +602,7 @@ test_expect_success () { export test_prereq if ! test_skip "$@" then - say >&3 "expecting success: $2" + say >&3 "expecting success of $TEST_NUMBER.$test_count '$1': $2" if test_run_ "$2" then test_ok_ "$1" @@ -1010,19 +1012,30 @@ test_must_be_empty () { fi } -# Tests that its two parameters refer to the same revision +# Tests that its two parameters refer to the same revision, or if '!' is +# provided first, that its other two parameters refer to different +# revisions. test_cmp_rev () { + local op='=' wrong_result=different + + if test $# -ge 1 && test "x$1" = 'x!' + then + op='!=' + wrong_result='the same' + shift + fi if test $# != 2 then error "bug in the test script: test_cmp_rev requires two revisions, but got $#" else local r1 r2 r1=$(git rev-parse --verify "$1") && - r2=$(git rev-parse --verify "$2") && - if test "$r1" != "$r2" + r2=$(git rev-parse --verify "$2") || return 1 + + if ! test "$r1" "$op" "$r2" then cat >&4 <<-EOF - error: two revisions point to different objects: + error: two revisions point to $wrong_result objects: '$1': $r1 '$2': $r2 EOF @@ -1173,6 +1186,34 @@ perl () { command "$PERL_PATH" "$@" 2>&7 } 7>&2 2>&4 +# Given the name of an environment variable with a bool value, normalize +# its value to a 0 (true) or 1 (false or empty string) return code. +# +# test_bool_env GIT_TEST_HTTPD +# +# Return with code corresponding to the given default value if the variable +# is unset. +# Abort the test script if either the value of the variable or the default +# are not valid bool values. + +test_bool_env () { + if test $# != 2 + then + BUG "test_bool_env requires two parameters (variable name and default value)" + fi + + git env--helper --type=bool --default="$2" --exit-code "$1" + ret=$? + case $ret in + 0|1) # unset or valid bool value + ;; + *) # invalid bool value or something unexpected + error >&7 "test_bool_env requires bool values both for \$$1 and for the default fallback" + ;; + esac + return $ret +} + # Exit the test suite, either by skipping all remaining tests or by # exiting with an error. If our prerequisite variable $1 falls back # on a default assume we were opportunistically trying to set up some @@ -1181,7 +1222,7 @@ perl () { # The error/skip message should be given by $2. # test_skip_or_die () { - if ! git env--helper --type=bool --default=false --exit-code $1 + if ! test_bool_env "$1" false then skip_all=$2 test_done @@ -1475,3 +1516,30 @@ test_set_port () { port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0})) eval $var=$port } + +# Compare a file containing rev-list bitmap traversal output to its non-bitmap +# counterpart. You can't just use test_cmp for this, because the two produce +# subtly different output: +# +# - regular output is in traversal order, whereas bitmap is split by type, +# with non-packed objects at the end +# +# - regular output has a space and the pathname appended to non-commit +# objects; bitmap output omits this +# +# This function normalizes and compares the two. The second file should +# always be the bitmap output. +test_bitmap_traversal () { + if test "$1" = "--no-confirm-bitmaps" + then + shift + elif cmp "$1" "$2" + then + echo >&2 "identical raw outputs; are you sure bitmaps were used?" + return 1 + fi && + cut -d' ' -f1 "$1" | sort >"$1.normalized" && + sort "$2" >"$2.normalized" && + test_cmp "$1.normalized" "$2.normalized" && + rm -f "$1.normalized" "$2.normalized" +} diff --git a/t/test-lib.sh b/t/test-lib.sh index 30b07e310f59..0ea1e5a05edd 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -212,6 +212,8 @@ fi TEST_STRESS_JOB_SFX="${GIT_TEST_STRESS_JOB_NR:+.stress-$GIT_TEST_STRESS_JOB_NR}" TEST_NAME="$(basename "$0" .sh)" +TEST_NUMBER="${TEST_NAME%%-*}" +TEST_NUMBER="${TEST_NUMBER#t}" TEST_RESULTS_DIR="$TEST_OUTPUT_DIRECTORY/test-results" TEST_RESULTS_BASE="$TEST_RESULTS_DIR/$TEST_NAME$TEST_STRESS_JOB_SFX" TRASH_DIRECTORY="trash directory.$TEST_NAME$TEST_STRESS_JOB_SFX" @@ -402,9 +404,13 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e ' unset XDG_CACHE_HOME unset XDG_CONFIG_HOME unset GITPERLLIB -GIT_AUTHOR_EMAIL=author@example.com +TEST_AUTHOR_LOCALNAME=author +TEST_AUTHOR_DOMAIN=example.com +GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN} GIT_AUTHOR_NAME='A U Thor' -GIT_COMMITTER_EMAIL=committer@example.com +TEST_COMMITTER_LOCALNAME=committer +TEST_COMMITTER_DOMAIN=example.com +GIT_COMMITTER_EMAIL=${TEST_COMMITTER_LOCALNAME}@${TEST_COMMITTER_DOMAIN} GIT_COMMITTER_NAME='C O Mitter' GIT_MERGE_VERBOSITY=5 GIT_MERGE_AUTOEDIT=no @@ -507,6 +513,9 @@ EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 LF=' ' +# Single quote +SQ=\' + # UTF-8 ZERO WIDTH NON-JOINER, which HFS+ ignores # when case-folding filenames u200c=$(printf '\342\200\214') @@ -567,6 +576,7 @@ export TERM error () { say_color error "error: $*" + finalize_junit_xml GIT_EXIT_OK=t exit 1 } @@ -695,7 +705,7 @@ test_failure_ () { say_color error "not ok $test_count - $1" shift printf '%s\n' "$*" | sed -e 's/^/# /' - test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; } + test "$immediate" = "" || { finalize_junit_xml; GIT_EXIT_OK=t; exit 1; } } test_known_broken_ok_ () { @@ -994,6 +1004,12 @@ test_skip () { to_skip=t skipped_reason="GIT_SKIP_TESTS" fi + if test -z "$to_skip" && test -n "$run_list" && + ! match_test_selector_list '--run' $test_count "$run_list" + then + to_skip=t + skipped_reason="--run" + fi if test -z "$to_skip" && test -n "$test_prereq" && ! test_have_prereq "$test_prereq" then @@ -1006,12 +1022,6 @@ test_skip () { fi skipped_reason="missing $missing_prereq${of_prereq}" fi - if test -z "$to_skip" && test -n "$run_list" && - ! match_test_selector_list '--run' $test_count "$run_list" - then - to_skip=t - skipped_reason="--run" - fi case "$to_skip" in t) @@ -1063,6 +1073,26 @@ write_junit_xml_testcase () { junit_have_testcase=t } +finalize_junit_xml () { + if test -n "$write_junit_xml" && test -n "$junit_xml_path" + then + test -n "$junit_have_testcase" || { + junit_start=$(test-tool date getnanos) + write_junit_xml_testcase "all tests skipped" + } + + # adjust the overall time + junit_time=$(test-tool date getnanos $junit_suite_start) + sed -e "s/\(]*/& time=\"$junit_time\"/" \ + <"$junit_xml_path" >"$junit_xml_path.new" + mv "$junit_xml_path.new" "$junit_xml_path" + + write_junit_xml " " "" + write_junit_xml= + fi +} + test_atexit_cleanup=: test_atexit_handler () { # In a succeeding test script 'test_atexit_handler' is invoked @@ -1085,21 +1115,7 @@ test_done () { # removed, so the commands can access pidfiles and socket files. test_atexit_handler - if test -n "$write_junit_xml" && test -n "$junit_xml_path" - then - test -n "$junit_have_testcase" || { - junit_start=$(test-tool date getnanos) - write_junit_xml_testcase "all tests skipped" - } - - # adjust the overall time - junit_time=$(test-tool date getnanos $junit_suite_start) - sed "s/]*/& time=\"$junit_time\"/" \ - <"$junit_xml_path" >"$junit_xml_path.new" - mv "$junit_xml_path.new" "$junit_xml_path" - - write_junit_xml " " "" - fi + finalize_junit_xml if test -z "$HARNESS_ACTIVE" then @@ -1391,23 +1407,23 @@ yes () { # The GIT_TEST_FAIL_PREREQS code hooks into test_set_prereq(), and # thus needs to be set up really early, and set an internal variable # for convenience so the hot test_set_prereq() codepath doesn't need -# to call "git env--helper". Only do that work if needed by seeing if -# GIT_TEST_FAIL_PREREQS is set at all. +# to call "git env--helper" (via test_bool_env). Only do that work +# if needed by seeing if GIT_TEST_FAIL_PREREQS is set at all. GIT_TEST_FAIL_PREREQS_INTERNAL= if test -n "$GIT_TEST_FAIL_PREREQS" then - if git env--helper --type=bool --default=0 --exit-code GIT_TEST_FAIL_PREREQS + if test_bool_env GIT_TEST_FAIL_PREREQS false then GIT_TEST_FAIL_PREREQS_INTERNAL=true test_set_prereq FAIL_PREREQS fi else test_lazy_prereq FAIL_PREREQS ' - git env--helper --type=bool --default=0 --exit-code GIT_TEST_FAIL_PREREQS + test_bool_env GIT_TEST_FAIL_PREREQS false ' fi -# Fix some commands on Windows +# Fix some commands on Windows, and other OS-specific things uname_s=$(uname -s) case $uname_s in *MINGW*) @@ -1438,6 +1454,12 @@ case $uname_s in test_set_prereq SED_STRIPS_CR test_set_prereq GREP_STRIPS_CR ;; +FreeBSD) + test_set_prereq REGEX_ILLSEQ + test_set_prereq POSIXPERM + test_set_prereq BSLASHPSPEC + test_set_prereq EXECKEEPSPID + ;; *) test_set_prereq POSIXPERM test_set_prereq BSLASHPSPEC @@ -1462,7 +1484,7 @@ then fi test_lazy_prereq C_LOCALE_OUTPUT ' - ! git env--helper --type=bool --default=0 --exit-code GIT_TEST_GETTEXT_POISON + ! test_bool_env GIT_TEST_GETTEXT_POISON false ' if test -z "$GIT_TEST_CHECK_CACHE_TREE" -- cgit 1.4.1