diff options
209 files changed, 3608 insertions, 1899 deletions
diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml index 9d070b9cdf..f1483059c7 100644 --- a/.github/workflows/check-whitespace.yml +++ b/.github/workflows/check-whitespace.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Set commit count shell: bash - run: echo "::set-env name=COMMIT_DEPTH::$((1+$COMMITS))" + run: echo "COMMIT_DEPTH=$((1+$COMMITS))" >>$GITHUB_ENV env: COMMITS: ${{ github.event.pull_request.commits }} @@ -58,12 +58,14 @@ jobs: - name: Add Check Output as Comment uses: actions/github-script@v3 id: add-comment + env: + log: ${{ steps.check_out.outputs.checkout }} with: script: | - github.issues.createComment({ + await github.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: "Whitespace errors found in workflow ${{ github.workflow }}:\n\n${{ steps.check_out.outputs.checkout }}" + body: `Whitespace errors found in workflow ${{ github.workflow }}:\n\n\`\`\`\n${process.env.log.replace(/\\n/g, "\n")}\n\`\`\`` }) if: ${{ failure() }} diff --git a/Documentation/MyFirstContribution.txt b/Documentation/MyFirstContribution.txt index 4f85a089ef..60eed5edcd 100644 --- a/Documentation/MyFirstContribution.txt +++ b/Documentation/MyFirstContribution.txt @@ -249,7 +249,7 @@ component you're working on, followed by a blank line (always required) and then the body of your commit message, which should provide the bulk of the context. Remember to be explicit and provide the "Why" of your change, especially if it couldn't easily be understood from your diff. When editing your commit message, -don't remove the Signed-off-by line which was added by `-s` above. +don't remove the `Signed-off-by` trailer which was added by `-s` above. ---- psuh: add a built-in by popular demand @@ -507,6 +507,9 @@ documentation is consistent with other Git and UNIX manpages; this makes life easier for your user, who can skip to the section they know contains the information they need. +NOTE: Before trying to build the docs, make sure you have the package `asciidoc` +installed. + Now that you've written your manpage, you'll need to build it explicitly. We convert your AsciiDoc to troff which is man-readable like so: @@ -522,8 +525,6 @@ $ make -C Documentation/ git-psuh.1 $ man Documentation/git-psuh.1 ---- -NOTE: You may need to install the package `asciidoc` to get this to work. - While this isn't as satisfying as running through `git help`, you can at least check that your help page looks right. diff --git a/Documentation/RelNotes/2.30.0.txt b/Documentation/RelNotes/2.30.0.txt index e17f5de200..defa865a6f 100644 --- a/Documentation/RelNotes/2.30.0.txt +++ b/Documentation/RelNotes/2.30.0.txt @@ -37,6 +37,34 @@ UI, Workflows & Features * "git resurrect" script (in contrib/) learned that the object names may be longer than 40-hex depending on the hash function in use. + * "git diff A...B" learned "git diff --merge-base A B", which is a + longer short-hand to say the same thing. + + * A sample 'push-to-checkout' hook, that performs the same as + what the built-in default action does, has been added. + + * "git diff" family of commands learned the "-I<regex>" option to + ignore hunks whose changed lines all match the given pattern. + + * The userdiff pattern learned to identify the function definition in + POSIX shells and bash. + + * "git checkout-index" did not consistently signal an error with its + exit status, but now it does. + + * A commit and tag object may have CR at the end of each and + every line (you can create such an object with hash-object or + using --cleanup=verbatim to decline the default clean-up + action), but it would make it impossible to have a blank line + to separate the title from the body of the message. We are now + more lenient and accept a line with lone CR on it as a blank line, + too. + + * Exit codes from "git remote add" etc. were not usable by scripted + callers, but now they are. + + * Zsh autocompletion (in contrib/) update. + Performance, Internal Implementation, Development Support etc. @@ -45,6 +73,35 @@ Performance, Internal Implementation, Development Support etc. * GitHub Actions automated test improvement to skip tests on a tree identical to what has already been tested. + * Test-coverage for running commit-graph task "git maintenance" has + been extended. + + * Our test scripts can be told to run only individual pieces while + skipping others with the "--run=..." option; they were taught to + take a substring of test title, in addition to numbers, to name the + test pieces to run. + + * Adjust tests so that they won't scream when the default initial + branch name is changed to 'main'. + + * Rewriting "git bisect" in C continues. + + * More preliminary tests have been added to document desired outcome + of various "directory rename" situations. + + * Micro clean-up of a couple of test scripts. + + * "git diff" and other commands that share the same machinery to + compare with working tree files have been taught to take advantage + of the fsmonitor data when available. + + * The code to detect premature EOF in the sideband demultiplexer has + been cleaned up. + + * Test scripts are being prepared to transition of the default branch + name to 'main'. + + Fixes since v2.29 ----------------- @@ -59,7 +116,86 @@ Fixes since v2.29 commits A and B. (merge 35166b1fb5 dl/checkout-p-merge-base later to maint). + * The side-band status report can be sent at the same time as the + primary payload multiplexed, but the demultiplexer on the receiving + end incorrectly split a single status report into two, which has + been corrected. + (merge 712b0377db js/avoid-split-sideband-message later to maint). + + * "git fast-import" wasted a lot of memory when many marks were in use. + (merge 3f018ec716 jk/fast-import-marks-alloc-fix later to maint). + + * A test helper "test_cmp A B" was taught to diagnose missing files A + or B as a bug in test, but some tests legitimately wanted to notice + a failure to even create file B as an error, in addition to leaving + the expected result in it, and were misdiagnosed as a bug. This + has been corrected. + (merge 262d5ad5a5 es/test-cmp-typocatcher later to maint). + + * When "git commit-graph" detects the same commit recorded more than + once while it is merging the layers, it used to die. The code now + ignores all but one of them and continues. + (merge 85102ac71b ds/commit-graph-merging-fix later to maint). + + * The meaning of a Signed-off-by trailer can vary from project to + project; this and also what it means to this project has been + clarified in the documentation. + (merge 3abd4a67d9 bk/sob-dco later to maint). + + * "git credential' didn't honor the core.askPass configuration + variable (among other things), which has been corrected. + (merge 567ad2c0f9 tk/credential-config later to maint). + + * Dev support to catch a tentative definition of a variable in our C + code as an error. + (merge 5539183622 jk/no-common later to maint). + + * "git rebase --rebase-merges" did not correctly pass --gpg-sign + command line option to underlying "git merge" when replaying a merge + using non-default merge strategy or when replaying an octopus merge + (because replaying a two-head merge with the default strategy was + done in a separate codepath, the problem did not trigger for most + users), which has been corrected. + (merge 43ad4f2eca sc/sequencer-gpg-octopus later to maint). + + * "git apply -R" did not handle patches that touch the same path + twice correctly, which has been corrected. This is most relevant + in a patch that changes a path from a regular file to a symbolic + link (and vice versa). + (merge b0f266de11 jt/apply-reverse-twice later to maint). + + * A recent oid->hash conversion missed one spot, breaking "git svn". + (merge 03bb366de4 bc/svn-hash-oid-fix later to maint). + + * The documentation on the "--abbrev=<n>" option did not say the + output may be longer than "<n>" hexdigits, which has been + clarified. + (merge cda34e0d0c jc/abbrev-doc later to maint). + + * "git p4" now honors init.defaultBranch configuration. + (merge 1b09d1917f js/p4-default-branch later to maint). + + * Recently the format of an internal state file "rebase -i" uses has + been tightened up for consistency, which would hurt those who start + "rebase -i" with old git and then continue with new git. Loosen + the reader side a bit (which we may want to tighten again in a year + or so). + (merge c779386182 jc/sequencer-stopped-sha-simplify later to maint). + * Other code cleanup, docfix, build fix, etc. (merge 3e0a5dc9af cc/doc-filter-branch-typofix later to maint). (merge 32c83afc2c cw/ci-ghwf-check-ws-errors later to maint). (merge 5eb2ed691b rs/tighten-callers-of-deref-tag later to maint). + (merge 6db29ab213 jk/fast-import-marks-cleanup later to maint). + (merge e5cf6d3df4 nk/dir-c-comment-update later to maint). + (merge 5710dcce74 jk/report-fn-typedef later to maint). + (merge 9a82db1056 en/sequencer-rollback-lock-cleanup later to maint). + (merge 4e1bee9a99 js/t7006-cleanup later to maint). + (merge f5bcde6c58 es/tutorial-mention-asciidoc-early later to maint). + (merge 714d491af0 so/format-patch-doc-on-default-diff-format later to maint). + (merge 0795df4b9b rs/clear-commit-marks-in-repo later to maint). + (merge 9542d56379 sd/prompt-local-variable later to maint). + (merge 06d43fad18 rs/pack-write-hashwrite-simplify later to maint). + (merge b7e20b4373 mc/typofix later to maint). + (merge f6bcd9a8a4 js/test-whitespace-fixes later to maint). + (merge 53b67a801b js/test-file-size later to maint). diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 291b61e262..d12094bac5 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -209,7 +209,7 @@ send them as replies to either an additional "cover letter" message (see below), the first patch, or the respective preceding patch. If your log message (including your name on the -Signed-off-by line) is not writable in ASCII, make sure that +`Signed-off-by` trailer) is not writable in ASCII, make sure that you send off a message in the correct encoding. WARNING: Be wary of your MUAs word-wrap @@ -229,7 +229,7 @@ previously sent. The `git format-patch` command follows the best current practice to format the body of an e-mail message. At the beginning of the patch should come your commit message, ending with the -Signed-off-by: lines, and a line that consists of three dashes, +`Signed-off-by` trailers, and a line that consists of three dashes, followed by the diffstat information and the patch itself. If you are forwarding a patch from somebody else, optionally, at the beginning of the e-mail message just before the commit @@ -290,25 +290,24 @@ identify them), to solicit comments and reviews. :git-ml: footnote:[The mailing list: git@vger.kernel.org] After the list reached a consensus that it is a good idea to apply the -patch, re-send it with "To:" set to the maintainer{current-maintainer} and "cc:" the -list{git-ml} for inclusion. +patch, re-send it with "To:" set to the maintainer{current-maintainer} +and "cc:" the list{git-ml} for inclusion. This is especially relevant +when the maintainer did not heavily participate in the discussion and +instead left the review to trusted others. Do not forget to add trailers such as `Acked-by:`, `Reviewed-by:` and `Tested-by:` lines as necessary to credit people who helped your -patch. +patch, and "cc:" them when sending such a final version for inclusion. [[sign-off]] -=== Certify your work by adding your "Signed-off-by: " line +=== Certify your work by adding your `Signed-off-by` trailer -To improve tracking of who did what, we've borrowed the -"sign-off" procedure from the Linux kernel project on patches -that are being emailed around. Although core Git is a lot -smaller project it is a good discipline to follow it. +To improve tracking of who did what, we ask you to certify that you +wrote the patch or have the right to pass it on under the same license +as ours, by "signing off" your patch. Without sign-off, we cannot +accept your patches. -The sign-off is a simple line at the end of the explanation for -the patch, which certifies that you wrote it or otherwise have -the right to pass it on as an open-source patch. The rules are -pretty simple: if you can certify the below D-C-O: +If you can certify the below D-C-O: [[dco]] .Developer's Certificate of Origin 1.1 @@ -338,23 +337,29 @@ d. I understand and agree that this project and the contribution this project or the open source license(s) involved. ____ -then you just add a line saying +you add a "Signed-off-by" trailer to your commit, that looks like +this: .... Signed-off-by: Random J Developer <random@developer.example.org> .... -This line can be automatically added by Git if you run the git-commit -command with the -s option. +This line can be added by Git if you run the git-commit command with +the -s option. -Notice that you can place your own Signed-off-by: line when +Notice that you can place your own `Signed-off-by` trailer when forwarding somebody else's patch with the above rules for D-C-O. Indeed you are encouraged to do so. Do not forget to place an in-body "From: " line at the beginning to properly attribute the change to its true author (see (2) above). +This procedure originally came from the Linux kernel project, so our +rule is quite similar to theirs, but what exactly it means to sign-off +your patch differs from project to project, so it may be different +from that of the project you are accustomed to. + [[real-name]] -Also notice that a real name is used in the Signed-off-by: line. Please +Also notice that a real name is used in the `Signed-off-by` trailer. Please don't hide your real name. [[commit-trailers]] diff --git a/Documentation/config.txt b/Documentation/config.txt index 025ca4df11..f292c2689e 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -265,7 +265,7 @@ color:: The basic colors accepted are `normal`, `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan` and `white`. The first color given is the foreground; the second is the background. All the basic colors except -`normal` have a bright variant that can be speficied by prefixing the +`normal` have a bright variant that can be specified by prefixing the color with `bright`, like `brightred`. + Colors may also be given as numbers between 0 and 255; these use ANSI diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt index c2efd8758a..851bf410a3 100644 --- a/Documentation/config/format.txt +++ b/Documentation/config/format.txt @@ -79,7 +79,7 @@ format.thread:: format.signOff:: A boolean value which lets you enable the `-s/--signoff` option of - format-patch by default. *Note:* Adding the Signed-off-by: line to a + format-patch by default. *Note:* Adding the `Signed-off-by` trailer to a patch should be a conscious act and means that you certify you have the rights to submit this work under the same open source license. Please see the 'SubmittingPatches' document for further discussion. diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 573fb9bb71..2e7a93894c 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -36,9 +36,9 @@ endif::git-format-patch[] -U<n>:: --unified=<n>:: Generate diffs with <n> lines of context instead of - the usual three. Implies `--patch`. + the usual three. ifndef::git-format-patch[] - Implies `-p`. + Implies `--patch`. endif::git-format-patch[] --output=<file>:: @@ -441,12 +441,16 @@ endif::git-format-patch[] --binary:: In addition to `--full-index`, output a binary diff that - can be applied with `git-apply`. Implies `--patch`. + can be applied with `git-apply`. +ifndef::git-format-patch[] + Implies `--patch`. +endif::git-format-patch[] --abbrev[=<n>]:: Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header - lines, show only a partial prefix. + lines, show the shortest prefix that is at least '<n>' + hexdigits long that uniquely refers the object. In diff-patch output format, `--full-index` takes higher precedence, i.e. if `--full-index` is specified, full blob names will be shown regardless of `--abbrev`. @@ -687,6 +691,11 @@ endif::git-format-patch[] --ignore-blank-lines:: Ignore changes whose lines are all blank. +-I<regex>:: +--ignore-matching-lines=<regex>:: + Ignore changes whose all lines match <regex>. This option may + be specified more than once. + --inter-hunk-context=<lines>:: Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other. diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index 38c0852139..06bc063542 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -33,7 +33,7 @@ OPTIONS -s:: --signoff:: - Add a `Signed-off-by:` line to the commit message, using + Add a `Signed-off-by` trailer to the commit message, using the committer identity of yourself. See the signoff option in linkgit:git-commit[1] for more information. diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt index 7e81541996..34b496d485 100644 --- a/Documentation/git-blame.txt +++ b/Documentation/git-blame.txt @@ -87,7 +87,9 @@ include::blame-options.txt[] --abbrev=<n>:: Instead of using the default 7+1 hexadecimal digits as the - abbreviated object name, use <n>+1 digits. Note that 1 column + abbreviated object name, use <m>+1 digits, where <m> is at + least <n> but ensures the commit object names are unique. + Note that 1 column is used for a caret to mark the boundary commit. diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index ace4ad3da8..adaa1782a8 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -9,7 +9,7 @@ SYNOPSIS -------- [verse] 'git branch' [--color[=<when>] | --no-color] [--show-current] - [-v [--abbrev=<length> | --no-abbrev]] + [-v [--abbrev=<n> | --no-abbrev]] [--column[=<options>] | --no-column] [--sort=<key>] [--merged [<commit>]] [--no-merged [<commit>]] [--contains [<commit>]] [--no-contains [<commit>]] @@ -194,8 +194,10 @@ This option is only applicable in non-verbose mode. Be more quiet when creating or deleting a branch, suppressing non-error messages. ---abbrev=<length>:: - Alter the sha1's minimum display length in the output listing. +--abbrev=<n>:: + In the verbose listing that show the commit object name, + show the shortest prefix that is at least '<n>' hexdigits + long that uniquely refers the object. The default value is 7 and can be overridden by the `core.abbrev` config option. diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt index 75feeef08a..5d750314b2 100644 --- a/Documentation/git-cherry-pick.txt +++ b/Documentation/git-cherry-pick.txt @@ -104,7 +104,7 @@ effect to your index in a row. -s:: --signoff:: - Add Signed-off-by line at the end of the commit message. + Add a `Signed-off-by` trailer at the end of the commit message. See the signoff option in linkgit:git-commit[1] for more information. -S[<keyid>]:: diff --git a/Documentation/git-commit-graph.txt b/Documentation/git-commit-graph.txt index de6b6de230..e1f48c95b3 100644 --- a/Documentation/git-commit-graph.txt +++ b/Documentation/git-commit-graph.txt @@ -39,7 +39,9 @@ COMMANDS -------- 'write':: -Write a commit-graph file based on the commits found in packfiles. +Write a commit-graph file based on the commits found in packfiles. If +the config option `core.commitGraph` is disabled, then this command will +output a warning, then return success without writing a commit-graph file. + With the `--stdin-packs` option, generate the new commit graph by walking objects only in the specified pack-indexes. (Cannot be combined diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index a3baea32ae..17150fa7ea 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -59,6 +59,7 @@ commit by giving the same set of parameters (options and paths). If you make a commit and then find a mistake immediately after that, you can recover from it with 'git reset'. +:git-commit: 1 OPTIONS ------- @@ -163,14 +164,7 @@ The `-m` option is mutually exclusive with `-c`, `-C`, and `-F`. message, the commit is aborted. This has no effect when a message is given by other means, e.g. with the `-m` or `-F` options. --s:: ---signoff:: - Add Signed-off-by line by the committer at the end of the commit - log message. The meaning of a signoff depends on the project, - but it typically certifies that committer has - the rights to submit this work under the same license and - agrees to a Developer Certificate of Origin - (see http://developercertificate.org/ for more information). +include::signoff-option.txt[] -n:: --no-verify:: diff --git a/Documentation/git-diff-index.txt b/Documentation/git-diff-index.txt index f4bd8155c0..27acb31cbf 100644 --- a/Documentation/git-diff-index.txt +++ b/Documentation/git-diff-index.txt @@ -9,7 +9,7 @@ git-diff-index - Compare a tree to the working tree or index SYNOPSIS -------- [verse] -'git diff-index' [-m] [--cached] [<common diff options>] <tree-ish> [<path>...] +'git diff-index' [-m] [--cached] [--merge-base] [<common diff options>] <tree-ish> [<path>...] DESCRIPTION ----------- @@ -27,7 +27,12 @@ include::diff-options.txt[] The id of a tree object to diff against. --cached:: - do not consider the on-disk file at all + Do not consider the on-disk file at all. + +--merge-base:: + Instead of comparing <tree-ish> directly, use the merge base + between <tree-ish> and HEAD instead. <tree-ish> must be a + commit. -m:: By default, files recorded in the index but not checked diff --git a/Documentation/git-diff-tree.txt b/Documentation/git-diff-tree.txt index 5c8a2a5e97..2fc24c542f 100644 --- a/Documentation/git-diff-tree.txt +++ b/Documentation/git-diff-tree.txt @@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git diff-tree' [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty] - [-t] [-r] [-c | --cc] [--combined-all-paths] [--root] + [-t] [-r] [-c | --cc] [--combined-all-paths] [--root] [--merge-base] [<common diff options>] <tree-ish> [<tree-ish>] [<path>...] DESCRIPTION @@ -43,6 +43,11 @@ include::diff-options.txt[] When `--root` is specified the initial commit will be shown as a big creation event. This is equivalent to a diff against the NULL tree. +--merge-base:: + Instead of comparing the <tree-ish>s directly, use the merge + base between the two <tree-ish>s as the "before" side. There + must be two <tree-ish>s given and they must both be commits. + --stdin:: When `--stdin` is specified, the command does not take <tree-ish> arguments from the command line. Instead, it diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt index 727f24d16e..7f4c8a8ce7 100644 --- a/Documentation/git-diff.txt +++ b/Documentation/git-diff.txt @@ -10,8 +10,8 @@ SYNOPSIS -------- [verse] 'git diff' [<options>] [<commit>] [--] [<path>...] -'git diff' [<options>] --cached [<commit>] [--] [<path>...] -'git diff' [<options>] <commit> [<commit>...] <commit> [--] [<path>...] +'git diff' [<options>] --cached [--merge-base] [<commit>] [--] [<path>...] +'git diff' [<options>] [--merge-base] <commit> [<commit>...] <commit> [--] [<path>...] 'git diff' [<options>] <commit>...<commit> [--] [<path>...] 'git diff' [<options>] <blob> <blob> 'git diff' [<options>] --no-index [--] <path> <path> @@ -40,7 +40,7 @@ files on disk. or when running the command outside a working tree controlled by Git. This form implies `--exit-code`. -'git diff' [<options>] --cached [<commit>] [--] [<path>...]:: +'git diff' [<options>] --cached [--merge-base] [<commit>] [--] [<path>...]:: This form is to view the changes you staged for the next commit relative to the named <commit>. Typically you @@ -49,6 +49,10 @@ files on disk. If HEAD does not exist (e.g. unborn branches) and <commit> is not given, it shows all staged changes. --staged is a synonym of --cached. ++ +If --merge-base is given, instead of using <commit>, use the merge base +of <commit> and HEAD. `git diff --merge-base A` is equivalent to +`git diff $(git merge-base A HEAD)`. 'git diff' [<options>] <commit> [--] [<path>...]:: @@ -58,23 +62,27 @@ files on disk. branch name to compare with the tip of a different branch. -'git diff' [<options>] <commit> <commit> [--] [<path>...]:: +'git diff' [<options>] [--merge-base] <commit> <commit> [--] [<path>...]:: This is to view the changes between two arbitrary <commit>. ++ +If --merge-base is given, use the merge base of the two commits for the +"before" side. `git diff --merge-base A B` is equivalent to +`git diff $(git merge-base A B) B`. 'git diff' [<options>] <commit> <commit>... <commit> [--] [<path>...]:: This form is to view the results of a merge commit. The first listed <commit> must be the merge itself; the remaining two or more commits should be its parents. A convenient way to produce - the desired set of revisions is to use the {caret}@ suffix. + the desired set of revisions is to use the `^@` suffix. For instance, if `master` names a merge commit, `git diff master master^@` gives the same combined diff as `git show master`. 'git diff' [<options>] <commit>..<commit> [--] [<path>...]:: - This is synonymous to the earlier form (without the "..") for + This is synonymous to the earlier form (without the `..`) for viewing the changes between two arbitrary <commit>. If <commit> on one side is omitted, it will have the same effect as using HEAD instead. @@ -83,20 +91,20 @@ files on disk. This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor - of both <commit>. "git diff A\...B" is equivalent to - "git diff $(git merge-base A B) B". You can omit any one + of both <commit>. `git diff A...B` is equivalent to + `git diff $(git merge-base A B) B`. You can omit any one of <commit>, which has the same effect as using HEAD instead. Just in case you are doing something exotic, it should be noted that all of the <commit> in the above description, except -in the last two forms that use ".." notations, can be any -<tree>. +in the `--merge-base` case and in the last two forms that use `..` +notations, can be any <tree>. For a more complete list of ways to spell <commit>, see "SPECIFYING REVISIONS" section in linkgit:gitrevisions[7]. However, "diff" is about comparing two _endpoints_, not ranges, -and the range notations ("<commit>..<commit>" and -"<commit>\...<commit>") do not mean a range as defined in the +and the range notations (`<commit>..<commit>` and +`<commit>...<commit>`) do not mean a range as defined in the "SPECIFYING RANGES" section in linkgit:gitrevisions[7]. 'git diff' [<options>] <blob> <blob>:: @@ -144,9 +152,9 @@ $ git diff HEAD <3> + <1> Changes in the working tree not yet staged for the next commit. <2> Changes between the index and your last commit; what you - would be committing if you run "git commit" without "-a" option. + would be committing if you run `git commit` without `-a` option. <3> Changes in the working tree since your last commit; what you - would be committing if you run "git commit -a" + would be committing if you run `git commit -a` Comparing with arbitrary commits:: + diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 0f81d0437b..bf1bb40f63 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -119,7 +119,7 @@ include::diff-options.txt[] -s:: --signoff:: - Add `Signed-off-by:` line to the commit message, using + Add a `Signed-off-by` trailer to the commit message, using the committer identity of yourself. See the signoff option in linkgit:git-commit[1] for more information. diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 3cb2ebb438..cbcf5263dd 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -19,7 +19,7 @@ SYNOPSIS [--exclude-standard] [--error-unmatch] [--with-tree=<tree-ish>] [--full-name] [--recurse-submodules] - [--abbrev] [--] [<file>...] + [--abbrev[=<n>]] [--] [<file>...] DESCRIPTION ----------- @@ -153,7 +153,8 @@ a space) at the start of each line: --abbrev[=<n>]:: Instead of showing the full 40-byte hexadecimal object - lines, show only a partial prefix. + lines, show the shortest prefix that is at least '<n>' + hexdigits long that uniquely refers the object. Non default number of digits can be specified with --abbrev=<n>. --debug:: diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt index a7515714da..db02d6d79a 100644 --- a/Documentation/git-ls-tree.txt +++ b/Documentation/git-ls-tree.txt @@ -62,7 +62,8 @@ OPTIONS --abbrev[=<n>]:: Instead of showing the full 40-byte hexadecimal object - lines, show only a partial prefix. + lines, show the shortest prefix that is at least '<n>' + hexdigits long that uniquely refers the object. Non default number of digits can be specified with --abbrev=<n>. --full-name:: diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt index dab9609013..ec233ac0c1 100644 --- a/Documentation/git-p4.txt +++ b/Documentation/git-p4.txt @@ -417,7 +417,7 @@ p4-post-changelist ~~~~~~~~~~~~~~~~~~ The `p4-post-changelist` hook is invoked after the submit has -successfully occured in P4. It takes no parameters and is meant +successfully occurred in P4. It takes no parameters and is meant primarily for notification and cannot affect the outcome of the git p4 submit action. diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 38e15488f6..a0487b5cc5 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -496,7 +496,7 @@ See also INCOMPATIBLE OPTIONS below. See also INCOMPATIBLE OPTIONS below. --signoff:: - Add a Signed-off-by: trailer to all the rebased commits. Note + Add a `Signed-off-by` trailer to all the rebased commits. Note that if `--interactive` is given then only commits marked to be picked, edited or reworded will have the trailer added. + diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt index ea73386c81..31c29c9b31 100644 --- a/Documentation/git-remote.txt +++ b/Documentation/git-remote.txt @@ -203,6 +203,17 @@ The remote configuration is achieved using the `remote.origin.url` and `remote.origin.fetch` configuration variables. (See linkgit:git-config[1]). +EXIT STATUS +----------- + +On success, the exit status is `0`. + +When subcommands such as 'add', 'rename', and 'remove' can't find the +remote in question, the exit status is `2`. When the remote already +exists, the exit status is `3`. + +On any other error, the exit status may be any other non-zero value. + EXAMPLES -------- diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt index 044276e9da..bb92a4a451 100644 --- a/Documentation/git-revert.txt +++ b/Documentation/git-revert.txt @@ -99,7 +99,7 @@ effect to your index in a row. -s:: --signoff:: - Add Signed-off-by line at the end of the commit message. + Add a `Signed-off-by` trailer at the end of the commit message. See the signoff option in linkgit:git-commit[1] for more information. --strategy=<strategy>:: diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index 0a69810147..b7bbbeadef 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -313,7 +313,7 @@ Automating the value of `sendemail.identity`. --[no-]signed-off-by-cc:: - If this is set, add emails found in Signed-off-by: or Cc: lines to the + If this is set, add emails found in the `Signed-off-by` trailer or Cc: lines to the cc list. Default is the value of `sendemail.signedoffbycc` configuration value; if that is unspecified, default to --signed-off-by-cc. @@ -340,7 +340,7 @@ Automating except for self (use 'self' for that). - 'bodycc' will avoid including anyone mentioned in Cc lines in the patch body (commit message) except for self (use 'self' for that). -- 'sob' will avoid including anyone mentioned in Signed-off-by lines except +- 'sob' will avoid including anyone mentioned in the Signed-off-by trailers except for self (use 'self' for that). - 'misc-by' will avoid including anyone mentioned in Acked-by, Reviewed-by, Tested-by and other "-by" lines in the patch body, diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt index 6624a14fbd..67b143cc81 100644 --- a/Documentation/git-svn.txt +++ b/Documentation/git-svn.txt @@ -701,7 +701,7 @@ creating the branch or tag. --use-log-author:: When retrieving svn commits into Git (as part of 'fetch', 'rebase', or - 'dcommit' operations), look for the first `From:` or `Signed-off-by:` line + 'dcommit' operations), look for the first `From:` line or `Signed-off-by` trailer in the log message and use that as the author string. + [verse] @@ -710,7 +710,7 @@ config key: svn.useLogAuthor --add-author-from:: When committing to svn from Git (as part of 'set-tree' or 'dcommit' operations), if the existing log message doesn't already have a - `From:` or `Signed-off-by:` line, append a `From:` line based on the + `From:` or `Signed-off-by` trailer, append a `From:` line based on the Git commit's author string. If you use this, then `--use-log-author` will retrieve a valid author string for all commits. + diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt index 2d0a03715b..e84e104f93 100644 --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@ -802,6 +802,9 @@ patterns are available: - `ada` suitable for source code in the Ada language. +- `bash` suitable for source code in the Bourne-Again SHell language. + Covers a superset of POSIX shell function definitions. + - `bibtex` suitable for files with BibTeX coded references. - `cpp` suitable for source code in the C and C++ languages. diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt index 6e461ace6e..ffccfc7760 100644 --- a/Documentation/githooks.txt +++ b/Documentation/githooks.txt @@ -164,7 +164,7 @@ can also be used to refuse the commit after inspecting the message file. The default 'commit-msg' hook, when enabled, detects duplicate -"Signed-off-by" lines, and aborts the commit if one is found. +`Signed-off-by` trailers, and aborts the commit if one is found. post-commit ~~~~~~~~~~~ @@ -655,7 +655,7 @@ p4-post-changelist This hook is invoked by `git-p4 submit`. The `p4-post-changelist` hook is invoked after the submit has -successfully occured in P4. It takes no parameters and is meant +successfully occurred in P4. It takes no parameters and is meant primarily for notification and cannot affect the outcome of the git p4 submit action. diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt index 80d4831662..eb0aabd396 100644 --- a/Documentation/merge-options.txt +++ b/Documentation/merge-options.txt @@ -77,16 +77,7 @@ When not possible, refuse to merge and exit with a non-zero status. With --no-log do not list one-line descriptions from the actual commits being merged. ---signoff:: ---no-signoff:: - Add Signed-off-by line by the committer at the end of the commit - log message. The meaning of a signoff depends on the project, - but it typically certifies that committer has - the rights to submit this work under the same license and - agrees to a Developer Certificate of Origin - (see http://developercertificate.org/ for more information). -+ -With --no-signoff do not add a Signed-off-by line. +include::signoff-option.txt[] --stat:: -n:: diff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt index 17c5aac4b7..27ddaf84a1 100644 --- a/Documentation/pretty-options.txt +++ b/Documentation/pretty-options.txt @@ -16,9 +16,9 @@ configuration (see linkgit:git-config[1]). --abbrev-commit:: Instead of showing the full 40-byte hexadecimal commit object - name, show only a partial prefix. Non default number of - digits can be specified with "--abbrev=<n>" (which also modifies - diff output, if it is displayed). + name, show a prefix that names the object uniquely. + "--abbrev=<n>" (which also modifies diff output, if it is displayed) + option can be used to specify the minimum length of the prefix. + This should make "--pretty=oneline" a whole lot more readable for people using 80-column terminals. diff --git a/Documentation/signoff-option.txt b/Documentation/signoff-option.txt new file mode 100644 index 0000000000..12aa2333e4 --- /dev/null +++ b/Documentation/signoff-option.txt @@ -0,0 +1,18 @@ +ifdef::git-commit[] +-s:: +endif::git-commit[] +--signoff:: +--no-signoff:: + Add a `Signed-off-by` trailer by the committer at the end of the commit + log message. The meaning of a signoff depends on the project + to which you're committing. For example, it may certify that + the committer has the rights to submit the work under the + project's license or agrees to some contributor representation, + such as a Developer Certificate of Origin. + (See http://developercertificate.org for the one used by the + Linux kernel and Git projects.) Consult the documentation or + leadership of the project to which you're contributing to + understand how the signoffs are used in that project. ++ +The --no-signoff option can be used to countermand an earlier --signoff +option on the command line. diff --git a/Documentation/technical/directory-rename-detection.txt b/Documentation/technical/directory-rename-detection.txt index 844629c8c4..49b83ef3cc 100644 --- a/Documentation/technical/directory-rename-detection.txt +++ b/Documentation/technical/directory-rename-detection.txt @@ -18,7 +18,8 @@ It is perhaps easiest to start with an example: More interesting possibilities exist, though, such as: * one side of history renames x -> z, and the other renames some file to - x/e, causing the need for the merge to do a transitive rename. + x/e, causing the need for the merge to do a transitive rename so that + the rename ends up at z/e. * one side of history renames x -> z, but also renames all files within x. For example, x/a -> z/alpha, x/b -> z/bravo, etc. @@ -35,7 +36,7 @@ More interesting possibilities exist, though, such as: directory itself contained inner directories that were renamed to yet other locations). - * combinations of the above; see t/t6043-merge-rename-directories.sh for + * combinations of the above; see t/t6423-merge-rename-directories.sh for various interesting cases. Limitations -- applicability of directory renames @@ -62,19 +63,19 @@ directory rename detection applies: Limitations -- detailed rules and testcases ------------------------------------------- -t/t6043-merge-rename-directories.sh contains extensive tests and commentary +t/t6423-merge-rename-directories.sh contains extensive tests and commentary which generate and explore the rules listed above. It also lists a few additional rules: a) If renames split a directory into two or more others, the directory with the most renames, "wins". - b) Avoid directory-rename-detection for a path, if that path is the - source of a rename on either side of a merge. - - c) Only apply implicit directory renames to directories if the other side + b) Only apply implicit directory renames to directories if the other side of history is the one doing the renaming. + c) Do not perform directory rename detection for directories which had no + new paths added to them. + Limitations -- support in different commands -------------------------------------------- @@ -2768,6 +2768,9 @@ endif ifdef GIT_TEST_INDEX_VERSION @echo GIT_TEST_INDEX_VERSION=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_INDEX_VERSION)))'\' >>$@+ endif +ifdef GIT_TEST_PERL_FATAL_WARNINGS + @echo GIT_TEST_PERL_FATAL_WARNINGS=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_PERL_FATAL_WARNINGS)))'\' >>$@+ +endif @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi ### Detect Python interpreter path changes @@ -4699,8 +4699,13 @@ static int apply_patch(struct apply_state *state, reverse_patches(patch); if (use_patch(state, patch)) { patch_stats(state, patch); - *listp = patch; - listp = &patch->next; + if (!list || !state->apply_in_reverse) { + *listp = patch; + listp = &patch->next; + } else { + patch->next = list; + list = patch; + } if ((patch->new_name && ends_with_path_components(patch->new_name, @@ -1090,7 +1090,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix) nr), nr, steps_msg); free(steps_msg); /* Clean up objects used, as they will be reused. */ - clear_commit_marks_all(ALL_REV_FLAGS); + repo_clear_commit_marks(r, ALL_REV_FLAGS); return bisect_checkout(bisect_rev, no_checkout); } diff --git a/builtin/am.c b/builtin/am.c index 4949535a7f..f22c73a05b 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -98,8 +98,6 @@ struct am_state { char *author_name; char *author_email; char *author_date; - char *committer_name; - char *committer_email; char *msg; size_t msg_len; @@ -132,8 +130,6 @@ struct am_state { */ static void am_state_init(struct am_state *state) { - const char *committer; - struct ident_split id; int gpgsign; memset(state, 0, sizeof(*state)); @@ -154,14 +150,6 @@ static void am_state_init(struct am_state *state) if (!git_config_get_bool("commit.gpgsign", &gpgsign)) state->sign_commit = gpgsign ? "" : NULL; - - committer = git_committer_info(IDENT_STRICT); - if (split_ident_line(&id, committer, strlen(committer)) < 0) - die(_("invalid committer: %s"), committer); - state->committer_name = - xmemdupz(id.name_begin, id.name_end - id.name_begin); - state->committer_email = - xmemdupz(id.mail_begin, id.mail_end - id.mail_begin); } /** @@ -173,8 +161,6 @@ static void am_state_release(struct am_state *state) free(state->author_name); free(state->author_email); free(state->author_date); - free(state->committer_name); - free(state->committer_email); free(state->msg); strvec_clear(&state->git_apply_opts); } @@ -1594,8 +1580,9 @@ static void do_commit(const struct am_state *state) IDENT_STRICT); if (state->committer_date_is_author_date) - committer = fmt_ident(state->committer_name, - state->committer_email, WANT_COMMITTER_IDENT, + committer = fmt_ident(getenv("GIT_COMMITTER_NAME"), + getenv("GIT_COMMITTER_EMAIL"), + WANT_COMMITTER_IDENT, state->ignore_date ? NULL : state->author_date, IDENT_STRICT); @@ -2237,7 +2224,7 @@ int cmd_am(int argc, const char **argv, const char *prefix) N_("allow fall back on 3way merging if needed")), OPT__QUIET(&state.quiet, N_("be quiet")), OPT_SET_INT('s', "signoff", &state.signoff, - N_("add a Signed-off-by line to the commit message"), + N_("add a Signed-off-by trailer to the commit message"), SIGNOFF_EXPLICIT), OPT_BOOL('u', "utf8", &state.utf8, N_("recode into utf8 (default)")), diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c index 7512b880f0..709eb713a3 100644 --- a/builtin/bisect--helper.c +++ b/builtin/bisect--helper.c @@ -20,9 +20,6 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") static const char * const git_bisect_helper_usage[] = { - N_("git bisect--helper --next-all"), - N_("git bisect--helper --write-terms <bad_term> <good_term>"), - N_("git bisect--helper --bisect-clean-state"), N_("git bisect--helper --bisect-reset [<commit>]"), N_("git bisect--helper --bisect-write [--no-log] <state> <revision> <good_term> <bad_term>"), N_("git bisect--helper --bisect-check-and-set-terms <command> <good_term> <bad_term>"), @@ -32,7 +29,8 @@ static const char * const git_bisect_helper_usage[] = { " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]"), N_("git bisect--helper --bisect-next"), N_("git bisect--helper --bisect-auto-next"), - N_("git bisect--helper --bisect-autostart"), + N_("git bisect--helper --bisect-state (bad|new) [<rev>]"), + N_("git bisect--helper --bisect-state (good|old) [<rev>...]"), NULL }; @@ -85,6 +83,19 @@ static int one_of(const char *term, ...) return res; } +/* + * return code BISECT_INTERNAL_SUCCESS_MERGE_BASE + * and BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND are codes + * that indicate special success. + */ + +static int is_bisect_success(enum bisect_error res) +{ + return !res || + res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND || + res == BISECT_INTERNAL_SUCCESS_MERGE_BASE; +} + static int write_in_file(const char *path, const char *mode, const char *format, va_list args) { FILE *fp = NULL; @@ -174,30 +185,6 @@ static int write_terms(const char *bad, const char *good) return res; } -static int is_expected_rev(const char *expected_hex) -{ - struct strbuf actual_hex = STRBUF_INIT; - int res = 0; - if (strbuf_read_file(&actual_hex, git_path_bisect_expected_rev(), 0) >= 40) { - strbuf_trim(&actual_hex); - res = !strcmp(actual_hex.buf, expected_hex); - } - strbuf_release(&actual_hex); - return res; -} - -static void check_expected_revs(const char **revs, int rev_nr) -{ - int i; - - for (i = 0; i < rev_nr; i++) { - if (!is_expected_rev(revs[i])) { - unlink_or_warn(git_path_bisect_ancestors_ok()); - unlink_or_warn(git_path_bisect_expected_rev()); - } - } -} - static int bisect_reset(const char *commit) { struct strbuf branch = STRBUF_INIT; @@ -609,12 +596,13 @@ static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const char return bisect_next(terms, prefix); } -static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) +static enum bisect_error bisect_start(struct bisect_terms *terms, const char **argv, int argc) { int no_checkout = 0; int first_parent_only = 0; int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0; - int flags, pathspec_pos, res = 0; + int flags, pathspec_pos; + enum bisect_error res = BISECT_OK; struct string_list revs = STRING_LIST_INIT_DUP; struct string_list states = STRING_LIST_INIT_DUP; struct strbuf start_head = STRBUF_INIT; @@ -753,14 +741,7 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) * Get rid of any old bisect state. */ if (bisect_clean_state()) - return -1; - - /* - * In case of mistaken revs or checkout error, or signals received, - * "bisect_auto_next" below may exit or misbehave. - * We have to trap this to be able to clean up using - * "bisect_clean_state". - */ + return BISECT_FAILED; /* * Write new start state @@ -777,7 +758,7 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) } if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR)) { - res = -1; + res = BISECT_FAILED; goto finish; } } @@ -789,25 +770,31 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) for (i = 0; i < states.nr; i++) if (bisect_write(states.items[i].string, revs.items[i].string, terms, 1)) { - res = -1; + res = BISECT_FAILED; goto finish; } if (must_write_terms && write_terms(terms->term_bad, terms->term_good)) { - res = -1; + res = BISECT_FAILED; goto finish; } res = bisect_append_log_quoted(argv); if (res) - res = -1; + res = BISECT_FAILED; finish: string_list_clear(&revs, 0); string_list_clear(&states, 0); strbuf_release(&start_head); strbuf_release(&bisect_names); + if (res) + return res; + + res = bisect_auto_next(terms, NULL); + if (!is_bisect_success(res)) + bisect_clean_state(); return res; } @@ -843,14 +830,84 @@ static int bisect_autostart(struct bisect_terms *terms) return res; } +static enum bisect_error bisect_state(struct bisect_terms *terms, const char **argv, + int argc) +{ + const char *state; + int i, verify_expected = 1; + struct object_id oid, expected; + struct strbuf buf = STRBUF_INIT; + struct oid_array revs = OID_ARRAY_INIT; + + if (!argc) + return error(_("Please call `--bisect-state` with at least one argument")); + + if (bisect_autostart(terms)) + return BISECT_FAILED; + + state = argv[0]; + if (check_and_set_terms(terms, state) || + !one_of(state, terms->term_good, terms->term_bad, "skip", NULL)) + return BISECT_FAILED; + + argv++; + argc--; + if (argc > 1 && !strcmp(state, terms->term_bad)) + return error(_("'git bisect %s' can take only one argument."), terms->term_bad); + + if (argc == 0) { + const char *head = "BISECT_HEAD"; + enum get_oid_result res_head = get_oid(head, &oid); + + if (res_head == MISSING_OBJECT) { + head = "HEAD"; + res_head = get_oid(head, &oid); + } + + if (res_head) + error(_("Bad rev input: %s"), head); + oid_array_append(&revs, &oid); + } + + /* + * All input revs must be checked before executing bisect_write() + * to discard junk revs. + */ + + for (; argc; argc--, argv++) { + if (get_oid(*argv, &oid)){ + error(_("Bad rev input: %s"), *argv); + oid_array_clear(&revs); + return BISECT_FAILED; + } + oid_array_append(&revs, &oid); + } + + if (strbuf_read_file(&buf, git_path_bisect_expected_rev(), 0) < the_hash_algo->hexsz || + get_oid_hex(buf.buf, &expected) < 0) + verify_expected = 0; /* Ignore invalid file contents */ + strbuf_release(&buf); + + for (i = 0; i < revs.nr; i++) { + if (bisect_write(state, oid_to_hex(&revs.oid[i]), terms, 0)) { + oid_array_clear(&revs); + return BISECT_FAILED; + } + if (verify_expected && !oideq(&revs.oid[i], &expected)) { + unlink_or_warn(git_path_bisect_ancestors_ok()); + unlink_or_warn(git_path_bisect_expected_rev()); + verify_expected = 0; + } + } + + oid_array_clear(&revs); + return bisect_auto_next(terms, NULL); +} + int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { enum { - NEXT_ALL = 1, - WRITE_TERMS, - BISECT_CLEAN_STATE, - CHECK_EXPECTED_REVS, - BISECT_RESET, + BISECT_RESET = 1, BISECT_WRITE, CHECK_AND_SET_TERMS, BISECT_NEXT_CHECK, @@ -858,18 +915,11 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) BISECT_START, BISECT_AUTOSTART, BISECT_NEXT, - BISECT_AUTO_NEXT + BISECT_AUTO_NEXT, + BISECT_STATE } cmdmode = 0; int res = 0, nolog = 0; struct option options[] = { - OPT_CMDMODE(0, "next-all", &cmdmode, - N_("perform 'git bisect next'"), NEXT_ALL), - OPT_CMDMODE(0, "write-terms", &cmdmode, - N_("write the terms to .git/BISECT_TERMS"), WRITE_TERMS), - OPT_CMDMODE(0, "bisect-clean-state", &cmdmode, - N_("cleanup the bisection state"), BISECT_CLEAN_STATE), - OPT_CMDMODE(0, "check-expected-revs", &cmdmode, - N_("check for expected revs"), CHECK_EXPECTED_REVS), OPT_CMDMODE(0, "bisect-reset", &cmdmode, N_("reset the bisection state"), BISECT_RESET), OPT_CMDMODE(0, "bisect-write", &cmdmode, @@ -886,8 +936,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("find the next bisection commit"), BISECT_NEXT), OPT_CMDMODE(0, "bisect-auto-next", &cmdmode, N_("verify the next bisection state then checkout the next bisection commit"), BISECT_AUTO_NEXT), - OPT_CMDMODE(0, "bisect-autostart", &cmdmode, - N_("start the bisection if it has not yet been started"), BISECT_AUTOSTART), + OPT_CMDMODE(0, "bisect-state", &cmdmode, + N_("mark the state of ref (or refs)"), BISECT_STATE), OPT_BOOL(0, "no-log", &nolog, N_("no log for BISECT_WRITE")), OPT_END() @@ -902,20 +952,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) usage_with_options(git_bisect_helper_usage, options); switch (cmdmode) { - case NEXT_ALL: - res = bisect_next_all(the_repository, prefix); - break; - case WRITE_TERMS: - if (argc != 2) - return error(_("--write-terms requires two arguments")); - return write_terms(argv[0], argv[1]); - case BISECT_CLEAN_STATE: - if (argc != 0) - return error(_("--bisect-clean-state requires no arguments")); - return bisect_clean_state(); - case CHECK_EXPECTED_REVS: - check_expected_revs(argv, argc); - return 0; case BISECT_RESET: if (argc > 1) return error(_("--bisect-reset requires either no argument or a commit")); @@ -959,11 +995,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) get_terms(&terms); res = bisect_auto_next(&terms, prefix); break; - case BISECT_AUTOSTART: - if (argc) - return error(_("--bisect-autostart does not accept arguments")); + case BISECT_STATE: set_terms(&terms, "bad", "good"); - res = bisect_autostart(&terms); + get_terms(&terms); + res = bisect_state(&terms, argv, argc); break; default: BUG("unknown subcommand %d", cmdmode); diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index a854fd16e7..4bbfc92dce 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -79,6 +79,14 @@ static int checkout_file(const char *name, const char *prefix) return errs > 0 ? -1 : 0; } + /* + * At this point we know we didn't try to check anything out. If it was + * because we did find an entry but it was stage 0, that's not an + * error. + */ + if (has_same_name && checkout_stage == CHECKOUT_ALL) + return 0; + if (!state.quiet) { fprintf(stderr, "git checkout-index: %s ", name); if (!has_same_name) @@ -159,6 +167,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) int prefix_length; int force = 0, quiet = 0, not_new = 0; int index_opt = 0; + int err = 0; struct option builtin_checkout_index_options[] = { OPT_BOOL('a', "all", &all, N_("check out all files in the index")), @@ -223,7 +232,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) if (read_from_stdin) die("git checkout-index: don't mix '--stdin' and explicit filenames"); p = prefix_path(prefix, prefix_length, arg); - checkout_file(p, prefix); + err |= checkout_file(p, prefix); free(p); } @@ -245,13 +254,16 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) strbuf_swap(&buf, &unquoted); } p = prefix_path(prefix, prefix_length, buf.buf); - checkout_file(p, prefix); + err |= checkout_file(p, prefix); free(p); } strbuf_release(&unquoted); strbuf_release(&buf); } + if (err) + return 1; + if (all) checkout_all(prefix, prefix_length); diff --git a/builtin/checkout.c b/builtin/checkout.c index 7c311cecb3..9b82119129 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1042,7 +1042,7 @@ static void orphaned_commit_warning(struct commit *old_commit, struct commit *ne describe_detached_head(_("Previous HEAD position was"), old_commit); /* Clean up objects used, as they will be reused. */ - clear_commit_marks_all(ALL_REV_FLAGS); + repo_clear_commit_marks(the_repository, ALL_REV_FLAGS); } static int switch_branches(const struct checkout_opts *opts, diff --git a/builtin/commit.c b/builtin/commit.c index 1dfd799ec5..505fe60956 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1507,7 +1507,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) OPT_STRING(0, "fixup", &fixup_message, N_("commit"), N_("use autosquash formatted message to fixup specified commit")), OPT_STRING(0, "squash", &squash_message, N_("commit"), N_("use autosquash formatted message to squash specified commit")), OPT_BOOL(0, "reset-author", &renew_authorship, N_("the commit is authored by me now (used with -C/-c/--amend)")), - OPT_BOOL('s', "signoff", &signoff, N_("add Signed-off-by:")), + OPT_BOOL('s', "signoff", &signoff, N_("add a Signed-off-by trailer")), OPT_FILENAME('t', "template", &template_file, N_("use specified template file")), OPT_BOOL('e', "edit", &edit_flag, N_("force edit of commit")), OPT_CLEANUP(&cleanup_arg), diff --git a/builtin/credential.c b/builtin/credential.c index 879acfbcda..d75dcdc64a 100644 --- a/builtin/credential.c +++ b/builtin/credential.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "credential.h" #include "builtin.h" +#include "config.h" static const char usage_msg[] = "git credential [fill|approve|reject]"; @@ -10,6 +11,8 @@ int cmd_credential(int argc, const char **argv, const char *prefix) const char *op; struct credential c = CREDENTIAL_INIT; + git_config(git_default_config, NULL); + if (argc != 2 || !strcmp(argv[1], "-h")) usage(usage_msg); op = argv[1]; diff --git a/builtin/diff-index.c b/builtin/diff-index.c index 93ec642423..7f5281c461 100644 --- a/builtin/diff-index.c +++ b/builtin/diff-index.c @@ -15,7 +15,7 @@ COMMON_DIFF_OPTIONS_HELP; int cmd_diff_index(int argc, const char **argv, const char *prefix) { struct rev_info rev; - int cached = 0; + unsigned int option = 0; int i; int result; @@ -32,7 +32,9 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) const char *arg = argv[i]; if (!strcmp(arg, "--cached")) - cached = 1; + option |= DIFF_INDEX_CACHED; + else if (!strcmp(arg, "--merge-base")) + option |= DIFF_INDEX_MERGE_BASE; else usage(diff_cache_usage); } @@ -46,7 +48,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) if (rev.pending.nr != 1 || rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1) usage(diff_cache_usage); - if (!cached) { + if (!(option & DIFF_INDEX_CACHED)) { setup_work_tree(); if (read_cache_preload(&rev.diffopt.pathspec) < 0) { perror("read_cache_preload"); @@ -56,7 +58,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) perror("read_cache"); return -1; } - result = run_diff_index(&rev, cached); + result = run_diff_index(&rev, option); UNLEAK(rev); return diff_result_code(&rev.diffopt, result); } diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index 802363d0a2..9fc95e959f 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -111,6 +111,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix) struct setup_revision_opt s_r_opt; struct userformat_want w; int read_stdin = 0; + int merge_base = 0; if (argc == 2 && !strcmp(argv[1], "-h")) usage(diff_tree_usage); @@ -143,9 +144,18 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix) read_stdin = 1; continue; } + if (!strcmp(arg, "--merge-base")) { + merge_base = 1; + continue; + } usage(diff_tree_usage); } + if (read_stdin && merge_base) + die(_("--stdin and --merge-base are mutually exclusive")); + if (merge_base && opt->pending.nr != 2) + die(_("--merge-base only works with two commits")); + /* * NOTE! We expect "a..b" to expand to "^a b" but it is * perfectly valid for revision range parser to yield "b ^a", @@ -165,7 +175,12 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix) case 2: tree1 = opt->pending.objects[0].item; tree2 = opt->pending.objects[1].item; - if (tree2->flags & UNINTERESTING) { + if (merge_base) { + struct object_id oid; + + diff_get_merge_base(opt, &oid); + tree1 = lookup_object(the_repository, &oid); + } else if (tree2->flags & UNINTERESTING) { SWAP(tree2, tree1); } diff_tree_oid(&tree1->oid, &tree2->oid, "", &opt->diffopt); diff --git a/builtin/diff.c b/builtin/diff.c index cd4083fed9..780c33877f 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -26,7 +26,7 @@ static const char builtin_diff_usage[] = "git diff [<options>] [<commit>] [--] [<path>...]\n" " or: git diff [<options>] --cached [<commit>] [--] [<path>...]\n" -" or: git diff [<options>] <commit> [<commit>...] <commit> [--] [<path>...]\n" +" or: git diff [<options>] <commit> [--merge-base] [<commit>...] <commit> [--] [<path>...]\n" " or: git diff [<options>] <commit>...<commit>] [--] [<path>...]\n" " or: git diff [<options>] <blob> <blob>]\n" " or: git diff [<options>] --no-index [--] <path> <path>]\n" @@ -134,11 +134,13 @@ static int builtin_diff_blobs(struct rev_info *revs, static int builtin_diff_index(struct rev_info *revs, int argc, const char **argv) { - int cached = 0; + unsigned int option = 0; while (1 < argc) { const char *arg = argv[1]; if (!strcmp(arg, "--cached") || !strcmp(arg, "--staged")) - cached = 1; + option |= DIFF_INDEX_CACHED; + else if (!strcmp(arg, "--merge-base")) + option |= DIFF_INDEX_MERGE_BASE; else usage(builtin_diff_usage); argv++; argc--; @@ -151,7 +153,7 @@ static int builtin_diff_index(struct rev_info *revs, revs->max_count != -1 || revs->min_age != -1 || revs->max_age != -1) usage(builtin_diff_usage); - if (!cached) { + if (!(option & DIFF_INDEX_CACHED)) { setup_work_tree(); if (read_cache_preload(&revs->diffopt.pathspec) < 0) { perror("read_cache_preload"); @@ -161,7 +163,7 @@ static int builtin_diff_index(struct rev_info *revs, perror("read_cache"); return -1; } - return run_diff_index(revs, cached); + return run_diff_index(revs, option); } static int builtin_diff_tree(struct rev_info *revs, @@ -170,19 +172,34 @@ static int builtin_diff_tree(struct rev_info *revs, struct object_array_entry *ent1) { const struct object_id *(oid[2]); - int swap = 0; + struct object_id mb_oid; + int merge_base = 0; - if (argc > 1) - usage(builtin_diff_usage); + while (1 < argc) { + const char *arg = argv[1]; + if (!strcmp(arg, "--merge-base")) + merge_base = 1; + else + usage(builtin_diff_usage); + argv++; argc--; + } - /* - * We saw two trees, ent0 and ent1. If ent1 is uninteresting, - * swap them. - */ - if (ent1->item->flags & UNINTERESTING) - swap = 1; - oid[swap] = &ent0->item->oid; - oid[1 - swap] = &ent1->item->oid; + if (merge_base) { + diff_get_merge_base(revs, &mb_oid); + oid[0] = &mb_oid; + oid[1] = &revs->pending.objects[1].item->oid; + } else { + int swap = 0; + + /* + * We saw two trees, ent0 and ent1. If ent1 is uninteresting, + * swap them. + */ + if (ent1->item->flags & UNINTERESTING) + swap = 1; + oid[swap] = &ent0->item->oid; + oid[1 - swap] = &ent1->item->oid; + } diff_tree_oid(oid[0], oid[1], "", &revs->diffopt); log_tree_diff_flush(revs); return 0; diff --git a/builtin/fast-import.c b/builtin/fast-import.c index 1bf50a73dc..dd4d09cece 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -150,7 +150,7 @@ struct recent_command { char *buf; }; -typedef void (*mark_set_inserter_t)(struct mark_set *s, struct object_id *oid, uintmax_t mark); +typedef void (*mark_set_inserter_t)(struct mark_set **s, struct object_id *oid, uintmax_t mark); typedef void (*each_mark_fn_t)(uintmax_t mark, void *obj, void *cbp); /* Configured limits on output */ @@ -526,13 +526,15 @@ static unsigned int hc_str(const char *s, size_t len) return r; } -static void insert_mark(struct mark_set *s, uintmax_t idnum, struct object_entry *oe) +static void insert_mark(struct mark_set **top, uintmax_t idnum, struct object_entry *oe) { + struct mark_set *s = *top; + while ((idnum >> s->shift) >= 1024) { s = mem_pool_calloc(&fi_mem_pool, 1, sizeof(struct mark_set)); - s->shift = marks->shift + 10; - s->data.sets[0] = marks; - marks = s; + s->shift = (*top)->shift + 10; + s->data.sets[0] = *top; + *top = s; } while (s->shift) { uintmax_t i = idnum >> s->shift; @@ -944,7 +946,7 @@ static int store_object( e = insert_object(&oid); if (mark) - insert_mark(marks, mark, e); + insert_mark(&marks, mark, e); if (e->idx.offset) { duplicate_count_by_type[type]++; return 1; @@ -1142,7 +1144,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark) e = insert_object(&oid); if (mark) - insert_mark(marks, mark, e); + insert_mark(&marks, mark, e); if (e->idx.offset) { duplicate_count_by_type[OBJ_BLOB]++; @@ -1717,7 +1719,7 @@ static void dump_marks(void) } } -static void insert_object_entry(struct mark_set *s, struct object_id *oid, uintmax_t mark) +static void insert_object_entry(struct mark_set **s, struct object_id *oid, uintmax_t mark) { struct object_entry *e; e = find_object(oid); @@ -1734,12 +1736,12 @@ static void insert_object_entry(struct mark_set *s, struct object_id *oid, uintm insert_mark(s, mark, e); } -static void insert_oid_entry(struct mark_set *s, struct object_id *oid, uintmax_t mark) +static void insert_oid_entry(struct mark_set **s, struct object_id *oid, uintmax_t mark) { insert_mark(s, mark, xmemdupz(oid, sizeof(*oid))); } -static void read_mark_file(struct mark_set *s, FILE *f, mark_set_inserter_t inserter) +static void read_mark_file(struct mark_set **s, FILE *f, mark_set_inserter_t inserter) { char line[512]; while (fgets(line, sizeof(line), f)) { @@ -1772,7 +1774,7 @@ static void read_marks(void) goto done; /* Marks file does not exist */ else die_errno("cannot read '%s'", import_marks_file); - read_mark_file(marks, f, insert_object_entry); + read_mark_file(&marks, f, insert_object_entry); fclose(f); done: import_marks_file_done = 1; @@ -3228,7 +3230,7 @@ static void parse_alias(void) die(_("Expected 'to' command, got %s"), command_buf.buf); e = find_object(&b.oid); assert(e); - insert_mark(marks, next_mark, e); + insert_mark(&marks, next_mark, e); } static char* make_fast_import_path(const char *path) @@ -3321,13 +3323,14 @@ static void option_rewrite_submodules(const char *arg, struct string_list *list) *f = '\0'; f++; ms = xcalloc(1, sizeof(*ms)); - string_list_insert(list, s)->util = ms; fp = fopen(f, "r"); if (!fp) die_errno("cannot read '%s'", f); - read_mark_file(ms, fp, insert_oid_entry); + read_mark_file(&ms, fp, insert_oid_entry); fclose(fp); + + string_list_insert(list, s)->util = ms; } static int parse_one_option(const char *option) @@ -3396,7 +3399,6 @@ static int parse_one_feature(const char *feature, int from_stream) option_rewrite_submodules(arg, &sub_marks_to); } else if (skip_prefix(feature, "rewrite-submodules-from=", &arg)) { option_rewrite_submodules(arg, &sub_marks_from); - } else if (skip_prefix(feature, "rewrite-submodules-from=", &arg)) { } else if (!strcmp(feature, "get-mark")) { ; /* Don't die - this feature is supported */ } else if (!strcmp(feature, "cat-blob")) { diff --git a/builtin/gc.c b/builtin/gc.c index 2b99596ec8..5cd2a43f9f 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -739,9 +739,15 @@ static int dfs_on_ref(const char *refname, commit = lookup_commit(the_repository, oid); if (!commit) return 0; - if (parse_commit(commit)) + if (parse_commit(commit) || + commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH) return 0; + data->num_not_in_graph++; + + if (data->num_not_in_graph >= data->limit) + return 1; + commit_list_append(commit, &stack); while (!result && stack) { @@ -788,7 +794,7 @@ static int should_write_commit_graph(void) result = for_each_ref(dfs_on_ref, &data); - clear_commit_marks_all(SEEN); + repo_clear_commit_marks(the_repository, SEEN); return result; } @@ -809,6 +815,10 @@ static int run_write_commit_graph(struct maintenance_run_opts *opts) static int maintenance_task_commit_graph(struct maintenance_run_opts *opts) { + prepare_repo_settings(the_repository); + if (!the_repository->settings.core_commit_graph) + return 0; + close_object_store(the_repository->objects); if (run_write_commit_graph(opts)) { error(_("failed to write commit-graph")); diff --git a/builtin/log.c b/builtin/log.c index 0a7ed4bef9..9f939e6cdf 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1738,7 +1738,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) OPT_CALLBACK_F('N', "no-numbered", &numbered, NULL, N_("use [PATCH] even with multiple patches"), PARSE_OPT_NOARG | PARSE_OPT_NONEG, no_numbered_callback), - OPT_BOOL('s', "signoff", &do_signoff, N_("add Signed-off-by:")), + OPT_BOOL('s', "signoff", &do_signoff, N_("add a Signed-off-by trailer")), OPT_BOOL(0, "stdout", &use_stdout, N_("print patches to standard out")), OPT_BOOL(0, "cover-letter", &cover_letter, diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index e72714a5a8..de8520778d 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -109,6 +109,7 @@ static void show_diff(struct merge_list *entry) xdemitconf_t xecfg; xdemitcb_t ecb; + memset(&xpp, 0, sizeof(xpp)); xpp.flags = 0; memset(&xecfg, 0, sizeof(xecfg)); xecfg.ctxlen = 3; diff --git a/builtin/merge.c b/builtin/merge.c index 9d5359edc2..4c133402a6 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -289,7 +289,7 @@ static struct option builtin_merge_options[] = { N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" }, OPT_AUTOSTASH(&autostash), OPT_BOOL(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")), - OPT_BOOL(0, "signoff", &signoff, N_("add Signed-off-by:")), + OPT_BOOL(0, "signoff", &signoff, N_("add a Signed-off-by trailer")), OPT_BOOL(0, "no-verify", &no_verify, N_("bypass pre-merge-commit and commit-msg hooks")), OPT_END() }; diff --git a/builtin/pull.c b/builtin/pull.c index 425950f469..17aa63cd35 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -142,7 +142,7 @@ static struct option pull_options[] = { N_("add (at most <n>) entries from shortlog to merge commit message"), PARSE_OPT_OPTARG), OPT_PASSTHRU(0, "signoff", &opt_signoff, NULL, - N_("add Signed-off-by:"), + N_("add a Signed-off-by trailer"), PARSE_OPT_OPTARG), OPT_PASSTHRU(0, "squash", &opt_squash, NULL, N_("create a single commit instead of doing a merge"), diff --git a/builtin/rebase.c b/builtin/rebase.c index eeca53382f..7b65525301 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1324,7 +1324,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) N_("do not show diffstat of what changed upstream"), PARSE_OPT_NOARG, NULL, REBASE_DIFFSTAT }, OPT_BOOL(0, "signoff", &options.signoff, - N_("add a Signed-off-by: line to each commit")), + N_("add a Signed-off-by trailer to each commit")), OPT_BOOL(0, "committer-date-is-author-date", &options.committer_date_is_author_date, N_("make committer date match author date")), diff --git a/builtin/remote.c b/builtin/remote.c index 63f2b46c3d..c1b211b272 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -191,8 +191,10 @@ static int add(int argc, const char **argv) url = argv[1]; remote = remote_get(name); - if (remote_is_configured(remote, 1)) - die(_("remote %s already exists."), name); + if (remote_is_configured(remote, 1)) { + error(_("remote %s already exists."), name); + exit(3); + } if (!valid_remote_name(name)) die(_("'%s' is not a valid remote name"), name); @@ -685,15 +687,19 @@ static int mv(int argc, const char **argv) rename.remote_branches = &remote_branches; oldremote = remote_get(rename.old_name); - if (!remote_is_configured(oldremote, 1)) - die(_("No such remote: '%s'"), rename.old_name); + if (!remote_is_configured(oldremote, 1)) { + error(_("No such remote: '%s'"), rename.old_name); + exit(2); + } if (!strcmp(rename.old_name, rename.new_name) && oldremote->origin != REMOTE_CONFIG) return migrate_file(oldremote); newremote = remote_get(rename.new_name); - if (remote_is_configured(newremote, 1)) - die(_("remote %s already exists."), rename.new_name); + if (remote_is_configured(newremote, 1)) { + error(_("remote %s already exists."), rename.new_name); + exit(3); + } if (!valid_remote_name(rename.new_name)) die(_("'%s' is not a valid remote name"), rename.new_name); @@ -826,8 +832,10 @@ static int rm(int argc, const char **argv) usage_with_options(builtin_remote_rm_usage, options); remote = remote_get(argv[1]); - if (!remote_is_configured(remote, 1)) - die(_("No such remote: '%s'"), argv[1]); + if (!remote_is_configured(remote, 1)) { + error(_("No such remote: '%s'"), argv[1]); + exit(2); + } known_remotes.to_delete = remote; for_each_remote(add_known_remote, &known_remotes); @@ -1508,8 +1516,10 @@ static int set_remote_branches(const char *remotename, const char **branches, strbuf_addf(&key, "remote.%s.fetch", remotename); remote = remote_get(remotename); - if (!remote_is_configured(remote, 1)) - die(_("No such remote '%s'"), remotename); + if (!remote_is_configured(remote, 1)) { + error(_("No such remote '%s'"), remotename); + exit(2); + } if (!add_mode && remove_all_fetch_refspecs(key.buf)) { strbuf_release(&key); @@ -1562,8 +1572,10 @@ static int get_url(int argc, const char **argv) remotename = argv[0]; remote = remote_get(remotename); - if (!remote_is_configured(remote, 1)) - die(_("No such remote '%s'"), remotename); + if (!remote_is_configured(remote, 1)) { + error(_("No such remote '%s'"), remotename); + exit(2); + } url_nr = 0; if (push_mode) { @@ -1630,8 +1642,10 @@ static int set_url(int argc, const char **argv) oldurl = newurl; remote = remote_get(remotename); - if (!remote_is_configured(remote, 1)) - die(_("No such remote '%s'"), remotename); + if (!remote_is_configured(remote, 1)) { + error(_("No such remote '%s'"), remotename); + exit(2); + } if (push_mode) { strbuf_addf(&name_buf, "remote.%s.pushurl", remotename); diff --git a/builtin/revert.c b/builtin/revert.c index f61cc5d82c..da8997dc86 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -107,7 +107,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) OPT_BOOL('n', "no-commit", &opts->no_commit, N_("don't automatically commit")), OPT_BOOL('e', "edit", &opts->edit, N_("edit the commit message")), OPT_NOOP_NOARG('r', NULL), - OPT_BOOL('s', "signoff", &opts->signoff, N_("add Signed-off-by:")), + OPT_BOOL('s', "signoff", &opts->signoff, N_("add a Signed-off-by trailer")), OPT_CALLBACK('m', "mainline", opts, N_("parent-number"), N_("select mainline parent"), option_parse_m), OPT_RERERE_AUTOUPDATE(&opts->allow_rerere_auto), diff --git a/commit-graph.c b/commit-graph.c index cb042bdba8..6f62a07313 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -2008,7 +2008,7 @@ static int commit_compare(const void *_a, const void *_b) static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx) { - uint32_t i; + uint32_t i, dedup_i = 0; if (ctx->report_progress) ctx->progress = start_delayed_progress( @@ -2023,17 +2023,27 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx) if (i && oideq(&ctx->commits.list[i - 1]->object.oid, &ctx->commits.list[i]->object.oid)) { - die(_("unexpected duplicate commit id %s"), - oid_to_hex(&ctx->commits.list[i]->object.oid)); + /* + * Silently ignore duplicates. These were likely + * created due to a commit appearing in multiple + * layers of the chain, which is unexpected but + * not invalid. We should make sure there is a + * unique copy in the new layer. + */ } else { unsigned int num_parents; + ctx->commits.list[dedup_i] = ctx->commits.list[i]; + dedup_i++; + num_parents = commit_list_count(ctx->commits.list[i]->parents); if (num_parents > 2) ctx->num_extra_edges += num_parents - 1; } } + ctx->commits.nr = dedup_i; + stop_progress(&ctx->progress); } @@ -2150,6 +2160,11 @@ int write_commit_graph(struct object_directory *odb, int replace = 0; struct bloom_filter_settings bloom_settings = DEFAULT_BLOOM_FILTER_SETTINGS; + prepare_repo_settings(the_repository); + if (!the_repository->settings.core_commit_graph) { + warning(_("attempting to write a commit-graph, but 'core.commitGraph' is disabled")); + return 0; + } if (!commit_graph_compatible(the_repository)) return 0; @@ -1586,7 +1586,7 @@ const char *find_commit_header(const char *msg, const char *key, size_t *out_len /* * Inspect the given string and determine the true "end" of the log message, in - * order to find where to put a new Signed-off-by: line. Ignored are + * order to find where to put a new Signed-off-by trailer. Ignored are * trailing comment lines and blank lines. To support "git commit -s * --amend" on an existing commit, we also ignore "Conflicts:". To * support "git commit -v", we truncate at cut lines. diff --git a/config.mak.dev b/config.mak.dev index 89b218d11a..3126a5364d 100644 --- a/config.mak.dev +++ b/config.mak.dev @@ -15,6 +15,7 @@ DEVELOPER_CFLAGS += -Wpointer-arith DEVELOPER_CFLAGS += -Wstrict-prototypes DEVELOPER_CFLAGS += -Wunused DEVELOPER_CFLAGS += -Wvla +DEVELOPER_CFLAGS += -fno-common ifndef COMPILER_FEATURES COMPILER_FEATURES := $(shell ./detect-compiler $(CC)) @@ -45,3 +46,5 @@ ifeq ($(filter gcc5,$(COMPILER_FEATURES)),) DEVELOPER_CFLAGS += -Wno-uninitialized endif endif + +GIT_TEST_PERL_FATAL_WARNINGS = YesPlease diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index aea30d74a0..7c81e4ba49 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -416,14 +416,13 @@ __gitcomp_builtin () local options eval "options=\${$var-}" - local completion_helper - if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then - completion_helper="--git-completion-helper-all" - else - completion_helper="--git-completion-helper" - fi - if [ -z "$options" ]; then + local completion_helper + if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then + completion_helper="--git-completion-helper-all" + else + completion_helper="--git-completion-helper" + fi # leading and trailing spaces are significant to make # option removal work correctly. options=" $incl $(__git ${cmd/_/ } $completion_helper) " || return @@ -1698,6 +1697,10 @@ __git_diff_common_options="--stat --numstat --shortstat --summary --patch --no-patch " +__git_diff_difftool_options="--cached --staged --pickaxe-all --pickaxe-regex + --base --ours --theirs --no-index --relative --merge-base + $__git_diff_common_options" + _git_diff () { __git_has_doubledash && return @@ -1720,10 +1723,7 @@ _git_diff () return ;; --*) - __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex - --base --ours --theirs --no-index - $__git_diff_common_options - " + __gitcomp "$__git_diff_difftool_options" return ;; esac @@ -1745,11 +1745,7 @@ _git_difftool () return ;; --*) - __gitcomp_builtin difftool "$__git_diff_common_options - --base --cached --ours --theirs - --pickaxe-all --pickaxe-regex - --relative --staged - " + __gitcomp_builtin difftool "$__git_diff_difftool_options" return ;; esac @@ -3467,88 +3463,8 @@ __gitk_main () __git_complete_revlist } -if [[ -n ${ZSH_VERSION-} ]] && - # Don't define these functions when sourced from 'git-completion.zsh', - # it has its own implementations. - [[ -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then - echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 - - autoload -U +X compinit && compinit - - __gitcomp () - { - emulate -L zsh - - local cur_="${3-$cur}" - - case "$cur_" in - --*=) - ;; - *) - local c IFS=$' \t\n' - local -a array - for c in ${=1}; do - c="$c${4-}" - case $c in - --*=*|*.) ;; - *) c="$c " ;; - esac - array[${#array[@]}+1]="$c" - done - compset -P '*[=:]' - compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 - ;; - esac - } - - __gitcomp_direct () - { - emulate -L zsh - - local IFS=$'\n' - compset -P '*[=:]' - compadd -Q -- ${=1} && _ret=0 - } - - __gitcomp_nl () - { - emulate -L zsh - - local IFS=$'\n' - compset -P '*[=:]' - compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 - } - - __gitcomp_file_direct () - { - emulate -L zsh - - local IFS=$'\n' - compset -P '*[=:]' - compadd -f -- ${=1} && _ret=0 - } - - __gitcomp_file () - { - emulate -L zsh - - local IFS=$'\n' - compset -P '*[=:]' - compadd -p "${2-}" -f -- ${=1} && _ret=0 - } - - _git () - { - local _ret=1 cur cword prev - cur=${words[CURRENT]} - prev=${words[CURRENT-1]} - let cword=CURRENT-1 - emulate ksh -c __${service}_main - let _ret && _default && _ret=0 - return _ret - } - - compdef _git git gitk +if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then + echo "ERROR: this script is obsolete, please see git-completion.zsh" 1>&2 return fi @@ -3570,18 +3486,6 @@ __git_complete () || complete -o default -o nospace -F $wrapper $1 } -# wrapper for backwards compatibility -_git () -{ - __git_wrap__git_main -} - -# wrapper for backwards compatibility -_gitk () -{ - __git_wrap__gitk_main -} - __git_complete git __git_main __git_complete gitk __gitk_main @@ -3589,6 +3493,6 @@ __git_complete gitk __gitk_main # when the user has tab-completed the executable name and consequently # included the '.exe' suffix. # -if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then -__git_complete git.exe __git_main +if [ "$OSTYPE" = cygwin ]; then + __git_complete git.exe __git_main fi diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index ce47e86b60..e0fda27f4c 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -2,26 +2,24 @@ # zsh completion wrapper for git # -# Copyright (c) 2012-2013 Felipe Contreras <felipe.contreras@gmail.com> +# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com> # -# You need git's bash completion script installed somewhere, by default it -# would be the location bash-completion uses. +# The recommended way to install this script is to make a copy of it as a +# file named '_git' inside any directory in your fpath. # -# If your script is somewhere else, you can configure it on your ~/.zshrc: +# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git', +# and then add the following to your ~/.zshrc file: # -# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh +# fpath=(~/.zsh $fpath) # -# The recommended way to install this script is to make a copy of it in -# ~/.zsh/ directory as ~/.zsh/git-completion.zsh and then add the following -# to your ~/.zshrc file: +# You need git's bash completion script installed. By default bash-completion's +# location will be used (e.g. pkg-config --variable=completionsdir bash-completion). +# +# If your bash completion script is somewhere else, you can specify the +# location in your ~/.zshrc: +# +# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash # -# fpath=(~/.zsh $fpath) - -complete () -{ - # do nothing - return 0 -} zstyle -T ':completion:*:*:git:*' tag-order && \ zstyle ':completion:*:*:git:*' tag-order 'common-commands' @@ -29,18 +27,26 @@ zstyle -T ':completion:*:*:git:*' tag-order && \ zstyle -s ":completion:*:*:git:*" script script if [ -z "$script" ]; then local -a locations - local e + local e bash_completion + + bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) || + bash_completion='/usr/share/bash-completion/completions/' + locations=( - $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash - '/etc/bash_completion.d/git' # fedora, old debian - '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian - '/usr/share/bash-completion/git' # gentoo + "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash + "$HOME/.local/share/bash-completion/completions/git" + "$bash_completion/git" + '/etc/bash_completion.d/git' # old debian ) for e in $locations; do test -f $e && script="$e" && break done fi + +local old_complete="$functions[complete]" +functions[complete]=: GIT_SOURCING_ZSH_COMPLETION=y . "$script" +functions[complete]="$old_complete" __gitcomp () { @@ -51,13 +57,35 @@ __gitcomp () case "$cur_" in --*=) ;; + --no-*) + local c IFS=$' \t\n' + local -a array + for c in ${=1}; do + if [[ $c == "--" ]]; then + continue + fi + c="$c${4-}" + case $c in + --*=|*.) ;; + *) c="$c " ;; + esac + array+=("$c") + done + compset -P '*[=:]' + compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 + ;; *) local c IFS=$' \t\n' local -a array for c in ${=1}; do + if [[ $c == "--" ]]; then + c="--no-...${4-}" + array+=("$c ") + break + fi c="$c${4-}" case $c in - --*=*|*.) ;; + --*=|*.) ;; *) c="$c " ;; esac array+=("$c") @@ -72,44 +100,57 @@ __gitcomp_direct () { emulate -L zsh - local IFS=$'\n' compset -P '*[=:]' - compadd -Q -- ${=1} && _ret=0 + compadd -Q -S '' -- ${(f)1} && _ret=0 } __gitcomp_nl () { emulate -L zsh - local IFS=$'\n' compset -P '*[=:]' - compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0 } -__gitcomp_nl_append () +__gitcomp_file () { emulate -L zsh - local IFS=$'\n' - compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + compadd -f -p "${2-}" -- ${(f)1} && _ret=0 +} + +__gitcomp_direct_append () +{ + __gitcomp_direct "$@" +} + +__gitcomp_nl_append () +{ + __gitcomp_nl "$@" } __gitcomp_file_direct () { - emulate -L zsh + __gitcomp_file "$1" "" +} - local IFS=$'\n' - compset -P '*[=:]' - compadd -f -- ${=1} && _ret=0 +_git_zsh () +{ + __gitcomp "v1.1" } -__gitcomp_file () +__git_complete_command () { emulate -L zsh - local IFS=$'\n' - compset -P '*[=:]' - compadd -p "${2-}" -f -- ${=1} && _ret=0 + local command="$1" + local completion_func="_git_${command//-/_}" + if (( $+functions[$completion_func] )); then + emulate ksh -c $completion_func + return 0 + else + return 1 + fi } __git_zsh_bash_func () @@ -118,14 +159,12 @@ __git_zsh_bash_func () local command=$1 - local completion_func="_git_${command//-/_}" - declare -f $completion_func >/dev/null && $completion_func && return + __git_complete_command "$command" && return local expansion=$(__git_aliased_command "$command") if [ -n "$expansion" ]; then words[1]=$expansion - completion_func="_git_${expansion//-/_}" - declare -f $completion_func >/dev/null && $completion_func + __git_complete_command "$expansion" fi } @@ -162,8 +201,9 @@ __git_zsh_cmd_common () __git_zsh_cmd_alias () { local -a list - list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*}) - _describe -t alias-commands 'aliases' list $* && _ret=0 + list=(${${(0)"$(git config -z --get-regexp '^alias\.*')"}#alias.}) + list=(${(f)"$(printf "%s:alias for '%s'\n" ${(f@)list})"}) + _describe -t alias-commands 'aliases' list && _ret=0 } __git_zsh_cmd_all () @@ -201,10 +241,13 @@ __git_zsh_main () case $state in (command) - _alternative \ - 'alias-commands:alias:__git_zsh_cmd_alias' \ - 'common-commands:common:__git_zsh_cmd_common' \ - 'all-commands:all:__git_zsh_cmd_all' && _ret=0 + _tags common-commands alias-commands all-commands + while _tags; do + _requested common-commands && __git_zsh_cmd_common + _requested alias-commands && __git_zsh_cmd_alias + _requested all-commands && __git_zsh_cmd_all + let _ret || break + done ;; (arg) local command="${words[1]}" __git_dir @@ -235,8 +278,12 @@ _git () if (( $+functions[__${service}_zsh_main] )); then __${service}_zsh_main - else + elif (( $+functions[__${service}_main] )); then emulate ksh -c __${service}_main + elif (( $+functions[_${service}] )); then + emulate ksh -c _${service} + elif (( $+functions[_${service//-/_}] )); then + emulate ksh -c _${service//-/_} fi let _ret && _default && _ret=0 diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 16260bab73..4640a1535d 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -97,7 +97,8 @@ # If you would like a colored hint about the current dirty state, set # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on # the colored output of "git status -sb" and are available only when -# using __git_ps1 for PROMPT_COMMAND or precmd. +# using __git_ps1 for PROMPT_COMMAND or precmd in Bash, +# but always available in Zsh. # # If you would like __git_ps1 to do nothing in the case when the current # directory is set up to be ignored by git, then set @@ -137,6 +138,7 @@ __git_ps1_show_upstream () done <<< "$output" # parse configuration values + local option for option in ${GIT_PS1_SHOWUPSTREAM}; do case "$option" in git|svn) upstream="$option" ;; @@ -553,9 +555,11 @@ __git_ps1 () local z="${GIT_PS1_STATESEPARATOR-" "}" - # NO color option unless in PROMPT_COMMAND mode - if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then - __git_ps1_colorize_gitstring + # NO color option unless in PROMPT_COMMAND mode or it's Zsh + if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then + if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then + __git_ps1_colorize_gitstring + fi fi b=${b##refs/heads/} diff --git a/diff-lib.c b/diff-lib.c index f95c6de75f..082e249fc3 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -13,6 +13,7 @@ #include "submodule.h" #include "dir.h" #include "fsmonitor.h" +#include "commit-reach.h" /* * diff-files @@ -97,6 +98,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option) diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/"); + refresh_fsmonitor(istate); + if (diff_unmerged_stage < 0) diff_unmerged_stage = 2; entries = istate->cache_nr; @@ -197,8 +200,17 @@ int run_diff_files(struct rev_info *revs, unsigned int option) if (ce_uptodate(ce) || ce_skip_worktree(ce)) continue; - /* If CE_VALID is set, don't look at workdir for file removal */ - if (ce->ce_flags & CE_VALID) { + /* + * When CE_VALID is set (via "update-index --assume-unchanged" + * or via adding paths while core.ignorestat is set to true), + * the user has promised that the working tree file for that + * path will not be modified. When CE_FSMONITOR_VALID is true, + * the fsmonitor knows that the path hasn't been modified since + * we refreshed the cached stat information. In either case, + * we do not have to stat to see if the path has been removed + * or modified. + */ + if (ce->ce_flags & (CE_VALID | CE_FSMONITOR_VALID)) { changed = 0; newmode = ce->ce_mode; } else { @@ -510,16 +522,74 @@ static int diff_cache(struct rev_info *revs, return unpack_trees(1, &t, &opts); } -int run_diff_index(struct rev_info *revs, int cached) +void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb) +{ + int i; + struct commit *mb_child[2] = {0}; + struct commit_list *merge_bases; + + for (i = 0; i < revs->pending.nr; i++) { + struct object *obj = revs->pending.objects[i].item; + if (obj->flags) + die(_("--merge-base does not work with ranges")); + if (obj->type != OBJ_COMMIT) + die(_("--merge-base only works with commits")); + } + + /* + * This check must go after the for loop above because A...B + * ranges produce three pending commits, resulting in a + * misleading error message. + */ + if (revs->pending.nr < 1 || revs->pending.nr > 2) + BUG("unexpected revs->pending.nr: %d", revs->pending.nr); + + for (i = 0; i < revs->pending.nr; i++) + mb_child[i] = lookup_commit_reference(the_repository, &revs->pending.objects[i].item->oid); + if (revs->pending.nr == 1) { + struct object_id oid; + + if (get_oid("HEAD", &oid)) + die(_("unable to get HEAD")); + + mb_child[1] = lookup_commit_reference(the_repository, &oid); + } + + merge_bases = repo_get_merge_bases(the_repository, mb_child[0], mb_child[1]); + if (!merge_bases) + die(_("no merge base found")); + if (merge_bases->next) + die(_("multiple merge bases found")); + + oidcpy(mb, &merge_bases->item->object.oid); + + free_commit_list(merge_bases); +} + +int run_diff_index(struct rev_info *revs, unsigned int option) { struct object_array_entry *ent; + int cached = !!(option & DIFF_INDEX_CACHED); + int merge_base = !!(option & DIFF_INDEX_MERGE_BASE); + struct object_id oid; + const char *name; + char merge_base_hex[GIT_MAX_HEXSZ + 1]; if (revs->pending.nr != 1) BUG("run_diff_index must be passed exactly one tree"); trace_performance_enter(); ent = revs->pending.objects; - if (diff_cache(revs, &ent->item->oid, ent->name, cached)) + + if (merge_base) { + diff_get_merge_base(revs, &oid); + name = oid_to_hex_r(merge_base_hex, &oid); + } else { + oidcpy(&oid, &ent->item->oid); + name = ent->name; + } + + if (diff_cache(revs, &oid, name, cached)) exit(128); diff_set_mnemonic_prefix(&revs->diffopt, "c/", cached ? "i/" : "w/"); @@ -3587,6 +3587,8 @@ static void builtin_diff(const char *name_a, if (header.len && !o->flags.suppress_diff_headers) ecbdata.header = &header; xpp.flags = o->xdl_opts; + xpp.ignore_regex = o->ignore_regex; + xpp.ignore_regex_nr = o->ignore_regex_nr; xpp.anchors = o->anchors; xpp.anchors_nr = o->anchors_nr; xecfg.ctxlen = o->context; @@ -3716,6 +3718,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b, memset(&xpp, 0, sizeof(xpp)); memset(&xecfg, 0, sizeof(xecfg)); xpp.flags = o->xdl_opts; + xpp.ignore_regex = o->ignore_regex; + xpp.ignore_regex_nr = o->ignore_regex_nr; xpp.anchors = o->anchors; xpp.anchors_nr = o->anchors_nr; xecfg.ctxlen = o->context; @@ -5203,6 +5207,22 @@ static int diff_opt_patience(const struct option *opt, return 0; } +static int diff_opt_ignore_regex(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + regex_t *regex; + + BUG_ON_OPT_NEG(unset); + regex = xmalloc(sizeof(*regex)); + if (regcomp(regex, arg, REG_EXTENDED | REG_NEWLINE)) + return error(_("invalid regex given to -I: '%s'"), arg); + ALLOC_GROW(options->ignore_regex, options->ignore_regex_nr + 1, + options->ignore_regex_alloc); + options->ignore_regex[options->ignore_regex_nr++] = regex; + return 0; +} + static int diff_opt_pickaxe_regex(const struct option *opt, const char *arg, int unset) { @@ -5491,6 +5511,9 @@ static void prep_parse_options(struct diff_options *options) OPT_BIT_F(0, "ignore-blank-lines", &options->xdl_opts, N_("ignore changes whose lines are all blank"), XDF_IGNORE_BLANK_LINES, PARSE_OPT_NONEG), + OPT_CALLBACK_F('I', "ignore-matching-lines", options, N_("<regex>"), + N_("ignore changes whose all lines match <regex>"), + 0, diff_opt_ignore_regex), OPT_BIT(0, "indent-heuristic", &options->xdl_opts, N_("heuristic to shift diff hunk boundaries for easy reading"), XDF_INDENT_HEURISTIC), @@ -234,6 +234,10 @@ struct diff_options { */ const char *pickaxe; + /* -I<regex> */ + regex_t **ignore_regex; + size_t ignore_regex_nr, ignore_regex_alloc; + const char *single_follow; const char *a_prefix, *b_prefix; const char *line_prefix; @@ -578,12 +582,17 @@ void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc); */ const char *diff_aligned_abbrev(const struct object_id *sha1, int); +void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb); + /* do not report anything on removed paths */ #define DIFF_SILENT_ON_REMOVED 01 /* report racily-clean paths as modified */ #define DIFF_RACY_IS_MODIFIED 02 int run_diff_files(struct rev_info *revs, unsigned int option); -int run_diff_index(struct rev_info *revs, int cached); + +#define DIFF_INDEX_CACHED 01 +#define DIFF_INDEX_MERGE_BASE 02 +int run_diff_index(struct rev_info *revs, unsigned int option); int do_diff_cache(const struct object_id *, struct diff_options *); int diff_flush_patch_id(struct diff_options *, struct object_id *, int, int); @@ -1040,9 +1040,9 @@ static int add_patterns_from_buffer(char *buf, size_t size, * an index if 'istate' is non-null), parse it and store the * exclude rules in "pl". * - * If "ss" is not NULL, compute SHA-1 of the exclude file and fill + * If "oid_stat" is not NULL, compute oid of the exclude file and fill * stat data from disk (only valid if add_patterns returns zero). If - * ss_valid is non-zero, "ss" must contain good value as input. + * oid_stat.valid is non-zero, "oid_stat" must contain good value as input. */ static int add_patterns(const char *fname, const char *base, int baselen, struct pattern_list *pl, struct index_state *istate, @@ -1090,7 +1090,7 @@ static int add_patterns(const char *fname, const char *base, int baselen, int pos; if (oid_stat->valid && !match_stat_data_racy(istate, &oid_stat->stat, &st)) - ; /* no content change, ss->sha1 still good */ + ; /* no content change, oid_stat->oid still good */ else if (istate && (pos = index_name_pos(istate, fname, strlen(fname))) >= 0 && !ce_stage(istate->cache[pos]) && diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index bd22e1ea88..9a664a4a58 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -626,8 +626,10 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out, void *current_branch_to_free; struct merge_parents merge_parents; - if (!suppress_dest_pattern_seen) + if (!suppress_dest_pattern_seen) { + string_list_append(&suppress_dest_patterns, "main"); string_list_append(&suppress_dest_patterns, "master"); + } memset(&merge_parents, 0, sizeof(merge_parents)); diff --git a/git-bisect.sh b/git-bisect.sh index ea7e684ebb..1f3f6e9fc5 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -39,37 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" TERM_BAD=bad TERM_GOOD=good -bisect_head() -{ - if git rev-parse --verify -q BISECT_HEAD > /dev/null - then - echo BISECT_HEAD - else - echo HEAD - fi -} - -bisect_start() { - git bisect--helper --bisect-start $@ || exit - - # - # Change state. - # In case of mistaken revs or checkout error, or signals received, - # "bisect_auto_next" below may exit or misbehave. - # We have to trap this to be able to clean up using - # "bisect_clean_state". - # - trap 'git bisect--helper --bisect-clean-state' 0 - trap 'exit 255' 1 2 3 15 - - # - # Check if we can proceed to the next bisect state. - # - git bisect--helper --bisect-auto-next || exit - - trap '-' 0 -} - bisect_skip() { all='' for arg in "$@" @@ -82,43 +51,7 @@ bisect_skip() { esac all="$all $revs" done - eval bisect_state 'skip' $all -} - -bisect_state() { - git bisect--helper --bisect-autostart || exit - state=$1 - git bisect--helper --check-and-set-terms $state $TERM_GOOD $TERM_BAD || exit - get_terms - case "$#,$state" in - 0,*) - die "Please call 'bisect_state' with at least one argument." ;; - 1,"$TERM_BAD"|1,"$TERM_GOOD"|1,skip) - bisected_head=$(bisect_head) - rev=$(git rev-parse --verify "$bisected_head") || - die "$(eval_gettext "Bad rev input: \$bisected_head")" - git bisect--helper --bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit - git bisect--helper --check-expected-revs "$rev" ;; - 2,"$TERM_BAD"|*,"$TERM_GOOD"|*,skip) - shift - hash_list='' - for rev in "$@" - do - sha=$(git rev-parse --verify "$rev^{commit}") || - die "$(eval_gettext "Bad rev input: \$rev")" - hash_list="$hash_list $sha" - done - for rev in $hash_list - do - git bisect--helper --bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit - done - git bisect--helper --check-expected-revs $hash_list ;; - *,"$TERM_BAD") - die "$(eval_gettext "'git bisect \$TERM_BAD' can take only one argument.")" ;; - *) - usage ;; - esac - git bisect--helper --bisect-auto-next + eval git bisect--helper --bisect-state 'skip' $all } bisect_visualize() { @@ -163,8 +96,7 @@ bisect_replay () { get_terms case "$command" in start) - cmd="bisect_start $rev $tail" - eval "$cmd" ;; + eval "git bisect--helper --bisect-start $rev $tail" ;; "$TERM_GOOD"|"$TERM_BAD"|skip) git bisect--helper --bisect-write "$command" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit;; terms) @@ -209,8 +141,7 @@ exit code \$res from '\$command' is < 0 or >= 128" >&2 state="$TERM_GOOD" fi - # We have to use a subshell because "bisect_state" can exit. - ( bisect_state $state >"$GIT_DIR/BISECT_RUN" ) + git bisect--helper --bisect-state $state >"$GIT_DIR/BISECT_RUN" res=$? cat "$GIT_DIR/BISECT_RUN" @@ -225,7 +156,7 @@ exit code \$res from '\$command' is < 0 or >= 128" >&2 if [ $res -ne 0 ] then eval_gettextln "bisect run failed: -'bisect_state \$state' exited with error code \$res" >&2 +'bisect-state \$state' exited with error code \$res" >&2 exit $res fi @@ -264,9 +195,9 @@ case "$#" in help) git bisect -h ;; start) - bisect_start "$@" ;; + git bisect--helper --bisect-start "$@" ;; bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") - bisect_state "$cmd" "$@" ;; + git bisect--helper --bisect-state "$cmd" "$@" ;; skip) bisect_skip "$@" ;; next) diff --git a/git-compat-util.h b/git-compat-util.h index 7a0fb7a045..adfea06897 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -489,11 +489,13 @@ static inline int const_error(void) #define error_errno(...) (error_errno(__VA_ARGS__), const_error()) #endif -void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params)); -void set_error_routine(void (*routine)(const char *err, va_list params)); -extern void (*get_error_routine(void))(const char *err, va_list params); -void set_warn_routine(void (*routine)(const char *warn, va_list params)); -extern void (*get_warn_routine(void))(const char *warn, va_list params); +typedef void (*report_fn)(const char *, va_list params); + +void set_die_routine(NORETURN_PTR report_fn routine); +void set_error_routine(report_fn routine); +report_fn get_error_routine(void); +void set_warn_routine(report_fn routine); +report_fn get_warn_routine(void); void set_die_is_recursing_routine(int (*routine)(void)); int starts_with(const char *str, const char *prefix); @@ -1668,7 +1668,7 @@ class P4Submit(Command, P4UserMap): Submit after inspect the message file. The `p4-post-changelist` hook is invoked after the submit has successfully - occured in P4. It takes no parameters and is meant primarily for notification + occurred in P4. It takes no parameters and is meant primarily for notification and cannot affect the outcome of the git p4 submit action. """ @@ -4186,7 +4186,7 @@ class P4Clone(P4Sync): # create a master branch and check out a work tree if gitBranchExists(self.branch): - system([ "git", "branch", "master", self.branch ]) + system([ "git", "branch", currentGitBranch(), self.branch ]) if not self.cloneBare: system([ "git", "checkout", "-f" ]) else: diff --git a/git-svn.perl b/git-svn.perl index 58f5a7ac8f..70cb5e2a83 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2,7 +2,7 @@ # Copyright (C) 2006, Eric Wong <normalperson@yhbt.net> # License: GPL v2 or later use 5.008; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use strict; use vars qw/ $AUTHOR $VERSION $oid $oid_short $oid_length @@ -453,12 +453,12 @@ void clear_object_flags(unsigned flags) } } -void clear_commit_marks_all(unsigned int flags) +void repo_clear_commit_marks(struct repository *r, unsigned int flags) { int i; - for (i = 0; i < the_repository->parsed_objects->obj_hash_size; i++) { - struct object *obj = the_repository->parsed_objects->obj_hash[i]; + for (i = 0; i < r->parsed_objects->obj_hash_size; i++) { + struct object *obj = r->parsed_objects->obj_hash[i]; if (obj && obj->type == OBJ_COMMIT) obj->flags &= ~flags; } @@ -191,8 +191,9 @@ void object_array_clear(struct object_array *array); void clear_object_flags(unsigned flags); /* - * Clear the specified object flags from all in-core commit objects. + * Clear the specified object flags from all in-core commit objects from + * the specified repository. */ -void clear_commit_marks_all(unsigned int flags); +void repo_clear_commit_marks(struct repository *r, unsigned int flags); #endif /* OBJECT_H */ diff --git a/pack-write.c b/pack-write.c index a6cdb3c67c..23e19cc1ec 100644 --- a/pack-write.c +++ b/pack-write.c @@ -48,7 +48,6 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec struct hashfile *f; struct pack_idx_entry **sorted_by_sha, **list, **last; off_t last_obj_offset = 0; - uint32_t array[256]; int i, fd; uint32_t index_version; @@ -106,10 +105,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec break; next++; } - array[i] = htonl(next - sorted_by_sha); + hashwrite_be32(f, next - sorted_by_sha); list = next; } - hashwrite(f, array, 256 * 4); /* * Write the actual SHA1 entries.. diff --git a/perl/FromCPAN/Error.pm b/perl/FromCPAN/Error.pm index 8b95e2d73d..d82b71325c 100644 --- a/perl/FromCPAN/Error.pm +++ b/perl/FromCPAN/Error.pm @@ -12,7 +12,7 @@ package Error; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use vars qw($VERSION); use 5.004; diff --git a/perl/Git.pm b/perl/Git.pm index 10df990959..02eacef0c2 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -9,7 +9,7 @@ package Git; use 5.008; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use File::Temp (); use File::Spec (); diff --git a/perl/Git/I18N.pm b/perl/Git/I18N.pm index bfb4fb67a1..2037f387c8 100644 --- a/perl/Git/I18N.pm +++ b/perl/Git/I18N.pm @@ -1,7 +1,7 @@ package Git::I18N; use 5.008; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); BEGIN { require Exporter; if ($] < 5.008003) { diff --git a/perl/Git/IndexInfo.pm b/perl/Git/IndexInfo.pm index 2a7b4908f3..9ee054f854 100644 --- a/perl/Git/IndexInfo.pm +++ b/perl/Git/IndexInfo.pm @@ -1,6 +1,6 @@ package Git::IndexInfo; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use Git qw/command_input_pipe command_close_pipe/; sub new { diff --git a/perl/Git/LoadCPAN.pm b/perl/Git/LoadCPAN.pm index e5585e75e8..0c360bc799 100644 --- a/perl/Git/LoadCPAN.pm +++ b/perl/Git/LoadCPAN.pm @@ -1,7 +1,7 @@ package Git::LoadCPAN; use 5.008; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); =head1 NAME diff --git a/perl/Git/LoadCPAN/Error.pm b/perl/Git/LoadCPAN/Error.pm index c6d2c45d80..5d84c20288 100644 --- a/perl/Git/LoadCPAN/Error.pm +++ b/perl/Git/LoadCPAN/Error.pm @@ -1,7 +1,7 @@ package Git::LoadCPAN::Error; use 5.008; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use Git::LoadCPAN ( module => 'Error', import => 1, diff --git a/perl/Git/LoadCPAN/Mail/Address.pm b/perl/Git/LoadCPAN/Mail/Address.pm index f70a4f064c..340e88a7a5 100644 --- a/perl/Git/LoadCPAN/Mail/Address.pm +++ b/perl/Git/LoadCPAN/Mail/Address.pm @@ -1,7 +1,7 @@ package Git::LoadCPAN::Mail::Address; use 5.008; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use Git::LoadCPAN ( module => 'Mail::Address', import => 0, diff --git a/perl/Git/Packet.pm b/perl/Git/Packet.pm index b75738bed4..d144f5168f 100644 --- a/perl/Git/Packet.pm +++ b/perl/Git/Packet.pm @@ -1,7 +1,7 @@ package Git::Packet; use 5.008; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); BEGIN { require Exporter; if ($] < 5.008003) { diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm index d1c352f92b..f6f1dc03c6 100644 --- a/perl/Git/SVN.pm +++ b/perl/Git/SVN.pm @@ -1,6 +1,6 @@ package Git::SVN; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use Fcntl qw/:DEFAULT :seek/; use constant rev_map_fmt => 'NH*'; use vars qw/$_no_metadata diff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm index c961444d4c..47fd048bf2 100644 --- a/perl/Git/SVN/Editor.pm +++ b/perl/Git/SVN/Editor.pm @@ -1,7 +1,7 @@ package Git::SVN::Editor; use vars qw/@ISA $_rmdir $_cp_similarity $_find_copies_harder $_rename_limit/; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use SVN::Core; use SVN::Delta; use Carp qw/croak/; diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm index 729e5337df..968309e6d6 100644 --- a/perl/Git/SVN/Fetcher.pm +++ b/perl/Git/SVN/Fetcher.pm @@ -3,7 +3,7 @@ use vars qw/@ISA $_ignore_regex $_include_regex $_preserve_empty_dirs $_placeholder_filename @deleted_gpath %added_placeholder $repo_id/; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use SVN::Delta; use Carp qw/croak/; use File::Basename qw/dirname/; diff --git a/perl/Git/SVN/GlobSpec.pm b/perl/Git/SVN/GlobSpec.pm index a0a8d17621..f2c1e1f6fb 100644 --- a/perl/Git/SVN/GlobSpec.pm +++ b/perl/Git/SVN/GlobSpec.pm @@ -1,6 +1,6 @@ package Git::SVN::GlobSpec; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); sub new { my ($class, $glob, $pattern_ok) = @_; diff --git a/perl/Git/SVN/Log.pm b/perl/Git/SVN/Log.pm index 3858fcf27d..cc8b484f84 100644 --- a/perl/Git/SVN/Log.pm +++ b/perl/Git/SVN/Log.pm @@ -1,6 +1,6 @@ package Git::SVN::Log; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use Git::SVN::Utils qw(fatal); use Git qw(command command_oneline @@ -298,7 +298,7 @@ sub cmd_show_log { get_author_info($c, $1, $2, $3); } elsif (/^${esc_color}(?:tree|parent|committer) /o) { # ignore - } elsif (/^${esc_color}:\d{6} \d{6} $::sha1_short/o) { + } elsif (/^${esc_color}:\d{6} \d{6} $::oid_short/o) { push @{$c->{raw}}, $_; } elsif (/^${esc_color}[ACRMDT]\t/) { # we could add $SVN->{svn_path} here, but that requires diff --git a/perl/Git/SVN/Memoize/YAML.pm b/perl/Git/SVN/Memoize/YAML.pm index 9676b8f2f7..8fcf6644a1 100644 --- a/perl/Git/SVN/Memoize/YAML.pm +++ b/perl/Git/SVN/Memoize/YAML.pm @@ -1,5 +1,5 @@ package Git::SVN::Memoize::YAML; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use strict; use YAML::Any (); diff --git a/perl/Git/SVN/Migration.pm b/perl/Git/SVN/Migration.pm index dc90f6a621..ed96ac593e 100644 --- a/perl/Git/SVN/Migration.pm +++ b/perl/Git/SVN/Migration.pm @@ -33,7 +33,7 @@ package Git::SVN::Migration; # possible if noMetadata or useSvmProps are set; but should # be no problem for users that use the (sensible) defaults. use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use Carp qw/croak/; use File::Path qw/mkpath/; use File::Basename qw/dirname basename/; diff --git a/perl/Git/SVN/Prompt.pm b/perl/Git/SVN/Prompt.pm index e940b08505..de158e848f 100644 --- a/perl/Git/SVN/Prompt.pm +++ b/perl/Git/SVN/Prompt.pm @@ -1,6 +1,6 @@ package Git::SVN::Prompt; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); require SVN::Core; use vars qw/$_no_auth_cache $_username/; diff --git a/perl/Git/SVN/Ra.pm b/perl/Git/SVN/Ra.pm index 2cfe055a9a..912e035040 100644 --- a/perl/Git/SVN/Ra.pm +++ b/perl/Git/SVN/Ra.pm @@ -1,7 +1,7 @@ package Git::SVN::Ra; use vars qw/@ISA $config_dir $_ignore_refs_regex $_log_window_size/; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use Memoize; use Git::SVN::Utils qw( canonicalize_url diff --git a/perl/Git/SVN/Utils.pm b/perl/Git/SVN/Utils.pm index 3d1a0933a2..5ca09ab448 100644 --- a/perl/Git/SVN/Utils.pm +++ b/perl/Git/SVN/Utils.pm @@ -1,7 +1,7 @@ package Git::SVN::Utils; use strict; -use warnings; +use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use SVN::Core; diff --git a/pkt-line.c b/pkt-line.c index 844c253ccd..d633005ef7 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -461,9 +461,11 @@ int recv_sideband(const char *me, int in_stream, int out) enum sideband_type sideband_type; while (1) { - len = packet_read(in_stream, NULL, NULL, buf, LARGE_PACKET_MAX, - 0); - if (!demultiplex_sideband(me, buf, len, 0, &scratch, + int status = packet_read_with_status(in_stream, NULL, NULL, + buf, LARGE_PACKET_MAX, + &len, + PACKET_READ_GENTLE_ON_EOF); + if (!demultiplex_sideband(me, status, buf, len, 0, &scratch, &sideband_type)) continue; switch (sideband_type) { @@ -471,6 +473,9 @@ int recv_sideband(const char *me, int in_stream, int out) write_or_die(out, buf + 1, len - 1); break; default: /* errors: message already written */ + if (scratch.len > 0) + BUG("unhandled incomplete sideband: '%s'", + scratch.buf); return sideband_type; } } @@ -517,9 +522,9 @@ enum packet_read_status packet_reader_read(struct packet_reader *reader) reader->options); if (!reader->use_sideband) break; - if (demultiplex_sideband(reader->me, reader->buffer, - reader->pktlen, 1, &scratch, - &sideband_type)) + if (demultiplex_sideband(reader->me, reader->status, + reader->buffer, reader->pktlen, 1, + &scratch, &sideband_type)) break; } diff --git a/ref-filter.c b/ref-filter.c index c62f6b4822..6476686fea 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1097,14 +1097,19 @@ static const char *copy_email(const char *buf, struct used_atom *atom) static char *copy_subject(const char *buf, unsigned long len) { - char *r = xmemdupz(buf, len); + struct strbuf sb = STRBUF_INIT; int i; - for (i = 0; i < len; i++) - if (r[i] == '\n') - r[i] = ' '; + for (i = 0; i < len; i++) { + if (buf[i] == '\r' && i + 1 < len && buf[i + 1] == '\n') + continue; /* ignore CR in CRLF */ - return r; + if (buf[i] == '\n') + strbuf_addch(&sb, ' '); + else + strbuf_addch(&sb, buf[i]); + } + return strbuf_detach(&sb, NULL); } static void grab_date(const char *buf, struct atom_value *v, const char *atomname) @@ -1228,20 +1233,23 @@ static void find_subpos(const char *buf, /* subject is first non-empty line */ *sub = buf; - /* subject goes to first empty line */ - while (buf < *sig && *buf && *buf != '\n') { - eol = strchrnul(buf, '\n'); - if (*eol) - eol++; - buf = eol; - } + /* subject goes to first empty line before signature begins */ + if ((eol = strstr(*sub, "\n\n"))) { + eol = eol < *sig ? eol : *sig; + /* check if message uses CRLF */ + } else if (! (eol = strstr(*sub, "\r\n\r\n"))) { + /* treat whole message as subject */ + eol = strrchr(*sub, '\0'); + } + buf = eol; *sublen = buf - *sub; /* drop trailing newline, if present */ - if (*sublen && (*sub)[*sublen - 1] == '\n') + while (*sublen && ((*sub)[*sublen - 1] == '\n' || + (*sub)[*sublen - 1] == '\r')) *sublen -= 1; /* skip any empty lines */ - while (*buf == '\n') + while (*buf == '\n' || *buf == '\r') buf++; *body = buf; *bodylen = strlen(buf); @@ -567,8 +567,11 @@ char *repo_default_branch_name(struct repository *r) const char *config_key = "init.defaultbranch"; const char *config_display_key = "init.defaultBranch"; char *ret = NULL, *full_ref; + const char *env = getenv("GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME"); - if (repo_config_get_string(r, config_key, &ret) < 0) + if (env && *env) + ret = xstrdup(env); + else if (repo_config_get_string(r, config_key, &ret) < 0) die(_("could not retrieve `%s`"), config_display_key); if (!ret) diff --git a/sequencer.c b/sequencer.c index d76cbded00..684ea9d5ce 100644 --- a/sequencer.c +++ b/sequencer.c @@ -314,8 +314,6 @@ int sequencer_remove_state(struct replay_opts *opts) } } - free(opts->committer_name); - free(opts->committer_email); free(opts->gpg_sign); free(opts->strategy); for (i = 0; i < opts->xopts_nr; i++) @@ -1460,8 +1458,8 @@ static int try_to_commit(struct repository *r, } else { reset_ident_date(); } - committer = fmt_ident(opts->committer_name, - opts->committer_email, + committer = fmt_ident(getenv("GIT_COMMITTER_NAME"), + getenv("GIT_COMMITTER_EMAIL"), WANT_COMMITTER_IDENT, opts->ignore_date ? NULL : date.buf, IDENT_STRICT); @@ -2653,7 +2651,7 @@ static int read_populate_opts(struct replay_opts *opts) } if (read_oneliner(&buf, rebase_path_squash_onto(), 0)) { - if (get_oid_hex(buf.buf, &opts->squash_onto) < 0) { + if (get_oid_committish(buf.buf, &opts->squash_onto) < 0) { ret = error(_("unusable squash-onto")); goto done_rebase_i; } @@ -3677,7 +3675,9 @@ static int do_merge(struct repository *r, strvec_push(&cmd.args, "-F"); strvec_push(&cmd.args, git_path_merge_msg(r)); if (opts->gpg_sign) - strvec_push(&cmd.args, opts->gpg_sign); + strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign); + else + strvec_push(&cmd.args, "--no-gpg-sign"); /* Add the tips to be merged */ for (j = to_merge; j; j = j->next) @@ -3689,7 +3689,6 @@ static int do_merge(struct repository *r, NULL, 0); rollback_lock_file(&lock); - rollback_lock_file(&lock); ret = run_command(&cmd); /* force re-reading of the cache */ @@ -4467,22 +4466,6 @@ static int commit_staged_changes(struct repository *r, return 0; } -static int init_committer(struct replay_opts *opts) -{ - struct ident_split id; - const char *committer; - - committer = git_committer_info(IDENT_STRICT); - if (split_ident_line(&id, committer, strlen(committer)) < 0) - return error(_("invalid committer '%s'"), committer); - opts->committer_name = - xmemdupz(id.name_begin, id.name_end - id.name_begin); - opts->committer_email = - xmemdupz(id.mail_begin, id.mail_end - id.mail_begin); - - return 0; -} - int sequencer_continue(struct repository *r, struct replay_opts *opts) { struct todo_list todo_list = TODO_LIST_INIT; @@ -4494,9 +4477,6 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) if (read_populate_opts(opts)) return -1; if (is_rebase_i(opts)) { - if (opts->committer_date_is_author_date && init_committer(opts)) - return -1; - if ((res = read_populate_todo(r, &todo_list, opts))) goto release_todo_list; @@ -5391,9 +5371,6 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla res = -1; - if (opts->committer_date_is_author_date && init_committer(opts)) - goto cleanup; - if (checkout_onto(r, opts, onto_name, &oid, orig_head)) goto cleanup; diff --git a/sequencer.h b/sequencer.h index b2a501e445..f925e349c5 100644 --- a/sequencer.h +++ b/sequencer.h @@ -50,8 +50,6 @@ struct replay_opts { int mainline; - char *committer_name; - char *committer_email; char *gpg_sign; enum commit_msg_cleanup_mode default_msg_cleanup; int explicit_cleanup; diff --git a/sideband.c b/sideband.c index 0a60662fa6..6f9e026732 100644 --- a/sideband.c +++ b/sideband.c @@ -3,6 +3,7 @@ #include "config.h" #include "sideband.h" #include "help.h" +#include "pkt-line.h" struct keyword_entry { /* @@ -114,7 +115,8 @@ static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n) #define ANSI_SUFFIX "\033[K" #define DUMB_SUFFIX " " -int demultiplex_sideband(const char *me, char *buf, int len, +int demultiplex_sideband(const char *me, int status, + char *buf, int len, int die_on_error, struct strbuf *scratch, enum sideband_type *sideband_type) @@ -130,17 +132,30 @@ int demultiplex_sideband(const char *me, char *buf, int len, suffix = DUMB_SUFFIX; } - if (len == 0) { - *sideband_type = SIDEBAND_FLUSH; - goto cleanup; - } - if (len < 1) { + if (status == PACKET_READ_EOF) { strbuf_addf(scratch, - "%s%s: protocol error: no band designator", + "%s%s: unexpected disconnect while reading sideband packet", scratch->len ? "\n" : "", me); *sideband_type = SIDEBAND_PROTOCOL_ERROR; goto cleanup; } + + if (len < 0) + BUG("negative length on non-eof packet read"); + + if (len == 0) { + if (status == PACKET_READ_NORMAL) { + strbuf_addf(scratch, + "%s%s: protocol error: missing sideband designator", + scratch->len ? "\n" : "", me); + *sideband_type = SIDEBAND_PROTOCOL_ERROR; + } else { + /* covers flush, delim, etc */ + *sideband_type = SIDEBAND_FLUSH; + } + goto cleanup; + } + band = buf[0] & 0xff; buf[len] = '\0'; len--; @@ -190,7 +205,7 @@ int demultiplex_sideband(const char *me, char *buf, int len, return 0; case 1: *sideband_type = SIDEBAND_PRIMARY; - break; + return 1; default: strbuf_addf(scratch, "%s%s: protocol error: bad band #%d", scratch->len ? "\n" : "", me, band); diff --git a/sideband.h b/sideband.h index 227740a58e..5a25331be5 100644 --- a/sideband.h +++ b/sideband.h @@ -18,8 +18,12 @@ enum sideband_type { * * scratch must be a struct strbuf allocated by the caller. It is used to store * progress messages split across multiple packets. + * + * The "status" parameter is a pkt-line response as returned by + * packet_read_with_status() (e.g., PACKET_READ_NORMAL). */ -int demultiplex_sideband(const char *me, char *buf, int len, +int demultiplex_sideband(const char *me, int status, + char *buf, int len, int die_on_error, struct strbuf *scratch, enum sideband_type *sideband_type); diff --git a/t/Makefile b/t/Makefile index c83fd18861..882d26eee3 100644 --- a/t/Makefile +++ b/t/Makefile @@ -34,6 +34,7 @@ CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP)) T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh)) THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh))) +TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh)) CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test))) CHAINLINT = sed -f chainlint.sed @@ -81,17 +82,17 @@ test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \ test-lint-filenames test-lint-duplicates: - @dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \ + @dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \ test -z "$$dups" || { \ echo >&2 "duplicate test numbers:" $$dups; exit 1; } test-lint-executable: - @bad=`for i in $(T); do test -x "$$i" || echo $$i; done` && \ + @bad=`for i in $(T) $(TPERF); do test -x "$$i" || echo $$i; done` && \ test -z "$$bad" || { \ echo >&2 "non-executable tests:" $$bad; exit 1; } test-lint-shell-syntax: - @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) + @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) $(TPERF) test-lint-filenames: @# We do *not* pass a glob to ls-files but use grep instead, to catch @@ -258,16 +258,21 @@ For an individual test suite --run could be used to specify that only some tests should be run or that some tests should be excluded from a run. -The argument for --run is a list of individual test numbers or -ranges with an optional negation prefix that define what tests in -a test suite to include in the run. A range is two numbers -separated with a dash and matches a range of tests with both ends -been included. You may omit the first or the second number to -mean "from the first test" or "up to the very last test" -respectively. - -Optional prefix of '!' means that the test or a range of tests -should be excluded from the run. +The argument for --run, <test-selector>, is a list of description +substrings or globs or individual test numbers or ranges with an +optional negation prefix (of '!') that define what tests in a test +suite to include (or exclude, if negated) in the run. A range is two +numbers separated with a dash and matches a range of tests with both +ends been included. You may omit the first or the second number to +mean "from the first test" or "up to the very last test" respectively. + +The argument to --run is split on commas into separate strings, +numbers, and ranges, and picks all tests that match any of the +individual selection criteria. If the substring of the description +text that you want to match includes a comma, use the glob character +'?' instead. For example --run='rebase,merge?cherry-pick' would match +on all tests that match either the glob *rebase* or the glob +*merge?cherry-pick*. If --run starts with an unprefixed number or range the initial set of tests to run is empty. If the first item starts with '!' @@ -275,9 +280,6 @@ all the tests are added to the initial set. After initial set is determined every test number or range is added or excluded from the set one by one, from left to right. -Individual numbers or ranges could be separated either by a space -or a comma. - For example, to run only tests up to a specific test (21), one could do this: @@ -290,7 +292,7 @@ or this: Common case is to run several setup tests (1, 2, 3) and then a specific test (21) that relies on that setup: - $ sh ./t9200-git-cvsexport-commit.sh --run='1 2 3 21' + $ sh ./t9200-git-cvsexport-commit.sh --run='1,2,3,21' or: @@ -298,17 +300,17 @@ or: or: - $ sh ./t9200-git-cvsexport-commit.sh --run='-3 21' + $ sh ./t9200-git-cvsexport-commit.sh --run='-3,21' As noted above, the test set is built by going through the items from left to right, so this: - $ sh ./t9200-git-cvsexport-commit.sh --run='1-4 !3' + $ sh ./t9200-git-cvsexport-commit.sh --run='1-4,!3' will run tests 1, 2, and 4. Items that come later have higher precedence. It means that this: - $ sh ./t9200-git-cvsexport-commit.sh --run='!3 1-4' + $ sh ./t9200-git-cvsexport-commit.sh --run='!3,1-4' would just run tests from 1 to 4, including 3. @@ -317,6 +319,18 @@ test in the test suite except from 7 up to 11: $ sh ./t9200-git-cvsexport-commit.sh --run='!7-11' +Sometimes there may be multiple tests with e.g. "setup" in their name +that are needed and rather than figuring out the number for all of them +we can just use "setup" as a substring/glob to match against the test +description: + + $ sh ./t0050-filesystem.sh --run=setup,9-11 + +or one could select both the setup tests and the rename ones (assuming all +relevant tests had those words in their descriptions): + + $ sh ./t0050-filesystem.sh --run=setup,rename + Some tests in a test suite rely on the previous tests performing certain actions, specifically some tests are designated as "setup" test, so you cannot _arbitrarily_ disable one test and diff --git a/t/helper/test-pkt-line.c b/t/helper/test-pkt-line.c index 69152958e5..5e638f0b97 100644 --- a/t/helper/test-pkt-line.c +++ b/t/helper/test-pkt-line.c @@ -84,6 +84,25 @@ static void unpack_sideband(void) } } +static int send_split_sideband(void) +{ + const char *part1 = "Hello,"; + const char *primary = "\001primary: regular output\n"; + const char *part2 = " world!\n"; + + send_sideband(1, 2, part1, strlen(part1), LARGE_PACKET_MAX); + packet_write(1, primary, strlen(primary)); + send_sideband(1, 2, part2, strlen(part2), LARGE_PACKET_MAX); + packet_response_end(1); + + return 0; +} + +static int receive_sideband(void) +{ + return recv_sideband("sideband", 0, 1); +} + int cmd__pkt_line(int argc, const char **argv) { if (argc < 2) @@ -95,6 +114,10 @@ int cmd__pkt_line(int argc, const char **argv) unpack(); else if (!strcmp(argv[1], "unpack-sideband")) unpack_sideband(); + else if (!strcmp(argv[1], "send-split-sideband")) + send_split_sideband(); + else if (!strcmp(argv[1], "receive-sideband")) + receive_sideband(); else die("invalid argument '%s'", argv[1]); diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 87a759149f..bd3fa3c6da 100644 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -144,7 +144,7 @@ create_lib_submodule_repo () { git checkout -b valid_sub1 && git revert HEAD && - git checkout master + git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" ) } diff --git a/t/perf/Makefile b/t/perf/Makefile index 8c47155a7c..fcb0e8865e 100644 --- a/t/perf/Makefile +++ b/t/perf/Makefile @@ -1,7 +1,7 @@ -include ../../config.mak export GIT_TEST_OPTIONS -all: perf +all: test-lint perf perf: pre-clean ./run @@ -12,4 +12,7 @@ pre-clean: clean: rm -rf build "trash directory".* test-results +test-lint: + $(MAKE) -C .. test-lint + .PHONY: all perf pre-clean clean diff --git a/t/perf/README b/t/perf/README index bd649afa97..fb9127a66f 100644 --- a/t/perf/README +++ b/t/perf/README @@ -28,6 +28,8 @@ the tests on the current git repository. 7810.3: grep --cached, cheap regex 3.07(3.02+0.25) 7810.4: grep --cached, expensive regex 9.39(30.57+0.24) +Output format is in seconds "Elapsed(User + System)" + You can compare multiple repositories and even git revisions with the 'run' script: diff --git a/t/perf/p3400-rebase.sh b/t/perf/p3400-rebase.sh index d202aaed06..7a0bb29448 100755 --- a/t/perf/p3400-rebase.sh +++ b/t/perf/p3400-rebase.sh @@ -9,16 +9,16 @@ test_expect_success 'setup rebasing on top of a lot of changes' ' git checkout -f -B base && git checkout -B to-rebase && git checkout -B upstream && - for i in $(seq 100) + for i in $(test_seq 100) do # simulate huge diffs echo change$i >unrelated-file$i && - seq 1000 >>unrelated-file$i && + test_seq 1000 >>unrelated-file$i && git add unrelated-file$i && test_tick && git commit -m commit$i unrelated-file$i && echo change$i >unrelated-file$i && - seq 1000 | tac >>unrelated-file$i && + test_seq 1000 | tac >>unrelated-file$i && git add unrelated-file$i && test_tick && git commit -m commit$i-reverse unrelated-file$i || diff --git a/t/perf/p7519-fsmonitor.sh b/t/perf/p7519-fsmonitor.sh index def7ecdbc7..fb20fe0937 100755 --- a/t/perf/p7519-fsmonitor.sh +++ b/t/perf/p7519-fsmonitor.sh @@ -114,63 +114,77 @@ test_expect_success "setup for fsmonitor" ' fi && git config core.fsmonitor "$INTEGRATION_SCRIPT" && - git update-index --fsmonitor + git update-index --fsmonitor && + mkdir 1_file 10_files 100_files 1000_files 10000_files && + for i in $(test_seq 1 10); do touch 10_files/$i; done && + for i in $(test_seq 1 100); do touch 100_files/$i; done && + for i in $(test_seq 1 1000); do touch 1000_files/$i; done && + for i in $(test_seq 1 10000); do touch 10000_files/$i; done && + git add 1_file 10_files 100_files 1000_files 10000_files && + git commit -m "Add files" && + git status # Warm caches ' -if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-tool drop-caches -fi +test_perf_w_drop_caches () { + if test -n "$GIT_PERF_7519_DROP_CACHE"; then + test-tool drop-caches + fi -test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" ' - git status -' + test_perf "$@" +} -if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-tool drop-caches -fi +test_fsmonitor_suite() { + test_perf_w_drop_caches "status (fsmonitor=$INTEGRATION_SCRIPT)" ' + git status + ' -test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" ' - git status -uno -' + test_perf_w_drop_caches "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" ' + git status -uno + ' -if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-tool drop-caches -fi + test_perf_w_drop_caches "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" ' + git status -uall + ' -test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" ' - git status -uall -' + test_perf_w_drop_caches "diff (fsmonitor=$INTEGRATION_SCRIPT)" ' + git diff + ' -test_expect_success "setup without fsmonitor" ' - unset INTEGRATION_SCRIPT && - git config --unset core.fsmonitor && - git update-index --no-fsmonitor -' + test_perf_w_drop_caches "diff -- 0_files (fsmonitor=$INTEGRATION_SCRIPT)" ' + git diff -- 1_file + ' -if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-tool drop-caches -fi + test_perf_w_drop_caches "diff -- 10_files (fsmonitor=$INTEGRATION_SCRIPT)" ' + git diff -- 10_files + ' -test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" ' - git status -' + test_perf_w_drop_caches "diff -- 100_files (fsmonitor=$INTEGRATION_SCRIPT)" ' + git diff -- 100_files + ' -if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-tool drop-caches -fi + test_perf_w_drop_caches "diff -- 1000_files (fsmonitor=$INTEGRATION_SCRIPT)" ' + git diff -- 1000_files + ' -test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" ' - git status -uno -' + test_perf_w_drop_caches "diff -- 10000_files (fsmonitor=$INTEGRATION_SCRIPT)" ' + git diff -- 10000_files + ' -if test -n "$GIT_PERF_7519_DROP_CACHE"; then - test-tool drop-caches -fi + test_perf_w_drop_caches "add (fsmonitor=$INTEGRATION_SCRIPT)" ' + git add --all + ' +} + +test_fsmonitor_suite -test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" ' - git status -uall +test_expect_success "setup without fsmonitor" ' + unset INTEGRATION_SCRIPT && + git config --unset core.fsmonitor && + git update-index --no-fsmonitor ' +test_fsmonitor_suite + if test_have_prereq WATCHMAN then watchman watch-del "$GIT_WORK_TREE" >/dev/null 2>&1 && diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index eb99892a87..22489c24dc 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -430,7 +430,7 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' " test_expect_success '--run basic' " run_sub_test_lib_test run-basic \ - '--run basic' --run='1 3 5' <<-\\EOF && + '--run basic' --run='1,3,5' <<-\\EOF && for i in 1 2 3 4 5 6 do test_expect_success \"passing test #\$i\" 'true' @@ -472,7 +472,7 @@ test_expect_success '--run with a range' " test_expect_success '--run with two ranges' " run_sub_test_lib_test run-two-ranges \ - '--run with two ranges' --run='1-2 5-6' <<-\\EOF && + '--run with two ranges' --run='1-2,5-6' <<-\\EOF && for i in 1 2 3 4 5 6 do test_expect_success \"passing test #\$i\" 'true' @@ -556,7 +556,7 @@ test_expect_success '--run with basic negation' " test_expect_success '--run with two negations' " run_sub_test_lib_test run-two-neg \ - '--run with two negations' --run='"'!3 !6'"' <<-\\EOF && + '--run with two negations' --run='"'!3,!6'"' <<-\\EOF && for i in 1 2 3 4 5 6 do test_expect_success \"passing test #\$i\" 'true' @@ -577,7 +577,7 @@ test_expect_success '--run with two negations' " test_expect_success '--run a range and negation' " run_sub_test_lib_test run-range-and-neg \ - '--run a range and negation' --run='"'-4 !2'"' <<-\\EOF && + '--run a range and negation' --run='"'-4,!2'"' <<-\\EOF && for i in 1 2 3 4 5 6 do test_expect_success \"passing test #\$i\" 'true' @@ -620,7 +620,7 @@ test_expect_success '--run range negation' " test_expect_success '--run include, exclude and include' " run_sub_test_lib_test run-inc-neg-inc \ '--run include, exclude and include' \ - --run='"'1-5 !1-3 2'"' <<-\\EOF && + --run='"'1-5,!1-3,2'"' <<-\\EOF && for i in 1 2 3 4 5 6 do test_expect_success \"passing test #\$i\" 'true' @@ -664,7 +664,7 @@ test_expect_success '--run include, exclude and include, comma separated' " test_expect_success '--run exclude and include' " run_sub_test_lib_test run-neg-inc \ '--run exclude and include' \ - --run='"'!3- 5'"' <<-\\EOF && + --run='"'!3-,5'"' <<-\\EOF && for i in 1 2 3 4 5 6 do test_expect_success \"passing test #\$i\" 'true' @@ -705,7 +705,31 @@ test_expect_success '--run empty selectors' " EOF " -test_expect_success '--run invalid range start' " +test_expect_success '--run substring selector' " + run_sub_test_lib_test run-substring-selector \ + '--run empty selectors' \ + --run='relevant' <<-\\EOF && + test_expect_success \"relevant test\" 'true' + for i in 1 2 3 4 5 6 + do + test_expect_success \"other test #\$i\" 'true' + done + test_done + EOF + check_sub_test_lib_test run-substring-selector <<-\\EOF + > ok 1 - relevant test + > ok 2 # skip other test #1 (--run) + > ok 3 # skip other test #2 (--run) + > ok 4 # skip other test #3 (--run) + > ok 5 # skip other test #4 (--run) + > ok 6 # skip other test #5 (--run) + > ok 7 # skip other test #6 (--run) + > # passed all 7 test(s) + > 1..7 + EOF +" + +test_expect_success '--run keyword selection' " run_sub_test_lib_test_err run-inv-range-start \ '--run invalid range start' \ --run='a-5' <<-\\EOF && @@ -735,21 +759,6 @@ test_expect_success '--run invalid range end' " EOF_ERR " -test_expect_success '--run invalid selector' " - run_sub_test_lib_test_err run-inv-selector \ - '--run invalid selector' \ - --run='1?' <<-\\EOF && - test_expect_success \"passing test #1\" 'true' - test_done - EOF - check_sub_test_lib_test_err run-inv-selector \ - <<-\\EOF_OUT 3<<-\\EOF_ERR - > FATAL: Unexpected exit with code 1 - EOF_OUT - > error: --run: invalid non-numeric in test selector: '1?' - EOF_ERR -" - test_set_prereq HAVEIT haveit=no diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 2f7c3dcd0f..69a320489f 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -553,14 +553,21 @@ test_expect_success '--initial-branch' ' test_expect_success 'overridden default initial branch name (config)' ' test_config_global init.defaultBranch nmb && - git init initial-branch-config && + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= git init initial-branch-config && git -C initial-branch-config symbolic-ref HEAD >actual && grep nmb actual ' +test_expect_success 'overridden default main branch name (env)' ' + test_config_global init.defaultBranch nmb && + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=env git init main-branch-env && + git -C main-branch-env symbolic-ref HEAD >actual && + grep env actual +' + test_expect_success 'invalid default branch name' ' - test_config_global init.defaultBranch "with space" && - test_must_fail git init initial-branch-invalid 2>err && + test_must_fail env GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME="with space" \ + git init initial-branch-invalid 2>err && test_i18ngrep "invalid branch name" err ' diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index 4bfffa9c31..f6deaf498b 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -23,10 +23,6 @@ generate_random_characters () { perl -pe "s/./chr((ord($&) % 26) + ord('a'))/sge" >"$TEST_ROOT/$NAME" } -file_size () { - test-tool path-utils file-size "$1" -} - filter_git () { rm -f *.log && git "$@" @@ -361,9 +357,9 @@ test_expect_success PERL 'required process filter should filter data' ' cp "$TEST_ROOT/test3 '\''sq'\'',\$x=.o" "testsubdir/test3 '\''sq'\'',\$x=.r" && >test4-empty.r && - S=$(file_size test.r) && - S2=$(file_size test2.r) && - S3=$(file_size "testsubdir/test3 '\''sq'\'',\$x=.r") && + S=$(test_file_size test.r) && + S2=$(test_file_size test2.r) && + S3=$(test_file_size "testsubdir/test3 '\''sq'\'',\$x=.r") && M=$(git hash-object test.r) && M2=$(git hash-object test2.r) && M3=$(git hash-object "testsubdir/test3 '\''sq'\'',\$x=.r") && @@ -432,9 +428,9 @@ test_expect_success PERL 'required process filter should filter data for various ( cd repo && - S=$(file_size test.r) && - S2=$(file_size test2.r) && - S3=$(file_size "testsubdir/test3 '\''sq'\'',\$x=.r") && + S=$(test_file_size test.r) && + S2=$(test_file_size test2.r) && + S3=$(test_file_size "testsubdir/test3 '\''sq'\'',\$x=.r") && M=$(git hash-object test.r) && M2=$(git hash-object test2.r) && M3=$(git hash-object "testsubdir/test3 '\''sq'\'',\$x=.r") && @@ -549,7 +545,7 @@ test_expect_success PERL 'required process filter takes precedence' ' echo "*.r filter=protocol" >.gitattributes && cp "$TEST_ROOT/test.o" test.r && - S=$(file_size test.r) && + S=$(test_file_size test.r) && # Check that the process filter is invoked here filter_git add . && @@ -573,7 +569,7 @@ test_expect_success PERL 'required process filter should be used only for "clean echo "*.r filter=protocol" >.gitattributes && cp "$TEST_ROOT/test.o" test.r && - S=$(file_size test.r) && + S=$(test_file_size test.r) && filter_git add . && cat >expected.log <<-EOF && @@ -697,9 +693,9 @@ test_expect_success PERL 'process filter should restart after unexpected write f echo "this is going to fail" >smudge-write-fail.o && cp smudge-write-fail.o smudge-write-fail.r && - S=$(file_size test.r) && - S2=$(file_size test2.r) && - SF=$(file_size smudge-write-fail.r) && + S=$(test_file_size test.r) && + S2=$(test_file_size test2.r) && + SF=$(test_file_size smudge-write-fail.r) && M=$(git hash-object test.r) && M2=$(git hash-object test2.r) && MF=$(git hash-object smudge-write-fail.r) && @@ -752,9 +748,9 @@ test_expect_success PERL 'process filter should not be restarted if it signals a echo "this will cause an error" >error.o && cp error.o error.r && - S=$(file_size test.r) && - S2=$(file_size test2.r) && - SE=$(file_size error.r) && + S=$(test_file_size test.r) && + S2=$(test_file_size test2.r) && + SE=$(test_file_size error.r) && M=$(git hash-object test.r) && M2=$(git hash-object test2.r) && ME=$(git hash-object error.r) && @@ -797,7 +793,7 @@ test_expect_success PERL 'process filter abort stops processing of all further f M="blob=$(git hash-object abort.r)" && rm -f debug.log && - SA=$(file_size abort.r) && + SA=$(test_file_size abort.r) && git add . && rm -f *.r && @@ -859,7 +855,7 @@ test_expect_success PERL 'delayed checkout in process filter' ' git commit -m "test commit" ) && - S=$(file_size "$TEST_ROOT/test.o") && + S=$(test_file_size "$TEST_ROOT/test.o") && PM="ref=refs/heads/master treeish=$(git -C repo rev-parse --verify master) " && M="${PM}blob=$(git -C repo rev-parse --verify master:test.a)" && cat >a.exp <<-EOF && diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh index 7b111a56fd..8d59905ef0 100755 --- a/t/t0070-fundamental.sh +++ b/t/t0070-fundamental.sh @@ -34,4 +34,22 @@ test_expect_success 'check for a bug in the regex routines' ' test-tool regex --bug ' +test_expect_success 'incomplete sideband messages are reassembled' ' + test-tool pkt-line send-split-sideband >split-sideband && + test-tool pkt-line receive-sideband <split-sideband 2>err && + grep "Hello, world" err +' + +test_expect_success 'eof on sideband message is reported' ' + printf 1234 >input && + test-tool pkt-line receive-sideband <input 2>err && + test_i18ngrep "unexpected disconnect" err +' + +test_expect_success 'missing sideband designator is reported' ' + printf 0004 >input && + test-tool pkt-line receive-sideband <input 2>err && + test_i18ngrep "missing sideband" err +' + test_done diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh index bc2d74098f..a18f8a473b 100755 --- a/t/t0300-credentials.sh +++ b/t/t0300-credentials.sh @@ -265,6 +265,32 @@ test_expect_success 'internal getpass does not ask for known username' ' EOF ' +test_expect_success 'git-credential respects core.askPass' ' + write_script alternate-askpass <<-\EOF && + echo >&2 "alternate askpass invoked" + echo alternate-value + EOF + test_config core.askpass "$PWD/alternate-askpass" && + ( + # unset GIT_ASKPASS set by lib-credential.sh which would + # override our config, but do so in a subshell so that we do + # not interfere with other tests + sane_unset GIT_ASKPASS && + check fill <<-\EOF + protocol=http + host=example.com + -- + protocol=http + host=example.com + username=alternate-value + password=alternate-value + -- + alternate askpass invoked + alternate askpass invoked + EOF + ) +' + HELPER="!f() { cat >/dev/null echo username=foo diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh index c13578a635..181956b241 100755 --- a/t/t1004-read-tree-m-u-wf.sh +++ b/t/t1004-read-tree-m-u-wf.sh @@ -20,7 +20,7 @@ test_expect_success 'two-way setup' ' git branch side && git tag -f branch-point && - echo file2 is not tracked on the master anymore && + echo file2 is not tracked on the master branch anymore && rm -f file2 subdir/file2 && git update-index --remove file2 subdir/file2 && git commit -a -m "master removes file2 and subdir/file2" diff --git a/t/t1050-large.sh b/t/t1050-large.sh index 61e89a8071..4bab6a513c 100755 --- a/t/t1050-large.sh +++ b/t/t1050-large.sh @@ -5,12 +5,6 @@ test_description='adding and checking out large blobs' . ./test-lib.sh -# This should be moved to test-lib.sh together with the -# copy in t0021 after both topics have graduated to 'master'. -file_size () { - test-tool path-utils file-size "$1" -} - test_expect_success setup ' # clone does not allow us to pass core.bigfilethreshold to # new repos, so set core.bigfilethreshold globally @@ -29,7 +23,7 @@ do test_expect_success "add with $config" ' test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" && git $config add large1 && - sz=$(file_size .git/objects/pack/pack-*.pack) && + sz=$(test_file_size .git/objects/pack/pack-*.pack) && case "$expect" in small) test "$sz" -le 100000 ;; large) test "$sz" -ge 100000 ;; diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 770e7be363..4c01e08551 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -585,10 +585,10 @@ test_expect_success 'stdin fails on unbalanced quotes' ' grep "fatal: badly quoted argument: \\\"master" err ' -test_expect_success 'stdin fails on invalid escape' ' - echo "create $a \"ma\zter\"" >stdin && +test_expect_success PREPARE_FOR_MAIN_BRANCH 'stdin fails on invalid escape' ' + echo "create $a \"ma\zn\"" >stdin && test_must_fail git update-ref --stdin <stdin 2>err && - grep "fatal: badly quoted argument: \\\"ma\\\\zter\\\"" err + grep "fatal: badly quoted argument: \\\"ma\\\\zn\\\"" err ' test_expect_success 'stdin fails on junk after quoted argument' ' @@ -704,9 +704,9 @@ test_expect_success 'stdin succeeds with quoted argument' ' test_cmp expect actual ' -test_expect_success 'stdin succeeds with escaped character' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'stdin succeeds with escaped character' ' git update-ref -d $a && - echo "create $a \"ma\\163ter\"" >stdin && + echo "create $a \"ma\\151n\"" >stdin && git update-ref --stdin <stdin && git rev-parse $m >expect && git rev-parse $a >actual && diff --git a/t/t2004-checkout-cache-temp.sh b/t/t2004-checkout-cache-temp.sh index a12afe93f3..a9352b08a8 100755 --- a/t/t2004-checkout-cache-temp.sh +++ b/t/t2004-checkout-cache-temp.sh @@ -88,9 +88,17 @@ test_expect_success 'checkout all stage 2 to temporary files' ' done ' +test_expect_success 'checkout all stages of unknown path' ' + rm -f path* .merge_* actual && + test_must_fail git checkout-index --stage=all --temp \ + -- does-not-exist 2>stderr && + test_i18ngrep not.in.the.cache stderr +' + test_expect_success 'checkout all stages/one file to nothing' ' rm -f path* .merge_* actual && - git checkout-index --stage=all --temp -- path0 >actual && + git checkout-index --stage=all --temp -- path0 >actual 2>stderr && + test_must_be_empty stderr && test_line_count = 0 actual ' diff --git a/t/t2006-checkout-index-basic.sh b/t/t2006-checkout-index-basic.sh index 57cbdfe9bc..8e181dbf01 100755 --- a/t/t2006-checkout-index-basic.sh +++ b/t/t2006-checkout-index-basic.sh @@ -21,4 +21,15 @@ test_expect_success 'checkout-index -h in broken repository' ' test_i18ngrep "[Uu]sage" broken/usage ' +test_expect_success 'checkout-index reports errors (cmdline)' ' + test_must_fail git checkout-index -- does-not-exist 2>stderr && + test_i18ngrep not.in.the.cache stderr +' + +test_expect_success 'checkout-index reports errors (stdin)' ' + echo does-not-exist | + test_must_fail git checkout-index --stdin 2>stderr && + test_i18ngrep not.in.the.cache stderr +' + test_done diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index f764b7e3f5..7cb7a70382 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -179,7 +179,8 @@ test_expect_success 'add -u resolves unmerged paths' ' test_expect_success '"add -u non-existent" should fail' ' test_must_fail git add -u non-existent && - ! (git ls-files | grep "non-existent") + git ls-files >actual && + ! grep "non-existent" actual ' test_done diff --git a/t/t2402-worktree-list.sh b/t/t2402-worktree-list.sh index b85bd2655d..795ddca2e4 100755 --- a/t/t2402-worktree-list.sh +++ b/t/t2402-worktree-list.sh @@ -61,7 +61,7 @@ test_expect_success '"list" all worktrees --porcelain' ' test_cmp expect actual ' -test_expect_success '"list" all worktress with locked annotation' ' +test_expect_success '"list" all worktrees with locked annotation' ' test_when_finished "rm -rf locked unlocked out && git worktree prune" && git worktree add --detach locked master && git worktree add --detach unlocked master && diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 6efe7a44bc..a0b832d59e 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -321,11 +321,11 @@ test_expect_success 'git branch --list -v with --abbrev' ' ' -test_expect_success 'git branch --column' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'git branch --column' ' COLUMNS=81 git branch --column=column >actual && cat >expect <<\EOF && - a/b/c bam foo l * master n o/p r - abc bar j/k m/m mb o/o q topic + a/b/c bam foo l * main n o/p r + abc bar j/k m/m mb o/o q topic EOF test_cmp expect actual ' @@ -358,15 +358,15 @@ EOF test_cmp expect actual ' -test_expect_success 'git branch with column.*' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'git branch with column.*' ' git config column.ui column && git config column.branch "dense" && COLUMNS=80 git branch >actual && git config --unset column.branch && git config --unset column.ui && cat >expect <<\EOF && - a/b/c bam foo l * master n o/p r - abc bar j/k m/m mb o/o q topic + a/b/c bam foo l * main n o/p r + abc bar j/k m/m mb o/o q topic EOF test_cmp expect actual ' @@ -375,9 +375,9 @@ test_expect_success 'git branch --column -v should fail' ' test_must_fail git branch --column -v ' -test_expect_success 'git branch -v with column.ui ignored' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'git branch -v with column.ui ignored' ' git config column.ui column && - COLUMNS=80 git branch -v | cut -c -9 | sed "s/ *$//" >actual && + COLUMNS=80 git branch -v | cut -c -8 | sed "s/ *$//" >actual && git config --unset column.ui && cat >expect <<\EOF && a/b/c diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh index efea5c4971..3733cd0091 100755 --- a/t/t3201-branch-contains.sh +++ b/t/t3201-branch-contains.sh @@ -242,7 +242,7 @@ test_expect_success 'branch --merged combined with --no-merged' ' # Here "topic" tracks "master" with one extra commit, and "zzz" points to the # same tip as master The name "zzz" must come alphabetically after "topic" # as we process them in that order. -test_expect_success 'branch --merged with --verbose' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'branch --merged with --verbose' ' git branch --track topic master && git branch zzz topic && git checkout topic && @@ -256,9 +256,9 @@ test_expect_success 'branch --merged with --verbose' ' test_cmp expect actual && git branch --verbose --merged topic >actual && 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 + main $(git rev-parse --short main) second on main + * topic $(git rev-parse --short topic ) [ahead 1] foo + zzz $(git rev-parse --short zzz ) second on main EOF test_i18ncmp expect actual ' diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh index 71818b90f0..d65586541d 100755 --- a/t/t3203-branch-output.sh +++ b/t/t3203-branch-output.sh @@ -329,7 +329,7 @@ test_expect_success '--color overrides auto-color' ' test_cmp expect.color actual ' -test_expect_success 'verbose output lists worktree path' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'verbose output lists worktree path' ' one=$(git rev-parse --short HEAD) && two=$(git rev-parse --short master) && cat >expect <<-EOF && @@ -337,7 +337,7 @@ test_expect_success 'verbose output lists worktree path' ' ambiguous $one one branch-one $two two + branch-two $one ($(pwd)/worktree_dir) one - master $two two + main $two two ref-to-branch $two two ref-to-remote $two two EOF diff --git a/t/t3205-branch-color.sh b/t/t3205-branch-color.sh index 4f1e16bb44..289625c464 100755 --- a/t/t3205-branch-color.sh +++ b/t/t3205-branch-color.sh @@ -28,12 +28,12 @@ test_expect_success 'regular output shows colors' ' test_cmp expect actual ' -test_expect_success 'verbose output shows colors' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'verbose output shows colors' ' oid=$(git rev-parse --short HEAD) && cat >expect <<-EOF && - * <CYAN>master <RESET> $oid foo - <BLUE>other <RESET> $oid foo - <YELLOW>remotes/origin/master<RESET> $oid foo + * <CYAN>main <RESET> $oid foo + <BLUE>other <RESET> $oid foo + <YELLOW>remotes/origin/main<RESET> $oid foo EOF git branch --color -v -a >actual.raw && test_decode_color <actual.raw >actual && diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index 927a4f4a4e..4afc528165 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -46,22 +46,22 @@ test_expect_success 'rebase fast-forward to master' ' test_expect_success 'rebase --stat' ' git reset --hard start && - git rebase --stat master >diffstat.txt && - grep "^ fileX | *1 +$" diffstat.txt + git rebase --stat master >diffstat.txt && + grep "^ fileX | *1 +$" diffstat.txt ' test_expect_success 'rebase w/config rebase.stat' ' git reset --hard start && - git config rebase.stat true && - git rebase master >diffstat.txt && - grep "^ fileX | *1 +$" diffstat.txt + git config rebase.stat true && + git rebase master >diffstat.txt && + grep "^ fileX | *1 +$" diffstat.txt ' test_expect_success 'rebase -n overrides config rebase.stat config' ' git reset --hard start && - git config rebase.stat true && - git rebase -n master >diffstat.txt && - ! grep "^ fileX | *1 +$" diffstat.txt + git config rebase.stat true && + git rebase -n master >diffstat.txt && + ! grep "^ fileX | *1 +$" diffstat.txt ' # Output to stderr: diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index 2a7d958ea7..5839719ba1 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -19,7 +19,7 @@ commit_message() { # \ # README ---------------------- Add subproject master - topic_4 - files_subtree/topic_5 # -# Where the merge moves the files master[123].t into the subdirectory +# Where the merge moves the files topic_[123].t into the subdirectory # files_subtree/ and topic_4 as well as files_subtree/topic_5 add files to that # directory directly. # diff --git a/t/t3435-rebase-gpg-sign.sh b/t/t3435-rebase-gpg-sign.sh index b47c59c190..54120b09d6 100755 --- a/t/t3435-rebase-gpg-sign.sh +++ b/t/t3435-rebase-gpg-sign.sh @@ -68,4 +68,60 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' ' test_must_fail git verify-commit HEAD ' +test_expect_success 'rebase -r, merge strategy, --gpg-sign will sign commit' ' + git reset --hard merged && + test_unconfig commit.gpgsign && + git rebase -fr --gpg-sign -s resolve --root && + git verify-commit HEAD +' + +test_expect_success 'rebase -r, merge strategy, commit.gpgsign=true will sign commit' ' + git reset --hard merged && + git config commit.gpgsign true && + git rebase -fr -s resolve --root && + git verify-commit HEAD +' + +test_expect_success 'rebase -r, merge strategy, commit.gpgsign=false --gpg-sign will sign commit' ' + git reset --hard merged && + git config commit.gpgsign false && + git rebase -fr --gpg-sign -s resolve --root && + git verify-commit HEAD +' + +test_expect_success "rebase -r, merge strategy, commit.gpgsign=true --no-gpg-sign won't sign commit" ' + git reset --hard merged && + git config commit.gpgsign true && + git rebase -fr --no-gpg-sign -s resolve --root && + test_must_fail git verify-commit HEAD +' + +test_expect_success 'rebase -r --gpg-sign will sign commit' ' + git reset --hard merged && + test_unconfig commit.gpgsign && + git rebase -fr --gpg-sign --root && + git verify-commit HEAD +' + +test_expect_success 'rebase -r with commit.gpgsign=true will sign commit' ' + git reset --hard merged && + git config commit.gpgsign true && + git rebase -fr --root && + git verify-commit HEAD +' + +test_expect_success 'rebase -r --gpg-sign with commit.gpgsign=false will sign commit' ' + git reset --hard merged && + git config commit.gpgsign false && + git rebase -fr --gpg-sign --root && + git verify-commit HEAD +' + +test_expect_success "rebase -r --no-gpg-sign with commit.gpgsign=true won't sign commit" ' + git reset --hard merged && + git config commit.gpgsign true && + git rebase -fr --no-gpg-sign --root && + test_must_fail git verify-commit HEAD +' + test_done diff --git a/t/t3920-crlf-messages.sh b/t/t3920-crlf-messages.sh new file mode 100755 index 0000000000..70ddce3a2e --- /dev/null +++ b/t/t3920-crlf-messages.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +test_description='Test ref-filter and pretty APIs for commit and tag messages using CRLF' +. ./test-lib.sh + +LIB_CRLF_BRANCHES="" + +create_crlf_ref () { + branch="$1" && + cat >.crlf-orig-$branch.txt && + cat .crlf-orig-$branch.txt | append_cr >.crlf-message-$branch.txt && + grep 'Subject' .crlf-orig-$branch.txt | tr '\n' ' ' | sed 's/[ ]*$//' | tr -d '\n' >.crlf-subject-$branch.txt && + grep 'Body' .crlf-message-$branch.txt >.crlf-body-$branch.txt || true && + LIB_CRLF_BRANCHES="${LIB_CRLF_BRANCHES} ${branch}" && + test_tick && + hash=$(git commit-tree HEAD^{tree} -p HEAD -F .crlf-message-${branch}.txt) && + git branch ${branch} ${hash} && + git tag tag-${branch} ${branch} -F .crlf-message-${branch}.txt --cleanup=verbatim +} + +create_crlf_refs () { + create_crlf_ref crlf <<-\EOF && + Subject first line + + Body first line + Body second line + EOF + create_crlf_ref crlf-empty-lines-after-subject <<-\EOF && + Subject first line + + + Body first line + Body second line + EOF + create_crlf_ref crlf-two-line-subject <<-\EOF && + Subject first line + Subject second line + + Body first line + Body second line + EOF + create_crlf_ref crlf-two-line-subject-no-body <<-\EOF && + Subject first line + Subject second line + EOF + create_crlf_ref crlf-two-line-subject-no-body-trailing-newline <<-\EOF + Subject first line + Subject second line + + EOF +} + +test_crlf_subject_body_and_contents() { + command_and_args="$@" && + command=$1 && + if test ${command} = "branch" || test ${command} = "for-each-ref" || test ${command} = "tag" + then + atoms="(contents:subject) (contents:body) (contents)" + elif test ${command} = "log" || test ${command} = "show" + then + atoms="s b B" + fi && + files="subject body message" && + while test -n "${atoms}" + do + set ${atoms} && atom=$1 && shift && atoms="$*" && + set ${files} && file=$1 && shift && files="$*" && + test_expect_success "${command}: --format='%${atom}' works with messages using CRLF" " + rm -f expect && + for ref in ${LIB_CRLF_BRANCHES} + do + cat .crlf-${file}-\"\${ref}\".txt >>expect && + printf \"\n\" >>expect + done && + git $command_and_args --format=\"%${atom}\" >actual && + test_cmp expect actual + " + done +} + + +test_expect_success 'Setup refs with commit and tag messages using CRLF' ' + test_commit inital && + create_crlf_refs +' + +test_expect_success 'branch: --verbose works with messages using CRLF' ' + rm -f expect && + for branch in $LIB_CRLF_BRANCHES + do + printf " " >>expect && + cat .crlf-subject-${branch}.txt >>expect && + printf "\n" >>expect + done && + git branch -v >tmp && + # Remove first two columns, and the line for the currently checked out branch + current=$(git branch --show-current) && + grep -v $current <tmp | awk "{\$1=\$2=\"\"}1" >actual && + test_cmp expect actual +' + +test_crlf_subject_body_and_contents branch --list crlf* + +test_crlf_subject_body_and_contents tag --list tag-crlf* + +test_crlf_subject_body_and_contents for-each-ref refs/heads/crlf* + +test_expect_success 'log: --oneline works with messages using CRLF' ' + for branch in $LIB_CRLF_BRANCHES + do + cat .crlf-subject-${branch}.txt >expect && + printf "\n" >>expect && + git log --oneline -1 ${branch} >tmp-branch && + git log --oneline -1 tag-${branch} >tmp-tag && + cut -d" " -f2- <tmp-branch >actual-branch && + cut -d" " -f2- <tmp-tag >actual-tag && + test_cmp expect actual-branch && + test_cmp expect actual-tag || return 1 + done +' + +test_crlf_subject_body_and_contents log --all --reverse --grep Subject + +test_crlf_subject_body_and_contents show $LIB_CRLF_BRANCHES + +test_done diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 5c7b0122b4..f72d456d3b 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -6,6 +6,7 @@ test_description='Various diff formatting options' . ./test-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh test_expect_success setup ' @@ -333,6 +334,7 @@ log -SF master --max-count=2 log -GF master log -GF -p master log -GF -p --pickaxe-all master +log -IA -IB -I1 -I2 -p master log --decorate --all log --decorate=full --all @@ -473,4 +475,43 @@ test_expect_success 'diff-tree --stdin with log formatting' ' test_cmp expect actual ' +test_expect_success 'diff -I<regex>: setup' ' + git checkout master && + test_seq 50 >file0 && + git commit -m "Set up -I<regex> test file" file0 && + test_seq 50 | sed -e "s/13/ten and three/" -e "/7\$/d" >file0 && + echo >>file0 +' +test_expect_success 'diff -I<regex>' ' + git diff --ignore-blank-lines -I"ten.*e" -I"^[124-9]" >actual && + cat >expect <<-\EOF && + diff --git a/file0 b/file0 + --- a/file0 + +++ b/file0 + @@ -34,7 +31,6 @@ + 34 + 35 + 36 + -37 + 38 + 39 + 40 + EOF + compare_diff_patch expect actual +' + +test_expect_success 'diff -I<regex> --stat' ' + git diff --stat --ignore-blank-lines -I"ten.*e" -I"^[124-9]" >actual && + cat >expect <<-\EOF && + file0 | 1 - + 1 file changed, 1 deletion(-) + EOF + test_cmp expect actual +' + +test_expect_success 'diff -I<regex>: detect malformed regex' ' + test_expect_code 129 git diff --ignore-matching-lines="^[124-9" 2>error && + test_i18ngrep "invalid regex given to -I: " error +' + test_done diff --git a/t/t4013/diff.log_-IA_-IB_-I1_-I2_-p_master b/t/t4013/diff.log_-IA_-IB_-I1_-I2_-p_master new file mode 100644 index 0000000000..929f35a05b --- /dev/null +++ b/t/t4013/diff.log_-IA_-IB_-I1_-I2_-p_master @@ -0,0 +1,99 @@ +$ git log -IA -IB -I1 -I2 -p master +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 +Merge: 9a6d494 c7a2ab9 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 + +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + + This is the second commit. + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor <author@example.com> +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 9d07797579..9675bc17db 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -27,6 +27,7 @@ test_expect_success 'setup' ' diffpatterns=" ada + bash bibtex cpp csharp diff --git a/t/t4018/bash-arithmetic-function b/t/t4018/bash-arithmetic-function new file mode 100644 index 0000000000..c0b276cb50 --- /dev/null +++ b/t/t4018/bash-arithmetic-function @@ -0,0 +1,4 @@ +RIGHT() (( + + ChangeMe = "$x" + "$y" +)) diff --git a/t/t4018/bash-bashism-style-compact b/t/t4018/bash-bashism-style-compact new file mode 100644 index 0000000000..1ca3126f61 --- /dev/null +++ b/t/t4018/bash-bashism-style-compact @@ -0,0 +1,6 @@ +function RIGHT { + function InvalidSyntax{ + : + echo 'ChangeMe' + } +} diff --git a/t/t4018/bash-bashism-style-function b/t/t4018/bash-bashism-style-function new file mode 100644 index 0000000000..f1de4fa831 --- /dev/null +++ b/t/t4018/bash-bashism-style-function @@ -0,0 +1,4 @@ +function RIGHT { + : + echo 'ChangeMe' +} diff --git a/t/t4018/bash-bashism-style-whitespace b/t/t4018/bash-bashism-style-whitespace new file mode 100644 index 0000000000..ade85dd3a5 --- /dev/null +++ b/t/t4018/bash-bashism-style-whitespace @@ -0,0 +1,4 @@ + function RIGHT ( ) { + + ChangeMe + } diff --git a/t/t4018/bash-conditional-function b/t/t4018/bash-conditional-function new file mode 100644 index 0000000000..c5949e829b --- /dev/null +++ b/t/t4018/bash-conditional-function @@ -0,0 +1,4 @@ +RIGHT() [[ \ + + "$a" > "$ChangeMe" +]] diff --git a/t/t4018/bash-missing-parentheses b/t/t4018/bash-missing-parentheses new file mode 100644 index 0000000000..8c8a05dd7a --- /dev/null +++ b/t/t4018/bash-missing-parentheses @@ -0,0 +1,6 @@ +function RIGHT { + functionInvalidSyntax { + : + echo 'ChangeMe' + } +} diff --git a/t/t4018/bash-mixed-style-compact b/t/t4018/bash-mixed-style-compact new file mode 100644 index 0000000000..d9364cba67 --- /dev/null +++ b/t/t4018/bash-mixed-style-compact @@ -0,0 +1,4 @@ +function RIGHT(){ + : + echo 'ChangeMe' +} diff --git a/t/t4018/bash-mixed-style-function b/t/t4018/bash-mixed-style-function new file mode 100644 index 0000000000..555f9b2466 --- /dev/null +++ b/t/t4018/bash-mixed-style-function @@ -0,0 +1,4 @@ +function RIGHT() { + + ChangeMe +} diff --git a/t/t4018/bash-nested-functions b/t/t4018/bash-nested-functions new file mode 100644 index 0000000000..2c9237ead4 --- /dev/null +++ b/t/t4018/bash-nested-functions @@ -0,0 +1,6 @@ +outer() { + RIGHT() { + : + echo 'ChangeMe' + } +} diff --git a/t/t4018/bash-other-characters b/t/t4018/bash-other-characters new file mode 100644 index 0000000000..a3f390d525 --- /dev/null +++ b/t/t4018/bash-other-characters @@ -0,0 +1,4 @@ +_RIGHT_0n() { + + ChangeMe +} diff --git a/t/t4018/bash-posix-style-compact b/t/t4018/bash-posix-style-compact new file mode 100644 index 0000000000..045bd2029b --- /dev/null +++ b/t/t4018/bash-posix-style-compact @@ -0,0 +1,4 @@ +RIGHT(){ + + ChangeMe +} diff --git a/t/t4018/bash-posix-style-function b/t/t4018/bash-posix-style-function new file mode 100644 index 0000000000..a4d144856e --- /dev/null +++ b/t/t4018/bash-posix-style-function @@ -0,0 +1,4 @@ +RIGHT() { + + ChangeMe +} diff --git a/t/t4018/bash-posix-style-whitespace b/t/t4018/bash-posix-style-whitespace new file mode 100644 index 0000000000..4d984f0aa4 --- /dev/null +++ b/t/t4018/bash-posix-style-whitespace @@ -0,0 +1,4 @@ + RIGHT ( ) { + + ChangeMe + } diff --git a/t/t4018/bash-subshell-function b/t/t4018/bash-subshell-function new file mode 100644 index 0000000000..80baa09484 --- /dev/null +++ b/t/t4018/bash-subshell-function @@ -0,0 +1,4 @@ +RIGHT() ( + + ChangeMe=2 +) diff --git a/t/t4018/bash-trailing-comment b/t/t4018/bash-trailing-comment new file mode 100644 index 0000000000..f1edbeda31 --- /dev/null +++ b/t/t4018/bash-trailing-comment @@ -0,0 +1,4 @@ +RIGHT() { # Comment + + ChangeMe +} diff --git a/t/t4068-diff-symmetric-merge-base.sh b/t/t4068-diff-symmetric-merge-base.sh new file mode 100755 index 0000000000..03487cc945 --- /dev/null +++ b/t/t4068-diff-symmetric-merge-base.sh @@ -0,0 +1,193 @@ +#!/bin/sh + +test_description='behavior of diff with symmetric-diff setups and --merge-base' + +. ./test-lib.sh + +# build these situations: +# - normal merge with one merge base (br1...b2r); +# - criss-cross merge ie 2 merge bases (br1...master); +# - disjoint subgraph (orphan branch, br3...master). +# +# B---E <-- master +# / \ / +# A X +# \ / \ +# C---D--G <-- br1 +# \ / +# ---F <-- br2 +# +# H <-- br3 +# +# We put files into a few commits so that we can verify the +# output as well. + +test_expect_success setup ' + git commit --allow-empty -m A && + echo b >b && + git add b && + git commit -m B && + git checkout -b br1 HEAD^ && + echo c >c && + git add c && + git commit -m C && + git tag commit-C && + git merge -m D master && + git tag commit-D && + git checkout master && + git merge -m E commit-C && + git checkout -b br2 commit-C && + echo f >f && + git add f && + git commit -m F && + git checkout br1 && + git merge -m G br2 && + git checkout --orphan br3 && + git commit -m H +' + +test_expect_success 'diff with one merge base' ' + git diff commit-D...br1 >tmp && + tail -n 1 tmp >actual && + echo +f >expect && + test_cmp expect actual +' + +# The output (in tmp) can have +b or +c depending +# on which merge base (commit B or C) is picked. +# It should have one of those two, which comes out +# to seven lines. +test_expect_success 'diff with two merge bases' ' + git diff br1...master >tmp 2>err && + test_line_count = 7 tmp && + test_line_count = 1 err +' + +test_expect_success 'diff with no merge bases' ' + test_must_fail git diff br2...br3 2>err && + test_i18ngrep "fatal: br2...br3: no merge base" err +' + +test_expect_success 'diff with too many symmetric differences' ' + test_must_fail git diff br1...master br2...br3 2>err && + test_i18ngrep "usage" err +' + +test_expect_success 'diff with symmetric difference and extraneous arg' ' + test_must_fail git diff master br1...master 2>err && + test_i18ngrep "usage" err +' + +test_expect_success 'diff with two ranges' ' + test_must_fail git diff master br1..master br2..br3 2>err && + test_i18ngrep "usage" err +' + +test_expect_success 'diff with ranges and extra arg' ' + test_must_fail git diff master br1..master commit-D 2>err && + test_i18ngrep "usage" err +' + +test_expect_success 'diff --merge-base with no commits' ' + test_must_fail git diff --merge-base +' + +test_expect_success 'diff --merge-base with three commits' ' + test_must_fail git diff --merge-base br1 br2 master 2>err && + test_i18ngrep "usage" err +' + +for cmd in diff-index diff +do + test_expect_success "$cmd --merge-base with one commit" ' + git checkout master && + git $cmd commit-C >expect && + git $cmd --merge-base br2 >actual && + test_cmp expect actual + ' + + test_expect_success "$cmd --merge-base with one commit and unstaged changes" ' + git checkout master && + test_when_finished git reset --hard && + echo unstaged >>c && + git $cmd commit-C >expect && + git $cmd --merge-base br2 >actual && + test_cmp expect actual + ' + + test_expect_success "$cmd --merge-base with one commit and staged and unstaged changes" ' + git checkout master && + test_when_finished git reset --hard && + echo staged >>c && + git add c && + echo unstaged >>c && + git $cmd commit-C >expect && + git $cmd --merge-base br2 >actual && + test_cmp expect actual + ' + + test_expect_success "$cmd --merge-base --cached with one commit and staged and unstaged changes" ' + git checkout master && + test_when_finished git reset --hard && + echo staged >>c && + git add c && + echo unstaged >>c && + git $cmd --cached commit-C >expect && + git $cmd --cached --merge-base br2 >actual && + test_cmp expect actual + ' + + test_expect_success "$cmd --merge-base with non-commit" ' + git checkout master && + test_must_fail git $cmd --merge-base master^{tree} 2>err && + test_i18ngrep "fatal: --merge-base only works with commits" err + ' + + test_expect_success "$cmd --merge-base with no merge bases and one commit" ' + git checkout master && + test_must_fail git $cmd --merge-base br3 2>err && + test_i18ngrep "fatal: no merge base found" err + ' + + test_expect_success "$cmd --merge-base with multiple merge bases and one commit" ' + git checkout master && + test_must_fail git $cmd --merge-base br1 2>err && + test_i18ngrep "fatal: multiple merge bases found" err + ' +done + +for cmd in diff-tree diff +do + test_expect_success "$cmd --merge-base with two commits" ' + git $cmd commit-C master >expect && + git $cmd --merge-base br2 master >actual && + test_cmp expect actual + ' + + test_expect_success "$cmd --merge-base commit and non-commit" ' + test_must_fail git $cmd --merge-base br2 master^{tree} 2>err && + test_i18ngrep "fatal: --merge-base only works with commits" err + ' + + test_expect_success "$cmd --merge-base with no merge bases and two commits" ' + test_must_fail git $cmd --merge-base br2 br3 2>err && + test_i18ngrep "fatal: no merge base found" err + ' + + test_expect_success "$cmd --merge-base with multiple merge bases and two commits" ' + test_must_fail git $cmd --merge-base master br1 2>err && + test_i18ngrep "fatal: multiple merge bases found" err + ' +done + +test_expect_success 'diff-tree --merge-base with one commit' ' + test_must_fail git diff-tree --merge-base master 2>err && + test_i18ngrep "fatal: --merge-base only works with two commits" err +' + +test_expect_success 'diff --merge-base with range' ' + test_must_fail git diff --merge-base br2..br3 2>err && + test_i18ngrep "fatal: --merge-base does not work with ranges" err +' + +test_done diff --git a/t/t4068-diff-symmetric.sh b/t/t4068-diff-symmetric.sh deleted file mode 100755 index 31d17a5af0..0000000000 --- a/t/t4068-diff-symmetric.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh - -test_description='behavior of diff with symmetric-diff setups' - -. ./test-lib.sh - -# build these situations: -# - normal merge with one merge base (br1...b2r); -# - criss-cross merge ie 2 merge bases (br1...master); -# - disjoint subgraph (orphan branch, br3...master). -# -# B---E <-- master -# / \ / -# A X -# \ / \ -# C---D--G <-- br1 -# \ / -# ---F <-- br2 -# -# H <-- br3 -# -# We put files into a few commits so that we can verify the -# output as well. - -test_expect_success setup ' - git commit --allow-empty -m A && - echo b >b && - git add b && - git commit -m B && - git checkout -b br1 HEAD^ && - echo c >c && - git add c && - git commit -m C && - git tag commit-C && - git merge -m D master && - git tag commit-D && - git checkout master && - git merge -m E commit-C && - git checkout -b br2 commit-C && - echo f >f && - git add f && - git commit -m F && - git checkout br1 && - git merge -m G br2 && - git checkout --orphan br3 && - git commit -m H -' - -test_expect_success 'diff with one merge base' ' - git diff commit-D...br1 >tmp && - tail -n 1 tmp >actual && - echo +f >expect && - test_cmp expect actual -' - -# The output (in tmp) can have +b or +c depending -# on which merge base (commit B or C) is picked. -# It should have one of those two, which comes out -# to seven lines. -test_expect_success 'diff with two merge bases' ' - git diff br1...master >tmp 2>err && - test_line_count = 7 tmp && - test_line_count = 1 err -' - -test_expect_success 'diff with no merge bases' ' - test_must_fail git diff br2...br3 >tmp 2>err && - test_i18ngrep "fatal: br2...br3: no merge base" err -' - -test_expect_success 'diff with too many symmetric differences' ' - test_must_fail git diff br1...master br2...br3 >tmp 2>err && - test_i18ngrep "usage" err -' - -test_expect_success 'diff with symmetric difference and extraneous arg' ' - test_must_fail git diff master br1...master >tmp 2>err && - test_i18ngrep "usage" err -' - -test_expect_success 'diff with two ranges' ' - test_must_fail git diff master br1..master br2..br3 >tmp 2>err && - test_i18ngrep "usage" err -' - -test_expect_success 'diff with ranges and extra arg' ' - test_must_fail git diff master br1..master commit-D >tmp 2>err && - test_i18ngrep "usage" err -' - -test_done diff --git a/t/t4114-apply-typechange.sh b/t/t4114-apply-typechange.sh index ebadbc347f..da3e64f811 100755 --- a/t/t4114-apply-typechange.sh +++ b/t/t4114-apply-typechange.sh @@ -88,6 +88,13 @@ test_expect_success 'symlink becomes file' ' ' test_debug 'cat patch' +test_expect_success 'symlink becomes file, in reverse' ' + git checkout -f foo-symlinked-to-bar && + git diff-tree -p HEAD foo-back-to-file > patch && + git checkout foo-back-to-file && + git apply -R --index < patch + ' + test_expect_success 'binary file becomes symlink' ' git checkout -f foo-becomes-binary && git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch && diff --git a/t/t4127-apply-same-fn.sh b/t/t4127-apply-same-fn.sh index 972946c174..305b7e649e 100755 --- a/t/t4127-apply-same-fn.sh +++ b/t/t4127-apply-same-fn.sh @@ -32,6 +32,10 @@ test_expect_success 'apply same filename with independent changes' ' test_expect_success 'apply same filename with overlapping changes' ' git reset --hard && + + # Store same_fn so that we can check apply -R in next test + cp same_fn same_fn1 && + modify "s/^d/z/" same_fn && git diff > patch0 && git add same_fn && @@ -43,6 +47,11 @@ test_expect_success 'apply same filename with overlapping changes' ' test_cmp same_fn same_fn2 ' +test_expect_success 'apply same filename with overlapping changes, in reverse' ' + git apply -R patch0 && + test_cmp same_fn same_fn1 +' + test_expect_success 'apply same new filename after rename' ' git reset --hard && git mv same_fn new_fn && diff --git a/t/t5315-pack-objects-compression.sh b/t/t5315-pack-objects-compression.sh index df970d7584..8bacd96275 100755 --- a/t/t5315-pack-objects-compression.sh +++ b/t/t5315-pack-objects-compression.sh @@ -4,12 +4,6 @@ test_description='pack-object compression configuration' . ./test-lib.sh -# This should be moved to test-lib.sh together with the -# copy in t0021 after both topics have graduated to 'master'. -file_size () { - test-tool path-utils file-size "$1" -} - test_expect_success setup ' printf "%2000000s" X | git hash-object -w --stdin >object-name && @@ -24,7 +18,7 @@ do test_expect_success "pack-objects with $config" ' test_when_finished "rm -f pack-*.*" && git $config pack-objects pack <object-name && - sz=$(file_size pack-*.pack) && + sz=$(test_file_size pack-*.pack) && case "$expect" in small) test "$sz" -le 100000 ;; large) test "$sz" -ge 100000 ;; diff --git a/t/t5324-split-commit-graph.sh b/t/t5324-split-commit-graph.sh index c334ee9155..4d3842b83b 100755 --- a/t/t5324-split-commit-graph.sh +++ b/t/t5324-split-commit-graph.sh @@ -440,4 +440,17 @@ test_expect_success '--split=replace with partial Bloom data' ' verify_chain_files_exist $graphdir ' +test_expect_success 'prevent regression for duplicate commits across layers' ' + git init dup && + git -C dup commit --allow-empty -m one && + git -C dup -c core.commitGraph=false commit-graph write --split=no-merge --reachable 2>err && + test_i18ngrep "attempting to write a commit-graph" err && + git -C dup commit-graph write --split=no-merge --reachable && + git -C dup commit --allow-empty -m two && + git -C dup commit-graph write --split=no-merge --reachable && + git -C dup commit --allow-empty -m three && + git -C dup commit-graph write --split --reachable && + git -C dup commit-graph verify +' + test_done diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index b84618c925..cc86ef213e 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -21,14 +21,15 @@ test_expect_success setup ' i=0 && while test $i -le $cnt do - i=$(($i+1)) && - test_tick && - echo "Commit #$i" >mozart/is/pink && - git update-index --add mozart/is/pink && - tree=$(git write-tree) && - commit=$(echo "Commit #$i" | git commit-tree $tree -p $parent) && - git update-ref refs/tags/commit$i $commit && - parent=$commit || return 1 + i=$(($i+1)) && + test_tick && + echo "Commit #$i" >mozart/is/pink && + git update-index --add mozart/is/pink && + tree=$(git write-tree) && + commit=$(echo "Commit #$i" | + git commit-tree $tree -p $parent) && + git update-ref refs/tags/commit$i $commit && + parent=$commit || return 1 done && git update-ref HEAD "$commit" && git clone ./. victim && @@ -38,14 +39,14 @@ test_expect_success setup ' i=0 && while test $i -le $cnt do - i=$(($i+1)) && - test_tick && - echo "Rebase #$i" >mozart/is/pink && - git update-index --add mozart/is/pink && - tree=$(git write-tree) && - commit=$(echo "Rebase #$i" | git commit-tree $tree -p $parent) && - git update-ref refs/tags/rebase$i $commit && - parent=$commit || return 1 + i=$(($i+1)) && + test_tick && + echo "Rebase #$i" >mozart/is/pink && + git update-index --add mozart/is/pink && + tree=$(git write-tree) && + commit=$(echo "Rebase #$i" | git commit-tree $tree -p $parent) && + git update-ref refs/tags/rebase$i $commit && + parent=$commit || return 1 done && git update-ref HEAD "$commit" && echo Rebase && @@ -57,11 +58,11 @@ test_expect_success 'pack the source repository' ' ' test_expect_success 'pack the destination repository' ' - ( - cd victim && - git repack -a -d && - git prune - ) + ( + cd victim && + git repack -a -d && + git prune + ) ' test_expect_success 'refuse pushing rewound head without --force' ' @@ -85,10 +86,10 @@ test_expect_success 'push can be used to delete a ref' ' test_expect_success 'refuse deleting push with denyDeletes' ' ( - cd victim && - test_might_fail git branch -D extra && - git config receive.denyDeletes true && - git branch extra master + cd victim && + test_might_fail git branch -D extra && + git config receive.denyDeletes true && + git branch extra master ) && test_must_fail git send-pack ./victim :extra master ' @@ -118,9 +119,9 @@ test_expect_success 'override denyDeletes with git -c receive-pack' ' test_expect_success 'denyNonFastforwards trumps --force' ' ( - cd victim && - test_might_fail git branch -D extra && - git config receive.denyNonFastforwards true + cd victim && + test_might_fail git branch -D extra && + git config receive.denyNonFastforwards true ) && victim_orig=$(cd victim && git rev-parse --verify master) && test_must_fail git send-pack --force ./victim master^:master && @@ -143,16 +144,16 @@ test_expect_success 'send-pack --all sends all branches' ' test_expect_success 'push --all excludes remote-tracking hierarchy' ' mkdir parent && ( - cd parent && - git init && : >file && git add file && git commit -m add + cd parent && + git init && : >file && git add file && git commit -m add ) && git clone parent child && ( - cd child && git push --all + cd child && git push --all ) && ( - cd parent && - test -z "$(git for-each-ref refs/remotes/origin)" + cd parent && + test -z "$(git for-each-ref refs/remotes/origin)" ) ' @@ -160,33 +161,33 @@ test_expect_success 'receive-pack runs auto-gc in remote repo' ' rm -rf parent child && git init parent && ( - # Setup a repo with 2 packs - cd parent && - echo "Some text" >file.txt && - git add . && - git commit -m "Initial commit" && - git repack -adl && - echo "Some more text" >>file.txt && - git commit -a -m "Second commit" && - git repack + # Setup a repo with 2 packs + cd parent && + echo "Some text" >file.txt && + git add . && + git commit -m "Initial commit" && + git repack -adl && + echo "Some more text" >>file.txt && + git commit -a -m "Second commit" && + git repack ) && cp -R parent child && ( - # Set the child to auto-pack if more than one pack exists - cd child && - git config gc.autopacklimit 1 && - git config gc.autodetach false && - git branch test_auto_gc && - # And create a file that follows the temporary object naming - # convention for the auto-gc to remove - : >.git/objects/tmp_test_object && - test-tool chmtime =-1209601 .git/objects/tmp_test_object + # Set the child to auto-pack if more than one pack exists + cd child && + git config gc.autopacklimit 1 && + git config gc.autodetach false && + git branch test_auto_gc && + # And create a file that follows the temporary object naming + # convention for the auto-gc to remove + : >.git/objects/tmp_test_object && + test-tool chmtime =-1209601 .git/objects/tmp_test_object ) && ( - cd parent && - echo "Even more text" >>file.txt && - git commit -a -m "Third commit" && - git send-pack ../child HEAD:refs/heads/test_auto_gc + cd parent && + echo "Even more text" >>file.txt && + git commit -a -m "Third commit" && + git send-pack ../child HEAD:refs/heads/test_auto_gc ) && test ! -e child/.git/objects/tmp_test_object ' @@ -195,15 +196,15 @@ rewound_push_setup() { rm -rf parent child && mkdir parent && ( - cd parent && - git init && - echo one >file && git add file && git commit -m one && - git config receive.denyCurrentBranch warn && - echo two >file && git commit -a -m two + cd parent && + git init && + echo one >file && git add file && git commit -m one && + git config receive.denyCurrentBranch warn && + echo two >file && git commit -a -m two ) && git clone parent child && ( - cd child && git reset --hard HEAD^ + cd child && git reset --hard HEAD^ ) } @@ -211,16 +212,16 @@ test_expect_success 'pushing explicit refspecs respects forcing' ' rewound_push_setup && parent_orig=$(cd parent && git rev-parse --verify master) && ( - cd child && - test_must_fail git send-pack ../parent \ - refs/heads/master:refs/heads/master + cd child && + test_must_fail git send-pack ../parent \ + refs/heads/master:refs/heads/master ) && parent_head=$(cd parent && git rev-parse --verify master) && test "$parent_orig" = "$parent_head" && ( - cd child && - git send-pack ../parent \ - +refs/heads/master:refs/heads/master + cd child && + git send-pack ../parent \ + +refs/heads/master:refs/heads/master ) && parent_head=$(cd parent && git rev-parse --verify master) && child_head=$(cd child && git rev-parse --verify master) && @@ -231,16 +232,16 @@ test_expect_success 'pushing wildcard refspecs respects forcing' ' rewound_push_setup && parent_orig=$(cd parent && git rev-parse --verify master) && ( - cd child && - test_must_fail git send-pack ../parent \ - "refs/heads/*:refs/heads/*" + cd child && + test_must_fail git send-pack ../parent \ + "refs/heads/*:refs/heads/*" ) && parent_head=$(cd parent && git rev-parse --verify master) && test "$parent_orig" = "$parent_head" && ( - cd child && - git send-pack ../parent \ - "+refs/heads/*:refs/heads/*" + cd child && + git send-pack ../parent \ + "+refs/heads/*:refs/heads/*" ) && parent_head=$(cd parent && git rev-parse --verify master) && child_head=$(cd child && git rev-parse --verify master) && @@ -250,8 +251,8 @@ test_expect_success 'pushing wildcard refspecs respects forcing' ' test_expect_success 'deny pushing to delete current branch' ' rewound_push_setup && ( - cd child && - test_must_fail git send-pack ../parent :refs/heads/master 2>errs + cd child && + test_must_fail git send-pack ../parent :refs/heads/master 2>errs ) ' @@ -289,7 +290,7 @@ test_expect_success 'receive-pack de-dupes .have lines' ' EOF GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION=0 \ - git push \ + git push \ --receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \ fork HEAD:foo && extract_ref_advertisement <trace >refs && diff --git a/t/t5402-post-merge-hook.sh b/t/t5402-post-merge-hook.sh index 6eb2ffd6ec..4aeea8f5b7 100755 --- a/t/t5402-post-merge-hook.sh +++ b/t/t5402-post-merge-hook.sh @@ -15,7 +15,7 @@ test_expect_success setup ' git update-index a && tree1=$(git write-tree) && commit1=$(echo modify | git commit-tree $tree1 -p $commit0) && - git update-ref refs/heads/master $commit0 && + git update-ref refs/heads/master $commit0 && git clone ./. clone1 && GIT_DIR=clone1/.git git update-index --add a && git clone ./. clone2 && @@ -23,34 +23,34 @@ test_expect_success setup ' ' for clone in 1 2; do - cat >clone${clone}/.git/hooks/post-merge <<'EOF' + cat >clone${clone}/.git/hooks/post-merge <<'EOF' #!/bin/sh echo $@ >> $GIT_DIR/post-merge.args EOF - chmod u+x clone${clone}/.git/hooks/post-merge + chmod u+x clone${clone}/.git/hooks/post-merge done test_expect_success 'post-merge does not run for up-to-date ' ' - GIT_DIR=clone1/.git git merge $commit0 && + GIT_DIR=clone1/.git git merge $commit0 && ! test -f clone1/.git/post-merge.args ' test_expect_success 'post-merge runs as expected ' ' - GIT_DIR=clone1/.git git merge $commit1 && + GIT_DIR=clone1/.git git merge $commit1 && test -e clone1/.git/post-merge.args ' test_expect_success 'post-merge from normal merge receives the right argument ' ' - grep 0 clone1/.git/post-merge.args + grep 0 clone1/.git/post-merge.args ' test_expect_success 'post-merge from squash merge runs as expected ' ' - GIT_DIR=clone2/.git git merge --squash $commit1 && + GIT_DIR=clone2/.git git merge --squash $commit1 && test -e clone2/.git/post-merge.args ' test_expect_success 'post-merge from squash merge receives the right argument ' ' - grep 1 clone2/.git/post-merge.args + grep 1 clone2/.git/post-merge.args ' test_done diff --git a/t/t5411-proc-receive-hook.sh b/t/t5411-proc-receive-hook.sh index 746487286f..98b0e81208 100755 --- a/t/t5411-proc-receive-hook.sh +++ b/t/t5411-proc-receive-hook.sh @@ -5,13 +5,16 @@ test_description='Test proc-receive hook' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/t5411/common-functions.sh setup_upstream_and_workbench () { - # Refs of upstream : master(A) - # Refs of workbench: master(A) tags/v123 + # Refs of upstream : main(A) + # Refs of workbench: main(A) tags/v123 test_expect_success "setup upstream and workbench" ' rm -rf upstream.git && rm -rf workbench && @@ -25,10 +28,10 @@ setup_upstream_and_workbench () { git config core.abbrev 7 && git tag -m "v123" v123 $A && git remote add origin ../upstream.git && - git push origin master && - git update-ref refs/heads/master $A $B && + git push origin main && + git update-ref refs/heads/main $A $B && git -C ../upstream.git update-ref \ - refs/heads/master $A $B + refs/heads/main $A $B ) && TAG=$(git -C workbench rev-parse v123) && @@ -99,8 +102,8 @@ start_httpd # Re-initialize the upstream repository and local workbench. setup_upstream_and_workbench -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "setup for HTTP protocol" ' git -C upstream.git config http.receivepack true && upstream="$HTTPD_DOCUMENT_ROOT_PATH/upstream.git" && diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh index 6580bebd8e..521a347710 100644 --- a/t/t5411/common-functions.sh +++ b/t/t5411/common-functions.sh @@ -28,7 +28,7 @@ create_commits_in () { shift || return 1 done && - git -C "$repo" update-ref refs/heads/master $oid + git -C "$repo" update-ref refs/heads/main $oid } # Format the output of git-push, git-show-ref and other commands to make a diff --git a/t/t5411/once-0010-report-status-v1.sh b/t/t5411/once-0010-report-status-v1.sh index dc2cf4a522..cb431a9c91 100644 --- a/t/t5411/once-0010-report-status-v1.sh +++ b/t/t5411/once-0010-report-status-v1.sh @@ -6,12 +6,12 @@ test_expect_success "setup proc-receive hook" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic1" \ + -r "ok refs/for/main/topic1" \ -r "option fall-through" \ - -r "ok refs/for/master/topic2" \ + -r "ok refs/for/main/topic2" \ -r "option refname refs/for/changes/23/123/1" \ -r "option new-oid $A" \ - -r "ok refs/for/master/topic2" \ + -r "ok refs/for/main/topic2" \ -r "option refname refs/for/changes/24/124/2" \ -r "option old-oid $B" \ -r "option new-oid $A" \ @@ -20,26 +20,26 @@ test_expect_success "setup proc-receive hook" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : (B) refs/for/master/topic1(A) foo(A) refs/for/next/topic(A) refs/for/master/topic2(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : (B) refs/for/main/topic1(A) foo(A) refs/for/next/topic(A) refs/for/main/topic2(A) test_expect_success "proc-receive: report status v1" ' { if test -z "$GIT_DEFAULT_HASH" || test "$GIT_DEFAULT_HASH" = "sha1" then - printf "%s %s refs/heads/master\0report-status\n" \ + printf "%s %s refs/heads/main\0report-status\n" \ $A $B | packetize else - printf "%s %s refs/heads/master\0report-status object-format=$GIT_DEFAULT_HASH\n" \ + printf "%s %s refs/heads/main\0report-status object-format=$GIT_DEFAULT_HASH\n" \ $A $B | packetize fi && - printf "%s %s refs/for/master/topic1\n" \ + printf "%s %s refs/for/main/topic1\n" \ $ZERO_OID $A | packetize && printf "%s %s refs/heads/foo\n" \ $ZERO_OID $A | packetize && printf "%s %s refs/for/next/topic\n" \ $ZERO_OID $A | packetize && - printf "%s %s refs/for/master/topic2\n" \ + printf "%s %s refs/for/main/topic2\n" \ $ZERO_OID $A | packetize && printf 0000 && printf "" | git -C "$upstream" pack-objects --stdout @@ -48,35 +48,35 @@ test_expect_success "proc-receive: report status v1" ' make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && # pre-receive hook - pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master - pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1 + pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main + pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic1 pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic - pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic2 + pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic2 # proc-receive hook - proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1 + proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic1 proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic - proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic2 - proc-receive> ok refs/for/master/topic1 + proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic2 + proc-receive> ok refs/for/main/topic1 proc-receive> option fall-through - proc-receive> ok refs/for/master/topic2 + proc-receive> ok refs/for/main/topic2 proc-receive> option refname refs/for/changes/23/123/1 proc-receive> option new-oid <COMMIT-A> - proc-receive> ok refs/for/master/topic2 + proc-receive> ok refs/for/main/topic2 proc-receive> option refname refs/for/changes/24/124/2 proc-receive> option old-oid <COMMIT-B> proc-receive> option new-oid <COMMIT-A> proc-receive> option forced-update proc-receive> ng refs/for/next/topic target branch not exist 000eunpack ok - 0019ok refs/heads/master - 001eok refs/for/master/topic1 + 0017ok refs/heads/main + 001cok refs/for/main/topic1 0016ok refs/heads/foo 0033ng refs/for/next/topic target branch not exist - 001eok refs/for/master/topic2 + 001cok refs/for/main/topic2 0000# post-receive hook - post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master - post-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1 + post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main + post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic1 post-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo post-receive< <ZERO-OID> <COMMIT-A> refs/for/changes/23/123/1 post-receive< <COMMIT-B> <COMMIT-A> refs/for/changes/24/124/2 @@ -86,9 +86,9 @@ test_expect_success "proc-receive: report status v1" ' git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/for/master/topic1 + <COMMIT-A> refs/for/main/topic1 <COMMIT-A> refs/heads/foo - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0000-standard-git-push.sh b/t/t5411/test-0000-standard-git-push.sh index e206587348..2b04b49367 100644 --- a/t/t5411/test-0000-standard-git-push.sh +++ b/t/t5411/test-0000-standard-git-push.sh @@ -1,39 +1,39 @@ -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git-push : master(B) next(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git-push : main(B) next(A) test_expect_success "git-push ($PROTOCOL)" ' git -C workbench push origin \ - $B:refs/heads/master \ + $B:refs/heads/main \ HEAD:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next To <URL/of/upstream.git> - <OID-A>..<OID-B> <COMMIT-B> -> master + <OID-A>..<OID-B> <COMMIT-B> -> main * [new branch] HEAD -> next EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(B) next(A) -# Refs of workbench: master(A) tags/v123 -# git-push --atomic: master(A) next(B) +# Refs of upstream : main(B) next(A) +# Refs of workbench: main(A) tags/v123 +# git-push --atomic: main(A) next(B) test_expect_success "git-push --atomic ($PROTOCOL)" ' test_must_fail git -C workbench push --atomic origin \ - master \ + main \ $B:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output <out | @@ -43,28 +43,28 @@ test_expect_success "git-push --atomic ($PROTOCOL)" ' >actual && cat >expect <<-EOF && To <URL/of/upstream.git> - ! [rejected] master -> master (non-fast-forward) + ! [rejected] main -> main (non-fast-forward) ! [rejected] <COMMIT-B> -> next (atomic push failed) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(B) next(A) -# Refs of workbench: master(A) tags/v123 -# git-push : master(A) next(B) +# Refs of upstream : main(B) next(A) +# Refs of workbench: main(A) tags/v123 +# git-push : main(A) next(B) test_expect_success "non-fast-forward git-push ($PROTOCOL)" ' test_must_fail git \ -C workbench \ -c advice.pushUpdateRejected=false \ push origin \ - master \ + main \ $B:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && @@ -75,48 +75,48 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL)" ' remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/next To <URL/of/upstream.git> <OID-A>..<OID-B> <COMMIT-B> -> next - ! [rejected] master -> master (non-fast-forward) + ! [rejected] main -> main (non-fast-forward) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main <COMMIT-B> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(B) next(B) -# Refs of workbench: master(A) tags/v123 -# git-push -f : master(A) NULL tags/v123 refs/review/master/topic(A) a/b/c(A) +# Refs of upstream : main(B) next(B) +# Refs of workbench: main(A) tags/v123 +# git-push -f : main(A) NULL tags/v123 refs/review/main/topic(A) a/b/c(A) test_expect_success "git-push -f ($PROTOCOL)" ' git -C workbench push -f origin \ refs/tags/v123 \ :refs/heads/next \ - master \ - master:refs/review/master/topic \ + main \ + main:refs/review/main/topic \ HEAD:refs/heads/a/b/c \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/master + remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/main remote: pre-receive< <COMMIT-B> <ZERO-OID> refs/heads/next remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c remote: # post-receive hook - remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/master + remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/main remote: post-receive< <COMMIT-B> <ZERO-OID> refs/heads/next remote: post-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 - remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/master/topic + remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c To <URL/of/upstream.git> - + <OID-B>...<OID-A> master -> master (forced update) + + <OID-B>...<OID-A> main -> main (forced update) - [deleted] next * [new tag] v123 -> v123 - * [new reference] master -> refs/review/master/topic + * [new reference] main -> refs/review/main/topic * [new branch] HEAD -> a/b/c EOF test_cmp expect actual && @@ -124,19 +124,19 @@ test_expect_success "git-push -f ($PROTOCOL)" ' make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && <COMMIT-A> refs/heads/a/b/c - <COMMIT-A> refs/heads/master - <COMMIT-A> refs/review/master/topic + <COMMIT-A> refs/heads/main + <COMMIT-A> refs/review/main/topic <TAG-v123> refs/tags/v123 EOF test_cmp expect actual ' -# Refs of upstream : master(A) tags/v123 refs/review/master/topic(A) a/b/c(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) tags/v123 refs/review/main/topic(A) a/b/c(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL)" ' ( cd "$upstream" && - git update-ref -d refs/review/master/topic && + git update-ref -d refs/review/main/topic && git update-ref -d refs/tags/v123 && git update-ref -d refs/heads/a/b/c ) diff --git a/t/t5411/test-0001-standard-git-push--porcelain.sh b/t/t5411/test-0001-standard-git-push--porcelain.sh index 48f6fcc846..747307f8da 100644 --- a/t/t5411/test-0001-standard-git-push--porcelain.sh +++ b/t/t5411/test-0001-standard-git-push--porcelain.sh @@ -1,21 +1,21 @@ -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git-push : master(B) next(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git-push : main(B) next(A) test_expect_success "git-push ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - $B:refs/heads/master \ + $B:refs/heads/main \ HEAD:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next To <URL/of/upstream.git> - <COMMIT-B>:refs/heads/master <OID-A>..<OID-B> + <COMMIT-B>:refs/heads/main <OID-A>..<OID-B> * HEAD:refs/heads/next [new branch] Done EOF @@ -23,18 +23,18 @@ test_expect_success "git-push ($PROTOCOL/porcelain)" ' git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(B) next(A) -# Refs of workbench: master(A) tags/v123 -# git-push --atomic: master(A) next(B) +# Refs of upstream : main(B) next(A) +# Refs of workbench: main(A) tags/v123 +# git-push --atomic: main(A) next(B) test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --atomic --porcelain origin \ - master \ + main \ $B:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output <out | @@ -45,28 +45,28 @@ test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" ' >actual && cat >expect <<-EOF && To <URL/of/upstream.git> - ! refs/heads/master:refs/heads/master [rejected] (non-fast-forward) + ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(B) next(A) -# Refs of workbench: master(A) tags/v123 -# git-push : master(A) next(B) +# Refs of upstream : main(B) next(A) +# Refs of workbench: main(A) tags/v123 +# git-push : main(A) next(B) test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" ' test_must_fail git \ -C workbench \ -c advice.pushUpdateRejected=false \ push --porcelain origin \ - master \ + main \ $B:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && @@ -77,49 +77,49 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" ' remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/next To <URL/of/upstream.git> <COMMIT-B>:refs/heads/next <OID-A>..<OID-B> - ! refs/heads/master:refs/heads/master [rejected] (non-fast-forward) + ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward) Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main <COMMIT-B> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(B) next(B) -# Refs of workbench: master(A) tags/v123 -# git-push -f : master(A) NULL tags/v123 refs/review/master/topic(A) a/b/c(A) +# Refs of upstream : main(B) next(B) +# Refs of workbench: main(A) tags/v123 +# git-push -f : main(A) NULL tags/v123 refs/review/main/topic(A) a/b/c(A) test_expect_success "git-push -f ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain -f origin \ refs/tags/v123 \ :refs/heads/next \ - master \ - master:refs/review/master/topic \ + main \ + main:refs/review/main/topic \ HEAD:refs/heads/a/b/c \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/master + remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/main remote: pre-receive< <COMMIT-B> <ZERO-OID> refs/heads/next remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c remote: # post-receive hook - remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/master + remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/main remote: post-receive< <COMMIT-B> <ZERO-OID> refs/heads/next remote: post-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 - remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/master/topic + remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c To <URL/of/upstream.git> - + refs/heads/master:refs/heads/master <OID-B>...<OID-A> (forced update) + + refs/heads/main:refs/heads/main <OID-B>...<OID-A> (forced update) - :refs/heads/next [deleted] * refs/tags/v123:refs/tags/v123 [new tag] - * refs/heads/master:refs/review/master/topic [new reference] + * refs/heads/main:refs/review/main/topic [new reference] * HEAD:refs/heads/a/b/c [new branch] Done EOF @@ -128,19 +128,19 @@ test_expect_success "git-push -f ($PROTOCOL/porcelain)" ' make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && <COMMIT-A> refs/heads/a/b/c - <COMMIT-A> refs/heads/master - <COMMIT-A> refs/review/master/topic + <COMMIT-A> refs/heads/main + <COMMIT-A> refs/review/main/topic <TAG-v123> refs/tags/v123 EOF test_cmp expect actual ' -# Refs of upstream : master(A) tags/v123 refs/review/master/topic(A) a/b/c(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) tags/v123 refs/review/main/topic(A) a/b/c(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL/porcelain)" ' ( cd "$upstream" && - git update-ref -d refs/review/master/topic && + git update-ref -d refs/review/main/topic && git update-ref -d refs/tags/v123 && git update-ref -d refs/heads/a/b/c ) diff --git a/t/t5411/test-0002-pre-receive-declined.sh b/t/t5411/test-0002-pre-receive-declined.sh index c246f7e68e..e7d113a158 100644 --- a/t/t5411/test-0002-pre-receive-declined.sh +++ b/t/t5411/test-0002-pre-receive-declined.sh @@ -5,25 +5,25 @@ test_expect_success "setup pre-receive hook ($PROTOCOL)" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git-push : master(B) next(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git-push : main(B) next(A) test_expect_success "git-push is declined ($PROTOCOL)" ' test_must_fail git -C workbench push origin \ - $B:refs/heads/master \ + $B:refs/heads/main \ HEAD:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && To <URL/of/upstream.git> - ! [remote rejected] <COMMIT-B> -> master (pre-receive hook declined) + ! [remote rejected] <COMMIT-B> -> main (pre-receive hook declined) ! [remote rejected] HEAD -> next (pre-receive hook declined) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0003-pre-receive-declined--porcelain.sh b/t/t5411/test-0003-pre-receive-declined--porcelain.sh index b14894de81..cc0cca6a47 100644 --- a/t/t5411/test-0003-pre-receive-declined--porcelain.sh +++ b/t/t5411/test-0003-pre-receive-declined--porcelain.sh @@ -5,18 +5,18 @@ test_expect_success "setup pre-receive hook ($PROTOCOL/porcelain)" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git-push : master(B) next(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git-push : main(B) next(A) test_expect_success "git-push is declined ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ - $B:refs/heads/master \ + $B:refs/heads/main \ HEAD:refs/heads/next \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && To <URL/of/upstream.git> - ! <COMMIT-B>:refs/heads/master [remote rejected] (pre-receive hook declined) + ! <COMMIT-B>:refs/heads/main [remote rejected] (pre-receive hook declined) ! HEAD:refs/heads/next [remote rejected] (pre-receive hook declined) Done EOF @@ -24,7 +24,7 @@ test_expect_success "git-push is declined ($PROTOCOL/porcelain)" ' git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0011-no-hook-error.sh b/t/t5411/test-0011-no-hook-error.sh index bb6ec92a92..c50830982f 100644 --- a/t/t5411/test-0011-no-hook-error.sh +++ b/t/t5411/test-0011-no-hook-error.sh @@ -1,64 +1,64 @@ -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : next(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : next(A) refs/for/main/topic(A) test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:next \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: error: cannot find hook "proc-receive" remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next To <URL/of/upstream.git> * [new branch] HEAD -> next - ! [remote rejected] HEAD -> refs/for/master/topic (fail to run proc-receive hook) + ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(A) next(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) next(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL)" ' git -C "$upstream" update-ref -d refs/heads/next ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push --atomic: (B) next(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push --atomic: (B) next(A) refs/for/main/topic(A) test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCOL)" ' test_must_fail git -C workbench push --atomic origin \ - $B:master \ + $B:main \ HEAD:next \ - HEAD:refs/for/master/topic >out 2>&1 && + HEAD:refs/for/main/topic >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: error: cannot find hook "proc-receive" To <URL/of/upstream.git> - ! [remote rejected] <COMMIT-B> -> master (fail to run proc-receive hook) + ! [remote rejected] <COMMIT-B> -> main (fail to run proc-receive hook) ! [remote rejected] HEAD -> next (fail to run proc-receive hook) - ! [remote rejected] HEAD -> refs/for/master/topic (fail to run proc-receive hook) + ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0012-no-hook-error--porcelain.sh b/t/t5411/test-0012-no-hook-error--porcelain.sh index 4814f74dc2..14ea433481 100644 --- a/t/t5411/test-0012-no-hook-error--porcelain.sh +++ b/t/t5411/test-0012-no-hook-error--porcelain.sh @@ -1,66 +1,66 @@ -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : next(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : next(A) refs/for/main/topic(A) test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:next \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: error: cannot find hook "proc-receive" remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next To <URL/of/upstream.git> * HEAD:refs/heads/next [new branch] - ! HEAD:refs/for/master/topic [remote rejected] (fail to run proc-receive hook) + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(A) next(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) next(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL/porcelain)" ' git -C "$upstream" update-ref -d refs/heads/next ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push --atomic: (B) next(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push --atomic: (B) next(A) refs/for/main/topic(A) test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain --atomic origin \ - $B:master \ + $B:main \ HEAD:next \ - HEAD:refs/for/master/topic >out 2>&1 && + HEAD:refs/for/main/topic >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: error: cannot find hook "proc-receive" To <URL/of/upstream.git> - ! <COMMIT-B>:refs/heads/master [remote rejected] (fail to run proc-receive hook) + ! <COMMIT-B>:refs/heads/main [remote rejected] (fail to run proc-receive hook) ! HEAD:refs/heads/next [remote rejected] (fail to run proc-receive hook) - ! HEAD:refs/for/master/topic [remote rejected] (fail to run proc-receive hook) + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0013-bad-protocol.sh b/t/t5411/test-0013-bad-protocol.sh index c5fe4cb37b..854c3e884a 100644 --- a/t/t5411/test-0013-bad-protocol.sh +++ b/t/t5411/test-0013-bad-protocol.sh @@ -5,12 +5,12 @@ test_expect_success "setup proc-receive hook (unknown version, $PROTOCOL)" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && @@ -20,7 +20,7 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" ' <actual >actual-report && cat >expect <<-EOF && To <URL/of/upstream.git> - ! [remote rejected] HEAD -> refs/for/master/topic (fail to run proc-receive hook) + ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual-report && @@ -36,7 +36,7 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" ' git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -48,30 +48,30 @@ test_expect_success "setup proc-receive hook (hook --die-version, $PROTOCOL)" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) test_expect_success "proc-receive: bad protocol (hook --die-version, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook remote: fatal: bad protocol version: 1 remote: error: proc-receive version "0" is not supported To <URL/of/upstream.git> - ! [remote rejected] HEAD -> refs/for/master/topic (fail to run proc-receive hook) + ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -83,21 +83,21 @@ test_expect_success "setup proc-receive hook (hook --die-readline, $PROTOCOL)" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) test_expect_success "proc-receive: bad protocol (hook --die-readline, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && - grep "remote: fatal: protocol error: expected \"old new ref\", got \"<ZERO-OID> <COMMIT-A> refs/for/master/topic\"" actual && + grep "remote: fatal: protocol error: expected \"old new ref\", got \"<ZERO-OID> <COMMIT-A> refs/for/main/topic\"" actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -109,38 +109,38 @@ test_expect_success "setup proc-receive hook (no report, $PROTOCOL)" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : next(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : next(A) refs/for/main/topic(A) test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ HEAD:refs/heads/next \ - HEAD:refs/for/master/topic >out 2>&1 && + HEAD:refs/for/main/topic >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next To <URL/of/upstream.git> * [new branch] HEAD -> next - ! [remote rejected] HEAD -> refs/for/master/topic (proc-receive failed to report status) + ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(A) next(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) next(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL)" ' git -C "$upstream" update-ref -d refs/heads/next @@ -154,29 +154,29 @@ test_expect_success "setup proc-receive hook (no ref, $PROTOCOL)" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ - HEAD:refs/for/master/topic\ + HEAD:refs/for/main/topic\ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive> ok remote: error: proc-receive reported incomplete status line: "ok" To <URL/of/upstream.git> - ! [remote rejected] HEAD -> refs/for/master/topic (proc-receive failed to report status) + ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -185,33 +185,33 @@ test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "xx refs/for/master/topic" + -r "xx refs/for/main/topic" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> xx refs/for/master/topic - remote: error: proc-receive reported bad status "xx" on ref "refs/for/master/topic" + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> xx refs/for/main/topic + remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" To <URL/of/upstream.git> - ! [remote rejected] HEAD -> refs/for/master/topic (proc-receive failed to report status) + ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0014-bad-protocol--porcelain.sh b/t/t5411/test-0014-bad-protocol--porcelain.sh index 53b47b0185..88c56311da 100644 --- a/t/t5411/test-0014-bad-protocol--porcelain.sh +++ b/t/t5411/test-0014-bad-protocol--porcelain.sh @@ -5,12 +5,12 @@ test_expect_success "setup proc-receive hook (unknown version, $PROTOCOL/porcela EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && @@ -20,7 +20,7 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porc <actual >actual-report && cat >expect <<-EOF && To <URL/of/upstream.git> - ! HEAD:refs/for/master/topic [remote rejected] (fail to run proc-receive hook) + ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook) Done EOF test_cmp expect actual-report && @@ -37,7 +37,7 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porc git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -49,39 +49,39 @@ test_expect_success "setup proc-receive hook (no report, $PROTOCOL/porcelain)" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : next(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : next(A) refs/for/main/topic(A) test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ HEAD:refs/heads/next \ - HEAD:refs/for/master/topic >out 2>&1 && + HEAD:refs/for/main/topic >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next To <URL/of/upstream.git> * HEAD:refs/heads/next [new branch] - ! HEAD:refs/for/master/topic [remote rejected] (proc-receive failed to report status) + ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(A) next(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) next(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL/porcelain)" ' git -C "$upstream" update-ref -d refs/heads/next @@ -95,30 +95,30 @@ test_expect_success "setup proc-receive hook (no ref, $PROTOCOL/porcelain)" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic\ + HEAD:refs/for/main/topic\ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive> ok remote: error: proc-receive reported incomplete status line: "ok" To <URL/of/upstream.git> - ! HEAD:refs/for/master/topic [remote rejected] (proc-receive failed to report status) + ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -127,34 +127,34 @@ test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL/porcelai write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "xx refs/for/master/topic" + -r "xx refs/for/main/topic" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> xx refs/for/master/topic - remote: error: proc-receive reported bad status "xx" on ref "refs/for/master/topic" + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> xx refs/for/main/topic + remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" To <URL/of/upstream.git> - ! HEAD:refs/for/master/topic [remote rejected] (proc-receive failed to report status) + ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0020-report-ng.sh b/t/t5411/test-0020-report-ng.sh index f726b7ca9c..5a9e0daf2d 100644 --- a/t/t5411/test-0020-report-ng.sh +++ b/t/t5411/test-0020-report-ng.sh @@ -2,32 +2,32 @@ test_expect_success "setup proc-receive hook (ng, no message, $PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ng refs/for/master/topic" + -r "ng refs/for/main/topic" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ng refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ng refs/for/main/topic To <URL/of/upstream.git> - ! [remote rejected] HEAD -> refs/for/master/topic (failed) + ! [remote rejected] HEAD -> refs/for/main/topic (failed) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -36,32 +36,32 @@ test_expect_success "setup proc-receive hook (ng message, $PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ng refs/for/master/topic error msg" + -r "ng refs/for/main/topic error msg" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL)" ' test_must_fail git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ng refs/for/master/topic error msg + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ng refs/for/main/topic error msg To <URL/of/upstream.git> - ! [remote rejected] HEAD -> refs/for/master/topic (error msg) + ! [remote rejected] HEAD -> refs/for/main/topic (error msg) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0021-report-ng--porcelain.sh b/t/t5411/test-0021-report-ng--porcelain.sh index fbf5569103..93475a83cf 100644 --- a/t/t5411/test-0021-report-ng--porcelain.sh +++ b/t/t5411/test-0021-report-ng--porcelain.sh @@ -2,33 +2,33 @@ test_expect_success "setup proc-receive hook (ng, no message, $PROTOCOL/porcelai write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ng refs/for/master/topic" + -r "ng refs/for/main/topic" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ng refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ng refs/for/main/topic To <URL/of/upstream.git> - ! HEAD:refs/for/master/topic [remote rejected] (failed) + ! HEAD:refs/for/main/topic [remote rejected] (failed) Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -37,33 +37,33 @@ test_expect_success "setup proc-receive hook (ng message, $PROTOCOL/porcelain)" write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ng refs/for/master/topic error msg" + -r "ng refs/for/main/topic error msg" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ng refs/for/master/topic error msg + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ng refs/for/main/topic error msg To <URL/of/upstream.git> - ! HEAD:refs/for/master/topic [remote rejected] (error msg) + ! HEAD:refs/for/main/topic [remote rejected] (error msg) Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0022-report-unexpect-ref.sh b/t/t5411/test-0022-report-unexpect-ref.sh index 92a415b929..f8be8a0ba1 100644 --- a/t/t5411/test-0022-report-unexpect-ref.sh +++ b/t/t5411/test-0022-report-unexpect-ref.sh @@ -2,44 +2,44 @@ test_expect_success "setup proc-receive hook (unexpected ref, $PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/heads/master" + -r "ok refs/heads/main" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : (B) refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : (B) refs/for/main/topic test_expect_success "proc-receive: report unexpected ref ($PROTOCOL)" ' test_must_fail git -C workbench push origin \ - $B:refs/heads/master \ - HEAD:refs/for/master/topic \ + $B:refs/heads/main \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/heads/master - remote: error: proc-receive reported status on unexpected ref: refs/heads/master + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/heads/main + remote: error: proc-receive reported status on unexpected ref: refs/heads/main remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main To <URL/of/upstream.git> - <OID-A>..<OID-B> <COMMIT-B> -> master - ! [remote rejected] HEAD -> refs/for/master/topic (proc-receive failed to report status) + <OID-A>..<OID-B> <COMMIT-B> -> main + ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main EOF test_cmp expect actual ' -# Refs of upstream : master(B) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(B) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL)" ' - git -C "$upstream" update-ref refs/heads/master $A + git -C "$upstream" update-ref refs/heads/main $A ' diff --git a/t/t5411/test-0023-report-unexpect-ref--porcelain.sh b/t/t5411/test-0023-report-unexpect-ref--porcelain.sh index acbf93e40a..778150fa03 100644 --- a/t/t5411/test-0023-report-unexpect-ref--porcelain.sh +++ b/t/t5411/test-0023-report-unexpect-ref--porcelain.sh @@ -2,45 +2,45 @@ test_expect_success "setup proc-receive hook (unexpected ref, $PROTOCOL/porcelai write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/heads/master" + -r "ok refs/heads/main" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : (B) refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : (B) refs/for/main/topic test_expect_success "proc-receive: report unexpected ref ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ - $B:refs/heads/master \ - HEAD:refs/for/master/topic \ + $B:refs/heads/main \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/heads/master - remote: error: proc-receive reported status on unexpected ref: refs/heads/master + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/heads/main + remote: error: proc-receive reported status on unexpected ref: refs/heads/main remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main To <URL/of/upstream.git> - <COMMIT-B>:refs/heads/master <OID-A>..<OID-B> - ! HEAD:refs/for/master/topic [remote rejected] (proc-receive failed to report status) + <COMMIT-B>:refs/heads/main <OID-A>..<OID-B> + ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main EOF test_cmp expect actual ' -# Refs of upstream : master(B) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(B) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL/porcelain)" ' - git -C "$upstream" update-ref refs/heads/master $A + git -C "$upstream" update-ref refs/heads/main $A ' diff --git a/t/t5411/test-0024-report-unknown-ref.sh b/t/t5411/test-0024-report-unknown-ref.sh index c3946f329a..d4e74e4681 100644 --- a/t/t5411/test-0024-report-unknown-ref.sh +++ b/t/t5411/test-0024-report-unknown-ref.sh @@ -2,12 +2,12 @@ test_expect_success "setup proc-receive hook (unexpected ref, $PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" + -r "ok refs/for/main/topic" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 # git push : refs/for/a/b/c/my/topic test_expect_success "proc-receive: report unknown reference ($PROTOCOL)" ' test_must_fail git -C workbench push origin \ @@ -19,8 +19,8 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL)" ' remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/my/topic remote: # proc-receive hook remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/my/topic - remote: proc-receive> ok refs/for/master/topic - remote: error: proc-receive reported status on unknown ref: refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic + remote: error: proc-receive reported status on unknown ref: refs/for/main/topic To <URL/of/upstream.git> ! [remote rejected] HEAD -> refs/for/a/b/c/my/topic (proc-receive failed to report status) EOF @@ -28,7 +28,7 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL)" ' git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0025-report-unknown-ref--porcelain.sh b/t/t5411/test-0025-report-unknown-ref--porcelain.sh index d093b1a579..039e8b6163 100644 --- a/t/t5411/test-0025-report-unknown-ref--porcelain.sh +++ b/t/t5411/test-0025-report-unknown-ref--porcelain.sh @@ -2,12 +2,12 @@ test_expect_success "setup proc-receive hook (unexpected ref, $PROTOCOL/porcelai write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" + -r "ok refs/for/main/topic" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 # git push : refs/for/a/b/c/my/topic test_expect_success "proc-receive: report unknown reference ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ @@ -19,8 +19,8 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL/porcelain remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/my/topic remote: # proc-receive hook remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/my/topic - remote: proc-receive> ok refs/for/master/topic - remote: error: proc-receive reported status on unknown ref: refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic + remote: error: proc-receive reported status on unknown ref: refs/for/main/topic To <URL/of/upstream.git> ! HEAD:refs/for/a/b/c/my/topic [remote rejected] (proc-receive failed to report status) Done @@ -29,7 +29,7 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL/porcelain git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0026-push-options.sh b/t/t5411/test-0026-push-options.sh index d0c4da8b23..d414be87d0 100644 --- a/t/t5411/test-0026-push-options.sh +++ b/t/t5411/test-0026-push-options.sh @@ -3,19 +3,19 @@ test_expect_success "setup proc-receive hook and disable push-options ($PROTOCOL write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" + -r "ok refs/for/main/topic" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push -o ... : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push -o ... : refs/for/main/topic test_expect_success "proc-receive: not support push options ($PROTOCOL)" ' test_must_fail git -C workbench push \ -o issue=123 \ -o reviewer=user1 \ origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && test_i18ngrep "fatal: the receiving end does not support push options" \ @@ -23,7 +23,7 @@ test_expect_success "proc-receive: not support push options ($PROTOCOL)" ' git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -32,9 +32,9 @@ test_expect_success "enable push options ($PROTOCOL)" ' git -C "$upstream" config receive.advertisePushOptions true ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push -o ... : next(A) refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push -o ... : next(A) refs/for/main/topic test_expect_success "proc-receive: push with options ($PROTOCOL)" ' git -C workbench push \ --atomic \ @@ -42,38 +42,38 @@ test_expect_success "proc-receive: push with options ($PROTOCOL)" ' -o reviewer=user1 \ origin \ HEAD:refs/heads/next \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook remote: proc-receive: atomic push_options - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive< issue=123 remote: proc-receive< reviewer=user1 - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic To <URL/of/upstream.git> * [new branch] HEAD -> next - * [new reference] HEAD -> refs/for/master/topic + * [new reference] HEAD -> refs/for/main/topic EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(A) next(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) next(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL)" ' git -C "$upstream" update-ref -d refs/heads/next ' diff --git a/t/t5411/test-0027-push-options--porcelain.sh b/t/t5411/test-0027-push-options--porcelain.sh index c89a1e7c57..d5d0dcb172 100644 --- a/t/t5411/test-0027-push-options--porcelain.sh +++ b/t/t5411/test-0027-push-options--porcelain.sh @@ -3,20 +3,20 @@ test_expect_success "setup proc-receive hook and disable push-options ($PROTOCOL write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" + -r "ok refs/for/main/topic" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push -o ... : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push -o ... : refs/for/main/topic test_expect_success "proc-receive: not support push options ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push \ --porcelain \ -o issue=123 \ -o reviewer=user1 \ origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && test_i18ngrep "fatal: the receiving end does not support push options" \ @@ -24,7 +24,7 @@ test_expect_success "proc-receive: not support push options ($PROTOCOL/porcelain git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -33,9 +33,9 @@ test_expect_success "enable push options ($PROTOCOL/porcelain)" ' git -C "$upstream" config receive.advertisePushOptions true ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push -o ... : next(A) refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push -o ... : next(A) refs/for/main/topic test_expect_success "proc-receive: push with options ($PROTOCOL/porcelain)" ' git -C workbench push \ --porcelain \ @@ -44,39 +44,39 @@ test_expect_success "proc-receive: push with options ($PROTOCOL/porcelain)" ' -o reviewer=user1 \ origin \ HEAD:refs/heads/next \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook remote: proc-receive: atomic push_options - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive< issue=123 remote: proc-receive< reviewer=user1 - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic To <URL/of/upstream.git> * HEAD:refs/heads/next [new branch] - * HEAD:refs/for/master/topic [new reference] + * HEAD:refs/for/main/topic [new reference] Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/next EOF test_cmp expect actual ' -# Refs of upstream : master(A) next(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) next(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL/porcelain)" ' git -C "$upstream" update-ref -d refs/heads/next ' diff --git a/t/t5411/test-0030-report-ok.sh b/t/t5411/test-0030-report-ok.sh index 44c99d3831..5d6feef118 100644 --- a/t/t5411/test-0030-report-ok.sh +++ b/t/t5411/test-0030-report-ok.sh @@ -2,34 +2,34 @@ test_expect_success "setup proc-receive hook (ok, $PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" + -r "ok refs/for/main/topic" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic test_expect_success "proc-receive: ok ($PROTOCOL)" ' git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: # post-receive hook - remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic To <URL/of/upstream.git> - * [new reference] HEAD -> refs/for/master/topic + * [new reference] HEAD -> refs/for/main/topic EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0031-report-ok--porcelain.sh b/t/t5411/test-0031-report-ok--porcelain.sh index 3223b26184..91666d32df 100644 --- a/t/t5411/test-0031-report-ok--porcelain.sh +++ b/t/t5411/test-0031-report-ok--porcelain.sh @@ -2,35 +2,35 @@ test_expect_success "setup proc-receive hook (ok, $PROTOCOL/porcelain)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" + -r "ok refs/for/main/topic" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic test_expect_success "proc-receive: ok ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: # post-receive hook - remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic To <URL/of/upstream.git> - * HEAD:refs/for/master/topic [new reference] + * HEAD:refs/for/main/topic [new reference] Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0032-report-with-options.sh b/t/t5411/test-0032-report-with-options.sh index b77b78c49f..a0faf5c7ff 100644 --- a/t/t5411/test-0032-report-with-options.sh +++ b/t/t5411/test-0032-report-with-options.sh @@ -7,24 +7,24 @@ test_expect_success "setup proc-receive hook (option without matching ok, $PROTO EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option without matching ok ($PROTOCOL)" ' test_must_fail git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive> option refname refs/pull/123/head remote: proc-receive> option old-oid <COMMIT-B> remote: error: proc-receive reported "option" without a matching "ok/ng" directive To <URL/of/upstream.git> - ! [remote rejected] HEAD -> refs/for/master/topic (proc-receive failed to report status) + ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status) EOF test_cmp expect actual ' @@ -33,25 +33,25 @@ test_expect_success "setup proc-receive hook (option refname, $PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/pull/123/head" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option refname ($PROTOCOL)" ' git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/pull/123/head remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head @@ -65,25 +65,25 @@ test_expect_success "setup proc-receive hook (option refname and forced-update, write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/pull/123/head" \ -r "option forced-update" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option refname and forced-update ($PROTOCOL)" ' git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/pull/123/head remote: proc-receive> option forced-update remote: # post-receive hook @@ -98,26 +98,26 @@ test_expect_success "setup proc-receive hook (option refname and old-oid, $PROTO write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/pull/123/head" \ -r "option old-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL)" ' git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/pull/123/head remote: proc-receive> option old-oid <COMMIT-B> remote: # post-receive hook @@ -132,30 +132,30 @@ test_expect_success "setup proc-receive hook (option old-oid, $PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option old-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option old-oid ($PROTOCOL)" ' git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option old-oid <COMMIT-B> remote: # post-receive hook - remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/master/topic + remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/main/topic To <URL/of/upstream.git> - <OID-B>..<OID-A> HEAD -> refs/for/master/topic + <OID-B>..<OID-A> HEAD -> refs/for/main/topic EOF test_cmp expect actual ' @@ -164,32 +164,32 @@ test_expect_success "setup proc-receive hook (option old-oid and new-oid, $PROTO write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option old-oid $A" \ -r "option new-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL)" ' git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic To <URL/of/upstream.git> - <OID-A>..<OID-B> HEAD -> refs/for/master/topic + <OID-A>..<OID-B> HEAD -> refs/for/main/topic EOF test_cmp expect actual ' @@ -201,7 +201,7 @@ test_expect_success "setup proc-receive hook (report with multiple rewrites, $PR -r "ok refs/for/a/b/c/topic" \ -r "ok refs/for/next/topic" \ -r "option refname refs/pull/123/head" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/pull/124/head" \ -r "option old-oid $B" \ -r "option forced-update" \ @@ -209,29 +209,29 @@ test_expect_success "setup proc-receive hook (report with multiple rewrites, $PR EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL)" ' git -C workbench push origin \ HEAD:refs/for/next/topic \ HEAD:refs/for/a/b/c/topic \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive> ok refs/for/a/b/c/topic remote: proc-receive> ok refs/for/next/topic remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/pull/124/head remote: proc-receive> option old-oid <COMMIT-B> remote: proc-receive> option forced-update @@ -250,7 +250,7 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL)" ' git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0033-report-with-options--porcelain.sh b/t/t5411/test-0033-report-with-options--porcelain.sh index 1fe352b686..32ae26bcfb 100644 --- a/t/t5411/test-0033-report-with-options--porcelain.sh +++ b/t/t5411/test-0033-report-with-options--porcelain.sh @@ -7,24 +7,24 @@ test_expect_success "setup proc-receive hook (option without matching ok, $PROTO EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option without matching ok ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive> option refname refs/pull/123/head remote: proc-receive> option old-oid <COMMIT-B> remote: error: proc-receive reported "option" without a matching "ok/ng" directive To <URL/of/upstream.git> - ! HEAD:refs/for/master/topic [remote rejected] (proc-receive failed to report status) + ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) Done EOF test_cmp expect actual @@ -34,25 +34,25 @@ test_expect_success "setup proc-receive hook (option refname, $PROTOCOL/porcelai write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/pull/123/head" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option refname ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/pull/123/head remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head @@ -67,26 +67,26 @@ test_expect_success "setup proc-receive hook (option refname and forced-update, write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/pull/123/head" \ -r "option forced-update" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option refname and forced-update ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/pull/123/head remote: proc-receive> option forced-update remote: # post-receive hook @@ -102,26 +102,26 @@ test_expect_success "setup proc-receive hook (option refname and old-oid, $PROTO write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/pull/123/head" \ -r "option old-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/pull/123/head remote: proc-receive> option old-oid <COMMIT-B> remote: # post-receive hook @@ -137,30 +137,30 @@ test_expect_success "setup proc-receive hook (option old-oid, $PROTOCOL/porcelai write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option old-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option old-oid ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option old-oid <COMMIT-B> remote: # post-receive hook - remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/master/topic + remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/main/topic To <URL/of/upstream.git> - HEAD:refs/for/master/topic <OID-B>..<OID-A> + HEAD:refs/for/main/topic <OID-B>..<OID-A> Done EOF test_cmp expect actual @@ -170,32 +170,32 @@ test_expect_success "setup proc-receive hook (option old-oid and new-oid, $PROTO write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option old-oid $A" \ -r "option new-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic To <URL/of/upstream.git> - HEAD:refs/for/master/topic <OID-A>..<OID-B> + HEAD:refs/for/main/topic <OID-A>..<OID-B> Done EOF test_cmp expect actual @@ -208,7 +208,7 @@ test_expect_success "setup proc-receive hook (report with multiple rewrites, $PR -r "ok refs/for/a/b/c/topic" \ -r "ok refs/for/next/topic" \ -r "option refname refs/pull/123/head" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/pull/124/head" \ -r "option old-oid $B" \ -r "option forced-update" \ @@ -217,29 +217,29 @@ test_expect_success "setup proc-receive hook (report with multiple rewrites, $PR EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ HEAD:refs/for/next/topic \ HEAD:refs/for/a/b/c/topic \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive> ok refs/for/a/b/c/topic remote: proc-receive> ok refs/for/next/topic remote: proc-receive> option refname refs/pull/123/head - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/pull/124/head remote: proc-receive> option old-oid <COMMIT-B> remote: proc-receive> option forced-update @@ -259,7 +259,7 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL/porc git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0034-report-ft.sh b/t/t5411/test-0034-report-ft.sh index aca2b0676c..c355c290d2 100644 --- a/t/t5411/test-0034-report-ft.sh +++ b/t/t5411/test-0034-report-ft.sh @@ -2,43 +2,43 @@ test_expect_success "setup proc-receive hook (ft, $PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option fall-through" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(B) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(B) test_expect_success "proc-receive: fall throught, let receive-pack to execute ($PROTOCOL)" ' git -C workbench push origin \ - $B:refs/for/master/topic \ + $B:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-B> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-B> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-B> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-B> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option fall-through remote: # post-receive hook - remote: post-receive< <ZERO-OID> <COMMIT-B> refs/for/master/topic + remote: post-receive< <ZERO-OID> <COMMIT-B> refs/for/main/topic To <URL/of/upstream.git> - * [new reference] <COMMIT-B> -> refs/for/master/topic + * [new reference] <COMMIT-B> -> refs/for/main/topic EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-B> refs/for/master/topic - <COMMIT-A> refs/heads/master + <COMMIT-B> refs/for/main/topic + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' -# Refs of upstream : master(A) refs/for/master/topic(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) refs/for/main/topic(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL)" ' - git -C "$upstream" update-ref -d refs/for/master/topic + git -C "$upstream" update-ref -d refs/for/main/topic ' diff --git a/t/t5411/test-0035-report-ft--porcelain.sh b/t/t5411/test-0035-report-ft--porcelain.sh index 30ffffb352..8ce4e58f2a 100644 --- a/t/t5411/test-0035-report-ft--porcelain.sh +++ b/t/t5411/test-0035-report-ft--porcelain.sh @@ -2,44 +2,44 @@ test_expect_success "setup proc-receive hook (fall-through, $PROTOCOL/porcelain) write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option fall-through" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(B) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(B) test_expect_success "proc-receive: fall throught, let receive-pack to execute ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - $B:refs/for/master/topic \ + $B:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-B> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-B> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-B> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-B> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option fall-through remote: # post-receive hook - remote: post-receive< <ZERO-OID> <COMMIT-B> refs/for/master/topic + remote: post-receive< <ZERO-OID> <COMMIT-B> refs/for/main/topic To <URL/of/upstream.git> - * <COMMIT-B>:refs/for/master/topic [new reference] + * <COMMIT-B>:refs/for/main/topic [new reference] Done EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-B> refs/for/master/topic - <COMMIT-A> refs/heads/master + <COMMIT-B> refs/for/main/topic + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' -# Refs of upstream : master(A) refs/for/master/topic(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) refs/for/main/topic(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL/porcelain)" ' - git -C "$upstream" update-ref -d refs/for/master/topic + git -C "$upstream" update-ref -d refs/for/main/topic ' diff --git a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh index 73283d81e8..fad8eea8a0 100644 --- a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh +++ b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh @@ -17,50 +17,50 @@ test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option old-oid $A" \ -r "option new-oid $B" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/24/124/1" \ -r "option old-oid $ZERO_OID" \ -r "option new-oid $A" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/25/125/1" \ -r "option old-oid $A" \ -r "option new-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) test_expect_success "proc-receive: multiple rewrite for one ref, no refname for the 1st rewrite ($PROTOCOL)" ' git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/24/124/1 remote: proc-receive> option old-oid <ZERO-OID> remote: proc-receive> option new-oid <COMMIT-A> - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/25/125/1 remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/25/125/1 To <URL/of/upstream.git> - <OID-A>..<OID-B> HEAD -> refs/for/master/topic + <OID-A>..<OID-B> HEAD -> refs/for/main/topic * [new reference] HEAD -> refs/changes/24/124/1 <OID-A>..<OID-B> HEAD -> refs/changes/25/125/1 EOF @@ -68,7 +68,7 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -80,10 +80,10 @@ test_expect_success "proc-receive: check remote-tracking #1 ($PROTOCOL)" ' cat >expect <<-EOF && <COMMIT-A> refs/t/changes/24/124/1 <COMMIT-B> refs/t/changes/25/125/1 - <COMMIT-B> refs/t/for/master/topic + <COMMIT-B> refs/t/for/main/topic EOF test_cmp expect actual && - git -C workbench update-ref -d refs/t/for/master/topic && + git -C workbench update-ref -d refs/t/for/main/topic && git -C workbench update-ref -d refs/t/changes/24/124/1 && git -C workbench update-ref -d refs/t/changes/25/125/1 ' @@ -92,14 +92,14 @@ test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/24/124/1" \ -r "option old-oid $ZERO_OID" \ -r "option new-oid $A" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option old-oid $A" \ -r "option new-oid $B" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/25/125/1" \ -r "option old-oid $B" \ -r "option new-oid $A" \ @@ -107,45 +107,45 @@ test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) test_expect_success "proc-receive: multiple rewrites for one ref, no refname for the 2nd rewrite ($PROTOCOL)" ' git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/24/124/1 remote: proc-receive> option old-oid <ZERO-OID> remote: proc-receive> option new-oid <COMMIT-A> - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/25/125/1 remote: proc-receive> option old-oid <COMMIT-B> remote: proc-receive> option new-oid <COMMIT-A> remote: proc-receive> option forced-update remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1 - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic remote: post-receive< <COMMIT-B> <COMMIT-A> refs/changes/25/125/1 To <URL/of/upstream.git> * [new reference] HEAD -> refs/changes/24/124/1 - <OID-A>..<OID-B> HEAD -> refs/for/master/topic + <OID-A>..<OID-B> HEAD -> refs/for/main/topic + <OID-B>...<OID-A> HEAD -> refs/changes/25/125/1 (forced update) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -157,10 +157,10 @@ test_expect_success "proc-receive: check remote-tracking #2 ($PROTOCOL)" ' cat >expect <<-EOF && <COMMIT-A> refs/t/changes/24/124/1 <COMMIT-A> refs/t/changes/25/125/1 - <COMMIT-B> refs/t/for/master/topic + <COMMIT-B> refs/t/for/main/topic EOF test_cmp expect actual && - git -C workbench update-ref -d refs/t/for/master/topic && + git -C workbench update-ref -d refs/t/for/main/topic && git -C workbench update-ref -d refs/t/changes/24/124/1 && git -C workbench update-ref -d refs/t/changes/25/125/1 ' @@ -169,31 +169,31 @@ test_expect_success "setup proc-receive hook (multiple rewrites for one ref, $PR write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/23/123/1" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/24/124/2" \ -r "option old-oid $A" \ -r "option new-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL)" ' git -C workbench push origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/23/123/1 - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/24/124/2 remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> @@ -208,7 +208,7 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL)" ' git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh index 77b5b22ed4..dc254d57eb 100644 --- a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh +++ b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh @@ -2,50 +2,50 @@ test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option old-oid $A" \ -r "option new-oid $B" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/24/124/1" \ -r "option old-oid $ZERO_OID" \ -r "option new-oid $A" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/25/125/1" \ -r "option old-oid $A" \ -r "option new-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) test_expect_success "proc-receive: multiple rewrite for one ref, no refname for the 1st rewrite ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/24/124/1 remote: proc-receive> option old-oid <ZERO-OID> remote: proc-receive> option new-oid <COMMIT-A> - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/25/125/1 remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/25/125/1 To <URL/of/upstream.git> - HEAD:refs/for/master/topic <OID-A>..<OID-B> + HEAD:refs/for/main/topic <OID-A>..<OID-B> * HEAD:refs/changes/24/124/1 [new reference] HEAD:refs/changes/25/125/1 <OID-A>..<OID-B> Done @@ -54,7 +54,7 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -63,14 +63,14 @@ test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/24/124/1" \ -r "option old-oid $ZERO_OID" \ -r "option new-oid $A" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option old-oid $A" \ -r "option new-oid $B" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/25/125/1" \ -r "option old-oid $B" \ -r "option new-oid $A" \ @@ -78,38 +78,38 @@ test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) test_expect_success "proc-receive: multiple rewrites for one ref, no refname for the 2nd rewrite ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/24/124/1 remote: proc-receive> option old-oid <ZERO-OID> remote: proc-receive> option new-oid <COMMIT-A> - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/25/125/1 remote: proc-receive> option old-oid <COMMIT-B> remote: proc-receive> option new-oid <COMMIT-A> remote: proc-receive> option forced-update remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1 - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic remote: post-receive< <COMMIT-B> <COMMIT-A> refs/changes/25/125/1 To <URL/of/upstream.git> * HEAD:refs/changes/24/124/1 [new reference] - HEAD:refs/for/master/topic <OID-A>..<OID-B> + HEAD:refs/for/main/topic <OID-A>..<OID-B> + HEAD:refs/changes/25/125/1 <OID-B>...<OID-A> (forced update) Done EOF @@ -117,7 +117,7 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' @@ -126,31 +126,31 @@ test_expect_success "setup proc-receive hook (multiple rewrites for one ref, $PR write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/23/123/1" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/changes/24/124/2" \ -r "option old-oid $A" \ -r "option new-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : refs/for/main/topic(A) test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain origin \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: # proc-receive hook - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/23/123/1 - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/changes/24/124/2 remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> @@ -166,7 +166,7 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL/porc git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' diff --git a/t/t5411/test-0038-report-mixed-refs.sh b/t/t5411/test-0038-report-mixed-refs.sh index a74a2cb449..0d071ebaa6 100644 --- a/t/t5411/test-0038-report-mixed-refs.sh +++ b/t/t5411/test-0038-report-mixed-refs.sh @@ -4,63 +4,63 @@ test_expect_success "setup proc-receive hook ($PROTOCOL)" ' test-tool proc-receive -v \ -r "ok refs/for/next/topic2" \ -r "ng refs/for/next/topic1 fail to call Web API" \ - -r "ok refs/for/master/topic" \ - -r "option refname refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ + -r "option refname refs/for/main/topic" \ -r "option old-oid $A" \ -r "option new-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : (B) bar(A) baz(A) refs/for/next/topic(A) foo(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : (B) bar(A) baz(A) refs/for/next/topic(A) foo(A) refs/for/main/topic(A) test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL)" ' test_must_fail git -C workbench push origin \ - $B:refs/heads/master \ + $B:refs/heads/main \ HEAD:refs/heads/bar \ HEAD:refs/heads/baz \ HEAD:refs/for/next/topic2 \ HEAD:refs/for/next/topic1 \ HEAD:refs/heads/foo \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ HEAD:refs/for/next/topic3 \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/bar remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/baz remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic2 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic1 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic3 remote: # proc-receive hook remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic2 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic1 - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic3 remote: proc-receive> ok refs/for/next/topic2 remote: proc-receive> ng refs/for/next/topic1 fail to call Web API - remote: proc-receive> ok refs/for/master/topic - remote: proc-receive> option refname refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic + remote: proc-receive> option refname refs/for/main/topic remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/bar remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/baz remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic2 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic To <URL/of/upstream.git> - <OID-A>..<OID-B> <COMMIT-B> -> master + <OID-A>..<OID-B> <COMMIT-B> -> main * [new branch] HEAD -> bar * [new branch] HEAD -> baz * [new reference] HEAD -> refs/for/next/topic2 * [new branch] HEAD -> foo - <OID-A>..<OID-B> HEAD -> refs/for/master/topic + <OID-A>..<OID-B> HEAD -> refs/for/main/topic ! [remote rejected] HEAD -> refs/for/next/topic1 (fail to call Web API) ! [remote rejected] HEAD -> refs/for/next/topic3 (proc-receive failed to report status) EOF @@ -71,17 +71,17 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL)" ' <COMMIT-A> refs/heads/bar <COMMIT-A> refs/heads/baz <COMMIT-A> refs/heads/foo - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main EOF test_cmp expect actual ' -# Refs of upstream : master(B) foo(A) bar(A)) baz(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(B) foo(A) bar(A)) baz(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL)" ' ( cd "$upstream" && - git update-ref refs/heads/master $A && + git update-ref refs/heads/main $A && git update-ref -d refs/heads/foo && git update-ref -d refs/heads/bar && git update-ref -d refs/heads/baz diff --git a/t/t5411/test-0039-report-mixed-refs--porcelain.sh b/t/t5411/test-0039-report-mixed-refs--porcelain.sh index e4baa13ea3..d8409912fd 100644 --- a/t/t5411/test-0039-report-mixed-refs--porcelain.sh +++ b/t/t5411/test-0039-report-mixed-refs--porcelain.sh @@ -4,63 +4,63 @@ test_expect_success "setup proc-receive hook ($PROTOCOL/porcelain)" ' test-tool proc-receive -v \ -r "ok refs/for/next/topic2" \ -r "ng refs/for/next/topic1 fail to call Web API" \ - -r "ok refs/for/master/topic" \ - -r "option refname refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ + -r "option refname refs/for/main/topic" \ -r "option old-oid $A" \ -r "option new-oid $B" EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : (B) bar(A) baz(A) refs/for/next/topic(A) foo(A) refs/for/master/topic(A) +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : (B) bar(A) baz(A) refs/for/next/topic(A) foo(A) refs/for/main/topic(A) test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcelain)" ' test_must_fail git -C workbench push --porcelain origin \ - $B:refs/heads/master \ + $B:refs/heads/main \ HEAD:refs/heads/bar \ HEAD:refs/heads/baz \ HEAD:refs/for/next/topic2 \ HEAD:refs/for/next/topic1 \ HEAD:refs/heads/foo \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ HEAD:refs/for/next/topic3 \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/bar remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/baz remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic2 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic1 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic3 remote: # proc-receive hook remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic2 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic1 - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic3 remote: proc-receive> ok refs/for/next/topic2 remote: proc-receive> ng refs/for/next/topic1 fail to call Web API - remote: proc-receive> ok refs/for/master/topic - remote: proc-receive> option refname refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic + remote: proc-receive> option refname refs/for/main/topic remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> remote: # post-receive hook - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/bar remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/baz remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic2 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo - remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic + remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic To <URL/of/upstream.git> - <COMMIT-B>:refs/heads/master <OID-A>..<OID-B> + <COMMIT-B>:refs/heads/main <OID-A>..<OID-B> * HEAD:refs/heads/bar [new branch] * HEAD:refs/heads/baz [new branch] * HEAD:refs/for/next/topic2 [new reference] * HEAD:refs/heads/foo [new branch] - HEAD:refs/for/master/topic <OID-A>..<OID-B> + HEAD:refs/for/main/topic <OID-A>..<OID-B> ! HEAD:refs/for/next/topic1 [remote rejected] (fail to call Web API) ! HEAD:refs/for/next/topic3 [remote rejected] (proc-receive failed to report status) Done @@ -72,17 +72,17 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcel <COMMIT-A> refs/heads/bar <COMMIT-A> refs/heads/baz <COMMIT-A> refs/heads/foo - <COMMIT-B> refs/heads/master + <COMMIT-B> refs/heads/main EOF test_cmp expect actual ' -# Refs of upstream : master(B) foo(A) bar(A)) baz(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(B) foo(A) bar(A)) baz(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL/porcelain)" ' ( cd "$upstream" && - git update-ref refs/heads/master $A && + git update-ref refs/heads/main $A && git update-ref -d refs/heads/foo && git update-ref -d refs/heads/bar && git update-ref -d refs/heads/baz diff --git a/t/t5411/test-0040-process-all-refs.sh b/t/t5411/test-0040-process-all-refs.sh index b07c999f53..2565302a17 100644 --- a/t/t5411/test-0040-process-all-refs.sh +++ b/t/t5411/test-0040-process-all-refs.sh @@ -3,12 +3,12 @@ test_expect_success "config receive.procReceiveRefs = refs ($PROTOCOL)" ' git -C "$upstream" config --add receive.procReceiveRefs refs ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "setup upstream branches ($PROTOCOL)" ' ( cd "$upstream" && - git update-ref refs/heads/master $B && + git update-ref refs/heads/main $B && git update-ref refs/heads/foo $A && git update-ref refs/heads/bar $A && git update-ref refs/heads/baz $A @@ -20,13 +20,13 @@ test_expect_success "setup proc-receive hook ($PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/heads/master" \ + -r "ok refs/heads/main" \ -r "option fall-through" \ -r "ok refs/heads/foo" \ -r "option fall-through" \ -r "ok refs/heads/bar" \ -r "option fall-through" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/pull/123/head" \ -r "option old-oid $A" \ -r "option new-oid $B" \ @@ -38,15 +38,15 @@ test_expect_success "setup proc-receive hook ($PROTOCOL)" ' EOF ' -# Refs of upstream : master(B) foo(A) bar(A)) baz(A) -# Refs of workbench: master(A) tags/v123 -# git push -f : master(A) (NULL) (B) refs/for/master/topic(A) refs/for/next/topic(A) +# Refs of upstream : main(B) foo(A) bar(A)) baz(A) +# Refs of workbench: main(A) tags/v123 +# git push -f : main(A) (NULL) (B) refs/for/main/topic(A) refs/for/next/topic(A) test_expect_success "proc-receive: process all refs ($PROTOCOL)" ' git -C workbench push -f origin \ - HEAD:refs/heads/master \ + HEAD:refs/heads/main \ :refs/heads/foo \ $B:refs/heads/bar \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ HEAD:refs/for/next/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && @@ -54,22 +54,22 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL)" ' remote: # pre-receive hook remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/bar remote: pre-receive< <COMMIT-A> <ZERO-OID> refs/heads/foo - remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/master - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/main + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic remote: # proc-receive hook remote: proc-receive< <COMMIT-A> <COMMIT-B> refs/heads/bar remote: proc-receive< <COMMIT-A> <ZERO-OID> refs/heads/foo - remote: proc-receive< <COMMIT-B> <COMMIT-A> refs/heads/master - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <COMMIT-B> <COMMIT-A> refs/heads/main + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic - remote: proc-receive> ok refs/heads/master + remote: proc-receive> ok refs/heads/main remote: proc-receive> option fall-through remote: proc-receive> ok refs/heads/foo remote: proc-receive> option fall-through remote: proc-receive> ok refs/heads/bar remote: proc-receive> option fall-through - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/pull/123/head remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> @@ -81,13 +81,13 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL)" ' remote: # post-receive hook remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/bar remote: post-receive< <COMMIT-A> <ZERO-OID> refs/heads/foo - remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/master + remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/main remote: post-receive< <COMMIT-A> <COMMIT-B> refs/pull/123/head remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/124/head To <URL/of/upstream.git> <OID-A>..<OID-B> <COMMIT-B> -> bar - [deleted] foo - + <OID-B>...<OID-A> HEAD -> master (forced update) + + <OID-B>...<OID-A> HEAD -> main (forced update) <OID-A>..<OID-B> HEAD -> refs/pull/123/head + <OID-B>...<OID-A> HEAD -> refs/pull/124/head (forced update) EOF @@ -97,13 +97,13 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL)" ' cat >expect <<-EOF && <COMMIT-B> refs/heads/bar <COMMIT-A> refs/heads/baz - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' -# Refs of upstream : master(A) bar(A) baz(B) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) bar(A) baz(B) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL)" ' ( cd "$upstream" && diff --git a/t/t5411/test-0041-process-all-refs--porcelain.sh b/t/t5411/test-0041-process-all-refs--porcelain.sh index 0dd9824616..e21420b60d 100644 --- a/t/t5411/test-0041-process-all-refs--porcelain.sh +++ b/t/t5411/test-0041-process-all-refs--porcelain.sh @@ -3,12 +3,12 @@ test_expect_success "config receive.procReceiveRefs = refs ($PROTOCOL/porcelain) git -C "$upstream" config --add receive.procReceiveRefs refs ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "setup upstream branches ($PROTOCOL/porcelain)" ' ( cd "$upstream" && - git update-ref refs/heads/master $B && + git update-ref refs/heads/main $B && git update-ref refs/heads/foo $A && git update-ref refs/heads/bar $A && git update-ref refs/heads/baz $A @@ -20,13 +20,13 @@ test_expect_success "setup proc-receive hook ($PROTOCOL/porcelain)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/heads/master" \ + -r "ok refs/heads/main" \ -r "option fall-through" \ -r "ok refs/heads/foo" \ -r "option fall-through" \ -r "ok refs/heads/bar" \ -r "option fall-through" \ - -r "ok refs/for/master/topic" \ + -r "ok refs/for/main/topic" \ -r "option refname refs/pull/123/head" \ -r "option old-oid $A" \ -r "option new-oid $B" \ @@ -38,15 +38,15 @@ test_expect_success "setup proc-receive hook ($PROTOCOL/porcelain)" ' EOF ' -# Refs of upstream : master(B) foo(A) bar(A)) baz(A) -# Refs of workbench: master(A) tags/v123 -# git push -f : master(A) (NULL) (B) refs/for/master/topic(A) refs/for/next/topic(A) +# Refs of upstream : main(B) foo(A) bar(A)) baz(A) +# Refs of workbench: main(A) tags/v123 +# git push -f : main(A) (NULL) (B) refs/for/main/topic(A) refs/for/next/topic(A) test_expect_success "proc-receive: process all refs ($PROTOCOL/porcelain)" ' git -C workbench push --porcelain -f origin \ - HEAD:refs/heads/master \ + HEAD:refs/heads/main \ :refs/heads/foo \ $B:refs/heads/bar \ - HEAD:refs/for/master/topic \ + HEAD:refs/for/main/topic \ HEAD:refs/for/next/topic \ >out 2>&1 && make_user_friendly_and_stable_output <out >actual && @@ -54,22 +54,22 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL/porcelain)" ' remote: # pre-receive hook remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/bar remote: pre-receive< <COMMIT-A> <ZERO-OID> refs/heads/foo - remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/master - remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/main + remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic remote: # proc-receive hook remote: proc-receive< <COMMIT-A> <COMMIT-B> refs/heads/bar remote: proc-receive< <COMMIT-A> <ZERO-OID> refs/heads/foo - remote: proc-receive< <COMMIT-B> <COMMIT-A> refs/heads/master - remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic + remote: proc-receive< <COMMIT-B> <COMMIT-A> refs/heads/main + remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic - remote: proc-receive> ok refs/heads/master + remote: proc-receive> ok refs/heads/main remote: proc-receive> option fall-through remote: proc-receive> ok refs/heads/foo remote: proc-receive> option fall-through remote: proc-receive> ok refs/heads/bar remote: proc-receive> option fall-through - remote: proc-receive> ok refs/for/master/topic + remote: proc-receive> ok refs/for/main/topic remote: proc-receive> option refname refs/pull/123/head remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> @@ -81,13 +81,13 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL/porcelain)" ' remote: # post-receive hook remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/bar remote: post-receive< <COMMIT-A> <ZERO-OID> refs/heads/foo - remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/master + remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/main remote: post-receive< <COMMIT-A> <COMMIT-B> refs/pull/123/head remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/124/head To <URL/of/upstream.git> <COMMIT-B>:refs/heads/bar <OID-A>..<OID-B> - :refs/heads/foo [deleted] - + HEAD:refs/heads/master <OID-B>...<OID-A> (forced update) + + HEAD:refs/heads/main <OID-B>...<OID-A> (forced update) HEAD:refs/pull/123/head <OID-A>..<OID-B> + HEAD:refs/pull/124/head <OID-B>...<OID-A> (forced update) Done @@ -98,13 +98,13 @@ test_expect_success "proc-receive: process all refs ($PROTOCOL/porcelain)" ' cat >expect <<-EOF && <COMMIT-B> refs/heads/bar <COMMIT-A> refs/heads/baz - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' -# Refs of upstream : master(A) bar(A) baz(B) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) bar(A) baz(B) +# Refs of workbench: main(A) tags/v123 test_expect_success "cleanup ($PROTOCOL/porcelain)" ' ( cd "$upstream" && diff --git a/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh b/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh index c22849cbe2..2e29518ec5 100644 --- a/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh +++ b/t/t5411/test-0050-proc-receive-refs-with-modifiers.sh @@ -2,7 +2,7 @@ test_expect_success "config receive.procReceiveRefs with modifiers ($PROTOCOL)" ( cd "$upstream" && git config --unset-all receive.procReceiveRefs && - git config --add receive.procReceiveRefs m:refs/heads/master && + git config --add receive.procReceiveRefs m:refs/heads/main && git config --add receive.procReceiveRefs ad:refs/heads && git config --add receive.procReceiveRefs "a!:refs/heads" ) @@ -12,7 +12,7 @@ test_expect_success "setup proc-receive hook ($PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/heads/master" \ + -r "ok refs/heads/main" \ -r "option refname refs/pull/123/head" \ -r "option old-oid $A" \ -r "option new-oid $B" \ @@ -21,22 +21,22 @@ test_expect_success "setup proc-receive hook ($PROTOCOL)" ' EOF ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 -# git push : master(B) tags/v123 +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 +# git push : main(B) tags/v123 test_expect_success "proc-receive: update branch and new tag ($PROTOCOL)" ' git -C workbench push origin \ - $B:refs/heads/master \ + $B:refs/heads/main \ v123 >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 remote: # proc-receive hook - remote: proc-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + remote: proc-receive< <COMMIT-A> <COMMIT-B> refs/heads/main remote: proc-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 - remote: proc-receive> ok refs/heads/master + remote: proc-receive> ok refs/heads/main remote: proc-receive> option refname refs/pull/123/head remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <COMMIT-B> @@ -53,20 +53,20 @@ test_expect_success "proc-receive: update branch and new tag ($PROTOCOL)" ' git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main EOF test_cmp expect actual ' -# Refs of upstream : master(A) -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) +# Refs of workbench: main(A) tags/v123 test_expect_success "setup upstream: create tags/v123 ($PROTOCOL)" ' git -C "$upstream" update-ref refs/heads/topic $A && git -C "$upstream" update-ref refs/tags/v123 $TAG && git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-A> refs/heads/topic <TAG-v123> refs/tags/v123 EOF @@ -77,7 +77,7 @@ test_expect_success "setup proc-receive hook ($PROTOCOL)" ' write_script "$upstream/hooks/proc-receive" <<-EOF printf >&2 "# proc-receive hook\n" test-tool proc-receive -v \ - -r "ok refs/heads/master" \ + -r "ok refs/heads/main" \ -r "option refname refs/pull/123/head" \ -r "option old-oid $A" \ -r "option new-oid $ZERO_OID" \ @@ -87,26 +87,26 @@ test_expect_success "setup proc-receive hook ($PROTOCOL)" ' EOF ' -# Refs of upstream : master(A) topic(A) tags/v123 -# Refs of workbench: master(A) tags/v123 +# Refs of upstream : main(A) topic(A) tags/v123 +# Refs of workbench: main(A) tags/v123 # git push : NULL topic(B) NULL next(A) test_expect_success "proc-receive: create/delete branch, and delete tag ($PROTOCOL)" ' git -C workbench push origin \ - :refs/heads/master \ + :refs/heads/main \ $B:refs/heads/topic \ $A:refs/heads/next \ :refs/tags/v123 >out 2>&1 && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && remote: # pre-receive hook - remote: pre-receive< <COMMIT-A> <ZERO-OID> refs/heads/master + remote: pre-receive< <COMMIT-A> <ZERO-OID> refs/heads/main remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/topic remote: pre-receive< <TAG-v123> <ZERO-OID> refs/tags/v123 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next remote: # proc-receive hook - remote: proc-receive< <COMMIT-A> <ZERO-OID> refs/heads/master + remote: proc-receive< <COMMIT-A> <ZERO-OID> refs/heads/main remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/heads/next - remote: proc-receive> ok refs/heads/master + remote: proc-receive> ok refs/heads/main remote: proc-receive> option refname refs/pull/123/head remote: proc-receive> option old-oid <COMMIT-A> remote: proc-receive> option new-oid <ZERO-OID> @@ -128,7 +128,7 @@ test_expect_success "proc-receive: create/delete branch, and delete tag ($PROTOC git -C "$upstream" show-ref >out && make_user_friendly_and_stable_output <out >actual && cat >expect <<-EOF && - <COMMIT-A> refs/heads/master + <COMMIT-A> refs/heads/main <COMMIT-B> refs/heads/topic EOF test_cmp expect actual diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 1156f52069..eaa6e90220 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -145,8 +145,8 @@ test_expect_success 'remove remote protects local branches' ' test_expect_success 'remove errors out early when deleting non-existent branch' ' ( cd test && - echo "fatal: No such remote: '\''foo'\''" >expect && - test_must_fail git remote rm foo 2>actual && + echo "error: No such remote: '\''foo'\''" >expect && + test_expect_code 2 git remote rm foo 2>actual && test_i18ncmp expect actual ) ' @@ -173,8 +173,8 @@ test_expect_success 'remove remote with a branch without configured merge' ' test_expect_success 'rename errors out early when deleting non-existent branch' ' ( cd test && - echo "fatal: No such remote: '\''foo'\''" >expect && - test_must_fail git remote rename foo bar 2>actual && + echo "error: No such remote: '\''foo'\''" >expect && + test_expect_code 2 git remote rename foo bar 2>actual && test_i18ncmp expect actual ) ' @@ -188,16 +188,16 @@ test_expect_success 'rename errors out early when when new name is invalid' ' test_expect_success 'add existing foreign_vcs remote' ' test_config remote.foo.vcs bar && - echo "fatal: remote foo already exists." >expect && - test_must_fail git remote add foo bar 2>actual && + echo "error: remote foo already exists." >expect && + test_expect_code 3 git remote add foo bar 2>actual && test_i18ncmp expect actual ' test_expect_success 'add existing foreign_vcs remote' ' test_config remote.foo.vcs bar && test_config remote.bar.vcs bar && - echo "fatal: remote bar already exists." >expect && - test_must_fail git remote rename foo bar 2>actual && + echo "error: remote bar already exists." >expect && + test_expect_code 3 git remote rename foo bar 2>actual && test_i18ncmp expect actual ' @@ -213,28 +213,28 @@ cat >test/expect <<EOF Push URL: $(pwd)/one HEAD branch: master Remote branches: - master new (next fetch will store in remotes/origin) - side tracked + main new (next fetch will store in remotes/origin) + side tracked Local branches configured for 'git pull': - ahead merges with remote master - master merges with remote master + ahead merges with remote main + main merges with remote main octopus merges with remote topic-a and with remote topic-b and with remote topic-c rebase rebases onto remote master Local refs configured for 'git push': - master pushes to master (local out of date) - master pushes to upstream (create) + main pushes to main (local out of date) + main pushes to upstream (create) * remote two Fetch URL: ../two Push URL: ../three HEAD branch: master Local refs configured for 'git push': - ahead forces to master (fast-forwardable) - master pushes to another (up to date) + ahead forces to main (fast-forwardable) + main pushes to another (up to date) EOF -test_expect_success 'show' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'show' ' ( cd test && git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream && @@ -277,15 +277,15 @@ cat >test/expect <<EOF master side Local branches configured for 'git pull': - ahead merges with remote master - master merges with remote master + ahead merges with remote main + main merges with remote main Local refs configured for 'git push' (status not queried): (matching) pushes to (matching) - refs/heads/master pushes to refs/heads/upstream + refs/heads/main pushes to refs/heads/upstream refs/tags/lastbackup forces to refs/tags/lastbackup EOF -test_expect_success 'show -n' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'show -n' ' mv one one.unreachable && ( cd test && @@ -328,7 +328,7 @@ test_expect_success 'set-head --auto' ' ) ' -test_expect_success 'set-head --auto has no problem w/multiple HEADs' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'set-head --auto has no problem w/multiple HEADs' ' ( cd test && git fetch two "refs/heads/*:refs/remotes/two/*" && @@ -1348,7 +1348,7 @@ test_expect_success 'unqualified <dst> refspec DWIM and advice' ' ) ' -test_expect_success 'refs/remotes/* <src> refspec and unqualified <dst> DWIM and advice' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'refs/remotes/* <src> refspec and unqualified <dst> DWIM and advice' ' ( cd two && git tag -a -m "Some tag" my-tag master && diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index dbc724e4c0..5d673358f9 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -942,7 +942,7 @@ test_expect_success 'fetching with auto-gc does not lock up' ' ) ' -test_expect_success C_LOCALE_OUTPUT 'fetch aligned output' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH,C_LOCALE_OUTPUT 'fetch aligned output' ' git clone . full-output && test_commit looooooooooooong-tag && ( @@ -951,13 +951,13 @@ test_expect_success C_LOCALE_OUTPUT 'fetch aligned output' ' grep -e "->" actual | cut -c 22- >../actual ) && cat >expect <<-\EOF && - master -> origin/master + main -> origin/main looooooooooooong-tag -> looooooooooooong-tag EOF test_cmp expect actual ' -test_expect_success C_LOCALE_OUTPUT 'fetch compact output' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH,C_LOCALE_OUTPUT 'fetch compact output' ' git clone . compact && test_commit extraaa && ( @@ -966,7 +966,7 @@ test_expect_success C_LOCALE_OUTPUT 'fetch compact output' ' grep -e "->" actual | cut -c 22- >../actual ) && cat >expect <<-\EOF && - master -> origin/* + main -> origin/* extraaa -> * EOF test_cmp expect actual diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 63205dfdf9..dd8e423d25 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -18,7 +18,7 @@ add_upstream_commit() { head2=$(git rev-parse --short HEAD) && echo "Fetching submodule submodule" > ../expect.err && echo "From $pwd/submodule" >> ../expect.err && - echo " $head1..$head2 master -> origin/master" >> ../expect.err + echo " $head1..$head2 main -> origin/main" >> ../expect.err ) && ( cd deepsubmodule && @@ -30,7 +30,7 @@ add_upstream_commit() { head2=$(git rev-parse --short HEAD) && echo "Fetching submodule submodule/subdir/deepsubmodule" >> ../expect.err echo "From $pwd/deepsubmodule" >> ../expect.err && - echo " $head1..$head2 master -> origin/master" >> ../expect.err + echo " $head1..$head2 main -> origin/main" >> ../expect.err ) } @@ -61,7 +61,7 @@ test_expect_success setup ' ) ' -test_expect_success "fetch --recurse-submodules recurses into submodules" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "fetch --recurse-submodules recurses into submodules" ' add_upstream_commit && ( cd downstream && @@ -71,7 +71,7 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" ' test_i18ncmp expect.err actual.err ' -test_expect_success "submodule.recurse option triggers recursive fetch" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "submodule.recurse option triggers recursive fetch" ' add_upstream_commit && ( cd downstream && @@ -81,7 +81,7 @@ test_expect_success "submodule.recurse option triggers recursive fetch" ' test_i18ncmp expect.err actual.err ' -test_expect_success "fetch --recurse-submodules -j2 has the same output behaviour" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "fetch --recurse-submodules -j2 has the same output behaviour" ' add_upstream_commit && ( cd downstream && @@ -111,7 +111,7 @@ test_expect_success "fetch --no-recurse-submodules only fetches superproject" ' test_must_be_empty actual.err ' -test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" ' ( cd downstream && git config -f .gitmodules submodule.submodule.fetchRecurseSubmodules true && @@ -141,7 +141,7 @@ test_expect_success "using fetchRecurseSubmodules=false in .git/config overrides test_must_be_empty actual.err ' -test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config" ' ( cd downstream && git fetch --recurse-submodules >../actual.out 2>../actual.err && @@ -170,7 +170,7 @@ test_expect_success "--quiet propagates to parallel submodules" ' test_must_be_empty actual.err ' -test_expect_success "--dry-run propagates to submodules" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "--dry-run propagates to submodules" ' add_upstream_commit && ( cd downstream && @@ -180,7 +180,7 @@ test_expect_success "--dry-run propagates to submodules" ' test_i18ncmp expect.err actual.err ' -test_expect_success "Without --dry-run propagates to submodules" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "Without --dry-run propagates to submodules" ' ( cd downstream && git fetch --recurse-submodules >../actual.out 2>../actual.err @@ -189,7 +189,7 @@ test_expect_success "Without --dry-run propagates to submodules" ' test_i18ncmp expect.err actual.err ' -test_expect_success "recurseSubmodules=true propagates into submodules" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "recurseSubmodules=true propagates into submodules" ' add_upstream_commit && ( cd downstream && @@ -200,7 +200,7 @@ test_expect_success "recurseSubmodules=true propagates into submodules" ' test_i18ncmp expect.err actual.err ' -test_expect_success "--recurse-submodules overrides config in submodule" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "--recurse-submodules overrides config in submodule" ' add_upstream_commit && ( cd downstream && @@ -225,7 +225,7 @@ test_expect_success "--no-recurse-submodules overrides config setting" ' test_must_be_empty actual.err ' -test_expect_success "Recursion doesn't happen when no new commits are fetched in the superproject" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion doesn't happen when no new commits are fetched in the superproject" ' ( cd downstream && ( @@ -239,13 +239,13 @@ test_expect_success "Recursion doesn't happen when no new commits are fetched in test_must_be_empty actual.err ' -test_expect_success "Recursion stops when no new submodule commits are fetched" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion stops when no new submodule commits are fetched" ' head1=$(git rev-parse --short HEAD) && git add submodule && git commit -m "new submodule" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." > expect.err.sub && - echo " $head1..$head2 master -> origin/master" >>expect.err.sub && + echo " $head1..$head2 main -> origin/main" >>expect.err.sub && head -3 expect.err >> expect.err.sub && ( cd downstream && @@ -255,7 +255,7 @@ test_expect_success "Recursion stops when no new submodule commits are fetched" test_must_be_empty actual.out ' -test_expect_success "Recursion doesn't happen when new superproject commits don't change any submodules" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion doesn't happen when new superproject commits don't change any submodules" ' add_upstream_commit && head1=$(git rev-parse --short HEAD) && echo a > file && @@ -263,7 +263,7 @@ test_expect_success "Recursion doesn't happen when new superproject commits don' git commit -m "new file" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." > expect.err.file && - echo " $head1..$head2 master -> origin/master" >> expect.err.file && + echo " $head1..$head2 main -> origin/main" >> expect.err.file && ( cd downstream && git fetch >../actual.out 2>../actual.err @@ -272,7 +272,7 @@ test_expect_success "Recursion doesn't happen when new superproject commits don' test_i18ncmp expect.err.file actual.err ' -test_expect_success "Recursion picks up config in submodule" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion picks up config in submodule" ' ( cd downstream && git fetch --recurse-submodules && @@ -287,7 +287,7 @@ test_expect_success "Recursion picks up config in submodule" ' git commit -m "new submodule" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." > expect.err.sub && - echo " $head1..$head2 master -> origin/master" >> expect.err.sub && + echo " $head1..$head2 main -> origin/main" >> expect.err.sub && cat expect.err >> expect.err.sub && ( cd downstream && @@ -301,7 +301,7 @@ test_expect_success "Recursion picks up config in submodule" ' test_must_be_empty actual.out ' -test_expect_success "Recursion picks up all submodules when necessary" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "Recursion picks up all submodules when necessary" ' add_upstream_commit && ( cd submodule && @@ -316,14 +316,14 @@ test_expect_success "Recursion picks up all submodules when necessary" ' head2=$(git rev-parse --short HEAD) && echo "Fetching submodule submodule" > ../expect.err.sub && echo "From $pwd/submodule" >> ../expect.err.sub && - echo " $head1..$head2 master -> origin/master" >> ../expect.err.sub + echo " $head1..$head2 main -> origin/main" >> ../expect.err.sub ) && head1=$(git rev-parse --short HEAD) && git add submodule && git commit -m "new submodule" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." > expect.err.2 && - echo " $head1..$head2 master -> origin/master" >> expect.err.2 && + echo " $head1..$head2 main -> origin/main" >> expect.err.2 && cat expect.err.sub >> expect.err.2 && tail -3 expect.err >> expect.err.2 && ( @@ -334,7 +334,7 @@ test_expect_success "Recursion picks up all submodules when necessary" ' test_must_be_empty actual.out ' -test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no new commits are fetched in the superproject (and ignores config)" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "'--recurse-submodules=on-demand' doesn't recurse when no new commits are fetched in the superproject (and ignores config)" ' add_upstream_commit && ( cd submodule && @@ -349,7 +349,7 @@ test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no ne head2=$(git rev-parse --short HEAD) && echo Fetching submodule submodule > ../expect.err.sub && echo "From $pwd/submodule" >> ../expect.err.sub && - echo " $head1..$head2 master -> origin/master" >> ../expect.err.sub + echo " $head1..$head2 main -> origin/main" >> ../expect.err.sub ) && ( cd downstream && @@ -361,14 +361,14 @@ test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no ne test_must_be_empty actual.err ' -test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necessary (and ignores config)" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "'--recurse-submodules=on-demand' recurses as deep as necessary (and ignores config)" ' head1=$(git rev-parse --short HEAD) && git add submodule && git commit -m "new submodule" && head2=$(git rev-parse --short HEAD) && tail -3 expect.err > expect.err.deepsub && echo "From $pwd/." > expect.err && - echo " $head1..$head2 master -> origin/master" >>expect.err && + echo " $head1..$head2 main -> origin/main" >>expect.err && cat expect.err.sub >> expect.err && cat expect.err.deepsub >> expect.err && ( @@ -389,7 +389,7 @@ test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necess test_i18ncmp expect.err actual.err ' -test_expect_success "'--recurse-submodules=on-demand' stops when no new submodule commits are found in the superproject (and ignores config)" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "'--recurse-submodules=on-demand' stops when no new submodule commits are found in the superproject (and ignores config)" ' add_upstream_commit && head1=$(git rev-parse --short HEAD) && echo a >> file && @@ -397,7 +397,7 @@ test_expect_success "'--recurse-submodules=on-demand' stops when no new submodul git commit -m "new file" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." > expect.err.file && - echo " $head1..$head2 master -> origin/master" >> expect.err.file && + echo " $head1..$head2 main -> origin/main" >> expect.err.file && ( cd downstream && git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err @@ -406,7 +406,7 @@ test_expect_success "'--recurse-submodules=on-demand' stops when no new submodul test_i18ncmp expect.err.file actual.err ' -test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "'fetch.recurseSubmodules=on-demand' overrides global config" ' ( cd downstream && git fetch --recurse-submodules @@ -418,7 +418,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config git commit -m "new submodule" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." > expect.err.2 && - echo " $head1..$head2 master -> origin/master" >>expect.err.2 && + echo " $head1..$head2 main -> origin/main" >>expect.err.2 && head -3 expect.err >> expect.err.2 && ( cd downstream && @@ -434,7 +434,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config test_i18ncmp expect.err.2 actual.err ' -test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' overrides fetch.recurseSubmodules" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "'submodule.<sub>.fetchRecurseSubmodules=on-demand' overrides fetch.recurseSubmodules" ' ( cd downstream && git fetch --recurse-submodules @@ -446,7 +446,7 @@ test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' override git commit -m "new submodule" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." > expect.err.2 && - echo " $head1..$head2 master -> origin/master" >>expect.err.2 && + echo " $head1..$head2 main -> origin/main" >>expect.err.2 && head -3 expect.err >> expect.err.2 && ( cd downstream && @@ -462,7 +462,7 @@ test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' override test_i18ncmp expect.err.2 actual.err ' -test_expect_success "don't fetch submodule when newly recorded commits are already present" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "don't fetch submodule when newly recorded commits are already present" ' ( cd submodule && git checkout -q HEAD^^ @@ -472,7 +472,7 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea git commit -m "submodule rewound" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." > expect.err && - echo " $head1..$head2 master -> origin/master" >> expect.err && + echo " $head1..$head2 main -> origin/main" >> expect.err && ( cd downstream && git fetch >../actual.out 2>../actual.err @@ -485,7 +485,7 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea ) ' -test_expect_success "'fetch.recurseSubmodules=on-demand' works also without .gitmodules entry" ' +test_expect_success PREPARE_FOR_MAIN_BRANCH "'fetch.recurseSubmodules=on-demand' works also without .gitmodules entry" ' ( cd downstream && git fetch --recurse-submodules @@ -497,7 +497,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' works also without .git git commit -m "new submodule without .gitmodules" && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." >expect.err.2 && - echo " $head1..$head2 master -> origin/master" >>expect.err.2 && + echo " $head1..$head2 main -> origin/main" >>expect.err.2 && head -3 expect.err >>expect.err.2 && ( cd downstream && diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh index 34487bbb8c..8f69a7854f 100755 --- a/t/t5570-git-daemon.sh +++ b/t/t5570-git-daemon.sh @@ -147,18 +147,18 @@ test_remote_error() } msg="access denied or repository not exported" -test_expect_success 'clone non-existent' "test_remote_error '$msg' clone nowhere.git " +test_expect_success 'clone non-existent' "test_remote_error '$msg' clone nowhere.git" test_expect_success 'push disabled' "test_remote_error '$msg' push repo.git master" -test_expect_success 'read access denied' "test_remote_error -x '$msg' fetch repo.git " -test_expect_success 'not exported' "test_remote_error -n '$msg' fetch repo.git " +test_expect_success 'read access denied' "test_remote_error -x '$msg' fetch repo.git" +test_expect_success 'not exported' "test_remote_error -n '$msg' fetch repo.git" stop_git_daemon start_git_daemon --informative-errors -test_expect_success 'clone non-existent' "test_remote_error 'no such repository' clone nowhere.git " +test_expect_success 'clone non-existent' "test_remote_error 'no such repository' clone nowhere.git" test_expect_success 'push disabled' "test_remote_error 'service not enabled' push repo.git master" -test_expect_success 'read access denied' "test_remote_error -x 'no such repository' fetch repo.git " -test_expect_success 'not exported' "test_remote_error -n 'repository not exported' fetch repo.git " +test_expect_success 'read access denied' "test_remote_error -x 'no such repository' fetch repo.git" +test_expect_success 'not exported' "test_remote_error -n 'repository not exported' fetch repo.git" stop_git_daemon start_git_daemon --interpolated-path="$GIT_DAEMON_DOCUMENT_ROOT_PATH/%H%D" diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh index 5e201e7d85..7f082fb23b 100755 --- a/t/t5606-clone-options.sh +++ b/t/t5606-clone-options.sh @@ -103,6 +103,7 @@ test_expect_success 'redirected clone -v does show progress' ' test_expect_success 'chooses correct default initial branch name' ' git init --bare empty && + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ git -c init.defaultBranch=up clone empty whats-up && test refs/heads/up = $(git -C whats-up symbolic-ref HEAD) && test refs/heads/up = $(git -C whats-up config branch.up.merge) @@ -117,9 +118,11 @@ test_expect_success 'guesses initial branch name correctly' ' git -c init.defaultBranch=none init --bare no-head && git -C initial-branch push ../no-head guess abc && + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ git clone no-head is-it2 && test_must_fail git -C is-it2 symbolic-ref refs/remotes/origin/HEAD && git -C no-head update-ref --no-deref HEAD refs/heads/guess && + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ git -c init.defaultBranch=guess clone no-head is-it3 && test refs/remotes/origin/guess = \ $(git -C is-it3 symbolic-ref refs/remotes/origin/HEAD) diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh index d9ecf0f4a9..b46940b725 100755 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@ -383,14 +383,14 @@ test_expect_success 'server is initially behind - ref in want' ' test_cmp expected actual ' -test_expect_success 'server loses a ref - ref in want' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH '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" && + echo "s/main/rain/" >"$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 + test_i18ngrep "fatal: remote error: unknown ref refs/heads/rain" err ' # DO NOT add non-httpd-specific tests here, because the last part of this diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index bc95da8a5f..99a1eaf332 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -339,7 +339,7 @@ commit $head1 .. (hinzugef${added_utf8_part_iso88591}gt) foo EOF -test_expect_success 'prepare expected messages (for test %b)' ' +test_expect_success 'setup expected messages (for test %b)' ' cat <<-EOF >expected.utf-8 && commit $head3 This commit message is much longer than the others, diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh index 7fc10f8593..fd202fcb94 100755 --- a/t/t6012-rev-list-simplify.sh +++ b/t/t6012-rev-list-simplify.sh @@ -168,7 +168,7 @@ test_expect_success '--full-diff is not affected by --parents' ' # # This example is explained in Documentation/rev-list-options.txt -test_expect_success 'rebuild repo' ' +test_expect_success 'setup rebuild repo' ' rm -rf .git * && git init && git switch -c topic && diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index 7d549748ef..f3e66eaf9b 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -556,7 +556,7 @@ test_expect_success 'merge.suppressDest configuration' ' head -n1 full.2 >actual && grep -e "Merge branch .side. into master$" actual && - git -c merge.suppressDest="ma??er" fmt-merge-msg <.git/FETCH_HEAD >full.3 && + git -c merge.suppressDest="ma?*[rn]" fmt-merge-msg <.git/FETCH_HEAD >full.3 && head -n1 full.3 >actual && grep -e "Merge branch .side." actual && ! grep -e " into master$" actual diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh index 781e470aea..0a21669f56 100755 --- a/t/t6302-for-each-ref-filter.sh +++ b/t/t6302-for-each-ref-filter.sh @@ -113,9 +113,9 @@ test_expect_success '%(color) must fail' ' test_must_fail git for-each-ref --format="%(color)%(refname)" ' -test_expect_success 'left alignment is default' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'left alignment is default' ' cat >expect <<-\EOF && - refname is refs/heads/master |refs/heads/master + refname is refs/heads/main |refs/heads/main refname is refs/heads/side |refs/heads/side refname is refs/odd/spot |refs/odd/spot refname is refs/tags/annotated-tag|refs/tags/annotated-tag @@ -131,9 +131,9 @@ test_expect_success 'left alignment is default' ' test_cmp expect actual ' -test_expect_success 'middle alignment' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'middle alignment' ' cat >expect <<-\EOF && - | refname is refs/heads/master |refs/heads/master + | refname is refs/heads/main |refs/heads/main | refname is refs/heads/side |refs/heads/side | refname is refs/odd/spot |refs/odd/spot |refname is refs/tags/annotated-tag|refs/tags/annotated-tag @@ -149,9 +149,9 @@ test_expect_success 'middle alignment' ' test_cmp expect actual ' -test_expect_success 'right alignment' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH 'right alignment' ' cat >expect <<-\EOF && - | refname is refs/heads/master|refs/heads/master + | refname is refs/heads/main|refs/heads/main | refname is refs/heads/side|refs/heads/side | refname is refs/odd/spot|refs/odd/spot |refname is refs/tags/annotated-tag|refs/tags/annotated-tag @@ -168,7 +168,7 @@ test_expect_success 'right alignment' ' ' cat >expect <<-\EOF -| refname is refs/heads/master |refs/heads/master +| refname is refs/heads/main |refs/heads/main | refname is refs/heads/side |refs/heads/side | refname is refs/odd/spot |refs/odd/spot | refname is refs/tags/annotated-tag |refs/tags/annotated-tag @@ -184,7 +184,7 @@ EOF test_align_permutations() { while read -r option do - test_expect_success "align:$option" ' + test_expect_success PREPARE_FOR_MAIN_BRANCH "align:$option" ' git for-each-ref --format="|%(align:$option)refname is %(refname)%(end)|%(refname)" >actual && test_cmp expect actual ' @@ -213,9 +213,9 @@ EOF # Individual atoms inside %(align:...) and %(end) must not be quoted. -test_expect_success 'alignment with format quote' " +test_expect_success PREPARE_FOR_MAIN_BRANCH 'alignment with format quote' " cat >expect <<-\EOF && - |' '\''master| A U Thor'\'' '| + |' '\''main| A U Thor'\'' '| |' '\''side| A U Thor'\'' '| |' '\''odd/spot| A U Thor'\'' '| |' '\''annotated-tag| '\'' '| @@ -231,9 +231,9 @@ test_expect_success 'alignment with format quote' " test_cmp expect actual " -test_expect_success 'nested alignment with quote formatting' " +test_expect_success PREPARE_FOR_MAIN_BRANCH 'nested alignment with quote formatting' " cat >expect <<-\EOF && - |' master '| + |' main '| |' side '| |' odd/spot '| |' annotated-tag '| diff --git a/t/t6423-merge-rename-directories.sh b/t/t6423-merge-rename-directories.sh index f7ecbb886d..06b46af765 100755 --- a/t/t6423-merge-rename-directories.sh +++ b/t/t6423-merge-rename-directories.sh @@ -1277,20 +1277,114 @@ test_expect_success '6a: Tricky rename/delete' ' ) ' -# Testcase 6b, Same rename done on both sides +# Testcase 6b1, Same rename done on both sides +# (Related to testcase 6b2 and 8e) +# Commit O: z/{b,c,d,e} +# Commit A: y/{b,c,d}, x/e +# Commit B: y/{b,c,d}, z/{e,f} +# Expected: y/{b,c,d,f}, x/e +# Note: Directory rename detection says A renamed z/ -> y/ (3 paths renamed +# to y/ and only 1 renamed to x/), therefore the new file 'z/f' in B +# should be moved to 'y/f'. +# +# This is a bit of an edge case where any behavior might surprise users, +# whether that is treating A as renaming z/ -> y/, treating A as renaming +# z/ -> x/, or treating A as not doing any directory rename. However, I +# think this answer is the least confusing and most consistent with the +# rules elsewhere. +# +# A note about z/ -> x/, since it may not be clear how that could come +# about: If we were to ignore files renamed by both sides +# (i.e. z/{b,c,d}), as directory rename detection did in git-2.18 thru +# at least git-2.28, then we would note there are no renames from z/ to +# y/ and one rename from z/ to x/ and thus come to the conclusion that +# A renamed z/ -> x/. This seems more confusing for end users than a +# rename of z/ to y/, it makes directory rename detection behavior +# harder for them to predict. As such, we modified the rule, changed +# the behavior on testcases 6b2 and 8e, and introduced this 6b1 testcase. + +test_setup_6b1 () { + test_create_repo 6b1 && + ( + cd 6b1 && + + mkdir z && + echo b >z/b && + echo c >z/c && + echo d >z/d && + echo e >z/e && + git add z && + test_tick && + git commit -m "O" && + + git branch O && + git branch A && + git branch B && + + git checkout A && + git mv z y && + mkdir x && + git mv y/e x/e && + test_tick && + git commit -m "A" && + + git checkout B && + git mv z y && + mkdir z && + git mv y/e z/e && + echo f >z/f && + git add z/f && + test_tick && + git commit -m "B" + ) +} + +test_expect_failure '6b1: Same renames done on both sides, plus another rename' ' + test_setup_6b1 && + ( + cd 6b1 && + + git checkout A^0 && + + git -c merge.directoryRenames=true merge -s recursive B^0 && + + git ls-files -s >out && + test_line_count = 5 out && + git ls-files -u >out && + test_line_count = 0 out && + git ls-files -o >out && + test_line_count = 1 out && + + git rev-parse >actual \ + HEAD:y/b HEAD:y/c HEAD:y/d HEAD:x/e HEAD:y/f && + git rev-parse >expect \ + O:z/b O:z/c O:z/d O:z/e B:z/f && + test_cmp expect actual + ) +' + +# Testcase 6b2, Same rename done on both sides # (Related to testcases 6c and 8e) # Commit O: z/{b,c} # Commit A: y/{b,c} # Commit B: y/{b,c}, z/d -# Expected: y/{b,c}, z/d -# Note: If we did directory rename detection here, we'd move z/d into y/, -# 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_setup_6b () { - test_create_repo 6b && +# Expected: y/{b,c,d} +# Alternate: y/{b,c}, z/d +# Note: Directory rename detection says A renamed z/ -> y/, therefore the new +# file 'z/d' in B should be moved to 'y/d'. +# +# We could potentially ignore the renames of z/{b,c} on side A since +# those were renamed on both sides. However, it's a bit of a corner +# case because what if there was also a z/e that side A moved to x/e +# and side B left alone? If we used the "ignore renames done on both +# sides" logic, then we'd compute that A renamed z/ -> x/, and move +# z/d to x/d. That seems more surprising and uglier than allowing +# the z/ -> y/ rename. + +test_setup_6b2 () { + test_create_repo 6b2 && ( - cd 6b && + cd 6b2 && mkdir z && echo b >z/b && @@ -1318,10 +1412,10 @@ test_setup_6b () { ) } -test_expect_success '6b: Same rename done on both sides' ' - test_setup_6b && +test_expect_failure '6b2: Same rename done on both sides' ' + test_setup_6b2 && ( - cd 6b && + cd 6b2 && git checkout A^0 && @@ -1335,7 +1429,7 @@ test_expect_success '6b: Same rename done on both sides' ' test_line_count = 1 out && git rev-parse >actual \ - HEAD:y/b HEAD:y/c HEAD:z/d && + HEAD:y/b HEAD:y/c HEAD:y/d && git rev-parse >expect \ O:z/b O:z/c B:z/d && test_cmp expect actual @@ -1343,7 +1437,7 @@ test_expect_success '6b: Same rename done on both sides' ' ' # Testcase 6c, Rename only done on same side -# (Related to testcases 6b and 8e) +# (Related to testcases 6b1, 6b2, and 8e) # Commit O: z/{b,c} # Commit A: z/{b,c} (no change) # Commit B: y/{b,c}, z/d @@ -2269,14 +2363,22 @@ test_expect_success '8d: rename/delete...or not?' ' # Notes: In commit A, directory z got renamed to y. In commit B, directory z # did NOT get renamed; the directory is still present; instead it is # considered to have just renamed a subset of paths in directory z -# elsewhere. However, this is much like testcase 6b (where commit B -# moves all the original paths out of z/ but opted to keep d -# within z/). This makes it hard to judge where d should end up. +# elsewhere. This is much like testcase 6b2 (where commit B moves all +# the original paths out of z/ but opted to keep d within z/). # -# It's possible that users would get confused about this, but what -# should we do instead? It's not at all clear to me whether z/d or -# y/d or something else is a better resolution here, and other cases -# start getting really tricky, so I just picked one. +# It was not clear in the past what should be done with this testcase; +# in fact, I noted that I "just picked one" previously. However, +# following the new logic for testcase 6b2, we should take the rename +# and move z/d to y/d. +# +# 6b1, 6b2, and this case are definitely somewhat fuzzy in terms of +# whether they are optimal for end users, but (a) the default for +# directory rename detection is to mark these all as conflicts +# anyway, (b) it feels like this is less prone to higher order corner +# case confusion, and (c) the current algorithm requires less global +# knowledge (i.e. less coupling in the algorithm between renames done +# on both sides) which thus means users are better able to predict +# the behavior, and predict it without computing as many details. test_setup_8e () { test_create_repo 8e && @@ -3947,31 +4049,124 @@ test_expect_success '12a: Moving one directory hierarchy into another' ' ) ' -# Testcase 12b, Moving two directory hierarchies into each other +# Testcase 12b1, Moving two directory hierarchies into each other # (Related to testcases 1c and 12c) # Commit O: node1/{leaf1, leaf2}, node2/{leaf3, leaf4} # Commit A: node1/{leaf1, leaf2, node2/{leaf3, leaf4}} # Commit B: node2/{leaf3, leaf4, node1/{leaf1, leaf2}} -# Expected: node1/node2/node1/{leaf1, leaf2}, +# Expected: node1/node2/{leaf3, leaf4} +# node2/node1/{leaf1, leaf2} +# NOTE: If there were new files added to the old node1/ or node2/ directories, +# then we would need to detect renames for those directories and would +# find that: +# commit A renames node2/ -> node1/node2/ +# commit B renames node1/ -> node2/node1/ +# Applying those directory renames to the initial result (making all +# four paths experience a transitive renaming), yields +# node1/node2/node1/{leaf1, leaf2} # node2/node1/node2/{leaf3, leaf4} +# as the result. It may be really weird to have two directories +# rename each other, but simple rules give weird results when given +# weird inputs. HOWEVER, the "If" at the beginning of those NOTE was +# false; there were no new files added and thus there is no directory +# rename detection to perform. As such, we just have simple renames +# and the expected answer is: +# node1/node2/{leaf3, leaf4} +# node2/node1/{leaf1, leaf2} + +test_setup_12b1 () { + test_create_repo 12b1 && + ( + cd 12b1 && + + mkdir -p node1 node2 && + echo leaf1 >node1/leaf1 && + echo leaf2 >node1/leaf2 && + echo leaf3 >node2/leaf3 && + echo leaf4 >node2/leaf4 && + git add node1 node2 && + test_tick && + git commit -m "O" && + + git branch O && + git branch A && + git branch B && + + git checkout A && + git mv node2/ node1/ && + test_tick && + git commit -m "A" && + + git checkout B && + git mv node1/ node2/ && + test_tick && + git commit -m "B" + ) +} + +test_expect_failure '12b1: Moving two directory hierarchies into each other' ' + test_setup_12b1 && + ( + cd 12b1 && + + git checkout A^0 && + + git -c merge.directoryRenames=true merge -s recursive B^0 && + + git ls-files -s >out && + test_line_count = 4 out && + + git rev-parse >actual \ + HEAD:node2/node1/leaf1 \ + HEAD:node2/node1/leaf2 \ + HEAD:node1/node2/leaf3 \ + HEAD:node1/node2/leaf4 && + git rev-parse >expect \ + O:node1/leaf1 \ + O:node1/leaf2 \ + O:node2/leaf3 \ + O:node2/leaf4 && + test_cmp expect actual + ) +' + +# Testcase 12b2, Moving two directory hierarchies into each other +# (Related to testcases 1c and 12c) +# Commit O: node1/{leaf1, leaf2}, node2/{leaf3, leaf4} +# Commit A: node1/{leaf1, leaf2, leaf5, node2/{leaf3, leaf4}} +# Commit B: node2/{leaf3, leaf4, leaf6, node1/{leaf1, leaf2}} +# Expected: node1/node2/{node1/{leaf1, leaf2}, leaf6} +# node2/node1/{node2/{leaf3, leaf4}, leaf5} # NOTE: Without directory renames, we would expect -# node2/node1/{leaf1, leaf2}, -# node1/node2/{leaf3, leaf4} +# A: node2/leaf3 -> node1/node2/leaf3 +# A: node2/leaf1 -> node1/node2/leaf4 +# A: Adds node1/leaf5 +# B: node1/leaf1 -> node2/node1/leaf1 +# B: node1/leaf2 -> node2/node1/leaf2 +# B: Adds node2/leaf6 # with directory rename detection, we note that # commit A renames node2/ -> node1/node2/ # commit B renames node1/ -> node2/node1/ -# therefore, applying those directory renames to the initial result -# (making all four paths experience a transitive renaming), yields -# the expected result. +# therefore, applying A's directory rename to the paths added in B gives: +# B: node1/leaf1 -> node1/node2/node1/leaf1 +# B: node1/leaf2 -> node1/node2/node1/leaf2 +# B: Adds node1/node2/leaf6 +# and applying B's directory rename to the paths added in A gives: +# A: node2/leaf3 -> node2/node1/node2/leaf3 +# A: node2/leaf1 -> node2/node1/node2/leaf4 +# A: Adds node2/node1/leaf5 +# resulting in the expected +# node1/node2/{node1/{leaf1, leaf2}, leaf6} +# node2/node1/{node2/{leaf3, leaf4}, leaf5} # # You may ask, is it weird to have two directories rename each other? # 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_setup_12b () { - test_create_repo 12b && +test_setup_12b2 () { + test_create_repo 12b2 && ( - cd 12b && + cd 12b2 && mkdir -p node1 node2 && echo leaf1 >node1/leaf1 && @@ -3988,43 +4183,51 @@ test_setup_12b () { git checkout A && git mv node2/ node1/ && + echo leaf5 >node1/leaf5 && + git add node1/leaf5 && test_tick && git commit -m "A" && git checkout B && git mv node1/ node2/ && + echo leaf6 >node2/leaf6 && + git add node2/leaf6 && test_tick && git commit -m "B" ) } -test_expect_success '12b: Moving two directory hierarchies into each other' ' - test_setup_12b && +test_expect_success '12b2: Moving two directory hierarchies into each other' ' + test_setup_12b2 && ( - cd 12b && + cd 12b2 && git checkout A^0 && git -c merge.directoryRenames=true merge -s recursive B^0 && git ls-files -s >out && - test_line_count = 4 out && + test_line_count = 6 out && git rev-parse >actual \ HEAD:node1/node2/node1/leaf1 \ HEAD:node1/node2/node1/leaf2 \ HEAD:node2/node1/node2/leaf3 \ - HEAD:node2/node1/node2/leaf4 && + HEAD:node2/node1/node2/leaf4 \ + HEAD:node2/node1/leaf5 \ + HEAD:node1/node2/leaf6 && git rev-parse >expect \ O:node1/leaf1 \ O:node1/leaf2 \ O:node2/leaf3 \ - O:node2/leaf4 && + O:node2/leaf4 \ + A:node1/leaf5 \ + B:node2/leaf6 && test_cmp expect actual ) ' -# Testcase 12c, Moving two directory hierarchies into each other w/ content merge +# Testcase 12c1, Moving two directory hierarchies into each other w/ content merge # (Related to testcase 12b) # Commit O: node1/{ leaf1_1, leaf2_1}, node2/{leaf3_1, leaf4_1} # Commit A: node1/{ leaf1_2, leaf2_2, node2/{leaf3_2, leaf4_2}} @@ -4032,13 +4235,103 @@ test_expect_success '12b: Moving two directory hierarchies into each other' ' # Expected: Content merge conflicts for each of: # node1/node2/node1/{leaf1, leaf2}, # node2/node1/node2/{leaf3, leaf4} -# NOTE: This is *exactly* like 12c, except that every path is modified on +# NOTE: This is *exactly* like 12b1, except that every path is modified on # each side of the merge. -test_setup_12c () { - test_create_repo 12c && +test_setup_12c1 () { + test_create_repo 12c1 && + ( + cd 12c1 && + + mkdir -p node1 node2 && + printf "1\n2\n3\n4\n5\n6\n7\n8\nleaf1\n" >node1/leaf1 && + printf "1\n2\n3\n4\n5\n6\n7\n8\nleaf2\n" >node1/leaf2 && + printf "1\n2\n3\n4\n5\n6\n7\n8\nleaf3\n" >node2/leaf3 && + printf "1\n2\n3\n4\n5\n6\n7\n8\nleaf4\n" >node2/leaf4 && + git add node1 node2 && + test_tick && + git commit -m "O" && + + git branch O && + git branch A && + git branch B && + + git checkout A && + git mv node2/ node1/ && + for i in `git ls-files`; do echo side A >>$i; done && + git add -u && + test_tick && + git commit -m "A" && + + git checkout B && + git mv node1/ node2/ && + for i in `git ls-files`; do echo side B >>$i; done && + git add -u && + test_tick && + git commit -m "B" + ) +} + +test_expect_failure '12c1: Moving one directory hierarchy into another w/ content merge' ' + test_setup_12c1 && + ( + cd 12c1 && + + git checkout A^0 && + + test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 && + + git ls-files -u >out && + test_line_count = 12 out && + + git rev-parse >actual \ + :1:node2/node1/leaf1 \ + :1:node2/node1/leaf2 \ + :1:node1/node2/leaf3 \ + :1:node1/node2/leaf4 \ + :2:node2/node1/leaf1 \ + :2:node2/node1/leaf2 \ + :2:node1/node2/leaf3 \ + :2:node1/node2/leaf4 \ + :3:node2/node1/leaf1 \ + :3:node2/node1/leaf2 \ + :3:node1/node2/leaf3 \ + :3:node1/node2/leaf4 && + git rev-parse >expect \ + O:node1/leaf1 \ + O:node1/leaf2 \ + O:node2/leaf3 \ + O:node2/leaf4 \ + A:node1/leaf1 \ + A:node1/leaf2 \ + A:node1/node2/leaf3 \ + A:node1/node2/leaf4 \ + B:node2/node1/leaf1 \ + B:node2/node1/leaf2 \ + B:node2/leaf3 \ + B:node2/leaf4 && + test_cmp expect actual + ) +' + +# Testcase 12c2, Moving two directory hierarchies into each other w/ content merge +# (Related to testcase 12b) +# Commit O: node1/{ leaf1_1, leaf2_1}, node2/{leaf3_1, leaf4_1} +# Commit A: node1/{ leaf1_2, leaf2_2, node2/{leaf3_2, leaf4_2}, leaf5} +# Commit B: node2/{node1/{leaf1_3, leaf2_3}, leaf3_3, leaf4_3, leaf6} +# Expected: Content merge conflicts for each of: +# node1/node2/node1/{leaf1, leaf2} +# node2/node1/node2/{leaf3, leaf4} +# plus +# node2/node1/leaf5 +# node1/node2/leaf6 +# NOTE: This is *exactly* like 12b2, except that every path from O is modified +# on each side of the merge. + +test_setup_12c2 () { + test_create_repo 12c2 && ( - cd 12c && + cd 12c2 && mkdir -p node1 node2 && printf "1\n2\n3\n4\n5\n6\n7\n8\nleaf1\n" >node1/leaf1 && @@ -4057,6 +4350,8 @@ test_setup_12c () { git mv node2/ node1/ && for i in `git ls-files`; do echo side A >>$i; done && git add -u && + echo leaf5 >node1/leaf5 && + git add node1/leaf5 && test_tick && git commit -m "A" && @@ -4064,20 +4359,24 @@ test_setup_12c () { git mv node1/ node2/ && for i in `git ls-files`; do echo side B >>$i; done && git add -u && + echo leaf6 >node2/leaf6 && + git add node2/leaf6 && test_tick && git commit -m "B" ) } -test_expect_success '12c: Moving one directory hierarchy into another w/ content merge' ' - test_setup_12c && +test_expect_success '12c2: Moving one directory hierarchy into another w/ content merge' ' + test_setup_12c2 && ( - cd 12c && + cd 12c2 && git checkout A^0 && test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 && + git ls-files -s >out && + test_line_count = 14 out && git ls-files -u >out && test_line_count = 12 out && @@ -4093,7 +4392,9 @@ test_expect_success '12c: Moving one directory hierarchy into another w/ content :3:node1/node2/node1/leaf1 \ :3:node1/node2/node1/leaf2 \ :3:node2/node1/node2/leaf3 \ - :3:node2/node1/node2/leaf4 && + :3:node2/node1/node2/leaf4 \ + :0:node2/node1/leaf5 \ + :0:node1/node2/leaf6 && git rev-parse >expect \ O:node1/leaf1 \ O:node1/leaf2 \ @@ -4106,7 +4407,9 @@ test_expect_success '12c: Moving one directory hierarchy into another w/ content B:node2/node1/leaf1 \ B:node2/node1/leaf2 \ B:node2/leaf3 \ - B:node2/leaf4 && + B:node2/leaf4 \ + A:node1/leaf5 \ + B:node2/leaf6 && test_cmp expect actual ) ' @@ -4227,6 +4530,201 @@ test_expect_success '12e: Rename/merge subdir into the root, variant 2' ' ) ' +# Testcase 12f, Rebase of patches with big directory rename +# Commit O: +# dir/subdir/{a,b,c,d,e_O,Makefile_TOP_O} +# dir/subdir/tweaked/{f,g,h,Makefile_SUB_O} +# dir/unchanged/<LOTS OF FILES> +# Commit A: +# (Remove f & g, move e into newsubdir, rename dir/->folder/, modify files) +# folder/subdir/{a,b,c,d,Makefile_TOP_A} +# folder/subdir/newsubdir/e_A +# folder/subdir/tweaked/{h,Makefile_SUB_A} +# folder/unchanged/<LOTS OF FILES> +# Commit B1: +# (add newfile.{c,py}, modify underscored files) +# dir/{a,b,c,d,e_B1,Makefile_TOP_B1,newfile.c} +# dir/tweaked/{f,g,h,Makefile_SUB_B1,newfile.py} +# dir/unchanged/<LOTS OF FILES> +# Commit B2: +# (Modify e further, add newfile.rs) +# dir/{a,b,c,d,e_B2,Makefile_TOP_B1,newfile.c,newfile.rs} +# dir/tweaked/{f,g,h,Makefile_SUB_B1,newfile.py} +# dir/unchanged/<LOTS OF FILES> +# Expected: +# B1-picked: +# folder/subdir/{a,b,c,d,Makefile_TOP_Merge1,newfile.c} +# folder/subdir/newsubdir/e_Merge1 +# folder/subdir/tweaked/{h,Makefile_SUB_Merge1,newfile.py} +# folder/unchanged/<LOTS OF FILES> +# B2-picked: +# folder/subdir/{a,b,c,d,Makefile_TOP_Merge1,newfile.c,newfile.rs} +# folder/subdir/newsubdir/e_Merge2 +# folder/subdir/tweaked/{h,Makefile_SUB_Merge1,newfile.py} +# folder/unchanged/<LOTS OF FILES> +# +# Notes: This testcase happens to exercise lots of the +# optimization-specific codepaths in merge-ort, and also +# demonstrated a failing of the directory rename detection algorithm +# in merge-recursive; newfile.c should not get pushed into +# folder/subdir/newsubdir/, yet merge-recursive put it there because +# the rename of dir/subdir/{a,b,c,d} -> folder/subdir/{a,b,c,d} +# looks like +# dir/ -> folder/, +# whereas the rename of dir/subdir/e -> folder/subdir/newsubdir/e +# looks like +# dir/subdir/ -> folder/subdir/newsubdir/ +# and if we note that newfile.c is found in dir/subdir/, we might +# overlook the dir/ -> folder/ rule that has more weight. + +test_setup_12f () { + test_create_repo 12f && + ( + cd 12f && + + mkdir -p dir/unchanged && + mkdir -p dir/subdir/tweaked && + echo a >dir/subdir/a && + echo b >dir/subdir/b && + echo c >dir/subdir/c && + echo d >dir/subdir/d && + test_seq 1 10 >dir/subdir/e && + test_seq 10 20 >dir/subdir/Makefile && + echo f >dir/subdir/tweaked/f && + echo g >dir/subdir/tweaked/g && + echo h >dir/subdir/tweaked/h && + test_seq 20 30 >dir/subdir/tweaked/Makefile && + for i in `test_seq 1 88`; do + echo content $i >dir/unchanged/file_$i + done && + git add . && + git commit -m "O" && + + git branch O && + git branch A && + git branch B && + + git switch A && + git rm dir/subdir/tweaked/f dir/subdir/tweaked/g && + test_seq 2 10 >dir/subdir/e && + test_seq 11 20 >dir/subdir/Makefile && + test_seq 21 30 >dir/subdir/tweaked/Makefile && + mkdir dir/subdir/newsubdir && + git mv dir/subdir/e dir/subdir/newsubdir/ && + git mv dir folder && + git add . && + git commit -m "A" && + + git switch B && + mkdir dir/subdir/newsubdir/ && + echo c code >dir/subdir/newfile.c && + echo python code >dir/subdir/newsubdir/newfile.py && + test_seq 1 11 >dir/subdir/e && + test_seq 10 21 >dir/subdir/Makefile && + test_seq 20 31 >dir/subdir/tweaked/Makefile && + git add . && + git commit -m "B1" && + + echo rust code >dir/subdir/newfile.rs && + test_seq 1 12 >dir/subdir/e && + git add . && + git commit -m "B2" + ) +} + +test_expect_failure '12f: Trivial directory resolve, caching, all kinds of fun' ' + test_setup_12f && + ( + cd 12f && + + git checkout A^0 && + git branch Bmod B && + + git -c merge.directoryRenames=true rebase A Bmod && + + echo Checking the pick of B1... && + + test_must_fail git rev-parse Bmod~1:dir && + + git ls-tree -r Bmod~1 >out && + test_line_count = 98 out && + + git diff --name-status A Bmod~1 >actual && + q_to_tab >expect <<-\EOF && + MQfolder/subdir/Makefile + AQfolder/subdir/newfile.c + MQfolder/subdir/newsubdir/e + AQfolder/subdir/newsubdir/newfile.py + MQfolder/subdir/tweaked/Makefile + EOF + test_cmp expect actual && + + # Three-way merged files + test_seq 2 11 >e_Merge1 && + test_seq 11 21 >Makefile_TOP && + test_seq 21 31 >Makefile_SUB && + git hash-object >expect \ + e_Merge1 \ + Makefile_TOP \ + Makefile_SUB && + git rev-parse >actual \ + Bmod~1:folder/subdir/newsubdir/e \ + Bmod~1:folder/subdir/Makefile \ + Bmod~1:folder/subdir/tweaked/Makefile && + test_cmp expect actual && + + # New files showed up at the right location with right contents + git rev-parse >expect \ + B~1:dir/subdir/newfile.c \ + B~1:dir/subdir/newsubdir/newfile.py && + git rev-parse >actual \ + Bmod~1:folder/subdir/newfile.c \ + Bmod~1:folder/subdir/newsubdir/newfile.py && + test_cmp expect actual && + + # Removed files + test_path_is_missing folder/subdir/tweaked/f && + test_path_is_missing folder/subdir/tweaked/g && + + # Unchanged files or directories + git rev-parse >actual \ + Bmod~1:folder/subdir/a \ + Bmod~1:folder/subdir/b \ + Bmod~1:folder/subdir/c \ + Bmod~1:folder/subdir/d \ + Bmod~1:folder/unchanged \ + Bmod~1:folder/subdir/tweaked/h && + git rev-parse >expect \ + O:dir/subdir/a \ + O:dir/subdir/b \ + O:dir/subdir/c \ + O:dir/subdir/d \ + O:dir/unchanged \ + O:dir/subdir/tweaked/h && + test_cmp expect actual && + + echo Checking the pick of B2... && + + test_must_fail git rev-parse Bmod:dir && + + git ls-tree -r Bmod >out && + test_line_count = 99 out && + + git diff --name-status Bmod~1 Bmod >actual && + q_to_tab >expect <<-\EOF && + AQfolder/subdir/newfile.rs + MQfolder/subdir/newsubdir/e + EOF + test_cmp expect actual && + + # Three-way merged file + test_seq 2 12 >e_Merge2 && + git hash-object e_Merge2 >expect && + git rev-parse Bmod:folder/subdir/newsubdir/e >actual && + test_cmp expect actual + ) +' + ########################################################################### # SECTION 13: Checking informational and conflict messages # diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index 00e09a375c..fdb450e446 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -19,7 +19,7 @@ test_expect_success 'setup' ' test_expect_success TTY 'some commands use a pager' ' rm -f paginated.out && test_terminal git log && - test -e paginated.out + test_path_is_file paginated.out ' test_expect_failure TTY 'pager runs from subdir' ' @@ -65,49 +65,49 @@ test_expect_success !MINGW,TTY 'LESS and LV envvars set by git-sh-setup' ' test_expect_success TTY 'some commands do not use a pager' ' rm -f paginated.out && test_terminal git rev-list HEAD && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success 'no pager when stdout is a pipe' ' rm -f paginated.out && git log | cat && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success 'no pager when stdout is a regular file' ' rm -f paginated.out && git log >file && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git --paginate rev-list uses a pager' ' rm -f paginated.out && test_terminal git --paginate rev-list HEAD && - test -e paginated.out + test_path_is_file paginated.out ' test_expect_success 'no pager even with --paginate when stdout is a pipe' ' rm -f file paginated.out && git --paginate log | cat && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'no pager with --no-pager' ' rm -f paginated.out && test_terminal git --no-pager log && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'configuration can disable pager' ' rm -f paginated.out && test_unconfig pager.grep && test_terminal git grep initial && - test -e paginated.out && + test_path_is_file paginated.out && rm -f paginated.out && test_config pager.grep false && test_terminal git grep initial && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'configuration can enable pager (from subdir)' ' @@ -122,107 +122,107 @@ test_expect_success TTY 'configuration can enable pager (from subdir)' ' test_terminal git bundle unbundle ../test.bundle ) && { - test -e paginated.out || - test -e subdir/paginated.out + test_path_is_file paginated.out || + test_path_is_file subdir/paginated.out } ' test_expect_success TTY 'git tag -l defaults to paging' ' rm -f paginated.out && test_terminal git tag -l && - test -e paginated.out + test_path_is_file paginated.out ' test_expect_success TTY 'git tag -l respects pager.tag' ' rm -f paginated.out && test_terminal git -c pager.tag=false tag -l && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git tag -l respects --no-pager' ' rm -f paginated.out && test_terminal git -c pager.tag --no-pager tag -l && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git tag with no args defaults to paging' ' # no args implies -l so this should page like -l rm -f paginated.out && test_terminal git tag && - test -e paginated.out + test_path_is_file paginated.out ' test_expect_success TTY 'git tag with no args respects pager.tag' ' # no args implies -l so this should page like -l rm -f paginated.out && test_terminal git -c pager.tag=false tag && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git tag --contains defaults to paging' ' # --contains implies -l so this should page like -l rm -f paginated.out && test_terminal git tag --contains && - test -e paginated.out + test_path_is_file paginated.out ' test_expect_success TTY 'git tag --contains respects pager.tag' ' # --contains implies -l so this should page like -l rm -f paginated.out && test_terminal git -c pager.tag=false tag --contains && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git tag -a defaults to not paging' ' test_when_finished "git tag -d newtag" && rm -f paginated.out && test_terminal git tag -am message newtag && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git tag -a ignores pager.tag' ' test_when_finished "git tag -d newtag" && rm -f paginated.out && test_terminal git -c pager.tag tag -am message newtag && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git tag -a respects --paginate' ' test_when_finished "git tag -d newtag" && rm -f paginated.out && test_terminal git --paginate tag -am message newtag && - test -e paginated.out + test_path_is_file paginated.out ' test_expect_success TTY 'git tag as alias ignores pager.tag with -a' ' test_when_finished "git tag -d newtag" && rm -f paginated.out && test_terminal git -c pager.tag -c alias.t=tag t -am message newtag && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git tag as alias respects pager.tag with -l' ' rm -f paginated.out && test_terminal git -c pager.tag=false -c alias.t=tag t -l && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git branch defaults to paging' ' rm -f paginated.out && test_terminal git branch && - test -e paginated.out + test_path_is_file paginated.out ' test_expect_success TTY 'git branch respects pager.branch' ' rm -f paginated.out && test_terminal git -c pager.branch=false branch && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git branch respects --no-pager' ' rm -f paginated.out && test_terminal git --no-pager branch && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git branch --edit-description ignores pager.branch' ' @@ -232,8 +232,8 @@ test_expect_success TTY 'git branch --edit-description ignores pager.branch' ' touch editor.used EOF EDITOR=./editor test_terminal git -c pager.branch branch --edit-description && - ! test -e paginated.out && - test -e editor.used + test_path_is_missing paginated.out && + test_path_is_file editor.used ' test_expect_success TTY 'git branch --set-upstream-to ignores pager.branch' ' @@ -242,13 +242,13 @@ test_expect_success TTY 'git branch --set-upstream-to ignores pager.branch' ' test_when_finished "git branch -D other" && test_terminal git -c pager.branch branch --set-upstream-to=other && test_when_finished "git branch --unset-upstream" && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git config ignores pager.config when setting' ' rm -f paginated.out && test_terminal git -c pager.config config foo.bar bar && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git config --edit ignores pager.config' ' @@ -257,33 +257,33 @@ test_expect_success TTY 'git config --edit ignores pager.config' ' touch editor.used EOF EDITOR=./editor test_terminal git -c pager.config config --edit && - ! test -e paginated.out && - test -e editor.used + test_path_is_missing paginated.out && + test_path_is_file editor.used ' test_expect_success TTY 'git config --get ignores pager.config' ' rm -f paginated.out && test_terminal git -c pager.config config --get foo.bar && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git config --get-urlmatch defaults to paging' ' rm -f paginated.out && test_terminal git -c http."https://foo.com/".bar=foo \ config --get-urlmatch http https://foo.com && - test -e paginated.out + test_path_is_file paginated.out ' test_expect_success TTY 'git config --get-all respects pager.config' ' rm -f paginated.out && test_terminal git -c pager.config=false config --get-all foo.bar && - ! test -e paginated.out + test_path_is_missing paginated.out ' test_expect_success TTY 'git config --list defaults to paging' ' rm -f paginated.out && test_terminal git config --list && - test -e paginated.out + test_path_is_file paginated.out ' @@ -392,7 +392,7 @@ test_default_pager() { export PATH && $full_command ) && - test -e default_pager_used + test_path_is_file default_pager_used " } @@ -406,7 +406,7 @@ test_PAGER_overrides() { PAGER='wc >PAGER_used' && export PAGER && $full_command && - test -e PAGER_used + test_path_is_file PAGER_used " } @@ -432,7 +432,7 @@ test_core_pager() { export PAGER && test_config core.pager 'wc >core.pager_used' && $full_command && - ${if_local_config}test -e core.pager_used + ${if_local_config}test_path_is_file core.pager_used " } @@ -464,7 +464,7 @@ test_pager_subdir_helper() { cd sub && $full_command ) && - ${if_local_config}test -e core.pager_used + ${if_local_config}test_path_is_file core.pager_used " } @@ -477,7 +477,7 @@ test_GIT_PAGER_overrides() { GIT_PAGER='wc >GIT_PAGER_used' && export GIT_PAGER && $full_command && - test -e GIT_PAGER_used + test_path_is_file GIT_PAGER_used " } @@ -489,7 +489,7 @@ test_doesnt_paginate() { GIT_PAGER='wc >GIT_PAGER_used' && export GIT_PAGER && $full_command && - ! test -e GIT_PAGER_used + test_path_is_missing GIT_PAGER_used " } diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 55116c2f04..b2def8bb16 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -53,6 +53,43 @@ test_expect_success 'run --task=<task>' ' test_subcommand git commit-graph write --split --reachable --no-progress <run-both.txt ' +test_expect_success 'core.commitGraph=false prevents write process' ' + GIT_TRACE2_EVENT="$(pwd)/no-commit-graph.txt" \ + git -c core.commitGraph=false maintenance run \ + --task=commit-graph 2>/dev/null && + test_subcommand ! git commit-graph write --split --reachable --no-progress \ + <no-commit-graph.txt +' + +test_expect_success 'commit-graph auto condition' ' + COMMAND="maintenance run --task=commit-graph --auto --quiet" && + + GIT_TRACE2_EVENT="$(pwd)/cg-no.txt" \ + git -c maintenance.commit-graph.auto=1 $COMMAND && + GIT_TRACE2_EVENT="$(pwd)/cg-negative-means-yes.txt" \ + git -c maintenance.commit-graph.auto="-1" $COMMAND && + + test_commit first && + + GIT_TRACE2_EVENT="$(pwd)/cg-zero-means-no.txt" \ + git -c maintenance.commit-graph.auto=0 $COMMAND && + GIT_TRACE2_EVENT="$(pwd)/cg-one-satisfied.txt" \ + git -c maintenance.commit-graph.auto=1 $COMMAND && + + git commit --allow-empty -m "second" && + git commit --allow-empty -m "third" && + + GIT_TRACE2_EVENT="$(pwd)/cg-two-satisfied.txt" \ + git -c maintenance.commit-graph.auto=2 $COMMAND && + + COMMIT_GRAPH_WRITE="git commit-graph write --split --reachable --no-progress" && + test_subcommand ! $COMMIT_GRAPH_WRITE <cg-no.txt && + test_subcommand $COMMIT_GRAPH_WRITE <cg-negative-means-yes.txt && + test_subcommand ! $COMMIT_GRAPH_WRITE <cg-zero-means-no.txt && + test_subcommand $COMMIT_GRAPH_WRITE <cg-one-satisfied.txt && + test_subcommand $COMMIT_GRAPH_WRITE <cg-two-satisfied.txt +' + test_expect_success 'run --task=bogus' ' test_must_fail git maintenance run --task=bogus 2>err && test_i18ngrep "is not a valid task" err diff --git a/t/t9303-fast-import-compression.sh b/t/t9303-fast-import-compression.sh index 5045f02a53..57d916524e 100755 --- a/t/t9303-fast-import-compression.sh +++ b/t/t9303-fast-import-compression.sh @@ -3,12 +3,6 @@ test_description='compression setting of fast-import utility' . ./test-lib.sh -# This should be moved to test-lib.sh together with the -# copy in t0021 after both topics have graduated to 'master'. -file_size () { - test-tool path-utils file-size "$1" -} - import_large () { ( echo blob @@ -24,7 +18,7 @@ do test_when_finished "rm -f .git/objects/pack/pack-*.*" && test_when_finished "rm -rf .git/objects/??" && import_large -c fastimport.unpacklimit=0 $config && - sz=$(file_size .git/objects/pack/pack-*.pack) && + sz=$(test_file_size .git/objects/pack/pack-*.pack) && case "$expect" in small) test "$sz" -le 100000 ;; large) test "$sz" -ge 100000 ;; @@ -47,7 +41,7 @@ do test_when_finished "rm -f .git/objects/pack/pack-*.*" && test_when_finished "rm -rf .git/objects/??" && import_large -c fastimport.unpacklimit=9 $config && - sz=$(file_size .git/objects/??/????*) && + sz=$(test_file_size .git/objects/??/????*) && case "$expect" in small) test "$sz" -le 100000 ;; large) test "$sz" -ge 100000 ;; diff --git a/t/t9304-fast-import-marks.sh b/t/t9304-fast-import-marks.sh new file mode 100755 index 0000000000..d4359dba21 --- /dev/null +++ b/t/t9304-fast-import-marks.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +test_description='test exotic situations with marks' +. ./test-lib.sh + +test_expect_success 'setup dump of basic history' ' + test_commit one && + git fast-export --export-marks=marks HEAD >dump +' + +test_expect_success 'setup large marks file' ' + # normally a marks file would have a lot of useful, unique + # marks. But for our purposes, just having a lot of nonsense + # ones is fine. Start at 1024 to avoid clashing with marks + # legitimately used in our tiny dump. + blob=$(git rev-parse HEAD:one.t) && + for i in $(test_seq 1024 16384) + do + echo ":$i $blob" + done >>marks +' + +test_expect_success 'import with large marks file' ' + git fast-import --import-marks=marks <dump +' + +test_expect_success 'setup dump with submodule' ' + git submodule add "$PWD" sub && + git commit -m "add submodule" && + git fast-export HEAD >dump +' + +test_expect_success 'setup submodule mapping with large id' ' + old=$(git rev-parse HEAD:sub) && + new=$(echo $old | sed s/./a/g) && + echo ":12345 $old" >from && + echo ":12345 $new" >to +' + +test_expect_success 'import with submodule mapping' ' + git init dst && + git -C dst fast-import \ + --rewrite-submodules-from=sub:../from \ + --rewrite-submodules-to=sub:../to \ + <dump && + git -C dst rev-parse HEAD:sub >actual && + echo "$new" >expect && + test_cmp expect actual +' + +test_done diff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh index 3e64b11eac..e7a91611dc 100755 --- a/t/t9603-cvsimport-patchsets.sh +++ b/t/t9603-cvsimport-patchsets.sh @@ -17,23 +17,23 @@ test_description='git cvsimport testing for correct patchset estimation' setup_cvs_test_repository t9603 test_expect_failure PERL 'import with criss cross times on revisions' ' - - git cvsimport -p"-x" -C module-git module && - (cd module-git && - git log --pretty=format:%s > ../actual-master && - git log A~2..A --pretty="format:%s %ad" -- > ../actual-A && - echo "" >> ../actual-master && - echo "" >> ../actual-A - ) && - echo "Rev 4 + git cvsimport -p"-x" -C module-git module && + ( + cd module-git && + git log --pretty=format:%s > ../actual-master && + git log A~2..A --pretty="format:%s %ad" -- > ../actual-A && + echo "" >> ../actual-master && + echo "" >> ../actual-A + ) && + echo "Rev 4 Rev 3 Rev 2 Rev 1" > expect-master && - test_cmp expect-master actual-master && + test_cmp expect-master actual-master && - echo "Rev 5 Branch A Wed Mar 11 19:09:10 2009 +0000 + echo "Rev 5 Branch A Wed Mar 11 19:09:10 2009 +0000 Rev 4 Branch A Wed Mar 11 19:03:52 2009 +0000" > expect-A && - test_cmp expect-A actual-A + test_cmp expect-A actual-A ' test_done diff --git a/t/t9801-git-p4-branch.sh b/t/t9801-git-p4-branch.sh index 67ff2711f5..a3abd778f9 100755 --- a/t/t9801-git-p4-branch.sh +++ b/t/t9801-git-p4-branch.sh @@ -67,7 +67,7 @@ test_expect_success 'import main, no branch detection' ' ( cd "$git" && git log --oneline --graph --decorate --all && - git rev-list master >wc && + git rev-list master -- >wc && test_line_count = 4 wc ) ' @@ -78,7 +78,7 @@ test_expect_success 'import branch1, no branch detection' ' ( cd "$git" && git log --oneline --graph --decorate --all && - git rev-list master >wc && + git rev-list master -- >wc && test_line_count = 2 wc ) ' @@ -89,7 +89,7 @@ test_expect_success 'import branch2, no branch detection' ' ( cd "$git" && git log --oneline --graph --decorate --all && - git rev-list master >wc && + git rev-list master -- >wc && test_line_count = 2 wc ) ' @@ -100,7 +100,7 @@ test_expect_success 'import depot, no branch detection' ' ( cd "$git" && git log --oneline --graph --decorate --all && - git rev-list master >wc && + git rev-list master -- >wc && test_line_count = 8 wc ) ' @@ -114,7 +114,7 @@ test_expect_success 'import depot, branch detection' ' git log --oneline --graph --decorate --all && # 4 main commits - git rev-list master >wc && + git rev-list master -- >wc && test_line_count = 4 wc && # 3 main, 1 integrate, 1 on branch2 @@ -137,7 +137,7 @@ test_expect_success 'import depot, branch detection, branchList branch definitio git log --oneline --graph --decorate --all && # 4 main commits - git rev-list master >wc && + git rev-list master -- >wc && test_line_count = 4 wc && # 3 main, 1 integrate, 1 on branch2 diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh index 7194fb2855..6b3cb0414a 100755 --- a/t/t9832-unshelve.sh +++ b/t/t9832-unshelve.sh @@ -68,7 +68,8 @@ EOF cd "$git" && change=$(last_shelved_change) && git p4 unshelve $change && - git show refs/remotes/p4-unshelved/$change | grep -q "Further description" && + git show refs/remotes/p4-unshelved/$change >actual && + grep -q "Further description" actual && git cherry-pick refs/remotes/p4-unshelved/$change && test_path_is_file file2 && test_cmp file1 "$cli"/file1 && diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index eb9e56c39e..2be9190425 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2012 Felipe Contreras +# Copyright (c) 2012-2020 Felipe Contreras # test_description='test bash completion' @@ -1055,13 +1055,13 @@ test_expect_success 'teardown after filtering matching refs' ' git -C otherrepo branch -D matching/branch-in-other ' -test_expect_success '__git_refs - for-each-ref format specifiers in prefix' ' +test_expect_success PREPARE_FOR_MAIN_BRANCH '__git_refs - for-each-ref format specifiers in prefix' ' cat >expected <<-EOF && evil-%%-%42-%(refname)..master EOF ( - cur="evil-%%-%42-%(refname)..mas" && - __git_refs "" "" "evil-%%-%42-%(refname).." mas >"$actual" + cur="evil-%%-%42-%(refname)..mai" && + __git_refs "" "" "evil-%%-%42-%(refname).." mai >"$actual" ) && test_cmp expected "$actual" ' diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 8d59b90348..59bbf75e83 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -783,6 +783,10 @@ test_line_count () { fi } +test_file_size () { + test-tool path-utils file-size "$1" +} + # Returns success if a comma separated string of keywords ($1) contains a # given keyword ($2). # Examples: @@ -952,13 +956,7 @@ test_expect_code () { # - not all diff versions understand "-u" test_cmp() { - test $# -eq 2 || BUG "test_cmp requires two arguments" - if ! eval "$GIT_TEST_CMP" '"$@"' - then - test "x$1" = x- || test -e "$1" || BUG "test_cmp '$1' missing" - test "x$2" = x- || test -e "$2" || BUG "test_cmp '$2' missing" - return 1 - fi + eval "$GIT_TEST_CMP" '"$@"' } # Check that the given config key has the expected value. @@ -987,13 +985,7 @@ test_cmp_config() { # test_cmp_bin - helper to compare binary files test_cmp_bin() { - test $# -eq 2 || BUG "test_cmp_bin requires two arguments" - if ! cmp "$@" - then - test "x$1" = x- || test -e "$1" || BUG "test_cmp_bin '$1' missing" - test "x$2" = x- || test -e "$2" || BUG "test_cmp_bin '$2' missing" - return 1 - fi + cmp "$@" } # Use this instead of test_cmp to compare files that contain expected and diff --git a/t/test-lib.sh b/t/test-lib.sh index ef31f40037..fa347ed3e1 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -499,6 +499,12 @@ then export GIT_INDEX_VERSION fi +if test -n "$GIT_TEST_PERL_FATAL_WARNINGS" +then + GIT_PERL_FATAL_WARNINGS=1 + export GIT_PERL_FATAL_WARNINGS +fi + # Add libc MALLOC and MALLOC_PERTURB test # only if we are not executing the test with valgrind if test -n "$valgrind" || @@ -769,15 +775,17 @@ match_pattern_list () { } match_test_selector_list () { + operation="$1" + shift title="$1" shift arg="$1" shift test -z "$1" && return 0 - # Both commas and whitespace are accepted as separators. + # Commas are accepted as separators. OLDIFS=$IFS - IFS=' ,' + IFS=',' set -- $1 IFS=$OLDIFS @@ -805,13 +813,13 @@ match_test_selector_list () { *-*) if expr "z${selector%%-*}" : "z[0-9]*[^0-9]" >/dev/null then - echo "error: $title: invalid non-numeric in range" \ + echo "error: $operation: invalid non-numeric in range" \ "start: '$orig_selector'" >&2 exit 1 fi if expr "z${selector#*-}" : "z[0-9]*[^0-9]" >/dev/null then - echo "error: $title: invalid non-numeric in range" \ + echo "error: $operation: invalid non-numeric in range" \ "end: '$orig_selector'" >&2 exit 1 fi @@ -819,9 +827,11 @@ match_test_selector_list () { *) if expr "z$selector" : "z[0-9]*[^0-9]" >/dev/null then - echo "error: $title: invalid non-numeric in test" \ - "selector: '$orig_selector'" >&2 - exit 1 + case "$title" in *${selector}*) + include=$positive + ;; + esac + continue fi esac @@ -1031,7 +1041,7 @@ test_skip () { skipped_reason="GIT_SKIP_TESTS" fi if test -z "$to_skip" && test -n "$run_list" && - ! match_test_selector_list '--run' $test_count "$run_list" + ! match_test_selector_list '--run' "$1" $test_count "$run_list" then to_skip=t skipped_reason="--run" @@ -1058,7 +1068,6 @@ test_skip () { " <skipped message=\"$message\" />" fi - say_color skip >&3 "skipping test: $@" say_color skip "ok $test_count # skip $1 ($skipped_reason)" : true ;; @@ -1702,3 +1711,10 @@ test_lazy_prereq SHA1 ' test_lazy_prereq REBASE_P ' test -z "$GIT_TEST_SKIP_REBASE_P" ' +# Special-purpose prereq for transitioning to a new default branch name: +# Some tests need more than just a mindless (case-preserving) s/master/main/g +# replacement. The non-trivial adjustments are guarded behind this +# prerequisite, acting kind of as a feature flag +test_lazy_prereq PREPARE_FOR_MAIN_BRANCH ' + test "$GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME" = main +' diff --git a/templates/hooks--push-to-checkout.sample b/templates/hooks--push-to-checkout.sample new file mode 100755 index 0000000000..af5a0c0018 --- /dev/null +++ b/templates/hooks--push-to-checkout.sample @@ -0,0 +1,78 @@ +#!/bin/sh + +# An example hook script to update a checked-out tree on a git push. +# +# This hook is invoked by git-receive-pack(1) when it reacts to git +# push and updates reference(s) in its repository, and when the push +# tries to update the branch that is currently checked out and the +# receive.denyCurrentBranch configuration variable is set to +# updateInstead. +# +# By default, such a push is refused if the working tree and the index +# of the remote repository has any difference from the currently +# checked out commit; when both the working tree and the index match +# the current commit, they are updated to match the newly pushed tip +# of the branch. This hook is to be used to override the default +# behaviour; however the code below reimplements the default behaviour +# as a starting point for convenient modification. +# +# The hook receives the commit with which the tip of the current +# branch is going to be updated: +commit=$1 + +# It can exit with a non-zero status to refuse the push (when it does +# so, it must not modify the index or the working tree). +die () { + echo >&2 "$*" + exit 1 +} + +# Or it can make any necessary changes to the working tree and to the +# index to bring them to the desired state when the tip of the current +# branch is updated to the new commit, and exit with a zero status. +# +# For example, the hook can simply run git read-tree -u -m HEAD "$1" +# in order to emulate git fetch that is run in the reverse direction +# with git push, as the two-tree form of git read-tree -u -m is +# essentially the same as git switch or git checkout that switches +# branches while keeping the local changes in the working tree that do +# not interfere with the difference between the branches. + +# The below is a more-or-less exact translation to shell of the C code +# for the default behaviour for git's push-to-checkout hook defined in +# the push_to_deploy() function in builtin/receive-pack.c. +# +# Note that the hook will be executed from the repository directory, +# not from the working tree, so if you want to perform operations on +# the working tree, you will have to adapt your code accordingly, e.g. +# by adding "cd .." or using relative paths. + +if ! git update-index -q --ignore-submodules --refresh +then + die "Up-to-date check failed" +fi + +if ! git diff-files --quiet --ignore-submodules -- +then + die "Working directory has unstaged changes" +fi + +# This is a rough translation of: +# +# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX +if git cat-file -e HEAD 2>/dev/null +then + head=HEAD +else + head=$(git hash-object -t tree --stdin </dev/null) +fi + +if ! git diff-index --quiet --cached --ignore-submodules $head -- +then + die "Working directory has staged changes" +fi + +if ! git read-tree -u -m "$commit" +then + die "Could not update working tree to new HEAD" +fi @@ -108,33 +108,33 @@ static int die_is_recursing_builtin(void) /* If we are in a dlopen()ed .so write to a global variable would segfault * (ugh), so keep things static. */ -static NORETURN_PTR void (*usage_routine)(const char *err, va_list params) = usage_builtin; -static NORETURN_PTR void (*die_routine)(const char *err, va_list params) = die_builtin; -static void (*error_routine)(const char *err, va_list params) = error_builtin; -static void (*warn_routine)(const char *err, va_list params) = warn_builtin; +static NORETURN_PTR report_fn usage_routine = usage_builtin; +static NORETURN_PTR report_fn die_routine = die_builtin; +static report_fn error_routine = error_builtin; +static report_fn warn_routine = warn_builtin; static int (*die_is_recursing)(void) = die_is_recursing_builtin; -void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params)) +void set_die_routine(NORETURN_PTR report_fn routine) { die_routine = routine; } -void set_error_routine(void (*routine)(const char *err, va_list params)) +void set_error_routine(report_fn routine) { error_routine = routine; } -void (*get_error_routine(void))(const char *err, va_list params) +report_fn get_error_routine(void) { return error_routine; } -void set_warn_routine(void (*routine)(const char *warn, va_list params)) +void set_warn_routine(report_fn routine) { warn_routine = routine; } -void (*get_warn_routine(void))(const char *warn, va_list params) +report_fn get_warn_routine(void) { return warn_routine; } diff --git a/userdiff.c b/userdiff.c index 9c63be9fb8..3f81a2261c 100644 --- a/userdiff.c +++ b/userdiff.c @@ -23,6 +23,27 @@ IPATTERN("ada", "[a-zA-Z][a-zA-Z0-9_]*" "|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?" "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"), +PATTERNS("bash", + /* Optional leading indentation */ + "^[ \t]*" + /* Start of captured text */ + "(" + "(" + /* POSIX identifier with mandatory parentheses */ + "[a-zA-Z_][a-zA-Z0-9_]*[ \t]*\\([ \t]*\\))" + "|" + /* Bashism identifier with optional parentheses */ + "(function[ \t]+[a-zA-Z_][a-zA-Z0-9_]*(([ \t]*\\([ \t]*\\))|([ \t]+))" + ")" + /* Optional whitespace */ + "[ \t]*" + /* Compound command starting with `{`, `(`, `((` or `[[` */ + "(\\{|\\(\\(?|\\[\\[)" + /* End of captured text */ + ")", + /* -- */ + /* Characters not in the default $IFS value */ + "[^ \t]+"), PATTERNS("dts", "!;\n" "!=\n" diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h index 032e3a9f41..7a04605146 100644 --- a/xdiff/xdiff.h +++ b/xdiff/xdiff.h @@ -79,6 +79,10 @@ typedef struct s_mmbuffer { typedef struct s_xpparam { unsigned long flags; + /* -I<regex> */ + regex_t **ignore_regex; + size_t ignore_regex_nr; + /* See Documentation/diff-options.txt. */ char **anchors; size_t anchors_nr; diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c index bd035139f9..380eb728ed 100644 --- a/xdiff/xdiffi.c +++ b/xdiff/xdiffi.c @@ -998,7 +998,7 @@ static int xdl_call_hunk_func(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, return 0; } -static void xdl_mark_ignorable(xdchange_t *xscr, xdfenv_t *xe, long flags) +static void xdl_mark_ignorable_lines(xdchange_t *xscr, xdfenv_t *xe, long flags) { xdchange_t *xch; @@ -1019,6 +1019,46 @@ static void xdl_mark_ignorable(xdchange_t *xscr, xdfenv_t *xe, long flags) } } +static int record_matches_regex(xrecord_t *rec, xpparam_t const *xpp) { + regmatch_t regmatch; + int i; + + for (i = 0; i < xpp->ignore_regex_nr; i++) + if (!regexec_buf(xpp->ignore_regex[i], rec->ptr, rec->size, 1, + ®match, 0)) + return 1; + + return 0; +} + +static void xdl_mark_ignorable_regex(xdchange_t *xscr, const xdfenv_t *xe, + xpparam_t const *xpp) +{ + xdchange_t *xch; + + for (xch = xscr; xch; xch = xch->next) { + xrecord_t **rec; + int ignore = 1; + long i; + + /* + * Do not override --ignore-blank-lines. + */ + if (xch->ignore) + continue; + + rec = &xe->xdf1.recs[xch->i1]; + for (i = 0; i < xch->chg1 && ignore; i++) + ignore = record_matches_regex(rec[i], xpp); + + rec = &xe->xdf2.recs[xch->i2]; + for (i = 0; i < xch->chg2 && ignore; i++) + ignore = record_matches_regex(rec[i], xpp); + + xch->ignore = ignore; + } +} + int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb) { xdchange_t *xscr; @@ -1038,7 +1078,10 @@ int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, } if (xscr) { if (xpp->flags & XDF_IGNORE_BLANK_LINES) - xdl_mark_ignorable(xscr, &xe, xpp->flags); + xdl_mark_ignorable_lines(xscr, &xe, xpp->flags); + + if (xpp->ignore_regex) + xdl_mark_ignorable_regex(xscr, &xe, xpp); if (ef(&xe, xscr, ecb, xecfg) < 0) { diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c index c7b35a9667..e694bfd9e3 100644 --- a/xdiff/xhistogram.c +++ b/xdiff/xhistogram.c @@ -235,6 +235,8 @@ static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env, int line1, int count1, int line2, int count2) { xpparam_t xpparam; + + memset(&xpparam, 0, sizeof(xpparam)); xpparam.flags = xpp->flags & ~XDF_DIFF_ALGORITHM_MASK; return xdl_fall_back_diff(env, &xpparam, diff --git a/xdiff/xpatience.c b/xdiff/xpatience.c index 3c5601b602..20699a6f60 100644 --- a/xdiff/xpatience.c +++ b/xdiff/xpatience.c @@ -318,6 +318,8 @@ static int fall_back_to_classic_diff(struct hashmap *map, int line1, int count1, int line2, int count2) { xpparam_t xpp; + + memset(&xpp, 0, sizeof(xpp)); xpp.flags = map->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK; return xdl_fall_back_diff(map->env, &xpp, |